diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorTests.cs index de9a661278d1..01bd57572275 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorTests.cs @@ -1,4 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; using OpenQA.Selenium.Appium.Windows; namespace PowerToysTests @@ -24,6 +26,53 @@ public void OpenEditorBySettingsButton() session.FindElementByAccessibilityId("PART_Close").Click(); } + [TestMethod] + public void ZoneCount() + { + + WaitSeconds(1); + + OpenFancyZonesSettings(); + + WaitSeconds(1); + + WindowsElement editorButton = session.FindElementByXPath("//Button[@Name=\"Edit zones\"]"); + Assert.IsNotNull(editorButton); + editorButton.Click(); + + WaitSeconds(1); + + WindowsElement minusButton = session.FindElementByAccessibilityId("decrementZones"); + Assert.IsNotNull(minusButton); + + WindowsElement plusButton = session.FindElementByAccessibilityId("incrementZones"); + Assert.IsNotNull(plusButton); + + WindowsElement zoneCount = session.FindElementByAccessibilityId("zoneCount"); + Assert.IsNotNull(zoneCount); + + int zoneCountQty; + Assert.IsTrue(Int32.TryParse(zoneCount.Text, out zoneCountQty)); + + for (int i = zoneCountQty; i > -5; --i) + { + Assert.IsTrue(Int32.TryParse(zoneCount.Text, out zoneCountQty)); + Assert.AreEqual(Math.Max(i, 1), zoneCountQty); + minusButton.Click(); + } + + for (int i = 1; i < 45; ++i) + { + Assert.IsTrue(Int32.TryParse(zoneCount.Text, out zoneCountQty)); + Assert.AreEqual(Math.Min(i, 40), zoneCountQty); + plusButton.Click(); + } + + WindowsElement mainWindow = session.FindElementByAccessibilityId("MainWindow1"); + Assert.IsNotNull(mainWindow); + mainWindow.SendKeys(Keys.Alt + Keys.F4); + } + [ClassInitialize] public static void ClassInitialize(TestContext context) { diff --git a/src/tests/win-app-driver/PowerToysSession.cs b/src/tests/win-app-driver/PowerToysSession.cs index c4c26b8544c0..a07a7b8e7f82 100644 --- a/src/tests/win-app-driver/PowerToysSession.cs +++ b/src/tests/win-app-driver/PowerToysSession.cs @@ -62,6 +62,11 @@ public static void TearDown() } } + public static void WaitSeconds(int seconds) + { + Thread.Sleep(TimeSpan.FromSeconds(seconds)); + } + public static void ShortWait() { Thread.Sleep(TimeSpan.FromSeconds(0.5));