From 35872b55ac3e1078d6d49020c82f34a85d3a7cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 23 Oct 2020 19:48:35 +0200 Subject: [PATCH] Update Android instrumentation runner to be closer to upstream The upstream instrumentation runners don't use runOnMainSync() in the onStart() method, update our runner to do the same and add a bit more logging. Also fixed a small typo in configure.cmake that I happened to notice. --- src/libraries/Native/Unix/configure.cmake | 2 +- .../Templates/MonoRunner.java | 31 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libraries/Native/Unix/configure.cmake b/src/libraries/Native/Unix/configure.cmake index 6cb5616b6ab44..8f0ca77cc3b1e 100644 --- a/src/libraries/Native/Unix/configure.cmake +++ b/src/libraries/Native/Unix/configure.cmake @@ -684,7 +684,7 @@ check_c_source_compiles( HAVE_MKSTEMP) if (NOT HAVE_MKSTEMPS AND NOT HAVE_MKSTEMP) - message(FATAL_ERROR "Cannot find mkstemp nor mkstemp on this platform.") + message(FATAL_ERROR "Cannot find mkstemps nor mkstemp on this platform.") endif() check_c_source_compiles( diff --git a/tools-local/tasks/mobile.tasks/AndroidAppBuilder/Templates/MonoRunner.java b/tools-local/tasks/mobile.tasks/AndroidAppBuilder/Templates/MonoRunner.java index b22be8c1f8104..6b061c476fd00 100644 --- a/tools-local/tasks/mobile.tasks/AndroidAppBuilder/Templates/MonoRunner.java +++ b/tools-local/tasks/mobile.tasks/AndroidAppBuilder/Templates/MonoRunner.java @@ -9,6 +9,7 @@ import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.os.Bundle; +import android.os.Looper; import android.util.Log; import android.view.View; import android.app.Activity; @@ -32,6 +33,7 @@ public class MonoRunner extends Instrumentation } static String entryPointLibName = "%EntryPointLibName%"; + static Bundle result = new Bundle(); @Override public void onCreate(Bundle arguments) { @@ -62,13 +64,13 @@ public static int initialize(String entryPointLibName, Context context) { // unzip libs and test files to filesDir unzipAssets(context, filesDir, "assets.zip"); - Log.i("DOTNET", "initRuntime, entryPointLibName=" + entryPointLibName); + Log.i("DOTNET", "MonoRunner initialize, entryPointLibName=" + entryPointLibName); return initRuntime(filesDir, cacheDir, docsDir, entryPointLibName); } @Override public void onStart() { - super.onStart(); + Looper.prepare(); if (entryPointLibName == "") { Log.e("DOTNET", "Missing entryPointLibName argument, pass '-e entryPointLibName ' to adb to specify which program to run."); @@ -76,19 +78,18 @@ public void onStart() { return; } int retcode = initialize(entryPointLibName, getContext()); - runOnMainSync(new Runnable() { - public void run() { - Bundle result = new Bundle(); - result.putInt("return-code", retcode); - - // Xharness cli expects "test-results-path" with test results - File testResults = new File(getDocsDir(getContext()) + "/testResults.xml"); - if (testResults.exists()) { - result.putString("test-results-path", testResults.getAbsolutePath()); - } - finish(retcode, result); - } - }); + + Log.i("DOTNET", "MonoRunner finished, return-code=" + retcode); + result.putInt("return-code", retcode); + + // Xharness cli expects "test-results-path" with test results + File testResults = new File(getDocsDir(getContext()) + "/testResults.xml"); + if (testResults.exists()) { + Log.i("DOTNET", "MonoRunner finished, test-results-path=" + testResults.getAbsolutePath()); + result.putString("test-results-path", testResults.getAbsolutePath()); + } + + finish(retcode, result); } static void unzipAssets(Context context, String toPath, String zipName) {