Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
14 changes: 0 additions & 14 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading