Skip to content

Commit

Permalink
Added test method for Fancy Zones count (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii44-zz authored Mar 17, 2020
1 parent ded6440 commit 23c441f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/tests/win-app-driver/FancyZonesTests/EditorTests.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
{
Expand Down
5 changes: 5 additions & 0 deletions src/tests/win-app-driver/PowerToysSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 23c441f

Please sign in to comment.