Skip to content

Commit

Permalink
Log UI data for failure (#20888)
Browse files Browse the repository at this point in the history
* Log UI data for failure

* - add sleep

* - change appium tests to be single task
  • Loading branch information
PureWeen committed Feb 28, 2024
1 parent b11b845 commit 4c699ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Expand Up @@ -8,6 +8,7 @@ namespace Maui.Controls.Sample.Platform
[Activity(
Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode)]
[IntentFilter(
new[] { Microsoft.Maui.ApplicationModel.Platform.Intent.ActionAppAction },
Expand Down
8 changes: 4 additions & 4 deletions src/Controls/tests/UITests/Tests/Issues/Issue11501.cs
Expand Up @@ -16,25 +16,25 @@ public Issue11501(TestDevice device) : base(device)
[TestCase("SwapFlyoutPage")]
[TestCase("SwapTabbedPage")]
[TestCase("RemoveAddTabs")]
public async Task MakingFragmentRelatedChangesWhileAppIsBackgroundedFails(string scenario)
public void MakingFragmentRelatedChangesWhileAppIsBackgroundedFails(string scenario)
{
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Mac, TestDevice.Windows });

try
{
App.WaitForElement(scenario);
App.Click(scenario);
App.WaitForElement("BackgroundMe");
App.BackgroundApp();

// Wait for app to finish backgrounding
await Task.Yield();
App.WaitForNoElement("BackgroundMe");
App.ForegroundApp();
App.WaitForElement("Restore");
App.Click("Restore");
}
catch
{
SaveUIDiagnosticInfo();

// Just in case these tests leave the app in an unreliable state
App.ResetApp();
FixtureSetup();
Expand Down
Expand Up @@ -74,6 +74,8 @@ CommandResponse BackgroundApp(IDictionary<string, object> parameters)
return CommandResponse.FailedEmptyResponse;

_app.Driver.BackgroundApp();
if (_app.GetTestDevice() == TestDevice.Android)
Thread.Sleep(500);

return CommandResponse.SuccessEmptyResponse;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TestUtils/src/UITest.NUnit/UITestBase.cs
Expand Up @@ -131,7 +131,7 @@ void SaveDeviceDiagnosticInfo([CallerMemberName] string? note = null)
}
}

void SaveUIDiagnosticInfo([CallerMemberName] string? note = null)
protected void SaveUIDiagnosticInfo([CallerMemberName] string? note = null)
{
var screenshotPath = GetGeneratedFilePath("ScreenShot.png", note);
if (screenshotPath is not null)
Expand Down

0 comments on commit 4c699ce

Please sign in to comment.