mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
UI Test Automation (#39777)
### Summary This pull request includes the following updates: 1. Improvements and stabilization of the UI automation framework 2. Setup of the UI automation pipeline 3. Add UI test cases for FancyZones 4. Add UI test cases for MouseUtils 5. Improvements of Hosts Editor UI tests --- ### Related Links - **Current Release checklist coverage**: https://github.com/microsoft/PowerToys/blob/feature/UITestAutomation/src/common/UITestAutomation/Doc/ui-automation-cover-list.md - **UI Automation pipeline**: https://microsoft.visualstudio.com/Dart/_build?definitionId=161438&_a=summary --------- Signed-off-by: Shawn Yuan <shuai.yuan.zju@gmail.com> Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Jerry Xu <n.xu@outlook.com> Co-authored-by: Zhaopeng Wang <zhaopengwang@microsoft.com> Co-authored-by: Xiaofeng Wang (from Dev Box) <xiaofengwang@microsoft.com> Co-authored-by: Mengyuan <162882040+chenmy77@users.noreply.github.com> Co-authored-by: yaqingmi <miyaqing01@gmail.com> Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Yaqing Mi (from Dev Box) <yaqingmi@microsoft.com> Co-authored-by: Kai Tao <69313318+vanzue@users.noreply.github.com> Co-authored-by: zhaopeng wang <33367956+wang563681252@users.noreply.github.com> Co-authored-by: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com> Co-authored-by: RokyZevon <12629919+RokyZevon@users.noreply.github.com> Co-authored-by: Yu Leng <42196638+moooyo@users.noreply.github.com> Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> Co-authored-by: Davide Giacometti <25966642+davidegiacometti@users.noreply.github.com> Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> Co-authored-by: ruslanlap <106077551+ruslanlap@users.noreply.github.com> Co-authored-by: Muhammad Danish <mdanishkhdev@gmail.com> Co-authored-by: Bennett Blodinger <benwa@users.noreply.github.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Ionuț Manța <ionut@janeasystems.com> Co-authored-by: Hao Liu <liuhaobupt@163.com> Co-authored-by: OlegHarchevkin <40352094+OlegKharchevkin@users.noreply.github.com> Co-authored-by: dcog989 <89043002+dcog989@users.noreply.github.com> Co-authored-by: PesBandi <127593627+PesBandi@users.noreply.github.com> Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Co-authored-by: vanzue <vanzue@outlook.com> Co-authored-by: Typpi <20943337+Nick2bad4u@users.noreply.github.com> Co-authored-by: Mike Griese <migrie@microsoft.com> Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com> Co-authored-by: Abhyudit <64366765+bitmap4@users.noreply.github.com> Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Ved Nig <vednig12@outlook.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Aung Khaing Khant <aungkhaingkhant.dev@gmail.com> Co-authored-by: Aung Khaing Khant <aungkhaingkhant@advent-soft.com> Co-authored-by: Dustin L. Howett <duhowett@microsoft.com> Co-authored-by: leileizhang <leilzh@microsoft.com> Co-authored-by: Dustin L. Howett <dustin@howett.net> Co-authored-by: Shawn Yuan <128874481+shuaiyuanxx@users.noreply.github.com> Co-authored-by: Shawn Yuan <shuai.yuan.zju@gmail.com> Co-authored-by: cryolithic <cryolithic@gmail.com> Co-authored-by: Lemonyte <49930425+lemonyte@users.noreply.github.com> Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com> Co-authored-by: Corey Hayward <72159232+CoreyHayward@users.noreply.github.com> Co-authored-by: Jerry Xu <nxu@microsoft.com> Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com> Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class ApplyLayoutTests : UITestBase
|
||||
{
|
||||
public ApplyLayoutTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(Parameters));
|
||||
|
||||
@@ -195,12 +196,6 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ApplyCustomLayout()
|
||||
{
|
||||
@@ -234,7 +229,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(Parameters.Monitors[0].MonitorNumber, data.AppliedLayouts[0].Device.MonitorNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.ApplyLayoutsOnEachMonitor")]
|
||||
[TestCategory("FancyZones Editor #10")]
|
||||
public void ApplyLayoutsOnEachMonitor()
|
||||
{
|
||||
// apply the layout on the first monitor
|
||||
@@ -261,7 +257,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(secondLayout.Uuid, data.AppliedLayouts.Find(x => x.Device.MonitorNumber == 2).AppliedLayout.Uuid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.ApplyTemplateWithDifferentParametersOnEachMonitor")]
|
||||
[TestCategory("FancyZones Editor #10")]
|
||||
public void ApplyTemplateWithDifferentParametersOnEachMonitor()
|
||||
{
|
||||
var layoutType = LayoutType.Columns;
|
||||
@@ -270,10 +267,10 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
// apply the layout on the first monitor, set parameters
|
||||
Session.Find<Element>(layoutName).Click();
|
||||
Session.Find<Element>(layoutName).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
var expectedFirstLayoutZoneCount = int.Parse(slider.Text!, CultureInfo.InvariantCulture);
|
||||
Session.Find<Button>(ElementName.Save).Click();
|
||||
|
||||
@@ -281,16 +278,16 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Session.Find<Element>(PowerToys.UITest.By.AccessibilityId("Monitors")).Find<Element>("Monitor 2").Click();
|
||||
Session.Find<Element>(layoutName).Click();
|
||||
Session.Find<Element>(layoutName).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Left);
|
||||
slider.SendKeys(Key.Left);
|
||||
var expectedSecondLayoutZoneCount = int.Parse(slider.Text!, CultureInfo.InvariantCulture);
|
||||
Session.Find<Button>(ElementName.Save).Click();
|
||||
|
||||
// verify the layout on the first monitor wasn't changed
|
||||
Session.Find<Element>(PowerToys.UITest.By.AccessibilityId("Monitors")).Find<Element>("Monitor 1").Click();
|
||||
Session.Find<Element>(layoutName).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
Assert.AreEqual(expectedFirstLayoutZoneCount, int.Parse(slider.Text!, CultureInfo.InvariantCulture));
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class CopyLayoutTests : UITestBase
|
||||
{
|
||||
public CopyLayoutTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
ParamsWrapper parameters = new ParamsWrapper
|
||||
{
|
||||
@@ -172,13 +173,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyTemplate_FromEditLayoutWindow")]
|
||||
[TestCategory("FancyZones Editor #4")]
|
||||
public void CopyTemplate_FromEditLayoutWindow()
|
||||
{
|
||||
string copiedLayoutName = TestConstants.TemplateLayoutNames[LayoutType.Focus] + " (1)";
|
||||
@@ -195,7 +191,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == copiedLayoutName));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyTemplate_FromEditLayoutWindow")]
|
||||
[TestCategory("FancyZones Editor #4")]
|
||||
public void CopyTemplate_FromContextMenu()
|
||||
{
|
||||
string copiedLayoutName = TestConstants.TemplateLayoutNames[LayoutType.Rows] + " (1)";
|
||||
@@ -211,7 +208,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == copiedLayoutName));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyTemplate_DefaultLayout")]
|
||||
[TestCategory("FancyZones Editor #13")]
|
||||
public void CopyTemplate_DefaultLayout()
|
||||
{
|
||||
string copiedLayoutName = TestConstants.TemplateLayoutNames[LayoutType.PriorityGrid] + " (1)";
|
||||
@@ -243,7 +241,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(defaultLayouts.Serialize(DefaultLayouts), defaultLayouts.Serialize(defaultLayoutData));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyCustomLayout_FromEditLayoutWindow")]
|
||||
[TestCategory("FancyZones Editor #4")]
|
||||
public void CopyCustomLayout_FromEditLayoutWindow()
|
||||
{
|
||||
string copiedLayoutName = CustomLayouts.CustomLayouts[0].Name + " (1)";
|
||||
@@ -260,7 +259,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == copiedLayoutName));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyCustomLayout_FromContextMenu")]
|
||||
[TestCategory("FancyZones Editor #4")]
|
||||
public void CopyCustomLayout_FromContextMenu()
|
||||
{
|
||||
string copiedLayoutName = CustomLayouts.CustomLayouts[0].Name + " (1)";
|
||||
@@ -276,7 +276,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == copiedLayoutName));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyCustomLayout_DefaultLayout")]
|
||||
[TestCategory("FancyZones Editor #13")]
|
||||
public void CopyCustomLayout_DefaultLayout()
|
||||
{
|
||||
string copiedLayoutName = CustomLayouts.CustomLayouts[0].Name + " (1)";
|
||||
@@ -308,7 +309,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(defaultLayouts.Serialize(DefaultLayouts), defaultLayouts.Serialize(defaultLayoutData));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CopyCustomLayout_Hotkey")]
|
||||
[TestCategory("FancyZones Editor #4")]
|
||||
public void CopyCustomLayout_Hotkey()
|
||||
{
|
||||
string copiedLayoutName = CustomLayouts.CustomLayouts[0].Name + " (1)";
|
||||
|
||||
@@ -16,13 +16,15 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class CreateLayoutTests : UITestBase
|
||||
{
|
||||
public CreateLayoutTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
|
||||
// prepare test editor parameters with 2 monitors before launching the editor
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
EditorParameters.ParamsWrapper parameters = new EditorParameters.ParamsWrapper
|
||||
@@ -132,12 +134,6 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CreateWithDefaultName()
|
||||
{
|
||||
@@ -156,7 +152,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == name));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CreateWithCustomName")]
|
||||
[TestCategory("FancyZones Editor #3")]
|
||||
public void CreateWithCustomName()
|
||||
{
|
||||
string name = "Layout Name";
|
||||
@@ -177,7 +174,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == name));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CreateGrid")]
|
||||
[TestCategory("FancyZones Editor #3")]
|
||||
public void CreateGrid()
|
||||
{
|
||||
CustomLayout type = CustomLayout.Grid;
|
||||
@@ -193,7 +191,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Type == type.TypeToString()));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CreateCanvas")]
|
||||
[TestCategory("FancyZones Editor #3")]
|
||||
public void CreateCanvas()
|
||||
{
|
||||
CustomLayout type = CustomLayout.Canvas;
|
||||
@@ -209,7 +208,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Type == type.TypeToString()));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CancelGridCreation")]
|
||||
[TestCategory("FancyZones Editor #3")]
|
||||
public void CancelGridCreation()
|
||||
{
|
||||
Session.Find<Element>(By.AccessibilityId(AccessibilityId.NewLayoutButton)).Click();
|
||||
@@ -223,7 +223,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(0, data.CustomLayouts.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CancelCanvasCreation")]
|
||||
[TestCategory("FancyZones Editor #3")]
|
||||
public void CancelCanvasCreation()
|
||||
{
|
||||
Session.Find<Element>(By.AccessibilityId(AccessibilityId.NewLayoutButton)).Click();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class CustomLayoutsTests : UITestBase
|
||||
{
|
||||
public CustomLayoutsTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
CustomLayouts customLayouts = new CustomLayouts();
|
||||
FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.WriteData(customLayouts.Serialize(Layouts));
|
||||
|
||||
@@ -208,12 +209,6 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Name_Initialize()
|
||||
{
|
||||
@@ -292,14 +287,14 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var type = layout.Type;
|
||||
Session.Find<Element>(layout.Name).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
|
||||
var value = type == CustomLayout.Canvas.TypeToString() ?
|
||||
new CustomLayouts().CanvasFromJsonElement(layout.Info.GetRawText()).SensitivityRadius :
|
||||
new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).SensitivityRadius;
|
||||
var expected = value + 1; // one step right
|
||||
var expected = value; // if have one step right please + 1
|
||||
|
||||
Assert.AreEqual($"{expected}", slider.Text);
|
||||
|
||||
@@ -321,9 +316,9 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var type = layout.Type;
|
||||
Session.Find<Element>(layout.Name).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
|
||||
var expected = type == CustomLayout.Canvas.TypeToString() ?
|
||||
new CustomLayouts().CanvasFromJsonElement(layout.Info.GetRawText()).SensitivityRadius :
|
||||
@@ -373,15 +368,15 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void SpaceAroundZones_Slider_Save()
|
||||
{
|
||||
var layout = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Grid.TypeToString() && new CustomLayouts().GridFromJsonElement(x.Info.GetRawText()).ShowSpacing);
|
||||
var expected = new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).Spacing + 1; // one step right
|
||||
var expected = new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).Spacing; // one step right
|
||||
Session.Find<Element>(layout.Name).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
Assert.AreEqual($"{expected}", slider.Text);
|
||||
|
||||
Session.Find<Button>(ElementName.Save).Click();
|
||||
Session.Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.PrimaryButton)).Click();
|
||||
|
||||
// verify the file
|
||||
var customLayouts = new CustomLayouts();
|
||||
@@ -397,9 +392,9 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Session.Find<Element>(layout.Name).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
var expected = new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).Spacing;
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
|
||||
// verify the file
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class DefaultLayoutsTest : UITestBase
|
||||
{
|
||||
public DefaultLayoutsTest()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
var defaultLayouts = new DefaultLayouts();
|
||||
FancyZonesEditorHelper.Files.DefaultLayoutsIOHelper.WriteData(defaultLayouts.Serialize(Layouts));
|
||||
|
||||
@@ -237,20 +238,16 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Default_Initialize")]
|
||||
[TestCategory("FancyZones Editor #12")]
|
||||
public void Initialize()
|
||||
{
|
||||
CheckTemplateLayouts(LayoutType.Grid, null);
|
||||
CheckCustomLayouts(string.Empty, CustomLayouts.CustomLayouts[0].Uuid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Default_Assign_Cancel")]
|
||||
[TestCategory("FancyZones Editor #12")]
|
||||
public void Assign_Cancel()
|
||||
{
|
||||
// assign Focus as a default horizontal and vertical layout
|
||||
@@ -266,7 +263,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
CheckCustomLayouts(string.Empty, CustomLayouts.CustomLayouts[0].Uuid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Default_Assign_Save")]
|
||||
[TestCategory("FancyZones Editor #12")]
|
||||
public void Assign_Save()
|
||||
{
|
||||
// assign Focus as a default horizontal and vertical layout
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class DeleteLayoutTests : UITestBase
|
||||
{
|
||||
public DeleteLayoutTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(Parameters));
|
||||
|
||||
@@ -215,19 +216,14 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Session.Find<Element>(CustomLayouts.CustomLayouts[0].Name).Click();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.DeleteNotAppliedLayout")]
|
||||
[TestCategory("FancyZones Editor #5")]
|
||||
public void DeleteNotAppliedLayout()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
Session.Find<Element>(deletedLayout).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
Session.Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.DeleteLayoutButton)).Click();
|
||||
Session.KeyboardAction(Keys.Tab, Keys.Enter);
|
||||
Session.SendKeySequence(Key.Tab, Key.Enter);
|
||||
|
||||
// verify the layout is removed
|
||||
Assert.IsTrue(Session.FindAll<Element>(deletedLayout).Count == 0);
|
||||
@@ -239,13 +235,15 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsFalse(data.CustomLayouts.Exists(x => x.Name == deletedLayout));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.DeleteAppliedLayout")]
|
||||
[TestCategory("FancyZones Editor #5")]
|
||||
public void DeleteAppliedLayout()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[0].Name;
|
||||
Session.Find<Element>(deletedLayout).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
Session.Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.DeleteLayoutButton)).Click();
|
||||
Session.KeyboardAction(Keys.Tab, Keys.Enter);
|
||||
|
||||
Session.SendKeySequence(Key.Tab, Key.Enter);
|
||||
|
||||
// verify the layout is removed
|
||||
Assert.IsTrue(Session.FindAll<Element>(deletedLayout).Count == 0);
|
||||
@@ -264,13 +262,14 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(LayoutType.Blank.TypeToString(), appliedLayoutsData.AppliedLayouts.Find(x => x.Device.Monitor == Parameters.Monitors[0].Monitor).AppliedLayout.Type);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.CancelDeletion")]
|
||||
[TestCategory("FancyZones Editor #5")]
|
||||
public void CancelDeletion()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
Session.Find<Element>(deletedLayout).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
Session.Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.DeleteLayoutButton)).Click();
|
||||
Session.KeyboardAction(Keys.Tab, Keys.Tab, Keys.Enter);
|
||||
Session.SendKeySequence(Key.Tab, Key.Tab, Key.Enter);
|
||||
|
||||
// verify the layout is not removed
|
||||
Assert.IsNotNull(Session.Find<Element>(deletedLayout));
|
||||
@@ -282,12 +281,13 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(data.CustomLayouts.Exists(x => x.Name == deletedLayout));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.DeleteFromContextMenu")]
|
||||
[TestCategory("FancyZones Editor #5")]
|
||||
public void DeleteFromContextMenu()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, deletedLayout, FancyZonesEditorHelper.ElementName.Delete);
|
||||
Session.KeyboardAction(Keys.Tab, Keys.Enter);
|
||||
Session.SendKeySequence(Key.Tab, Key.Enter);
|
||||
|
||||
// verify the layout is removed
|
||||
Assert.IsTrue(Session.FindAll<Element>(deletedLayout).Count == 0);
|
||||
@@ -299,12 +299,13 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsFalse(data.CustomLayouts.Exists(x => x.Name == deletedLayout));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.DeleteDefaultLayout")]
|
||||
[TestCategory("FancyZones Editor #5")]
|
||||
public void DeleteDefaultLayout()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, deletedLayout, FancyZonesEditorHelper.ElementName.Delete);
|
||||
Session.KeyboardAction(Keys.Tab, Keys.Enter);
|
||||
Session.SendKeySequence(Key.Tab, Key.Enter);
|
||||
|
||||
// verify the default layout is reset to the "default" default
|
||||
Session.Find<Element>(TestConstants.TemplateLayoutNames[LayoutType.PriorityGrid]).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
@@ -318,12 +319,13 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(LayoutType.PriorityGrid.TypeToString(), data.DefaultLayouts.Find(x => x.MonitorConfiguration == configuration).Layout.Type);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.DeleteLayoutWithHotkey")]
|
||||
[TestCategory("FancyZones Editor #5")]
|
||||
public void DeleteLayoutWithHotkey()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, deletedLayout, FancyZonesEditorHelper.ElementName.Delete);
|
||||
Session.KeyboardAction(Keys.Tab, Keys.Enter);
|
||||
Session.SendKeySequence(Key.Tab, Key.Enter);
|
||||
|
||||
// verify the hotkey is available
|
||||
Session.Find<Element>(CustomLayouts.CustomLayouts[0].Name).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class EditLayoutTests : UITestBase
|
||||
{
|
||||
public EditLayoutTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
ParamsWrapper parameters = new ParamsWrapper
|
||||
{
|
||||
@@ -209,13 +210,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.OpenEditMode")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void OpenEditMode()
|
||||
{
|
||||
Session.Find<Element>(Layouts.CustomLayouts[0].Name).Find<Button>(By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
@@ -224,7 +220,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.OpenEditModeFromContextMenu")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void OpenEditModeFromContextMenu()
|
||||
{
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, Layouts.CustomLayouts[0].Name, FancyZonesEditorHelper.ElementName.EditZones);
|
||||
@@ -232,7 +229,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_AddZone_Save")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_AddZone_Save()
|
||||
{
|
||||
var canvas = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Canvas.TypeToString());
|
||||
@@ -248,7 +246,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected.Zones.Count + 1, actual.Zones.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_AddZone_Cancel")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_AddZone_Cancel()
|
||||
{
|
||||
var canvas = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Canvas.TypeToString());
|
||||
@@ -264,7 +263,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected.Zones.Count, actual.Zones.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_DeleteZone_Save")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_DeleteZone_Save()
|
||||
{
|
||||
var canvas = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Canvas.TypeToString());
|
||||
@@ -280,7 +280,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected.Zones.Count - 1, actual.Zones.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_DeleteZone_Cancel")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_DeleteZone_Cancel()
|
||||
{
|
||||
var canvas = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Canvas.TypeToString());
|
||||
@@ -296,7 +297,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected.Zones.Count, actual.Zones.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_MoveZone_Save")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_MoveZone_Save()
|
||||
{
|
||||
int zoneNumber = 1;
|
||||
@@ -333,7 +335,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_MoveZone_Cancel")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_MoveZone_Cancel()
|
||||
{
|
||||
int zoneNumber = 1;
|
||||
@@ -357,7 +360,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_ResizeZone_Save")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_ResizeZone_Save()
|
||||
{
|
||||
int zoneNumber = 1;
|
||||
@@ -366,7 +370,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var canvas = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Canvas.TypeToString());
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, canvas.Name, FancyZonesEditorHelper.ElementName.EditZones);
|
||||
|
||||
FancyZonesEditorHelper.GetZone(Session, zoneNumber, FancyZonesEditorHelper.ClassName.CanvasZone)?.Find<Element>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.TopRightCorner)).Drag(xOffset, yOffset);
|
||||
FancyZonesEditorHelper.GetZone(Session, zoneNumber, FancyZonesEditorHelper.ClassName.CanvasZone)?.Find<Thumb>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.TopRightCorner)).Drag(xOffset, yOffset);
|
||||
Session.Find<Button>(ElementName.Save).Click();
|
||||
|
||||
// check the file
|
||||
@@ -394,7 +398,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Canvas_ResizeZone_Cancel")]
|
||||
[TestCategory("FancyZones Editor #7")]
|
||||
public void Canvas_ResizeZone_Cancel()
|
||||
{
|
||||
int zoneNumber = 1;
|
||||
@@ -403,7 +408,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var canvas = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Canvas.TypeToString());
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, canvas.Name, FancyZonesEditorHelper.ElementName.EditZones);
|
||||
|
||||
FancyZonesEditorHelper.GetZone(Session, zoneNumber, FancyZonesEditorHelper.ClassName.CanvasZone)?.Find<Element>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.TopRightCorner)).Drag(xOffset, yOffset);
|
||||
FancyZonesEditorHelper.GetZone(Session, zoneNumber, FancyZonesEditorHelper.ClassName.CanvasZone)?.Find<Thumb>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.TopRightCorner)).Drag(xOffset, yOffset);
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
|
||||
// check the file
|
||||
@@ -421,7 +426,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Grid_SplitZone_Save")]
|
||||
[TestCategory("FancyZones Editor #8")]
|
||||
public void Grid_SplitZone_Save()
|
||||
{
|
||||
int zoneNumber = 1;
|
||||
@@ -450,7 +456,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Grid_SplitZone_Cancel")]
|
||||
[TestCategory("FancyZones Editor #8")]
|
||||
public void Grid_SplitZone_Cancel()
|
||||
{
|
||||
int zoneNumber = 1;
|
||||
@@ -481,7 +488,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Grid_MergeZones_Save")]
|
||||
[TestCategory("FancyZones Editor #8")]
|
||||
public void Grid_MergeZones_Save()
|
||||
{
|
||||
var grid = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Grid.TypeToString());
|
||||
@@ -515,7 +523,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.IsTrue(actual.CellChildMap[1].SequenceEqual([1, 2]));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Grid_MergeZones_Cancel")]
|
||||
[TestCategory("FancyZones Editor #8")]
|
||||
public void Grid_MergeZones_Cancel()
|
||||
{
|
||||
var grid = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Grid.TypeToString());
|
||||
@@ -551,7 +560,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Grid_MoveSplitter_Save")]
|
||||
[TestCategory("FancyZones Editor #8")]
|
||||
public void Grid_MoveSplitter_Save()
|
||||
{
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
@@ -614,7 +624,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.Grid_MoveSplitter_Cancel")]
|
||||
[TestCategory("FancyZones Editor #8")]
|
||||
public void Grid_MoveSplitter_Cancel()
|
||||
{
|
||||
var grid = Layouts.CustomLayouts.Find(x => x.Type == CustomLayout.Grid.TypeToString() && x.Name == "Grid-9");
|
||||
|
||||
@@ -25,13 +25,14 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class FirstLunchTest : UITestBase
|
||||
{
|
||||
public FirstLunchTest()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
ParamsWrapper parameters = new ParamsWrapper
|
||||
{
|
||||
@@ -141,12 +142,6 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FirstLaunch()
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class LayoutHotkeysTests : UITestBase
|
||||
{
|
||||
public LayoutHotkeysTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
ParamsWrapper parameters = new ParamsWrapper
|
||||
{
|
||||
@@ -206,13 +207,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HotKey_Initialize")]
|
||||
[TestCategory("FancyZones Editor #11")]
|
||||
public void Initialize()
|
||||
{
|
||||
foreach (var layout in CustomLayouts.CustomLayouts)
|
||||
@@ -256,7 +252,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HotKey_Assign_Save")]
|
||||
[TestCategory("FancyZones Editor #11")]
|
||||
public void Assign_Save()
|
||||
{
|
||||
var layout = CustomLayouts.CustomLayouts[2]; // a layout without assigned hotkey
|
||||
@@ -299,7 +296,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HotKey_Assign_Cancel")]
|
||||
[TestCategory("FancyZones Editor #11")]
|
||||
public void Assign_Cancel()
|
||||
{
|
||||
var layout = CustomLayouts.CustomLayouts[2]; // a layout without assigned hotkey
|
||||
@@ -338,7 +336,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HotKey_Assign_AllPossibleValues")]
|
||||
[TestCategory("FancyZones Editor #11")]
|
||||
public void Assign_AllPossibleValues()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -384,7 +383,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HotKey_Reset_Save")]
|
||||
[TestCategory("FancyZones Editor #11")]
|
||||
public void Reset_Save()
|
||||
{
|
||||
var layout = CustomLayouts.CustomLayouts[0]; // a layout with assigned hotkey
|
||||
@@ -424,7 +424,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HotKey_Reset_Cancel")]
|
||||
[TestCategory("FancyZones Editor #11")]
|
||||
public void Reset_Cancel()
|
||||
{
|
||||
var layout = CustomLayouts.CustomLayouts[0]; // a layout with assigned hotkey
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class TestCaseFirstLaunch : UITestBase
|
||||
{
|
||||
public TestCaseFirstLaunch()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class RunFancyZonesEditorTest : UITestBase
|
||||
{
|
||||
public RunFancyZonesEditorTest()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext testContext)
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
|
||||
@@ -163,12 +163,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
AppliedLayouts = new List<AppliedLayouts.AppliedLayoutWrapper> { },
|
||||
};
|
||||
FancyZonesEditorHelper.Files.AppliedLayoutsIOHelper.WriteData(appliedLayouts.Serialize(appliedLayoutsWrapper));
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -73,13 +73,14 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
};
|
||||
|
||||
public TemplateLayoutsTests()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
ParamsWrapper parameters = new ParamsWrapper
|
||||
{
|
||||
@@ -191,13 +192,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
this.RestartScopeExe();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.ZoneNumber_Cancel")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void ZoneNumber_Cancel()
|
||||
{
|
||||
var type = LayoutType.Rows;
|
||||
@@ -205,9 +201,9 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var expected = layout.ZoneCount;
|
||||
Session.Find<Button>(TestConstants.TemplateLayoutNames[type]).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.TemplateZoneSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Left);
|
||||
slider.SendKeys(Key.Left);
|
||||
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
|
||||
@@ -218,7 +214,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HighlightDistance_Initialize")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void HighlightDistance_Initialize()
|
||||
{
|
||||
foreach (var (type, name) in TestConstants.TemplateLayoutNames)
|
||||
@@ -239,7 +236,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HighlightDistance_Save")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void HighlightDistance_Save()
|
||||
{
|
||||
var type = LayoutType.Focus;
|
||||
@@ -247,11 +245,11 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var value = layout.SensitivityRadius;
|
||||
Session.Find<Button>(TestConstants.TemplateLayoutNames[type]).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
|
||||
var expected = value + 1; // one step right
|
||||
var expected = value; // one step right
|
||||
Assert.AreEqual($"{expected}", slider.Text);
|
||||
|
||||
Session.Find<Button>(ElementName.Save).Click();
|
||||
@@ -263,7 +261,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.HighlightDistance_Cancel")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void HighlightDistance_Cancel()
|
||||
{
|
||||
var type = LayoutType.Focus;
|
||||
@@ -271,9 +270,9 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var expected = layout.SensitivityRadius;
|
||||
Session.Find<Button>(TestConstants.TemplateLayoutNames[type]).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SensitivitySlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
|
||||
// verify the file
|
||||
@@ -283,7 +282,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.SpaceAroundZones_Initialize")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void SpaceAroundZones_Initialize()
|
||||
{
|
||||
foreach (var (type, name) in TestConstants.TemplateLayoutNames)
|
||||
@@ -309,17 +309,18 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.SpaceAroundZones_Slider_Save")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void SpaceAroundZones_Slider_Save()
|
||||
{
|
||||
var type = LayoutType.PriorityGrid;
|
||||
var layout = Layouts.LayoutTemplates.Find(x => x.Type == type.TypeToString());
|
||||
var expected = layout.Spacing + 1;
|
||||
var expected = layout.Spacing;
|
||||
Session.Find<Button>(TestConstants.TemplateLayoutNames[type]).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
slider.SendKeys(Key.Right);
|
||||
Assert.AreEqual($"{expected}", slider.Text);
|
||||
|
||||
Session.Find<Button>(ElementName.Save).Click();
|
||||
@@ -331,7 +332,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.SpaceAroundZones_Slider_Cancel")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void SpaceAroundZones_Slider_Cancel()
|
||||
{
|
||||
var type = LayoutType.PriorityGrid;
|
||||
@@ -339,10 +341,10 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
var expected = layout.Spacing;
|
||||
Session.Find<Button>(TestConstants.TemplateLayoutNames[type]).Click();
|
||||
|
||||
var slider = Session.Find<Element>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
var slider = Session.Find<Custom>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.SpacingSlider));
|
||||
Assert.IsNotNull(slider);
|
||||
slider.SendKeys(Keys.Right);
|
||||
Assert.AreEqual($"{expected + 1}", slider.Text);
|
||||
slider.SendKeys(Key.Right);
|
||||
Assert.AreEqual($"{expected}", slider.Text);
|
||||
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
|
||||
@@ -353,7 +355,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.SpaceAroundZones_Toggle_Save")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void SpaceAroundZones_Toggle_Save()
|
||||
{
|
||||
var type = LayoutType.PriorityGrid;
|
||||
@@ -376,7 +379,8 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.SpaceAroundZones_Toggle_Cancel")]
|
||||
[TestCategory("FancyZones Editor #6")]
|
||||
public void SpaceAroundZones_Toggle_Cancel()
|
||||
{
|
||||
var type = LayoutType.PriorityGrid;
|
||||
|
||||
@@ -23,17 +23,12 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public class UIInitializeTest : UITestBase
|
||||
{
|
||||
public UIInitializeTest()
|
||||
: base(PowerToysModule.FancyZone)
|
||||
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
||||
{
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestMethod("FancyZonesEditor.Basic.EditorParams_VerifySelectedMonitor")]
|
||||
[TestCategory("FancyZones Editor #10")]
|
||||
public void EditorParams_VerifySelectedMonitor()
|
||||
{
|
||||
InitFileData();
|
||||
@@ -737,6 +732,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
|
||||
private void InitFileData()
|
||||
{
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
EditorParameters editorParameters = new EditorParameters();
|
||||
ParamsWrapper parameters = new ParamsWrapper
|
||||
{
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using static FancyZonesEditorCommon.Data.AppZoneHistory.AppZoneHistoryWrapper;
|
||||
using static FancyZonesEditorCommon.Data.CustomLayouts;
|
||||
|
||||
namespace FancyZonesEditorCommon.Data
|
||||
{
|
||||
public class AppZoneHistory : EditorData<AppZoneHistory.AppZoneHistoryListWrapper>
|
||||
{
|
||||
public string File
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\app-zone-history.json";
|
||||
}
|
||||
}
|
||||
|
||||
public struct AppZoneHistoryWrapper
|
||||
{
|
||||
public struct ZoneHistoryWrapper
|
||||
{
|
||||
public int[][] ZoneIndexSet { get; set; }
|
||||
|
||||
public DeviceIdWrapper Device { get; set; }
|
||||
|
||||
public string ZonesetUuid { get; set; }
|
||||
}
|
||||
|
||||
public struct DeviceIdWrapper
|
||||
{
|
||||
public string Monitor { get; set; }
|
||||
|
||||
public string MonitorInstance { get; set; }
|
||||
|
||||
public int MonitorNumber { get; set; }
|
||||
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
public string VirtualDesktop { get; set; }
|
||||
}
|
||||
|
||||
public string AppPath { get; set; }
|
||||
|
||||
public List<ZoneHistoryWrapper> History { get; set; }
|
||||
}
|
||||
|
||||
public struct AppZoneHistoryListWrapper
|
||||
{
|
||||
public List<AppZoneHistoryWrapper> AppZoneHistory { get; set; }
|
||||
}
|
||||
|
||||
public JsonElement ToJsonElement(ZoneHistoryWrapper info)
|
||||
{
|
||||
string json = JsonSerializer.Serialize(info, this.JsonOptions);
|
||||
return JsonSerializer.Deserialize<JsonElement>(json);
|
||||
}
|
||||
|
||||
public JsonElement ToJsonElement(DeviceIdWrapper info)
|
||||
{
|
||||
string json = JsonSerializer.Serialize(info, this.JsonOptions);
|
||||
return JsonSerializer.Deserialize<JsonElement>(json);
|
||||
}
|
||||
|
||||
public ZoneHistoryWrapper ZoneHistoryFromJsonElement(string json)
|
||||
{
|
||||
return JsonSerializer.Deserialize<ZoneHistoryWrapper>(json, this.JsonOptions);
|
||||
}
|
||||
|
||||
public DeviceIdWrapper GridFromJsonElement(string json)
|
||||
{
|
||||
return JsonSerializer.Deserialize<DeviceIdWrapper>(json, this.JsonOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ namespace Microsoft.FancyZonesEditor.UITests.Utils
|
||||
|
||||
public IOTestHelper LayoutTemplatesIOHelper { get; }
|
||||
|
||||
public IOTestHelper AppZoneHistoryIOHelper { get; }
|
||||
|
||||
public FancyZonesEditorFiles()
|
||||
{
|
||||
ParamsIOHelper = new IOTestHelper(new EditorParameters().File);
|
||||
@@ -28,6 +30,7 @@ namespace Microsoft.FancyZonesEditor.UITests.Utils
|
||||
DefaultLayoutsIOHelper = new IOTestHelper(new DefaultLayouts().File);
|
||||
LayoutHotkeysIOHelper = new IOTestHelper(new LayoutHotkeys().File);
|
||||
LayoutTemplatesIOHelper = new IOTestHelper(new LayoutTemplates().File);
|
||||
AppZoneHistoryIOHelper = new IOTestHelper(new AppZoneHistory().File);
|
||||
}
|
||||
|
||||
public void Restore()
|
||||
@@ -38,6 +41,7 @@ namespace Microsoft.FancyZonesEditor.UITests.Utils
|
||||
DefaultLayoutsIOHelper.RestoreData();
|
||||
LayoutHotkeysIOHelper.RestoreData();
|
||||
LayoutTemplatesIOHelper.RestoreData();
|
||||
AppZoneHistoryIOHelper.RestoreData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
session.Find<Element>(By.ClassName(ClassName.ContextMenu)).Find<Element>(menuItem).Click();
|
||||
}
|
||||
|
||||
public static Element? GetZone(Session session, int zoneNumber, string zoneClassName)
|
||||
public static Custom? GetZone(Session session, int zoneNumber, string zoneClassName)
|
||||
{
|
||||
var zones = session.FindAll<Element>(By.ClassName(zoneClassName));
|
||||
var zones = session.FindAll<Custom>(By.ClassName(zoneClassName));
|
||||
foreach (var zone in zones)
|
||||
{
|
||||
try
|
||||
@@ -157,7 +157,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
|
||||
public static void MoveSplitter(Session session, int index, int xOffset, int yOffset)
|
||||
{
|
||||
var thumbs = session.FindAll<Element>(By.ClassName(ClassName.Thumb));
|
||||
var thumbs = session.FindAll<Thumb>(By.ClassName(ClassName.Thumb));
|
||||
if (thumbs.Count == 0 || index >= thumbs.Count)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.FancyZonesEditor.UITests.Utils;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
|
||||
namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
{
|
||||
public class FancyZonesEditorSession
|
||||
{
|
||||
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
|
||||
private const string FancyZonesEditorPath = @"\..\..\..\PowerToys.FancyZonesEditor.exe";
|
||||
|
||||
private static FancyZonesEditorFiles? _files;
|
||||
|
||||
public static FancyZonesEditorFiles Files
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_files == null)
|
||||
{
|
||||
_files = new FancyZonesEditorFiles();
|
||||
}
|
||||
|
||||
return _files;
|
||||
}
|
||||
}
|
||||
|
||||
public WindowsDriver<WindowsElement>? Session { get; }
|
||||
|
||||
public WindowsElement? MainEditorWindow { get; }
|
||||
|
||||
public FancyZonesEditorSession(TestContext testContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Launch FancyZonesEditor
|
||||
string? path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
path += FancyZonesEditorPath;
|
||||
|
||||
AppiumOptions opts = new AppiumOptions();
|
||||
opts.AddAdditionalCapability("app", path);
|
||||
Session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
testContext.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
Assert.IsNotNull(Session, "Session not initialized");
|
||||
|
||||
testContext.WriteLine("Session: " + Session.SessionId.ToString());
|
||||
testContext.WriteLine("Title: " + Session.Title);
|
||||
|
||||
// Set implicit timeout to make element search to retry every 500 ms
|
||||
Session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3);
|
||||
|
||||
// Find main editor window
|
||||
try
|
||||
{
|
||||
MainEditorWindow = Session.FindElementByAccessibilityId("MainWindow1");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Assert.IsNotNull(MainEditorWindow, "Main editor window not found");
|
||||
}
|
||||
}
|
||||
|
||||
public void Close(TestContext testContext)
|
||||
{
|
||||
// Close the session
|
||||
if (Session != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// FZEditor application can be closed by explicitly closing main editor window
|
||||
MainEditorWindow?.SendKeys(Keys.Alt + Keys.F4);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
testContext.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
Session.Quit();
|
||||
Session.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private WindowsElement? GetLayout(string layoutName)
|
||||
{
|
||||
var listItem = Session?.FindElementByName(layoutName);
|
||||
Assert.IsNotNull(listItem, "Layout " + layoutName + " not found");
|
||||
return listItem;
|
||||
}
|
||||
|
||||
public WindowsElement? OpenContextMenu(string layoutName)
|
||||
{
|
||||
RightClick_Layout(layoutName);
|
||||
var menu = Session?.FindElementByClassName("ContextMenu");
|
||||
Assert.IsNotNull(menu, "Context menu not found");
|
||||
return menu;
|
||||
}
|
||||
|
||||
public void Click_CreateNewLayout()
|
||||
{
|
||||
var button = Session?.FindElementByAccessibilityId("NewLayoutButton");
|
||||
Assert.IsNotNull(button, "Create new layout button not found");
|
||||
button?.Click();
|
||||
}
|
||||
|
||||
public void Click_EditLayout(string layoutName)
|
||||
{
|
||||
var layout = GetLayout(layoutName);
|
||||
var editButton = layout?.FindElementByAccessibilityId("EditLayoutButton");
|
||||
Assert.IsNotNull(editButton, "Edit button not found");
|
||||
editButton.Click();
|
||||
}
|
||||
|
||||
public void RightClick_Layout(string layoutName)
|
||||
{
|
||||
var layout = GetLayout(layoutName);
|
||||
Actions actions = new Actions(Session);
|
||||
actions.MoveToElement(layout);
|
||||
actions.MoveByOffset(30, 30);
|
||||
actions.ContextClick();
|
||||
actions.Build().Perform();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,12 @@ namespace Microsoft.FancyZonesEditor.UITests.Utils
|
||||
}
|
||||
}
|
||||
|
||||
// For get app zone history data
|
||||
public string GetData()
|
||||
{
|
||||
return ReadFile(_file);
|
||||
}
|
||||
|
||||
private string ReadFile(string fileName)
|
||||
{
|
||||
var attempts = 0;
|
||||
|
||||
Reference in New Issue
Block a user