Skip to content

Commit

Permalink
Hopefully, it works on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkatz6 committed Jun 28, 2024
1 parent 69fd549 commit 04c39b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
4 changes: 0 additions & 4 deletions azure-pipelines-integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,3 @@ jobs:
inputs:
OperationType: 'Stop'
displayName: 'Stop WinAppDriver'

- publish: 'tests/Avalonia.IntegrationTests.Appium/bin/Debug/net8.0/rootSource.xml'
displayName: 'Publish appium logs on failure'
condition: always()
24 changes: 12 additions & 12 deletions tests/Avalonia.IntegrationTests.Appium/TrayIconTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public TrayIconTests(DefaultAppFixture fixture)
if (OperatingSystem.IsWindows())
{
_rootSession = fixture.CreateNestedSession("Root");
var rootSource = _rootSession.PageSource;
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "rootSource.xml"), rootSource);
}

var tabs = _session.FindElementByAccessibilityId("MainTabs");
Expand All @@ -40,9 +38,9 @@ public void Should_Handle_Left_Click()
var avaloinaTrayIconButton = GetTrayIconButton(_rootSession ?? _session, TrayIconName);
Assert.NotNull(avaloinaTrayIconButton);

avaloinaTrayIconButton.Click();
avaloinaTrayIconButton.SendClick();

Thread.Sleep(1000);
Thread.Sleep(2000);

var checkBox = _session.FindElementByAccessibilityId("TrayIconClicked");
Assert.True(checkBox.GetIsChecked());
Expand All @@ -58,9 +56,9 @@ public void Should_Handle_Context_Menu_Item_Click()
Assert.NotNull(contextMenu);

var menuItem = contextMenu.FindElementByName("Raise Menu Clicked");
menuItem.Click();
Thread.Sleep(1000);
menuItem.SendClick();

Thread.Sleep(2000);

var checkBox = _session.FindElementByAccessibilityId("TrayIconMenuClicked");
Assert.True(checkBox.GetIsChecked());
Expand Down Expand Up @@ -88,7 +86,7 @@ public void Can_Toggle_TrayIcon_Visibility()
{
if (OperatingSystem.IsWindows())
{
var taskBar = session.FindElementsByName("Taskbar")
var taskBar = session.FindElementsByClassName("Shell_TrayWnd")
.FirstOrDefault() ?? throw new InvalidOperationException("Couldn't find Taskbar on current system.");

if (TryToGetIcon(taskBar, trayIconName) is { } trayIcon)
Expand All @@ -100,15 +98,17 @@ public void Can_Toggle_TrayIcon_Visibility()
// Add a sleep here, as previous test might still run popup closing animation.
Thread.Sleep(1000);

// Try to open "Show hidden icons" (win11) or "Notification Chevron" (win10)
// win11: SystemTrayIcon
// win10: Notification Chevron
var trayIconsButton = taskBar.FindElementsByAccessibilityId("SystemTrayIcon").FirstOrDefault()
?? taskBar.FindElementsByName("Notification Chevron").FirstOrDefault()
?? throw new InvalidOperationException("SystemTrayIcon cannot be found.");
trayIconsButton.Click();

// Try to open "System tray" (win11) or "Notification Overflow" (win10)
var trayIconsFlyout = session.FindElementsByName("System tray overflow window.").FirstOrDefault()
?? taskBar.FindElementsByName("Notification Overflow").FirstOrDefault()
// win11: TopLevelWindowForOverflowXamlIsland
// win10: NotifyIconOverflowWindow
var trayIconsFlyout = session.FindElementsByClassName("TopLevelWindowForOverflowXamlIsland").FirstOrDefault()
?? taskBar.FindElementsByClassName("NotifyIconOverflowWindow").FirstOrDefault()
?? throw new InvalidOperationException("System tray overflow window cannot be found.");
return TryToGetIcon(trayIconsFlyout, trayIconName);
}
Expand Down

0 comments on commit 04c39b3

Please sign in to comment.