mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
WinAppDriver tests update (#5882)
* tray button fix * settings closing changed * ignore old settings tests * changed test init * changed launch * separated app history file * select enabled modules on launch
This commit is contained in:
parent
c6c9839208
commit
13d61bd866
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
using OpenQA.Selenium.Interactions;
|
using OpenQA.Selenium.Interactions;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -223,6 +224,9 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MoveBottomRightCorner()
|
public void MoveBottomRightCorner()
|
||||||
{
|
{
|
||||||
|
WindowsElement zone = session.FindElementByAccessibilityId("Caption");
|
||||||
|
Assert.IsNotNull(zone, "Unable to move zone");
|
||||||
|
new Actions(session).MoveToElement(zone).ClickAndHold().MoveByOffset(creatorWindow.Rect.Width / 2, 0).Release().Perform();
|
||||||
WindowsElement bottomRightCorner = session.FindElementByAccessibilityId("SEResize");
|
WindowsElement bottomRightCorner = session.FindElementByAccessibilityId("SEResize");
|
||||||
WindowsElement topBorder = session.FindElementByAccessibilityId("NResize");
|
WindowsElement topBorder = session.FindElementByAccessibilityId("NResize");
|
||||||
WindowsElement leftBorder = session.FindElementByAccessibilityId("WResize");
|
WindowsElement leftBorder = session.FindElementByAccessibilityId("WResize");
|
||||||
@ -260,17 +264,13 @@ namespace PowerToysTests
|
|||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
|
||||||
|
|
||||||
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
ResetSettings();
|
ResetSettings();
|
||||||
|
|
||||||
if (!isPowerToysLaunched)
|
Assert.IsTrue(OpenEditor());
|
||||||
{
|
|
||||||
LaunchPowerToys();
|
|
||||||
}
|
|
||||||
OpenEditor();
|
|
||||||
OpenCustomLayouts();
|
OpenCustomLayouts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,27 +278,24 @@ namespace PowerToysTests
|
|||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
CloseEditor();
|
CloseEditor();
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
if (session == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//create canvas zone
|
//create canvas zone
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
creatorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCleanup]
|
[TestCleanup]
|
||||||
public void TestCleanup()
|
public void TestCleanup()
|
||||||
{
|
{
|
||||||
if (session == null)
|
AppiumWebElement cancelButton = creatorWindow.FindElementByName("Cancel");
|
||||||
return;
|
Assert.IsNotNull(cancelButton);
|
||||||
|
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
||||||
new Actions(session).MoveToElement(session.FindElementByXPath("//Button[@Name=\"Cancel\"]")).Click().Perform();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
using OpenQA.Selenium.Interactions;
|
using OpenQA.Selenium.Interactions;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
private void SetLayoutName(string name)
|
private void SetLayoutName(string name)
|
||||||
{
|
{
|
||||||
WindowsElement textBox = session.FindElementByClassName("TextBox");
|
AppiumWebElement textBox = creatorWindow.FindElementByClassName("TextBox");
|
||||||
textBox.Click();
|
textBox.Click();
|
||||||
textBox.SendKeys(Keys.Control + "a");
|
textBox.SendKeys(Keys.Control + "a");
|
||||||
textBox.SendKeys(Keys.Backspace);
|
textBox.SendKeys(Keys.Backspace);
|
||||||
@ -21,7 +22,7 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
private void CancelTest()
|
private void CancelTest()
|
||||||
{
|
{
|
||||||
WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]");
|
AppiumWebElement cancelButton = creatorWindow.FindElementByXPath("//Button[@Name=\"Cancel\"]");
|
||||||
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
private void SaveTest(string type, string name, int zoneCount)
|
private void SaveTest(string type, string name, int zoneCount)
|
||||||
{
|
{
|
||||||
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
|
new Actions(session).MoveToElement(editorWindow.FindElementByName("Save and apply")).Click().Perform();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
||||||
@ -43,10 +44,10 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateCancel()
|
public void CreateCancel()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
ZoneCountTest(0, 0);
|
ZoneCountTest(0, 0);
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
editorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||||
ZoneCountTest(1, 0);
|
ZoneCountTest(1, 0);
|
||||||
|
|
||||||
CancelTest();
|
CancelTest();
|
||||||
@ -55,7 +56,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateEmpty()
|
public void CreateEmpty()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
ZoneCountTest(0, 0);
|
ZoneCountTest(0, 0);
|
||||||
|
|
||||||
SaveTest("canvas", "Custom Layout 1", 0);
|
SaveTest("canvas", "Custom Layout 1", 0);
|
||||||
@ -64,10 +65,10 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateSingleZone()
|
public void CreateSingleZone()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
ZoneCountTest(0, 0);
|
ZoneCountTest(0, 0);
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
editorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||||
ZoneCountTest(1, 0);
|
ZoneCountTest(1, 0);
|
||||||
|
|
||||||
SaveTest("canvas", "Custom Layout 1", 1);
|
SaveTest("canvas", "Custom Layout 1", 1);
|
||||||
@ -76,11 +77,11 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateManyZones()
|
public void CreateManyZones()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
ZoneCountTest(0, 0);
|
ZoneCountTest(0, 0);
|
||||||
|
|
||||||
const int expectedZoneCount = 20;
|
const int expectedZoneCount = 20;
|
||||||
WindowsElement addButton = session.FindElementByAccessibilityId("newZoneButton");
|
AppiumWebElement addButton = editorWindow.FindElementByAccessibilityId("newZoneButton");
|
||||||
for (int i = 0; i < expectedZoneCount; i++)
|
for (int i = 0; i < expectedZoneCount; i++)
|
||||||
{
|
{
|
||||||
addButton.Click();
|
addButton.Click();
|
||||||
@ -93,12 +94,12 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateDeleteZone()
|
public void CreateDeleteZone()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
ZoneCountTest(0, 0);
|
ZoneCountTest(0, 0);
|
||||||
|
|
||||||
WindowsElement addButton = session.FindElementByAccessibilityId("newZoneButton");
|
AppiumWebElement addButton = editorWindow.FindElementByAccessibilityId("newZoneButton");
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
//add zone
|
//add zone
|
||||||
addButton.Click();
|
addButton.Click();
|
||||||
@ -117,7 +118,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateWithName()
|
public void CreateWithName()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
string name = "My custom zone layout name";
|
string name = "My custom zone layout name";
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
SaveTest("canvas", name, 0);
|
SaveTest("canvas", name, 0);
|
||||||
@ -126,7 +127,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateWithEmptyName()
|
public void CreateWithEmptyName()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
string name = "";
|
string name = "";
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
SaveTest("canvas", name, 0);
|
SaveTest("canvas", name, 0);
|
||||||
@ -135,7 +136,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateWithUnicodeCharactersName()
|
public void CreateWithUnicodeCharactersName()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
string name = "ёÖ±¬āݾᵩὡ√ﮘﻹտ";
|
string name = "ёÖ±¬āݾᵩὡ√ﮘﻹտ";
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
SaveTest("canvas", name, 0);
|
SaveTest("canvas", name, 0);
|
||||||
@ -145,55 +146,21 @@ namespace PowerToysTests
|
|||||||
public void RenameLayout()
|
public void RenameLayout()
|
||||||
{
|
{
|
||||||
//create layout
|
//create layout
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
string name = "My custom zone layout name";
|
string name = "My custom zone layout name";
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
SaveTest("canvas", name, 0);
|
SaveTest("canvas", name, 0);
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
//rename layout
|
//rename layout
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
OpenCustomLayouts();
|
OpenCustomLayouts();
|
||||||
OpenCreatorWindow(name, "Custom layout creator");
|
OpenCreatorWindow(name);
|
||||||
name = "New name";
|
name = "New name";
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
SaveTest("canvas", name, 0);
|
SaveTest("canvas", name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void RemoveLayout()
|
|
||||||
{
|
|
||||||
//create layout
|
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
|
||||||
string name = "Name";
|
|
||||||
SetLayoutName(name);
|
|
||||||
SaveTest("canvas", name, 0);
|
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
//save layout id
|
|
||||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
|
||||||
Assert.AreEqual(1, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
|
||||||
string layoutId = settings["custom-zone-sets"][0]["uuid"].ToString();
|
|
||||||
|
|
||||||
//remove layout
|
|
||||||
OpenEditor();
|
|
||||||
OpenCustomLayouts();
|
|
||||||
WindowsElement nameLabel = session.FindElementByXPath("//Text[@Name=\"" + name + "\"]");
|
|
||||||
new Actions(session).MoveToElement(nameLabel).MoveByOffset(nameLabel.Rect.Width / 2 + 10, 0).Click().Perform();
|
|
||||||
|
|
||||||
//settings are saved on window closing
|
|
||||||
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform();
|
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
//check settings
|
|
||||||
settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
|
||||||
Assert.AreEqual(0, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
|
||||||
foreach (JObject device in settings["devices"].ToObject<JArray>())
|
|
||||||
{
|
|
||||||
Assert.AreNotEqual(layoutId, device["active-zoneset"]["uuid"], "Deleted layout still applied");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void AddRemoveSameLayoutNames()
|
public void AddRemoveSameLayoutNames()
|
||||||
{
|
{
|
||||||
@ -202,50 +169,20 @@ namespace PowerToysTests
|
|||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
//create layout
|
//create layout
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
|
|
||||||
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
|
new Actions(session).MoveToElement(editorWindow.FindElementByName("Save and apply")).Click().Perform();
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
//remove layout
|
//remove layout
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
OpenCustomLayouts();
|
OpenCustomLayouts();
|
||||||
WindowsElement nameLabel = session.FindElementByXPath("//Text[@Name=\"" + name + "\"]");
|
AppiumWebElement nameLabel = editorWindow.FindElementByXPath("//Text[@Name=\"" + name + "\"]");
|
||||||
new Actions(session).MoveToElement(nameLabel).MoveByOffset(nameLabel.Rect.Width / 2 + 10, 0).Click().Perform();
|
new Actions(session).MoveToElement(nameLabel).MoveByOffset(nameLabel.Rect.Width / 2 + 10, 0).Click().Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
//settings are saved on window closing
|
//settings are saved on window closing
|
||||||
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform();
|
new Actions(session).MoveToElement(editorWindow.FindElementByAccessibilityId("PART_Close")).Click().Perform();
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
//check settings
|
|
||||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
|
||||||
Assert.AreEqual(0, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void AddRemoveDifferentLayoutNames()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
string name = i.ToString();
|
|
||||||
|
|
||||||
//create layout
|
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
|
||||||
SetLayoutName(name);
|
|
||||||
|
|
||||||
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
|
|
||||||
|
|
||||||
//remove layout
|
|
||||||
OpenEditor();
|
|
||||||
OpenCustomLayouts();
|
|
||||||
WindowsElement nameLabel = session.FindElementByXPath("//Text[@Name=\"" + name + "\"]");
|
|
||||||
new Actions(session).MoveToElement(nameLabel).MoveByOffset(nameLabel.Rect.Width / 2 + 10, 0).Click().Perform();
|
|
||||||
}
|
|
||||||
|
|
||||||
//settings are saved on window closing
|
|
||||||
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform();
|
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
//check settings
|
//check settings
|
||||||
@ -259,62 +196,52 @@ namespace PowerToysTests
|
|||||||
string name = "Name";
|
string name = "Name";
|
||||||
|
|
||||||
//create layout
|
//create layout
|
||||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
OpenCreatorWindow("Create new custom");
|
||||||
SetLayoutName(name);
|
SetLayoutName(name);
|
||||||
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
|
new Actions(session).MoveToElement(editorWindow.FindElementByName("Save and apply")).Click().Perform();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
//save layout id
|
//save layout id
|
||||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
||||||
Assert.AreEqual(1, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
Assert.AreEqual(1, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
||||||
string layoutId = settings["custom-zone-sets"][0]["uuid"].ToString();
|
|
||||||
|
|
||||||
//remove layout
|
//remove layout
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
OpenCustomLayouts();
|
OpenCustomLayouts();
|
||||||
WindowsElement nameLabel = session.FindElementByXPath("//Text[@Name=\"" + name + "\"]");
|
AppiumWebElement nameLabel = editorWindow.FindElementByXPath("//Text[@Name=\"" + name + "\"]");
|
||||||
new Actions(session).MoveToElement(nameLabel).MoveByOffset(nameLabel.Rect.Width / 2 + 10, 0).Click().Perform();
|
new Actions(session).MoveToElement(nameLabel).MoveByOffset(nameLabel.Rect.Width / 2 + 10, 0).Click().Perform();
|
||||||
|
|
||||||
//apply
|
//apply
|
||||||
new Actions(session).MoveToElement(session.FindElementByName("Apply")).Click().Perform();
|
new Actions(session).MoveToElement(editorWindow.FindElementByName("Apply")).Click().Perform();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
//check settings
|
//check settings
|
||||||
settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
||||||
Assert.AreEqual(0, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
Assert.AreEqual(0, settings["custom-zone-sets"].ToObject<JArray>().Count);
|
||||||
foreach (JObject device in settings["devices"].ToObject<JArray>())
|
|
||||||
{
|
|
||||||
Assert.AreNotEqual(layoutId, device["active-zoneset"]["uuid"], "Deleted layout still applied");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
|
|
||||||
ResetSettings();
|
ResetDefaultFancyZonesSettings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassCleanup]
|
[ClassCleanup]
|
||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
if (session == null)
|
ResetDefaultZoneSettings(true);
|
||||||
return;
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
if (!isPowerToysLaunched)
|
|
||||||
{
|
|
||||||
LaunchPowerToys();
|
|
||||||
}
|
|
||||||
OpenEditor();
|
|
||||||
OpenCustomLayouts();
|
OpenCustomLayouts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +249,7 @@ namespace PowerToysTests
|
|||||||
public void TestCleanup()
|
public void TestCleanup()
|
||||||
{
|
{
|
||||||
CloseEditor();
|
CloseEditor();
|
||||||
ResetDefaultZoneSettings(false);
|
ExitPowerToys();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,11 +48,11 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MoveVerticalSplitter()
|
public void MoveVerticalSplitter()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
int expected = thumb.Rect.X;
|
int expected = thumb.Rect.X;
|
||||||
|
|
||||||
Move(thumb, Screen.PrimaryScreen.WorkingArea.Right, false, false);
|
Move(thumb, Screen.PrimaryScreen.WorkingArea.Right, true, false);
|
||||||
int actual = thumb.Rect.X;
|
int actual = thumb.Rect.X;
|
||||||
|
|
||||||
Assert.AreEqual(expected, actual);
|
Assert.AreEqual(expected, actual);
|
||||||
@ -104,11 +104,11 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MoveHorizontalSplitter()
|
public void MoveHorizontalSplitter()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
@ -160,10 +160,11 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateSplitter()
|
public void CreateSplitter()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WaitSeconds(2);
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(3, zones.Count, "Zones count invalid");
|
Assert.AreEqual(3, zones.Count, "Zones count invalid");
|
||||||
|
|
||||||
const int defaultSpacing = 16;
|
const int defaultSpacing = 16;
|
||||||
@ -171,23 +172,24 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
new Actions(session).MoveToElement(zones[0]).Click().Perform();
|
new Actions(session).MoveToElement(zones[0]).Click().Perform();
|
||||||
|
|
||||||
zones = session.FindElementsByClassName("GridZone");
|
zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(4, zones.Count);
|
Assert.AreEqual(4, zones.Count);
|
||||||
|
|
||||||
//check splitted zone
|
//check splitted zone
|
||||||
Assert.AreEqual(zones[0].Rect.Top, defaultSpacing);
|
Assert.AreEqual(zones[0].Rect.Top, defaultSpacing);
|
||||||
Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - splitPos + defaultSpacing / 2) <= 2);
|
Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - splitPos + defaultSpacing / 2) <= 2);
|
||||||
Assert.IsTrue(Math.Abs(zones[3].Rect.Top - splitPos - defaultSpacing / 2) <= 2);
|
Assert.IsTrue(Math.Abs(zones[1].Rect.Top - splitPos - defaultSpacing / 2) <= 2);
|
||||||
Assert.AreEqual(zones[3].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing);
|
Assert.AreEqual(zones[1].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestSplitterShiftAfterCreation()
|
public void TestSplitterShiftAfterCreation()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WaitSeconds(2);
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(3, zones.Count, "Zones count invalid");
|
Assert.AreEqual(3, zones.Count, "Zones count invalid");
|
||||||
|
|
||||||
const int defaultSpacing = 16;
|
const int defaultSpacing = 16;
|
||||||
@ -196,12 +198,12 @@ namespace PowerToysTests
|
|||||||
int firstSplitPos = zones[0].Rect.Y + zones[0].Rect.Height / 4;
|
int firstSplitPos = zones[0].Rect.Y + zones[0].Rect.Height / 4;
|
||||||
new Actions(session).MoveToElement(zones[0]).MoveByOffset(0, -(zones[0].Rect.Height / 4)).Click().Perform();
|
new Actions(session).MoveToElement(zones[0]).MoveByOffset(0, -(zones[0].Rect.Height / 4)).Click().Perform();
|
||||||
|
|
||||||
zones = session.FindElementsByClassName("GridZone");
|
zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(4, zones.Count);
|
Assert.AreEqual(4, zones.Count);
|
||||||
|
|
||||||
Assert.AreEqual(zones[0].Rect.Top, defaultSpacing);
|
Assert.AreEqual(zones[0].Rect.Top, defaultSpacing);
|
||||||
Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - firstSplitPos + defaultSpacing / 2) <= 2);
|
Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - firstSplitPos + defaultSpacing / 2) <= 2);
|
||||||
Assert.IsTrue(Math.Abs(zones[3].Rect.Top - firstSplitPos - defaultSpacing / 2) <= 2);
|
Assert.IsTrue(Math.Abs(zones[1].Rect.Top - firstSplitPos - defaultSpacing / 2) <= 2);
|
||||||
Assert.AreEqual(zones[3].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing);
|
Assert.AreEqual(zones[3].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing);
|
||||||
|
|
||||||
//create second split
|
//create second split
|
||||||
@ -210,7 +212,7 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
new Actions(session).MoveToElement(zones[3]).Click().Perform();
|
new Actions(session).MoveToElement(zones[3]).Click().Perform();
|
||||||
|
|
||||||
zones = session.FindElementsByClassName("GridZone");
|
zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(5, zones.Count);
|
Assert.AreEqual(5, zones.Count);
|
||||||
|
|
||||||
//check first split on same position
|
//check first split on same position
|
||||||
@ -227,20 +229,20 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateSplitterWithShiftPressed()
|
public void CreateSplitterWithShiftPressed()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
new Actions(session).MoveToElement(thumbs[0]).MoveByOffset(-100, 0)
|
new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-100, 0)
|
||||||
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
||||||
.Perform();
|
.Perform();
|
||||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count);
|
||||||
|
|
||||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(4, zones.Count);
|
Assert.AreEqual(4, zones.Count);
|
||||||
|
|
||||||
//check that zone was splitted vertically
|
//check that zone was splitted vertically
|
||||||
@ -252,12 +254,12 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CreateSplitterWithShiftPressedFocusOnGridEditor()
|
public void CreateSplitterWithShiftPressedFocusOnGridEditor()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-100, 0)
|
new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-100, 0)
|
||||||
@ -265,7 +267,7 @@ namespace PowerToysTests
|
|||||||
.Perform();
|
.Perform();
|
||||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count);
|
||||||
|
|
||||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Assert.AreEqual(4, zones.Count);
|
Assert.AreEqual(4, zones.Count);
|
||||||
|
|
||||||
//check that zone was splitted vertically
|
//check that zone was splitted vertically
|
||||||
@ -277,11 +279,11 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MoveHorizontallyWithLimiter()
|
public void MoveHorizontallyWithLimiter()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
@ -290,7 +292,7 @@ namespace PowerToysTests
|
|||||||
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
||||||
.Perform();
|
.Perform();
|
||||||
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(4, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(4, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
Assert.AreEqual(3, thumbs.Count);
|
Assert.AreEqual(3, thumbs.Count);
|
||||||
|
|
||||||
//move thumbs
|
//move thumbs
|
||||||
@ -311,11 +313,11 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MoveVerticallyWithLimiter()
|
public void MoveVerticallyWithLimiter()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
@ -324,7 +326,7 @@ namespace PowerToysTests
|
|||||||
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
||||||
.Perform();
|
.Perform();
|
||||||
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(4, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(4, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
Assert.AreEqual(3, thumbs.Count);
|
Assert.AreEqual(3, thumbs.Count);
|
||||||
|
|
||||||
//move thumbs
|
//move thumbs
|
||||||
@ -345,29 +347,29 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MergeZones()
|
public void MergeZones()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
Assert.AreEqual(3, zones.Count);
|
Assert.AreEqual(3, zones.Count);
|
||||||
Assert.AreEqual(2, thumbs.Count);
|
Assert.AreEqual(2, thumbs.Count);
|
||||||
|
|
||||||
Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10);
|
Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10);
|
||||||
|
|
||||||
WindowsElement mergeButton = session.FindElementByName("Merge zones");
|
AppiumWebElement mergeButton = gridEditor.FindElementByName("Merge zones");
|
||||||
Assert.IsNotNull(mergeButton, "Cannot merge: no merge button");
|
Assert.IsNotNull(mergeButton, "Cannot merge: no merge button");
|
||||||
new Actions(session).Click(mergeButton).Perform();
|
new Actions(session).Click(mergeButton).Perform();
|
||||||
|
|
||||||
Assert.AreEqual(2, session.FindElementsByClassName("GridZone").Count);
|
Assert.AreEqual(2, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||||
Assert.AreEqual(1, gridEditor.FindElementsByClassName("Thumb").Count);
|
Assert.AreEqual(1, gridEditor.FindElementsByClassName("Thumb").Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MoveAfterMerge()
|
public void MoveAfterMerge()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||||
Assert.IsNotNull(gridEditor);
|
Assert.IsNotNull(gridEditor);
|
||||||
|
|
||||||
@ -380,14 +382,15 @@ namespace PowerToysTests
|
|||||||
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
|
|
||||||
//merge zones
|
//merge zones
|
||||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||||
Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10);
|
Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10);
|
||||||
WindowsElement mergeButton = session.FindElementByName("Merge zones");
|
AppiumWebElement mergeButton = gridEditor.FindElementByName("Merge zones");
|
||||||
Assert.IsNotNull(mergeButton, "Cannot merge: no merge button");
|
Assert.IsNotNull(mergeButton, "Cannot merge: no merge button");
|
||||||
new Actions(session).Click(mergeButton).Perform();
|
new Actions(session).Click(mergeButton).Perform();
|
||||||
|
|
||||||
//move thumb
|
//move thumb
|
||||||
AppiumWebElement thumb = thumbs[1]; //thumb from merged zone is still present
|
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||||
|
AppiumWebElement thumb = thumbs[0];
|
||||||
Move(thumb, 0, false, true);
|
Move(thumb, 0, false, true);
|
||||||
Assert.IsTrue(thumb.Rect.Left <= moveStep);
|
Assert.IsTrue(thumb.Rect.Left <= moveStep);
|
||||||
Assert.IsTrue(thumb.Rect.Right > 0);
|
Assert.IsTrue(thumb.Rect.Right > 0);
|
||||||
@ -396,9 +399,9 @@ namespace PowerToysTests
|
|||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
|
|
||||||
ResetSettings();
|
ResetSettings();
|
||||||
|
|
||||||
@ -406,7 +409,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
LaunchPowerToys();
|
LaunchPowerToys();
|
||||||
}
|
}
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
OpenTemplates();
|
OpenTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,6 +417,7 @@ namespace PowerToysTests
|
|||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
CloseEditor();
|
CloseEditor();
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +430,7 @@ namespace PowerToysTests
|
|||||||
[TestCleanup]
|
[TestCleanup]
|
||||||
public void TestCleanup()
|
public void TestCleanup()
|
||||||
{
|
{
|
||||||
WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]");
|
AppiumWebElement cancelButton = creatorWindow.FindElementByName("Cancel");
|
||||||
Assert.IsNotNull(cancelButton);
|
Assert.IsNotNull(cancelButton);
|
||||||
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
using OpenQA.Selenium.Interactions;
|
using OpenQA.Selenium.Interactions;
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ namespace PowerToysTests
|
|||||||
void RemoveSettingsFile()
|
void RemoveSettingsFile()
|
||||||
{
|
{
|
||||||
File.Delete(_zoneSettingsPath);
|
File.Delete(_zoneSettingsPath);
|
||||||
|
File.Delete(_appHistoryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveSettingsFolder()
|
void RemoveSettingsFolder()
|
||||||
@ -22,44 +24,62 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
string zoneSettings = "";
|
string zoneSettings = "";
|
||||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||||
|
|
||||||
|
string appHistory = "";
|
||||||
|
File.WriteAllText(_appHistoryPath, appHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateDefaultSettingsFile()
|
void CreateDefaultSettingsFile()
|
||||||
{
|
{
|
||||||
string zoneSettings = "{\"app-zone-history\":[],\"devices\":[],\"custom-zone-sets\":[]}";
|
string zoneSettings = "{\"devices\":[],\"custom-zone-sets\":[]}";
|
||||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||||
|
|
||||||
|
string appHistory = "{\"app-zone-history\":[]}";
|
||||||
|
File.WriteAllText(_appHistoryPath, appHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateValidSettingsFile()
|
void CreateValidSettingsFile()
|
||||||
{
|
{
|
||||||
string zoneSettings = "{\"app-zone-history\":[{\"app-path\":\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\Extensions\\TestPlatform\\testhost.exe\",\"zone-index\":3,\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"zoneset-uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\"}],\"devices\":[{\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"active-zoneset\":{\"uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\",\"type\":\"columns\"},\"editor-show-spacing\":true,\"editor-spacing\":16,\"editor-zone-count\":3}],\"custom-zone-sets\":[]}";
|
string zoneSettings = "{\"devices\":[{\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"active-zoneset\":{\"uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\",\"type\":\"columns\"},\"editor-show-spacing\":true,\"editor-spacing\":16,\"editor-zone-count\":3}],\"custom-zone-sets\":[]}";
|
||||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||||
|
|
||||||
|
string appHistory = "{\"app-zone-history\":[{\"app-path\":\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\Extensions\\TestPlatform\\testhost.exe\",\"zone-index\":3,\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"zoneset-uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\"}]}";
|
||||||
|
File.WriteAllText(_appHistoryPath, appHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateValidSettingsFileWithUtf8()
|
void CreateValidSettingsFileWithUtf8()
|
||||||
{
|
{
|
||||||
string zoneSettings = "{\"app-zone-history\":[{\"app-path\":\"C:\\Program Files (x86)\\йцукен\\testhost.exe\",\"zone-index\":3,\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"zoneset-uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\"}],\"devices\":[{\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"active-zoneset\":{\"uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\",\"type\":\"columns\"},\"editor-show-spacing\":true,\"editor-spacing\":16,\"editor-zone-count\":3}],\"custom-zone-sets\":[]}";
|
string zoneSettings = "{\"devices\":[{\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"active-zoneset\":{\"uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\",\"type\":\"columns\"},\"editor-show-spacing\":true,\"editor-spacing\":16,\"editor-zone-count\":3}],\"custom-zone-sets\":[]}";
|
||||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||||
|
|
||||||
|
string appHistory = "{\"app-zone-history\":[{\"app-path\":\"C:\\Program Files (x86)\\йцукен\\testhost.exe\",\"zone-index\":3,\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"zoneset-uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\"}]}";
|
||||||
|
File.WriteAllText(_appHistoryPath, appHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateInvalidSettingsFile()
|
void CreateInvalidSettingsFile()
|
||||||
{
|
{
|
||||||
string zoneSettings = "{\"app-zone-history\":[{\"app-path\":\"C:\\Program Files (x86)\\Microsoft Visual Studio\\testhost.exe\",\"zone-index\":3,\"device-id\":\"wrong-device-id\",\"zoneset-uuid\":\"{D13ABB6D-invalid-uuid-C8C0836D99CC}\"}],\"devices\":[{\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"active-zoneset\":{\"uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\",\"type\":\"columns\"},\"editor-show-spacing\":true,\"editor-spacing\":16,\"editor-zone-count\":3}],\"custom-zone-sets\":[]}";
|
string zoneSettings = "{\"app-zone-history\":[{\"app-path\":\"C:\\Program Files (x86)\\Microsoft Visual Studio\\testhost.exe\",\"zone-index\":3,\"device-id\":\"wrong-device-id\",\"zoneset-uuid\":\"{D13ABB6D-invalid-uuid-C8C0836D99CC}\"}],\"devices\":[{\"device-id\":\"DELA026#5&10a58c63&0&UID16777488_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\",\"active-zoneset\":{\"uuid\":\"{D13ABB6D-7721-4176-9647-C8C0836D99CC}\",\"type\":\"columns\"},\"editor-show-spacing\":true,\"editor-spacing\":16,\"editor-zone-count\":3}],\"custom-zone-sets\":[]}";
|
||||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||||
|
|
||||||
|
string appHistory = "";
|
||||||
|
File.WriteAllText(_appHistoryPath, appHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateCroppedSettingsFile()
|
void CreateCroppedSettingsFile()
|
||||||
{
|
{
|
||||||
string zoneSettings = "{\"app-zone-history\":[],\"devices\":[],\"custom-zone-sets\":[{\"uuid\":\"{8BEC7183-C90E-4D41-AD1C-1AC2BC4760BA}\",\"name\":\"";
|
string zoneSettings = "{\"devices\":[],\"custom-zone-sets\":[{\"uuid\":\"{8BEC7183-C90E-4D41-AD1C-1AC2BC4760BA}\",\"name\":\"";
|
||||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||||
|
|
||||||
|
string appHistory = "{\"app-zone-history\":[]}";
|
||||||
|
File.WriteAllText(_appHistoryPath, appHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestEditorOpened()
|
void TestEditorOpened(bool errorExpected = false)
|
||||||
{
|
{
|
||||||
WindowsElement errorMessage = null;
|
WindowsElement errorMessage = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
errorMessage = WaitElementByName("FancyZones Editor Exception Handler");
|
errorMessage = session.FindElementByName("FancyZones Editor Exception Handler");
|
||||||
if (errorMessage != null)
|
if (errorMessage != null)
|
||||||
{
|
{
|
||||||
errorMessage.FindElementByName("OK").Click();
|
errorMessage.FindElementByName("OK").Click();
|
||||||
@ -70,34 +90,29 @@ namespace PowerToysTests
|
|||||||
//no error message, it's ok
|
//no error message, it's ok
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
editorWindow = session.FindElementByName("FancyZones Editor");
|
||||||
{
|
|
||||||
editorWindow = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
|
|
||||||
}
|
|
||||||
catch (OpenQA.Selenium.WebDriverException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.IsNotNull(editorWindow);
|
Assert.IsNotNull(editorWindow);
|
||||||
Assert.IsNull(errorMessage);
|
|
||||||
|
if (!errorExpected)
|
||||||
|
{
|
||||||
|
Assert.IsNull(errorMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorBySettingsButton()
|
void OpenEditorBySettingsButton()
|
||||||
{
|
{
|
||||||
OpenSettings();
|
OpenSettings();
|
||||||
OpenFancyZonesSettings();
|
OpenFancyZonesSettings();
|
||||||
|
settingsWindow.FindElementByName("Launch zones editor").Click();
|
||||||
WindowsElement editorButton = session.FindElementByXPath("//Button[@Name=\"Edit zones\"]");
|
|
||||||
Assert.IsNotNull(editorButton);
|
|
||||||
|
|
||||||
editorButton.Click();
|
|
||||||
TestEditorOpened();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorByHotkey()
|
void OpenEditorByHotkey()
|
||||||
{
|
{
|
||||||
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
||||||
TestEditorOpened();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -105,6 +120,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
RemoveSettingsFile();
|
RemoveSettingsFile();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -121,6 +137,7 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
RemoveSettingsFolder();
|
RemoveSettingsFolder();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -128,6 +145,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateEmptySettingsFile();
|
CreateEmptySettingsFile();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -135,6 +153,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateDefaultSettingsFile();
|
CreateDefaultSettingsFile();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -142,6 +161,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateValidSettingsFile();
|
CreateValidSettingsFile();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -149,6 +169,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateValidSettingsFileWithUtf8();
|
CreateValidSettingsFileWithUtf8();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -156,6 +177,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateInvalidSettingsFile();
|
CreateInvalidSettingsFile();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -163,6 +185,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateCroppedSettingsFile();
|
CreateCroppedSettingsFile();
|
||||||
OpenEditorBySettingsButton();
|
OpenEditorBySettingsButton();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -170,6 +193,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
RemoveSettingsFile();
|
RemoveSettingsFile();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -185,6 +209,7 @@ namespace PowerToysTests
|
|||||||
*/
|
*/
|
||||||
RemoveSettingsFolder();
|
RemoveSettingsFolder();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -192,6 +217,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateEmptySettingsFile();
|
CreateEmptySettingsFile();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -199,6 +225,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateDefaultSettingsFile();
|
CreateDefaultSettingsFile();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -206,6 +233,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateValidSettingsFile();
|
CreateValidSettingsFile();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -213,6 +241,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateValidSettingsFileWithUtf8();
|
CreateValidSettingsFileWithUtf8();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -220,6 +249,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateInvalidSettingsFile();
|
CreateInvalidSettingsFile();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -227,14 +257,15 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
CreateCroppedSettingsFile();
|
CreateCroppedSettingsFile();
|
||||||
OpenEditorByHotkey();
|
OpenEditorByHotkey();
|
||||||
|
TestEditorOpened(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
|
|
||||||
ResetDefaultFancyZonesSettings(true);
|
ResetDefaultFancyZonesSettings(true);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium;
|
||||||
|
|
||||||
namespace PowerToysTests
|
namespace PowerToysTests
|
||||||
{
|
{
|
||||||
@ -18,10 +17,10 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void ZoneCount()
|
public void ZoneCount()
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
WindowsElement minusButton = session.FindElementByAccessibilityId("decrementZones");
|
AppiumWebElement minusButton = editorWindow.FindElementByAccessibilityId("decrementZones");
|
||||||
WindowsElement zoneCount = session.FindElementByAccessibilityId("zoneCount");
|
AppiumWebElement zoneCount = editorWindow.FindElementByAccessibilityId("zoneCount");
|
||||||
|
|
||||||
int editorZoneCountValue;
|
int editorZoneCountValue;
|
||||||
Assert.IsTrue(Int32.TryParse(zoneCount.Text, out editorZoneCountValue));
|
Assert.IsTrue(Int32.TryParse(zoneCount.Text, out editorZoneCountValue));
|
||||||
@ -35,18 +34,18 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
if (j == 0 || i == -4)
|
if (j == 0 || i == -4)
|
||||||
{
|
{
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
|
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
|
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
minusButton = session.FindElementByAccessibilityId("decrementZones");
|
minusButton = editorWindow.FindElementByAccessibilityId("decrementZones");
|
||||||
zoneCount = session.FindElementByAccessibilityId("zoneCount");
|
zoneCount = editorWindow.FindElementByAccessibilityId("zoneCount");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowsElement plusButton = session.FindElementByAccessibilityId("incrementZones");
|
AppiumWebElement plusButton = editorWindow.FindElementByAccessibilityId("incrementZones");
|
||||||
|
|
||||||
for (int i = 2; i < 45; ++i)
|
for (int i = 2; i < 45; ++i)
|
||||||
{
|
{
|
||||||
@ -56,7 +55,7 @@ namespace PowerToysTests
|
|||||||
Assert.AreEqual(Math.Min(i, 40), editorZoneCountValue);
|
Assert.AreEqual(Math.Min(i, 40), editorZoneCountValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
|
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
|
||||||
}
|
}
|
||||||
@ -66,13 +65,13 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
WindowsElement spaceAroundSetting = session.FindElementByAccessibilityId("spaceAroundSetting");
|
AppiumWebElement spaceAroundSetting = editorWindow.FindElementByAccessibilityId("spaceAroundSetting");
|
||||||
bool spaceAroundSettingValue = spaceAroundSetting.Selected;
|
bool spaceAroundSettingValue = spaceAroundSetting.Selected;
|
||||||
spaceAroundSetting.Click();
|
spaceAroundSetting.Click();
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
|
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
@ -83,25 +82,24 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void SpacingTestsValid()
|
public void SpacingTestsValid()
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
WindowsElement spaceAroundSetting = session.FindElementByAccessibilityId("spaceAroundSetting");
|
AppiumWebElement spaceAroundSetting = editorWindow.FindElementByAccessibilityId("spaceAroundSetting");
|
||||||
bool editorShowSpacingValue = spaceAroundSetting.Selected;
|
bool editorShowSpacingValue = spaceAroundSetting.Selected;
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
foreach (string editorSpacingValue in validValues)
|
foreach (string editorSpacingValue in validValues)
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
WindowsElement paddingValue = WaitElementByAccessibilityId("paddingValue");
|
AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
|
||||||
ClearText(paddingValue);
|
ClearText(paddingValue);
|
||||||
paddingValue.SendKeys(editorSpacingValue);
|
paddingValue.SendKeys(editorSpacingValue);
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
|
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
|
||||||
@ -112,13 +110,12 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void SpacingTestsInvalid()
|
public void SpacingTestsInvalid()
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
WindowsElement spaceAroundSetting = session.FindElementByAccessibilityId("spaceAroundSetting");
|
AppiumWebElement spaceAroundSetting = editorWindow.FindElementByAccessibilityId("spaceAroundSetting");
|
||||||
bool editorShowSpacingValue = spaceAroundSetting.Selected;
|
bool editorShowSpacingValue = spaceAroundSetting.Selected;
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" };
|
string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" };
|
||||||
|
|
||||||
@ -126,14 +123,13 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
foreach (string value in invalidValues)
|
foreach (string value in invalidValues)
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
WindowsElement paddingValue = WaitElementByAccessibilityId("paddingValue");
|
AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
|
||||||
ClearText(paddingValue);
|
ClearText(paddingValue);
|
||||||
paddingValue.SendKeys(value);
|
paddingValue.SendKeys(value);
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
WaitSeconds(1);
|
|
||||||
|
|
||||||
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
|
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
|
||||||
Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing));
|
Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing));
|
||||||
@ -143,19 +139,19 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void SpacingTestLargeValue()
|
public void SpacingTestLargeValue()
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
session.FindElementByXPath("//Text[@Name=\"Grid\"]").Click();
|
editorWindow.FindElementByName("Grid").Click();
|
||||||
|
|
||||||
WindowsElement paddingValue = session.FindElementByAccessibilityId("paddingValue");
|
AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
|
||||||
ClearText(paddingValue);
|
ClearText(paddingValue);
|
||||||
paddingValue.SendKeys("1000");
|
paddingValue.SendKeys("1000");
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
|
|
||||||
editorWindow = null;
|
editorWindow = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OpenEditor();
|
Assert.IsTrue(OpenEditor());
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
@ -169,7 +165,7 @@ namespace PowerToysTests
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearText(WindowsElement windowsElement)
|
private void ClearText(AppiumWebElement windowsElement)
|
||||||
{
|
{
|
||||||
windowsElement.SendKeys(Keys.Home);
|
windowsElement.SendKeys(Keys.Home);
|
||||||
windowsElement.SendKeys(Keys.Control + Keys.Delete);
|
windowsElement.SendKeys(Keys.Control + Keys.Delete);
|
||||||
@ -178,10 +174,9 @@ namespace PowerToysTests
|
|||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
|
|
||||||
ResetSettings();
|
ResetSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,19 +184,19 @@ namespace PowerToysTests
|
|||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
CloseSettings();
|
CloseSettings();
|
||||||
|
ResetDefaultFancyZonesSettings(false);
|
||||||
|
ResetDefaultZoneSettings(false);
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCleanup]
|
[TestCleanup]
|
||||||
public void TestCleanup()
|
public void TestCleanup()
|
||||||
{
|
{
|
||||||
ResetSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
@ -9,13 +9,12 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
private void ApplyLayout(string tabName)
|
private void ApplyLayout(string tabName)
|
||||||
{
|
{
|
||||||
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
|
editorWindow.FindElementByName(tabName).Click();
|
||||||
session.FindElementByXPath(elementXPath).Click();
|
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Assert.IsNull(session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]"));
|
Assert.IsNull(session.FindElementByName("FancyZones Editor"));
|
||||||
}
|
}
|
||||||
catch (OpenQA.Selenium.WebDriverException)
|
catch (OpenQA.Selenium.WebDriverException)
|
||||||
{
|
{
|
||||||
@ -67,9 +66,9 @@ namespace PowerToysTests
|
|||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
|
|
||||||
ResetDefaultFancyZonesSettings(true);
|
ResetDefaultFancyZonesSettings(true);
|
||||||
}
|
}
|
||||||
@ -78,16 +77,14 @@ namespace PowerToysTests
|
|||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
CloseSettings();
|
CloseSettings();
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
if (session == null)
|
Assert.IsTrue(OpenEditor());
|
||||||
return;
|
|
||||||
|
|
||||||
OpenEditor();
|
|
||||||
OpenTemplates();
|
OpenTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Interactions;
|
using OpenQA.Selenium.Interactions;
|
||||||
|
|
||||||
namespace PowerToysTests
|
namespace PowerToysTests
|
||||||
@ -11,13 +11,19 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
private void ChangeLayout()
|
private void ChangeLayout()
|
||||||
{
|
{
|
||||||
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_TitleBar")).MoveByOffset(0, -50).Click().Perform();
|
new Actions(session).MoveToElement(creatorWindow.FindElementByAccessibilityId("PART_TitleBar")).MoveByOffset(0, -50).Click().Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CancelTest()
|
private void Cancel(AppiumWebElement creatorWindow)
|
||||||
{
|
{
|
||||||
WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]");
|
AppiumWebElement cancelButton = creatorWindow.FindElementByName("Cancel");
|
||||||
|
Assert.IsNotNull(cancelButton);
|
||||||
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelTest(AppiumWebElement creatorWindow)
|
||||||
|
{
|
||||||
|
Cancel(creatorWindow);
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
Assert.AreEqual(_defaultZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed");
|
Assert.AreEqual(_defaultZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed");
|
||||||
@ -25,7 +31,7 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
private void SaveTest()
|
private void SaveTest()
|
||||||
{
|
{
|
||||||
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
|
new Actions(session).MoveToElement(creatorWindow.FindElementByName("Save and apply")).Click().Perform();
|
||||||
WaitSeconds(1);
|
WaitSeconds(1);
|
||||||
|
|
||||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
||||||
@ -36,70 +42,70 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditFocusCancel()
|
public void EditFocusCancel()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Focus", "Custom layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Focus", "EditTemplateButton");
|
||||||
ZoneCountTest(3, 0);
|
ZoneCountTest(3, 0);
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
creatorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||||
ZoneCountTest(4, 0);
|
ZoneCountTest(4, 0);
|
||||||
|
|
||||||
CancelTest();
|
CancelTest(creatorWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditColumnsCancel()
|
public void EditColumnsCancel()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
ZoneCountTest(0, 4);
|
ZoneCountTest(0, 4);
|
||||||
|
|
||||||
CancelTest();
|
CancelTest(creatorWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditRowsCancel()
|
public void EditRowsCancel()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
ZoneCountTest(0, 4);
|
ZoneCountTest(0, 4);
|
||||||
|
|
||||||
CancelTest();
|
CancelTest(creatorWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditGridCancel()
|
public void EditGridCancel()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Grid", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Grid", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
ZoneCountTest(0, 4);
|
ZoneCountTest(0, 4);
|
||||||
|
|
||||||
CancelTest();
|
CancelTest(creatorWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditPriorityGridCancel()
|
public void EditPriorityGridCancel()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Priority Grid", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
ZoneCountTest(0, 4);
|
ZoneCountTest(0, 4);
|
||||||
|
|
||||||
CancelTest();
|
CancelTest(creatorWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditFocusSave()
|
public void EditFocusSave()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Focus", "Custom layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Focus", "EditTemplateButton");
|
||||||
ZoneCountTest(3, 0);
|
ZoneCountTest(3, 0);
|
||||||
|
|
||||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
creatorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||||
ZoneCountTest(4, 0);
|
ZoneCountTest(4, 0);
|
||||||
|
|
||||||
SaveTest();
|
SaveTest();
|
||||||
@ -108,7 +114,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditColumnsSave()
|
public void EditColumnsSave()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
@ -120,7 +126,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditRowsSave()
|
public void EditRowsSave()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
@ -132,7 +138,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditGridSave()
|
public void EditGridSave()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Grid", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Grid", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
@ -144,7 +150,7 @@ namespace PowerToysTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void EditPriorityGridSave()
|
public void EditPriorityGridSave()
|
||||||
{
|
{
|
||||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator", "EditTemplateButton");
|
OpenCreatorWindow("Priority Grid", "EditTemplateButton");
|
||||||
ZoneCountTest(0, 3);
|
ZoneCountTest(0, 3);
|
||||||
|
|
||||||
ChangeLayout();
|
ChangeLayout();
|
||||||
@ -156,32 +162,26 @@ namespace PowerToysTests
|
|||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context, false);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
EnableModules(false, true, false, false, false, false, false, false);
|
||||||
|
|
||||||
ResetDefaultFancyZonesSettings(false);
|
ResetDefaultFancyZonesSettings(false);
|
||||||
ResetDefaultZoneSettings(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassCleanup]
|
[ClassCleanup]
|
||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
CloseSettings();
|
CloseSettings();
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
if (session == null)
|
ResetDefaultZoneSettings(true);
|
||||||
return;
|
Assert.IsTrue(OpenEditor());
|
||||||
|
|
||||||
if (!isPowerToysLaunched)
|
|
||||||
{
|
|
||||||
LaunchPowerToys();
|
|
||||||
}
|
|
||||||
OpenEditor();
|
|
||||||
OpenTemplates();
|
OpenTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,10 +198,8 @@ namespace PowerToysTests
|
|||||||
}
|
}
|
||||||
catch (OpenQA.Selenium.WebDriverException)
|
catch (OpenQA.Selenium.WebDriverException)
|
||||||
{
|
{
|
||||||
//editor has already closed
|
//editor was already closed
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetDefaultZoneSettings(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
using OpenQA.Selenium.Interactions;
|
using OpenQA.Selenium.Interactions;
|
||||||
using System;
|
using System;
|
||||||
@ -8,6 +9,7 @@ namespace PowerToysTests
|
|||||||
public class FancyZonesEditor : PowerToysSession
|
public class FancyZonesEditor : PowerToysSession
|
||||||
{
|
{
|
||||||
protected static WindowsElement editorWindow;
|
protected static WindowsElement editorWindow;
|
||||||
|
protected static AppiumWebElement creatorWindow;
|
||||||
|
|
||||||
protected static void ResetSettings()
|
protected static void ResetSettings()
|
||||||
{
|
{
|
||||||
@ -15,22 +17,24 @@ namespace PowerToysTests
|
|||||||
ResetDefaultZoneSettings(true);
|
ResetDefaultZoneSettings(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void OpenEditor()
|
protected static bool OpenEditor()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
||||||
WaitSeconds(2);
|
|
||||||
//editorWindow = WaitElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
|
//editorWindow = WaitElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
|
||||||
editorWindow = WaitElementByName("FancyZones Editor");
|
editorWindow = session.FindElementByName("FancyZones Editor");
|
||||||
//may not find editor by name in 0.16.1
|
|
||||||
//editorWindow = WaitElementByAccessibilityId("MainWindow1");
|
|
||||||
Assert.IsNotNull(editorWindow, "Couldn't find editor window");
|
Assert.IsNotNull(editorWindow, "Couldn't find editor window");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void CloseEditor()
|
protected static void CloseEditor()
|
||||||
@ -78,15 +82,13 @@ namespace PowerToysTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void OpenCreatorWindow(string tabName, string creatorWindowName, string buttonId = "EditCustomButton")
|
protected static void OpenCreatorWindow(string tabName, string buttonId = "EditCustomButton")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
|
editorWindow.FindElementByName(tabName).Click();
|
||||||
WaitElementByXPath(elementXPath).Click();
|
editorWindow.FindElementByAccessibilityId(buttonId).Click();
|
||||||
WaitElementByAccessibilityId(buttonId).Click();
|
creatorWindow = editorWindow.FindElementByXPath("//Window");
|
||||||
|
|
||||||
WindowsElement creatorWindow = WaitElementByName(creatorWindowName);
|
|
||||||
Assert.IsNotNull(creatorWindow, "Creator window didn't open");
|
Assert.IsNotNull(creatorWindow, "Creator window didn't open");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -12,6 +12,7 @@ using OpenQA.Selenium.Interactions;
|
|||||||
|
|
||||||
namespace PowerToysTests
|
namespace PowerToysTests
|
||||||
{
|
{
|
||||||
|
[Ignore]
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class FancyZonesSettingsTests : PowerToysSession
|
public class FancyZonesSettingsTests : PowerToysSession
|
||||||
{
|
{
|
||||||
@ -39,7 +40,7 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JObject settings = JObject.Parse(File.ReadAllText(_settingsPath));
|
JObject settings = JObject.Parse(File.ReadAllText(_fancyZonesSettingsPath));
|
||||||
return settings["properties"].ToObject<JObject>();
|
return settings["properties"].ToObject<JObject>();
|
||||||
}
|
}
|
||||||
catch (Newtonsoft.Json.JsonReaderException)
|
catch (Newtonsoft.Json.JsonReaderException)
|
||||||
@ -717,8 +718,7 @@ namespace PowerToysTests
|
|||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context);
|
Setup(context);
|
||||||
if (session == null)
|
Assert.IsNotNull(session);
|
||||||
return;
|
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -741,6 +741,7 @@ namespace PowerToysTests
|
|||||||
//element couldn't be located
|
//element couldn't be located
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +753,7 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_initialSettingsJson = JObject.Parse(_initialSettings);
|
_initialSettingsJson = JObject.Parse(_initialFancyZonesSettings);
|
||||||
}
|
}
|
||||||
catch (Newtonsoft.Json.JsonReaderException)
|
catch (Newtonsoft.Json.JsonReaderException)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using OpenQA.Selenium.Appium;
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
@ -17,22 +18,27 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
protected static WindowsDriver<WindowsElement> session;
|
protected static WindowsDriver<WindowsElement> session;
|
||||||
protected static bool isPowerToysLaunched = false;
|
protected static bool isPowerToysLaunched = false;
|
||||||
protected static WindowsElement trayButton;
|
|
||||||
|
|
||||||
|
protected static WindowsElement trayButton;
|
||||||
|
protected static WindowsElement settingsWindow;
|
||||||
|
|
||||||
|
protected static string _commonSettingsFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys");
|
||||||
protected static string _settingsFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\FancyZones");
|
protected static string _settingsFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\FancyZones");
|
||||||
protected static string _settingsPath = _settingsFolderPath + "\\settings.json";
|
protected static string _fancyZonesSettingsPath = _settingsFolderPath + "\\settings.json";
|
||||||
protected static string _zoneSettingsPath = _settingsFolderPath + "\\zones-settings.json";
|
protected static string _zoneSettingsPath = _settingsFolderPath + "\\zones-settings.json";
|
||||||
protected static string _appHistoryPath = _settingsFolderPath + "\\app-zone-history.json";
|
protected static string _appHistoryPath = _settingsFolderPath + "\\app-zone-history.json";
|
||||||
|
protected static string _commonSettingsPath = _commonSettingsFolderPath + "\\settings.json";
|
||||||
|
|
||||||
protected static string _initialSettings = "";
|
protected static string _initialFancyZonesSettings = "";
|
||||||
protected static string _initialZoneSettings = "";
|
protected static string _initialZoneSettings = "";
|
||||||
protected static string _initialAppHistorySettings = "";
|
protected static string _initialAppHistorySettings = "";
|
||||||
|
protected static string _initialCommonSettings = "";
|
||||||
|
|
||||||
protected const string _defaultSettings = "{\"version\":\"1.0\",\"name\":\"FancyZones\",\"properties\":{\"fancyzones_shiftDrag\":{\"value\":true},\"fancyzones_mouseSwitch\":{\"value\":false},\"fancyzones_overrideSnapHotkeys\":{\"value\":false},\"fancyzones_moveWindowAcrossMonitors\":{\"value\":false},\"fancyzones_zoneSetChange_flashZones\":{\"value\":false},\"fancyzones_displayChange_moveWindows\":{\"value\":false},\"fancyzones_zoneSetChange_moveWindows\":{\"value\":false},\"fancyzones_appLastZone_moveWindows\":{\"value\":false},\"use_cursorpos_editor_startupscreen\":{\"value\":true},\"fancyzones_zoneHighlightColor\":{\"value\":\"#0078D7\"},\"fancyzones_highlight_opacity\":{\"value\":90},\"fancyzones_editor_hotkey\":{\"value\":{\"win\":true,\"ctrl\":false,\"alt\":false,\"shift\":false,\"code\":192,\"key\":\"`\"}},\"fancyzones_excluded_apps\":{\"value\":\"\"}}}";
|
protected const string _defaultFancyZonesSettings = "{\"version\":\"1.0\",\"name\":\"FancyZones\",\"properties\":{\"fancyzones_shiftDrag\":{\"value\":true},\"fancyzones_mouseSwitch\":{\"value\":false},\"fancyzones_overrideSnapHotkeys\":{\"value\":false},\"fancyzones_moveWindowAcrossMonitors\":{\"value\":false},\"fancyzones_zoneSetChange_flashZones\":{\"value\":false},\"fancyzones_displayChange_moveWindows\":{\"value\":false},\"fancyzones_zoneSetChange_moveWindows\":{\"value\":false},\"fancyzones_appLastZone_moveWindows\":{\"value\":false},\"use_cursorpos_editor_startupscreen\":{\"value\":true},\"fancyzones_zoneHighlightColor\":{\"value\":\"#0078D7\"},\"fancyzones_highlight_opacity\":{\"value\":90},\"fancyzones_editor_hotkey\":{\"value\":{\"win\":true,\"ctrl\":false,\"alt\":false,\"shift\":false,\"code\":192,\"key\":\"`\"}},\"fancyzones_excluded_apps\":{\"value\":\"\"}}}";
|
||||||
protected const string _defaultZoneSettings = "{\"app-zone-history\":[],\"devices\":[],\"custom-zone-sets\":[]}";
|
protected const string _defaultZoneSettings = "{\"devices\":[],\"custom-zone-sets\":[]}";
|
||||||
|
|
||||||
|
|
||||||
public static void Setup(TestContext context, bool isLaunchRequired = true)
|
public static void Setup(TestContext context)
|
||||||
{
|
{
|
||||||
if (session == null)
|
if (session == null)
|
||||||
{
|
{
|
||||||
@ -45,13 +51,11 @@ namespace PowerToysTests
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions);
|
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions);
|
||||||
|
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
trayButton = session.FindElementByAccessibilityId("1502");
|
trayButton = session.FindElementByAccessibilityId("1502");
|
||||||
|
|
||||||
isPowerToysLaunched = CheckPowerToysLaunched();
|
isPowerToysLaunched = CheckPowerToysLaunched();
|
||||||
if (!isPowerToysLaunched && isLaunchRequired)
|
|
||||||
{
|
|
||||||
LaunchPowerToys();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -66,6 +70,9 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
if (session != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
|
trayButton = null;
|
||||||
|
settingsWindow = null;
|
||||||
|
|
||||||
session.Quit();
|
session.Quit();
|
||||||
session = null;
|
session = null;
|
||||||
}
|
}
|
||||||
@ -76,83 +83,32 @@ namespace PowerToysTests
|
|||||||
Thread.Sleep(TimeSpan.FromSeconds(seconds));
|
Thread.Sleep(TimeSpan.FromSeconds(seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Trying to find element by XPath
|
|
||||||
protected static WindowsElement WaitElementByName(string name, double maxTime = 10)
|
|
||||||
{
|
|
||||||
WindowsElement result = null;
|
|
||||||
Stopwatch timer = new Stopwatch();
|
|
||||||
timer.Start();
|
|
||||||
while (timer.Elapsed < TimeSpan.FromSeconds(maxTime))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result = session.FindElementByName(name);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Trying to find element by XPath
|
|
||||||
protected static WindowsElement WaitElementByXPath(string xPath, double maxTime = 10)
|
|
||||||
{
|
|
||||||
WindowsElement result = null;
|
|
||||||
Stopwatch timer = new Stopwatch();
|
|
||||||
timer.Start();
|
|
||||||
while (timer.Elapsed < TimeSpan.FromSeconds(maxTime))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result = session.FindElementByXPath(xPath);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Trying to find element by AccessibilityId
|
|
||||||
protected static WindowsElement WaitElementByAccessibilityId(string accessibilityId, double maxTime = 10)
|
|
||||||
{
|
|
||||||
WindowsElement result = null;
|
|
||||||
Stopwatch timer = new Stopwatch();
|
|
||||||
timer.Start();
|
|
||||||
while (timer.Elapsed < TimeSpan.FromSeconds(maxTime))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result = session.FindElementByAccessibilityId(accessibilityId);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void OpenSettings()
|
public static void OpenSettings()
|
||||||
{
|
{
|
||||||
|
trayButton.Click();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
trayButton.Click();
|
PowerToysTrayButton().Click();
|
||||||
session.FindElementByXPath("//Button[@Name=\"PowerToys\"]").Click();
|
settingsWindow = session.FindElementByName("PowerToys Settings");
|
||||||
trayButton.Click();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trayButton.Click(); //close
|
||||||
|
Assert.IsNotNull(settingsWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OpenFancyZonesSettings()
|
public static void OpenFancyZonesSettings()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WindowsElement fzNavigationButton = WaitElementByXPath("//Button[@Name=\"FancyZones\"]");
|
AppiumWebElement fzNavigationButton = settingsWindow.FindElementByName("FancyZones");
|
||||||
Assert.IsNotNull(fzNavigationButton);
|
Assert.IsNotNull(fzNavigationButton);
|
||||||
|
|
||||||
fzNavigationButton.Click();
|
fzNavigationButton.Click();
|
||||||
fzNavigationButton.Click();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -167,7 +123,9 @@ namespace PowerToysTests
|
|||||||
WindowsElement settings = session.FindElementByName("PowerToys Settings");
|
WindowsElement settings = session.FindElementByName("PowerToys Settings");
|
||||||
if (settings != null)
|
if (settings != null)
|
||||||
{
|
{
|
||||||
settings.SendKeys(Keys.Alt + Keys.F4);
|
settings.Click();
|
||||||
|
settings.FindElementByName("Close").Click();
|
||||||
|
//settings.SendKeys(Keys.Alt + Keys.F4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -176,40 +134,47 @@ namespace PowerToysTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static AppiumWebElement PowerToysTrayButton()
|
||||||
|
{
|
||||||
|
WindowsElement notificationOverflow = session.FindElementByName("Notification Overflow");
|
||||||
|
AppiumWebElement overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
||||||
|
AppiumWebElement powerToys = overflowArea.FindElementByXPath("//Button[contains(@Name, \"PowerToys\")]");
|
||||||
|
return powerToys;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool CheckPowerToysLaunched()
|
private static bool CheckPowerToysLaunched()
|
||||||
{
|
{
|
||||||
bool isLaunched = false;
|
bool isLaunched = false;
|
||||||
|
trayButton.Click();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
trayButton.Click();
|
AppiumWebElement pt = PowerToysTrayButton();
|
||||||
WindowsElement pt = WaitElementByXPath("//Button[@Name=\"PowerToys\"]");
|
|
||||||
isLaunched = (pt != null);
|
isLaunched = (pt != null);
|
||||||
trayButton.Click(); //close
|
|
||||||
}
|
}
|
||||||
catch (OpenQA.Selenium.WebDriverException)
|
catch (OpenQA.Selenium.WebDriverException)
|
||||||
{
|
{
|
||||||
//PowerToys not found
|
//PowerToys not found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trayButton.Click(); //close
|
||||||
return isLaunched;
|
return isLaunched;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LaunchPowerToys()
|
public static void LaunchPowerToys()
|
||||||
{
|
{
|
||||||
|
AppiumOptions opts = new AppiumOptions();
|
||||||
|
opts.AddAdditionalCapability("app", AppPath);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AppiumOptions opts = new AppiumOptions();
|
|
||||||
opts.PlatformName = "Windows";
|
|
||||||
opts.AddAdditionalCapability("app", AppPath);
|
|
||||||
|
|
||||||
WindowsDriver<WindowsElement> driver = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts);
|
WindowsDriver<WindowsElement> driver = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts);
|
||||||
Assert.IsNotNull(driver);
|
Assert.IsNotNull(driver);
|
||||||
driver.LaunchApp();
|
driver.LaunchApp();
|
||||||
}
|
}
|
||||||
catch (OpenQA.Selenium.WebDriverException ex)
|
catch (WebDriverException)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Exception on PowerToys launch:" + ex.Message);
|
//exception is expected since WinApDriver tries to find main app window
|
||||||
//exception could be thrown even if app launched successfully
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isPowerToysLaunched = true;
|
isPowerToysLaunched = true;
|
||||||
@ -217,26 +182,48 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
public static void ExitPowerToys()
|
public static void ExitPowerToys()
|
||||||
{
|
{
|
||||||
|
trayButton.Click();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
trayButton.Click();
|
AppiumWebElement pt = PowerToysTrayButton();
|
||||||
|
Assert.IsNotNull(pt, "Could not exit PowerToys");
|
||||||
|
|
||||||
WindowsElement pt = WaitElementByXPath("//Button[@Name=\"PowerToys\"]");
|
|
||||||
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
||||||
|
session.FindElementByAccessibilityId("40001").Click();
|
||||||
|
//WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
|
||||||
|
|
||||||
WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
|
|
||||||
trayButton.Click(); //close tray
|
|
||||||
isPowerToysLaunched = false;
|
isPowerToysLaunched = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trayButton.Click(); //close tray
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnableModules(bool colorPicker, bool fancyZones, bool fileExplorer, bool imageResizer, bool keyboardManager, bool powerRename, bool powerRun, bool shortcutGuide, bool relaunch = false)
|
||||||
|
{
|
||||||
|
JObject json = JObject.Parse(_initialCommonSettings);
|
||||||
|
JObject enabled = new JObject();
|
||||||
|
enabled["ColorPicker"] = colorPicker;
|
||||||
|
enabled["FancyZones"] = fancyZones;
|
||||||
|
enabled["File Explorer"] = fileExplorer;
|
||||||
|
enabled["Image Resizer"] = imageResizer;
|
||||||
|
enabled["Keyboard Manager"] = keyboardManager;
|
||||||
|
enabled["PowerRename"] = powerRename;
|
||||||
|
enabled["PowerToys Run"] = powerRun;
|
||||||
|
enabled["Shortcut Guide"] = shortcutGuide;
|
||||||
|
|
||||||
|
json["enabled"] = enabled;
|
||||||
|
|
||||||
|
ResetSettings(_commonSettingsFolderPath, _commonSettingsPath, json.ToString(), relaunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ResetDefaultFancyZonesSettings(bool relaunch)
|
public static void ResetDefaultFancyZonesSettings(bool relaunch)
|
||||||
{
|
{
|
||||||
ResetSettings(_settingsFolderPath, _settingsPath, _defaultSettings, relaunch);
|
ResetSettings(_settingsFolderPath, _fancyZonesSettingsPath, _defaultFancyZonesSettings, relaunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ResetDefaultZoneSettings(bool relaunch)
|
public static void ResetDefaultZoneSettings(bool relaunch)
|
||||||
@ -252,11 +239,7 @@ namespace PowerToysTests
|
|||||||
}
|
}
|
||||||
File.WriteAllText(filePath, data);
|
File.WriteAllText(filePath, data);
|
||||||
|
|
||||||
if (isPowerToysLaunched)
|
ExitPowerToys();
|
||||||
{
|
|
||||||
ExitPowerToys();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relaunch)
|
if (relaunch)
|
||||||
{
|
{
|
||||||
LaunchPowerToys();
|
LaunchPowerToys();
|
||||||
@ -267,9 +250,19 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_initialSettings.Length == 0)
|
if (_initialCommonSettings.Length == 0)
|
||||||
{
|
{
|
||||||
_initialSettings = File.ReadAllText(_settingsPath);
|
_initialCommonSettings = File.ReadAllText(_commonSettingsPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_initialFancyZonesSettings.Length == 0)
|
||||||
|
{
|
||||||
|
_initialFancyZonesSettings = File.ReadAllText(_fancyZonesSettingsPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -298,13 +291,22 @@ namespace PowerToysTests
|
|||||||
|
|
||||||
private static void RestoreUserSettings()
|
private static void RestoreUserSettings()
|
||||||
{
|
{
|
||||||
if (_initialSettings.Length > 0)
|
if (_initialCommonSettings.Length > 0)
|
||||||
{
|
{
|
||||||
File.WriteAllText(_settingsPath, _initialSettings);
|
File.WriteAllText(_commonSettingsPath, _initialCommonSettings);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
File.Delete(_settingsPath);
|
File.Delete(_commonSettingsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_initialFancyZonesSettings.Length > 0)
|
||||||
|
{
|
||||||
|
File.WriteAllText(_fancyZonesSettingsPath, _initialFancyZonesSettings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Delete(_fancyZonesSettingsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_initialZoneSettings.Length > 0)
|
if (_initialZoneSettings.Length > 0)
|
||||||
|
@ -17,7 +17,7 @@ namespace PowerToysTests
|
|||||||
OpenSettings();
|
OpenSettings();
|
||||||
|
|
||||||
//check settings window opened
|
//check settings window opened
|
||||||
WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
|
WindowsElement settingsWindow = session.FindElementByName("PowerToys Settings");
|
||||||
Assert.IsNotNull(settingsWindow);
|
Assert.IsNotNull(settingsWindow);
|
||||||
|
|
||||||
isSettingsOpened = true;
|
isSettingsOpened = true;
|
||||||
@ -28,19 +28,20 @@ namespace PowerToysTests
|
|||||||
{
|
{
|
||||||
//open tray
|
//open tray
|
||||||
trayButton.Click();
|
trayButton.Click();
|
||||||
|
WaitSeconds(1);
|
||||||
isTrayOpened = true;
|
isTrayOpened = true;
|
||||||
|
|
||||||
//open PowerToys context menu
|
//open PowerToys context menu
|
||||||
WindowsElement pt = session.FindElementByName("PowerToys");
|
AppiumWebElement pt = PowerToysTrayButton();
|
||||||
Assert.IsNotNull(pt);
|
Assert.IsNotNull(pt);
|
||||||
|
|
||||||
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
||||||
|
|
||||||
//open settings
|
//open settings
|
||||||
WaitElementByXPath("//MenuItem[@Name=\"Settings\"]").Click();
|
session.FindElementByXPath("//MenuItem[@Name=\"Settings\"]").Click();
|
||||||
|
|
||||||
//check settings window opened
|
//check settings window opened
|
||||||
WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
|
WindowsElement settingsWindow = session.FindElementByName("PowerToys Settings");
|
||||||
Assert.IsNotNull(settingsWindow);
|
Assert.IsNotNull(settingsWindow);
|
||||||
|
|
||||||
isSettingsOpened = true;
|
isSettingsOpened = true;
|
||||||
@ -52,24 +53,21 @@ namespace PowerToysTests
|
|||||||
//open PowerToys context menu
|
//open PowerToys context menu
|
||||||
trayButton.Click();
|
trayButton.Click();
|
||||||
isTrayOpened = true;
|
isTrayOpened = true;
|
||||||
|
WaitSeconds(1);
|
||||||
|
|
||||||
WindowsElement notificationOverflow = session.FindElementByName("Notification Overflow");
|
AppiumWebElement powerToys = PowerToysTrayButton();
|
||||||
AppiumWebElement overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
|
||||||
AppiumWebElement powerToys = overflowArea.FindElementByName("PowerToys");
|
|
||||||
Assert.IsNotNull(powerToys);
|
Assert.IsNotNull(powerToys);
|
||||||
|
|
||||||
new Actions(session).MoveToElement(powerToys).ContextClick().Perform();
|
new Actions(session).MoveToElement(powerToys).ContextClick().Perform();
|
||||||
|
|
||||||
//exit
|
//exit
|
||||||
WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
|
session.FindElementByAccessibilityId("40001").Click();
|
||||||
|
|
||||||
//check PowerToys exited
|
//check PowerToys exited
|
||||||
powerToys = null;
|
powerToys = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
notificationOverflow = session.FindElementByName("Notification Overflow");
|
powerToys = PowerToysTrayButton();
|
||||||
overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
|
||||||
powerToys = overflowArea.FindElementByName("PowerToys");
|
|
||||||
}
|
}
|
||||||
catch (OpenQA.Selenium.WebDriverException)
|
catch (OpenQA.Selenium.WebDriverException)
|
||||||
{
|
{
|
||||||
@ -84,20 +82,24 @@ namespace PowerToysTests
|
|||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context);
|
Setup(context);
|
||||||
|
Assert.IsNotNull(session);
|
||||||
|
|
||||||
|
if (!isPowerToysLaunched)
|
||||||
|
{
|
||||||
|
LaunchPowerToys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassCleanup]
|
[ClassCleanup]
|
||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
if (session == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
isSettingsOpened = false;
|
isSettingsOpened = false;
|
||||||
isTrayOpened = false;
|
isTrayOpened = false;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using OpenQA.Selenium.Appium;
|
using OpenQA.Selenium.Appium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
@ -8,7 +7,7 @@ using OpenQA.Selenium.Interactions;
|
|||||||
namespace PowerToysTests
|
namespace PowerToysTests
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class TestShortcutHelper : PowerToysSession
|
public class TestShortcutGuideHelper : PowerToysSession
|
||||||
{
|
{
|
||||||
// Try to manage Press/Release of Windows Key here,
|
// Try to manage Press/Release of Windows Key here,
|
||||||
// since Keyboard.PressKey seems to release the key if pressed
|
// since Keyboard.PressKey seems to release the key if pressed
|
||||||
@ -37,19 +36,26 @@ namespace PowerToysTests
|
|||||||
public void AppearsOnWinKeyPress()
|
public void AppearsOnWinKeyPress()
|
||||||
{
|
{
|
||||||
PressWinKey();
|
PressWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
WaitSeconds(3);
|
||||||
WindowsElement shortcutHelperWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Pane[@ClassName=\"PToyD2DPopup\"]");
|
|
||||||
Assert.IsNotNull(shortcutHelperWindow);
|
try
|
||||||
ReleaseWinKey();
|
{
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
WindowsElement shortcutHelperWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Pane[@ClassName=\"PToyD2DPopup\"]");
|
||||||
|
Assert.IsNotNull(shortcutHelperWindow);
|
||||||
|
}
|
||||||
|
catch(OpenQA.Selenium.WebDriverException)
|
||||||
|
{
|
||||||
|
Assert.Fail("Shortcut Guide not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[ExpectedException(typeof(InvalidOperationException),
|
[ExpectedException(typeof(InvalidOperationException),
|
||||||
"The Shortcut Guide UI was still found after releasing the key.")]
|
"The Shortcut Guide UI was still found after releasing the key.")]
|
||||||
public void DisappearsOnWinKeyRelease()
|
public void DisappearsOnWinKeyRelease()
|
||||||
{
|
{
|
||||||
PressWinKey();
|
PressWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
WaitSeconds(2);
|
||||||
WindowsElement shortcutHelperWindow;
|
WindowsElement shortcutHelperWindow;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -61,20 +67,21 @@ namespace PowerToysTests
|
|||||||
// Not the exception we wanted to catch here.
|
// Not the exception we wanted to catch here.
|
||||||
Assert.Fail("Shortcut Guide not found");
|
Assert.Fail("Shortcut Guide not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseWinKey();
|
ReleaseWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(0.5));
|
|
||||||
shortcutHelperWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Pane[@ClassName=\"PToyD2DPopup\"]");
|
shortcutHelperWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Pane[@ClassName=\"PToyD2DPopup\"]");
|
||||||
|
Assert.IsNull(shortcutHelperWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void DoesNotBlockStartMenuOnShortPress()
|
public void DoesNotBlockStartMenuOnShortPress()
|
||||||
{
|
{
|
||||||
PressWinKey();
|
PressWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(0.4));
|
WaitSeconds(0.4);
|
||||||
// FindElementByClassName will be faster than using with XPath.
|
// FindElementByClassName will be faster than using with XPath.
|
||||||
WindowsElement shortcutHelperWindow = session.FindElementByClassName("PToyD2DPopup");
|
WindowsElement shortcutHelperWindow = session.FindElementByClassName("PToyD2DPopup");
|
||||||
Assert.IsNotNull(shortcutHelperWindow);
|
Assert.IsNotNull(shortcutHelperWindow);
|
||||||
ReleaseWinKey();
|
ReleaseWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(0.5));
|
|
||||||
WindowsElement startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]");
|
WindowsElement startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]");
|
||||||
}
|
}
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -83,7 +90,7 @@ namespace PowerToysTests
|
|||||||
public void DoesNotSpawnStartMenuOnLongPress()
|
public void DoesNotSpawnStartMenuOnLongPress()
|
||||||
{
|
{
|
||||||
PressWinKey();
|
PressWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
WaitSeconds(2);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// FindElementByClassName will be faster than using with XPath.
|
// FindElementByClassName will be faster than using with XPath.
|
||||||
@ -96,25 +103,32 @@ namespace PowerToysTests
|
|||||||
Assert.Fail("Shortcut Guide not found");
|
Assert.Fail("Shortcut Guide not found");
|
||||||
}
|
}
|
||||||
ReleaseWinKey();
|
ReleaseWinKey();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(0.5));
|
|
||||||
WindowsElement startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]");
|
WindowsElement startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitialize(TestContext context)
|
public static void ClassInitialize(TestContext context)
|
||||||
{
|
{
|
||||||
Setup(context);
|
Setup(context);
|
||||||
|
Assert.IsNotNull(session);
|
||||||
|
EnableModules(false, false, false, false, false, false, false, true);
|
||||||
|
|
||||||
|
if (!isPowerToysLaunched)
|
||||||
|
{
|
||||||
|
LaunchPowerToys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClassCleanup]
|
[ClassCleanup]
|
||||||
public static void ClassCleanup()
|
public static void ClassCleanup()
|
||||||
{
|
{
|
||||||
|
ExitPowerToys();
|
||||||
TearDown();
|
TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
if (session == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
isWinKeyPressed = false;
|
isWinKeyPressed = false;
|
||||||
|
|
||||||
// If the start menu is open, close it.
|
// If the start menu is open, close it.
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
|
<Import Project="..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
@ -134,7 +134,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="PowerToysSession.cs" />
|
<Compile Include="PowerToysSession.cs" />
|
||||||
<Compile Include="PowerToysTrayTests.cs" />
|
<Compile Include="PowerToysTrayTests.cs" />
|
||||||
<Compile Include="TestShortcutHelper.cs" />
|
<Compile Include="TestShortcutGuideHelper.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<WCFMetadata Include="Connected Services\" />
|
<WCFMetadata Include="Connected Services\" />
|
||||||
|
Loading…
Reference in New Issue
Block a user