Compare commits

...

2 Commits

Author SHA1 Message Date
Leilei Zhang
4279ef45d3 fix spelling check 2025-08-22 18:11:41 +08:00
Leilei Zhang
7fc20ba0d9 fix ui tests 2025-08-22 17:59:59 +08:00
6 changed files with 34 additions and 17 deletions

View File

@@ -168,6 +168,7 @@ callbackptr
calpwstr
Cangjie
CANRENAME
Canvascustomlayout
CAPTUREBLT
CAPTURECHANGED
CARETBLINKING
@@ -574,6 +575,7 @@ GPOCA
gpp
gpu
gradians
Gridcustomlayout
GSM
gtm
guiddata

View File

@@ -283,8 +283,7 @@ namespace UITests_FancyZones
// Set Hotkey
this.AttachFancyZonesEditor();
var layout = "Grid custom layout";
Session.Find<Element>(layout).Find<Button>(By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
Session.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard)).Find<Button>(By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
const string key = "0";
var hotkeyComboBox = Session.Find<Element>(By.AccessibilityId(AccessibilityId.HotkeyComboBox));
Assert.IsNotNull(hotkeyComboBox);
@@ -299,7 +298,7 @@ namespace UITests_FancyZones
SendKeys(Key.Win, Key.Ctrl, Key.Alt, Key.Num0);
Task.Delay(3000).Wait();
this.AttachFancyZonesEditor();
var element = this.Find<Element>(layout);
var element = this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard));
Assert.IsTrue(element.Selected, $"{element.Selected} Grid custom layout is not visible");
this.CloseFancyZonesEditor();
this.AttachPowertoySetting();
@@ -307,7 +306,7 @@ namespace UITests_FancyZones
SendKeys(Key.Win, Key.Ctrl, Key.Alt, Key.Num1);
Task.Delay(3000).Wait();
this.AttachFancyZonesEditor();
element = this.Find<Element>("Grid-9");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.Grid9LayoutCard));
Assert.IsTrue(element.Selected, $"{element.Selected} Grid-9 is not visible");
this.CloseFancyZonesEditor();
this.AttachPowertoySetting();
@@ -315,7 +314,7 @@ namespace UITests_FancyZones
SendKeys(Key.Win, Key.Ctrl, Key.Alt, Key.Num2);
Task.Delay(3000).Wait();
this.AttachFancyZonesEditor();
element = this.Find<Element>("Canvas custom layout");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.CanvasCustomLayoutCard));
Assert.IsTrue(element.Selected, $"{element.Selected} Canvas custom layout is not visible");
this.CloseFancyZonesEditor();
this.AttachPowertoySetting();
@@ -424,21 +423,21 @@ namespace UITests_FancyZones
SendKeys(Key.Win, Key.Ctrl, Key.Alt, Key.Num0);
this.AttachFancyZonesEditor();
var element = this.Find<Element>("Grid custom layout");
var element = this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard));
Assert.IsFalse(element.Selected, $"{element.Selected} Grid custom layout is not visible");
this.CloseFancyZonesEditor();
this.AttachPowertoySetting();
SendKeys(Key.Win, Key.Ctrl, Key.Alt, Key.Num1);
this.AttachFancyZonesEditor();
element = this.Find<Element>("Grid-9");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.Grid9LayoutCard));
Assert.IsFalse(element.Selected, $"{element.Selected} Grid-9 is not visible");
this.CloseFancyZonesEditor();
this.AttachPowertoySetting();
SendKeys(Key.Win, Key.Ctrl, Key.Alt, Key.Num2);
this.AttachFancyZonesEditor();
element = this.Find<Element>("Canvas custom layout");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.CanvasCustomLayoutCard));
Assert.IsFalse(element.Selected, $"{element.Selected} Canvas custom layout is not visible");
this.CloseFancyZonesEditor();
this.AttachPowertoySetting();
@@ -453,7 +452,7 @@ namespace UITests_FancyZones
this.OpenFancyZonesPanel();
this.AttachFancyZonesEditor();
var element = this.Find<Element>("Grid custom layout");
var element = this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard));
element.Click();
this.CloseFancyZonesEditor();
this.ExitScopeExe();
@@ -463,8 +462,8 @@ namespace UITests_FancyZones
this.RestartScopeExe();
this.OpenFancyZonesPanel();
this.AttachFancyZonesEditor();
element = this.Find<Element>("Grid custom layout");
Assert.IsTrue(element.Selected, $"{element.Selected} Canvas custom layout is not visible");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard));
Assert.IsTrue(element.Selected, $"{element.Selected} Grid custom layout is not visible");
this.CloseFancyZonesEditor();
// close the virtual desktop
@@ -483,7 +482,7 @@ namespace UITests_FancyZones
this.OpenFancyZonesPanel();
this.AttachFancyZonesEditor();
var element = this.Find<Element>("Grid custom layout");
var element = this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard));
element.Click();
this.CloseFancyZonesEditor();
this.ExitScopeExe();
@@ -493,7 +492,7 @@ namespace UITests_FancyZones
this.RestartScopeExe();
this.OpenFancyZonesPanel();
this.AttachFancyZonesEditor();
element = this.Find<Element>("Grid-9");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.Grid9LayoutCard));
element.Click();
this.CloseFancyZonesEditor();
this.ExitScopeExe();
@@ -502,7 +501,7 @@ namespace UITests_FancyZones
this.RestartScopeExe();
this.OpenFancyZonesPanel();
this.AttachFancyZonesEditor();
element = this.Find<Element>("Grid custom layout");
element = this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard));
Assert.IsTrue(element.Selected, $"{element.Selected} Grid custom layout is not visible");
this.CloseFancyZonesEditor();
this.ExitScopeExe();
@@ -523,8 +522,8 @@ namespace UITests_FancyZones
this.OpenFancyZonesPanel();
this.AttachFancyZonesEditor();
this.Find<Element>("Grid custom layout").Click();
this.Find<Element>("Grid custom layout").Find<Button>(By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard)).Click();
this.Find<Element>(By.AccessibilityId(AccessibilityId.GridCustomLayoutCard)).Find<Button>(By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
Session.Find<Button>(By.AccessibilityId(AccessibilityId.DeleteLayoutButton)).Click();
Session.SendKeySequence(Key.Tab, Key.Enter);
@@ -619,7 +618,7 @@ namespace UITests_FancyZones
private void AttachFancyZonesEditor()
{
Task.Delay(4000).Wait();
this.Find<Button>("Launch layout editor").Click();
this.Find<Button>(By.AccessibilityId(AccessibilityId.LaunchLayoutEditorButton)).Click();
Task.Delay(3000).Wait();
this.Session.Attach(PowerToysModule.FancyZone);

View File

@@ -41,9 +41,13 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
public const string MainWindow = "MainWindow1";
public const string Monitors = "Monitors";
public const string NewLayoutButton = "NewLayoutButton";
public const string LaunchLayoutEditorButton = "LaunchLayoutEditorButton";
// layout card
public const string EditLayoutButton = "EditLayoutButton";
public const string GridCustomLayoutCard = "GridcustomlayoutCard";
public const string Grid9LayoutCard = "Grid-9Card";
public const string CanvasCustomLayoutCard = "CanvascustomlayoutCard";
// edit layout window: common for template and custom layouts
public const string DialogTitle = "EditLayoutDialogTitle";

View File

@@ -71,12 +71,22 @@ namespace FancyZonesEditor.Models
{
_name = value;
FirePropertyChanged(nameof(Name));
FirePropertyChanged(nameof(AutomationId));
}
}
}
private string _name;
// AutomationId - used for UI automation testing
public virtual string AutomationId
{
get
{
return _name?.Replace(" ", string.Empty) + "Card";
}
}
public LayoutType Type { get; set; }
#pragma warning disable CA1720 // Identifier contains type name (Not worth the effort to change this now.)

View File

@@ -145,6 +145,7 @@
<Setter Property="Background" Value="{DynamicResource LayoutItemBackgroundBrush}" />
<Setter Property="IsSelected" Value="{Binding IsApplied, Mode=OneWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Name}" />
<Setter Property="AutomationProperties.AutomationId" Value="{Binding AutomationId}" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
<!--<Setter Property="IsHoldingEnabled" Value="True" />-->
<Setter Property="CornerRadius" Value="4" />

View File

@@ -34,6 +34,7 @@
<tkcontrols:SettingsCard
x:Uid="FancyZones_LaunchEditorButtonControl"
ActionIcon="{ui:FontIcon Glyph=&#xE8A7;}"
AutomationProperties.AutomationId="LaunchLayoutEditorButton"
Command="{x:Bind ViewModel.LaunchEditorEventHandler}"
HeaderIcon="{ui:FontIcon Glyph=&#xEB3C;}"
IsClickEnabled="True" />