diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs index bb4870821b5..e7a4dd5031c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs @@ -20,6 +20,20 @@ public class DeviceTest: BaseTest { public const string GuestUserName = "guest1"; + // When running on CI we often see failures where the test fails to spot the "Displayed:" line + // because time between when we start logging and when the application actually is launched + // by the emulator is longer than the timeout we specify (usually 30s). Use this constant as the + // default timeout for all the activity start monitoring calls, adjust per-test as necessary. + // + // Sometimes emulators, for whatever reason, launch the app after a delay of up to 100s and the + // logcat is filled with time-consuming Java exceptions unrelated to our test. We need to account + // for that. Most of the tests used 30s as the activity start timeout, so let's give the emulator + // up to 2 minutes to gather all its ducks in the row + 30 "standard" seconds for our test app + // to start. + // + // It is recommended that no test waiting for the "Displayed:" message waits shorter than this + public const int ActivityStartTimeoutInSeconds = 150; + protected string DeviceAbi { get; private set; } protected int DeviceSdkVersion { get; private set;} diff --git a/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs b/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs index 3b3b5ee14c2..eecbe937e4d 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs @@ -183,7 +183,7 @@ public void InstallAndRun () Assert.IsTrue (appBuilder.Install (app), "Install should have succeeded."); RunProjectAndAssert (app, appBuilder); Assert.True ( - WaitForActivityToStart (app.PackageName, "MainActivity", Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), 30), + WaitForActivityToStart (app.PackageName, "MainActivity", Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started." ); } diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index c287a1416c1..5c787f694f8 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -92,7 +92,7 @@ public void ApplicationRunsWithoutDebugger ([Values] bool isRelease, [Values] bo AssertExtractNativeLibs (manifest, extractNativeLibs); RunProjectAndAssert (proj, b); Assert.True (WaitForActivityToStart (proj.PackageName, "MainActivity", - Path.Combine (Root, b.ProjectDirectory, "logcat.log"), 30), "Activity should have started."); + Path.Combine (Root, b.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started."); b.BuildLogFile = "uninstall.log"; Assert.True (b.Uninstall (proj), "Project should have uninstalled."); } @@ -173,7 +173,7 @@ public void ClassLibraryMainLauncherRuns ([Values] bool preloadAssemblies, [Valu Assert.True (appBuilder.Install (app), "app should have installed."); RunProjectAndAssert (app, appBuilder); Assert.True (WaitForActivityToStart (app.PackageName, "MainActivity", - Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), 30), "Activity should have started."); + Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started."); } } diff --git a/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs b/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs index fd543fda9d5..697274e0cb6 100644 --- a/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs @@ -210,7 +210,7 @@ public void FastDevWithEmbeddedDex ([Values (false, true)] bool useEmbeddedDex) ClearAdbLogcat (); RunProjectAndAssert (proj, b); Assert.True (WaitForActivityToStart (proj.PackageName, "MainActivity", - Path.Combine (Root, b.ProjectDirectory, "logcat.log"), 30), "Activity should have started."); + Path.Combine (Root, b.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started."); b.BuildLogFile = "uninstall.log"; Assert.True (b.Uninstall (proj), "Project should have uninstalled."); } diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index dc3e1a83644..241f116a183 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -19,20 +19,6 @@ namespace Xamarin.Android.Build.Tests [Category ("UsesDevice")] public class InstallAndRunTests : DeviceTest { - // When running on CI we often see failures where the test fails to spot the "Displayed:" line - // because time between when we start logging and when the application actually is launched - // by the emulator is longer than the timeout we specify (usually 30s). Use this constant as the - // default timeout for all the activity start monitoring calls, adjust per-test as necessary. - // - // Sometimes emulators, for whatever reason, launch the app after a delay of up to 100s and the - // logcat is filled with time-consuming Java exceptions unrelated to our test. We need to account - // for that. Most of the tests used 30s as the activity start timeout, so let's give the emulator - // up to 2 minutes to gather all its ducks in the row + 30 "standard" seconds for our test app - // to start. - // - // It is recommended that no test waiting for the "Displayed:" message waits shorter than this - public const int ActivityStartTimeoutInSeconds = 150; - static ProjectBuilder builder; static XamarinAndroidApplicationProject proj;