Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test method for Fancy Zones count #3

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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