From a5a5a84847d2367d14b5ecc1ce3b68edf2275413 Mon Sep 17 00:00:00 2001 From: Yavor Georgiev Date: Wed, 25 May 2016 16:16:07 +0200 Subject: [PATCH] Prepare a looper when running headless Android tests --- .../TestRunnerInstrumentation.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/IntegrationTests.XamarinAndroid/TestRunnerInstrumentation.cs b/Tests/IntegrationTests.XamarinAndroid/TestRunnerInstrumentation.cs index e65d06a636..dc753292c5 100644 --- a/Tests/IntegrationTests.XamarinAndroid/TestRunnerInstrumentation.cs +++ b/Tests/IntegrationTests.XamarinAndroid/TestRunnerInstrumentation.cs @@ -41,6 +41,8 @@ public override void OnCreate (Bundle arguments) public override void OnStart () { + NativeMethods.ALooper_prepare(0); + using (var output = Context.OpenFileOutput ("TestResults.Android.xml", FileCreationMode.WorldReadable)) { IntegrationTests.Shared.TestRunner.Run ("Xamarin.Android", output); @@ -48,6 +50,12 @@ public override void OnStart () this.Finish (Result.Ok, null); } + + private static class NativeMethods + { + [System.Runtime.InteropServices.DllImport("android")] + internal static extern IntPtr ALooper_prepare(int opts); + } } }