mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-04 20:21:18 +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 OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System.Windows.Forms;
|
||||
@ -223,6 +224,9 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
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 topBorder = session.FindElementByAccessibilityId("NResize");
|
||||
WindowsElement leftBorder = session.FindElementByAccessibilityId("WResize");
|
||||
@ -260,17 +264,13 @@ namespace PowerToysTests
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
ResetSettings();
|
||||
|
||||
if (!isPowerToysLaunched)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
OpenCustomLayouts();
|
||||
}
|
||||
|
||||
@ -278,27 +278,24 @@ namespace PowerToysTests
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
CloseEditor();
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
//create canvas zone
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
OpenCreatorWindow("Create new custom");
|
||||
creatorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
new Actions(session).MoveToElement(session.FindElementByXPath("//Button[@Name=\"Cancel\"]")).Click().Perform();
|
||||
AppiumWebElement cancelButton = creatorWindow.FindElementByName("Cancel");
|
||||
Assert.IsNotNull(cancelButton);
|
||||
new Actions(session).MoveToElement(cancelButton).Click().Perform();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
|
||||
@ -12,7 +13,7 @@ namespace PowerToysTests
|
||||
{
|
||||
private void SetLayoutName(string name)
|
||||
{
|
||||
WindowsElement textBox = session.FindElementByClassName("TextBox");
|
||||
AppiumWebElement textBox = creatorWindow.FindElementByClassName("TextBox");
|
||||
textBox.Click();
|
||||
textBox.SendKeys(Keys.Control + "a");
|
||||
textBox.SendKeys(Keys.Backspace);
|
||||
@ -21,7 +22,7 @@ namespace PowerToysTests
|
||||
|
||||
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();
|
||||
WaitSeconds(1);
|
||||
|
||||
@ -30,7 +31,7 @@ namespace PowerToysTests
|
||||
|
||||
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);
|
||||
|
||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
||||
@ -43,10 +44,10 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateCancel()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
ZoneCountTest(0, 0);
|
||||
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
editorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
ZoneCountTest(1, 0);
|
||||
|
||||
CancelTest();
|
||||
@ -55,7 +56,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateEmpty()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
ZoneCountTest(0, 0);
|
||||
|
||||
SaveTest("canvas", "Custom Layout 1", 0);
|
||||
@ -64,10 +65,10 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateSingleZone()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
ZoneCountTest(0, 0);
|
||||
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
editorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
ZoneCountTest(1, 0);
|
||||
|
||||
SaveTest("canvas", "Custom Layout 1", 1);
|
||||
@ -76,11 +77,11 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateManyZones()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
ZoneCountTest(0, 0);
|
||||
|
||||
const int expectedZoneCount = 20;
|
||||
WindowsElement addButton = session.FindElementByAccessibilityId("newZoneButton");
|
||||
AppiumWebElement addButton = editorWindow.FindElementByAccessibilityId("newZoneButton");
|
||||
for (int i = 0; i < expectedZoneCount; i++)
|
||||
{
|
||||
addButton.Click();
|
||||
@ -93,12 +94,12 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateDeleteZone()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
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
|
||||
addButton.Click();
|
||||
@ -117,7 +118,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateWithName()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
string name = "My custom zone layout name";
|
||||
SetLayoutName(name);
|
||||
SaveTest("canvas", name, 0);
|
||||
@ -126,7 +127,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateWithEmptyName()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
string name = "";
|
||||
SetLayoutName(name);
|
||||
SaveTest("canvas", name, 0);
|
||||
@ -135,7 +136,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateWithUnicodeCharactersName()
|
||||
{
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
string name = "ёÖ±¬āݾᵩὡ√ﮘﻹտ";
|
||||
SetLayoutName(name);
|
||||
SaveTest("canvas", name, 0);
|
||||
@ -145,55 +146,21 @@ namespace PowerToysTests
|
||||
public void RenameLayout()
|
||||
{
|
||||
//create layout
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
string name = "My custom zone layout name";
|
||||
SetLayoutName(name);
|
||||
SaveTest("canvas", name, 0);
|
||||
WaitSeconds(1);
|
||||
|
||||
//rename layout
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
OpenCustomLayouts();
|
||||
OpenCreatorWindow(name, "Custom layout creator");
|
||||
OpenCreatorWindow(name);
|
||||
name = "New name";
|
||||
SetLayoutName(name);
|
||||
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]
|
||||
public void AddRemoveSameLayoutNames()
|
||||
{
|
||||
@ -202,50 +169,20 @@ namespace PowerToysTests
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
//create layout
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
SetLayoutName(name);
|
||||
|
||||
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
|
||||
WaitSeconds(1);
|
||||
new Actions(session).MoveToElement(editorWindow.FindElementByName("Save and apply")).Click().Perform();
|
||||
|
||||
//remove layout
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
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();
|
||||
}
|
||||
|
||||
//settings are saved on window closing
|
||||
new Actions(session).MoveToElement(session.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();
|
||||
new Actions(session).MoveToElement(editorWindow.FindElementByAccessibilityId("PART_Close")).Click().Perform();
|
||||
WaitSeconds(1);
|
||||
|
||||
//check settings
|
||||
@ -259,62 +196,52 @@ namespace PowerToysTests
|
||||
string name = "Name";
|
||||
|
||||
//create layout
|
||||
OpenCreatorWindow("Create new custom", "Custom layout creator");
|
||||
OpenCreatorWindow("Create new custom");
|
||||
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);
|
||||
|
||||
//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();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
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();
|
||||
|
||||
//apply
|
||||
new Actions(session).MoveToElement(session.FindElementByName("Apply")).Click().Perform();
|
||||
new Actions(session).MoveToElement(editorWindow.FindElementByName("Apply")).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");
|
||||
}
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
|
||||
ResetSettings();
|
||||
ResetDefaultFancyZonesSettings(false);
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
if (!isPowerToysLaunched)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
OpenEditor();
|
||||
ResetDefaultZoneSettings(true);
|
||||
Assert.IsTrue(OpenEditor());
|
||||
OpenCustomLayouts();
|
||||
}
|
||||
|
||||
@ -322,7 +249,7 @@ namespace PowerToysTests
|
||||
public void TestCleanup()
|
||||
{
|
||||
CloseEditor();
|
||||
ResetDefaultZoneSettings(false);
|
||||
ExitPowerToys();
|
||||
}
|
||||
}
|
||||
}
|
@ -48,11 +48,11 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void MoveVerticalSplitter()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(2, thumbs.Count);
|
||||
|
||||
@ -94,7 +94,7 @@ namespace PowerToysTests
|
||||
{
|
||||
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;
|
||||
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -104,11 +104,11 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void MoveHorizontalSplitter()
|
||||
{
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(2, thumbs.Count);
|
||||
|
||||
@ -160,10 +160,11 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateSplitter()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
WaitSeconds(2);
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
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");
|
||||
|
||||
const int defaultSpacing = 16;
|
||||
@ -171,23 +172,24 @@ namespace PowerToysTests
|
||||
|
||||
new Actions(session).MoveToElement(zones[0]).Click().Perform();
|
||||
|
||||
zones = session.FindElementsByClassName("GridZone");
|
||||
zones = gridEditor.FindElementsByClassName("GridZone");
|
||||
Assert.AreEqual(4, zones.Count);
|
||||
|
||||
//check splitted zone
|
||||
Assert.AreEqual(zones[0].Rect.Top, defaultSpacing);
|
||||
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.AreEqual(zones[3].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing);
|
||||
Assert.IsTrue(Math.Abs(zones[1].Rect.Top - splitPos - defaultSpacing / 2) <= 2);
|
||||
Assert.AreEqual(zones[1].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestSplitterShiftAfterCreation()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
WaitSeconds(2);
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
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");
|
||||
|
||||
const int defaultSpacing = 16;
|
||||
@ -196,12 +198,12 @@ namespace PowerToysTests
|
||||
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();
|
||||
|
||||
zones = session.FindElementsByClassName("GridZone");
|
||||
zones = gridEditor.FindElementsByClassName("GridZone");
|
||||
Assert.AreEqual(4, zones.Count);
|
||||
|
||||
Assert.AreEqual(zones[0].Rect.Top, defaultSpacing);
|
||||
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);
|
||||
|
||||
//create second split
|
||||
@ -210,7 +212,7 @@ namespace PowerToysTests
|
||||
|
||||
new Actions(session).MoveToElement(zones[3]).Click().Perform();
|
||||
|
||||
zones = session.FindElementsByClassName("GridZone");
|
||||
zones = gridEditor.FindElementsByClassName("GridZone");
|
||||
Assert.AreEqual(5, zones.Count);
|
||||
|
||||
//check first split on same position
|
||||
@ -227,20 +229,20 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateSplitterWithShiftPressed()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
.Perform();
|
||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count);
|
||||
|
||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
||||
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||
Assert.AreEqual(4, zones.Count);
|
||||
|
||||
//check that zone was splitted vertically
|
||||
@ -252,12 +254,12 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void CreateSplitterWithShiftPressedFocusOnGridEditor()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
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);
|
||||
|
||||
new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-100, 0)
|
||||
@ -265,7 +267,7 @@ namespace PowerToysTests
|
||||
.Perform();
|
||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count);
|
||||
|
||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
||||
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||
Assert.AreEqual(4, zones.Count);
|
||||
|
||||
//check that zone was splitted vertically
|
||||
@ -277,11 +279,11 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void MoveHorizontallyWithLimiter()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(2, thumbs.Count);
|
||||
|
||||
@ -290,7 +292,7 @@ namespace PowerToysTests
|
||||
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
||||
.Perform();
|
||||
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(4, session.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(4, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(3, thumbs.Count);
|
||||
|
||||
//move thumbs
|
||||
@ -311,11 +313,11 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void MoveVerticallyWithLimiter()
|
||||
{
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(2, thumbs.Count);
|
||||
|
||||
@ -324,7 +326,7 @@ namespace PowerToysTests
|
||||
.KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift)
|
||||
.Perform();
|
||||
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(4, session.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(4, gridEditor.FindElementsByClassName("GridZone").Count);
|
||||
Assert.AreEqual(3, thumbs.Count);
|
||||
|
||||
//move thumbs
|
||||
@ -345,29 +347,29 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void MergeZones()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
ReadOnlyCollection<WindowsElement> zones = session.FindElementsByClassName("GridZone");
|
||||
ReadOnlyCollection<AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone");
|
||||
ReadOnlyCollection<AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
Assert.AreEqual(3, zones.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);
|
||||
|
||||
WindowsElement mergeButton = session.FindElementByName("Merge zones");
|
||||
AppiumWebElement mergeButton = gridEditor.FindElementByName("Merge zones");
|
||||
Assert.IsNotNull(mergeButton, "Cannot merge: no merge button");
|
||||
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);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MoveAfterMerge()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
WindowsElement gridEditor = session.FindElementByClassName("GridEditor");
|
||||
Assert.IsNotNull(gridEditor);
|
||||
|
||||
@ -380,14 +382,15 @@ namespace PowerToysTests
|
||||
thumbs = gridEditor.FindElementsByClassName("Thumb");
|
||||
|
||||
//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);
|
||||
WindowsElement mergeButton = session.FindElementByName("Merge zones");
|
||||
AppiumWebElement mergeButton = gridEditor.FindElementByName("Merge zones");
|
||||
Assert.IsNotNull(mergeButton, "Cannot merge: no merge button");
|
||||
new Actions(session).Click(mergeButton).Perform();
|
||||
|
||||
//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);
|
||||
Assert.IsTrue(thumb.Rect.Left <= moveStep);
|
||||
Assert.IsTrue(thumb.Rect.Right > 0);
|
||||
@ -396,9 +399,9 @@ namespace PowerToysTests
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
|
||||
ResetSettings();
|
||||
|
||||
@ -406,7 +409,7 @@ namespace PowerToysTests
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
OpenTemplates();
|
||||
}
|
||||
|
||||
@ -414,6 +417,7 @@ namespace PowerToysTests
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
CloseEditor();
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
@ -426,7 +430,7 @@ namespace PowerToysTests
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
|
||||
@ -11,6 +12,7 @@ namespace PowerToysTests
|
||||
void RemoveSettingsFile()
|
||||
{
|
||||
File.Delete(_zoneSettingsPath);
|
||||
File.Delete(_appHistoryPath);
|
||||
}
|
||||
|
||||
void RemoveSettingsFolder()
|
||||
@ -22,44 +24,62 @@ namespace PowerToysTests
|
||||
{
|
||||
string zoneSettings = "";
|
||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||
|
||||
string appHistory = "";
|
||||
File.WriteAllText(_appHistoryPath, appHistory);
|
||||
}
|
||||
|
||||
void CreateDefaultSettingsFile()
|
||||
{
|
||||
string zoneSettings = "{\"app-zone-history\":[],\"devices\":[],\"custom-zone-sets\":[]}";
|
||||
string zoneSettings = "{\"devices\":[],\"custom-zone-sets\":[]}";
|
||||
File.WriteAllText(_zoneSettingsPath, zoneSettings);
|
||||
|
||||
string appHistory = "{\"app-zone-history\":[]}";
|
||||
File.WriteAllText(_appHistoryPath, appHistory);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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()
|
||||
{
|
||||
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);
|
||||
|
||||
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()
|
||||
{
|
||||
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);
|
||||
|
||||
string appHistory = "";
|
||||
File.WriteAllText(_appHistoryPath, appHistory);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
string appHistory = "{\"app-zone-history\":[]}";
|
||||
File.WriteAllText(_appHistoryPath, appHistory);
|
||||
}
|
||||
|
||||
void TestEditorOpened()
|
||||
void TestEditorOpened(bool errorExpected = false)
|
||||
{
|
||||
WindowsElement errorMessage = null;
|
||||
try
|
||||
{
|
||||
errorMessage = WaitElementByName("FancyZones Editor Exception Handler");
|
||||
errorMessage = session.FindElementByName("FancyZones Editor Exception Handler");
|
||||
if (errorMessage != null)
|
||||
{
|
||||
errorMessage.FindElementByName("OK").Click();
|
||||
@ -70,34 +90,29 @@ namespace PowerToysTests
|
||||
//no error message, it's ok
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
editorWindow = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
|
||||
}
|
||||
catch (OpenQA.Selenium.WebDriverException)
|
||||
{
|
||||
}
|
||||
|
||||
editorWindow = session.FindElementByName("FancyZones Editor");
|
||||
Assert.IsNotNull(editorWindow);
|
||||
|
||||
if (!errorExpected)
|
||||
{
|
||||
Assert.IsNull(errorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNotNull(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenEditorBySettingsButton()
|
||||
{
|
||||
OpenSettings();
|
||||
OpenFancyZonesSettings();
|
||||
|
||||
WindowsElement editorButton = session.FindElementByXPath("//Button[@Name=\"Edit zones\"]");
|
||||
Assert.IsNotNull(editorButton);
|
||||
|
||||
editorButton.Click();
|
||||
TestEditorOpened();
|
||||
settingsWindow.FindElementByName("Launch zones editor").Click();
|
||||
}
|
||||
|
||||
void OpenEditorByHotkey()
|
||||
{
|
||||
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -105,6 +120,7 @@ namespace PowerToysTests
|
||||
{
|
||||
RemoveSettingsFile();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -121,6 +137,7 @@ namespace PowerToysTests
|
||||
|
||||
RemoveSettingsFolder();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -128,6 +145,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateEmptySettingsFile();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -135,6 +153,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateDefaultSettingsFile();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -142,6 +161,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateValidSettingsFile();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -149,6 +169,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateValidSettingsFileWithUtf8();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -156,6 +177,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateInvalidSettingsFile();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -163,6 +185,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateCroppedSettingsFile();
|
||||
OpenEditorBySettingsButton();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -170,6 +193,7 @@ namespace PowerToysTests
|
||||
{
|
||||
RemoveSettingsFile();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -185,6 +209,7 @@ namespace PowerToysTests
|
||||
*/
|
||||
RemoveSettingsFolder();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -192,6 +217,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateEmptySettingsFile();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -199,6 +225,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateDefaultSettingsFile();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -206,6 +233,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateValidSettingsFile();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -213,6 +241,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateValidSettingsFileWithUtf8();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -220,6 +249,7 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateInvalidSettingsFile();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -227,14 +257,15 @@ namespace PowerToysTests
|
||||
{
|
||||
CreateCroppedSettingsFile();
|
||||
OpenEditorByHotkey();
|
||||
TestEditorOpened(true);
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
|
||||
ResetDefaultFancyZonesSettings(true);
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Appium;
|
||||
|
||||
namespace PowerToysTests
|
||||
{
|
||||
@ -18,10 +17,10 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void ZoneCount()
|
||||
{
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
|
||||
WindowsElement minusButton = session.FindElementByAccessibilityId("decrementZones");
|
||||
WindowsElement zoneCount = session.FindElementByAccessibilityId("zoneCount");
|
||||
AppiumWebElement minusButton = editorWindow.FindElementByAccessibilityId("decrementZones");
|
||||
AppiumWebElement zoneCount = editorWindow.FindElementByAccessibilityId("zoneCount");
|
||||
|
||||
int editorZoneCountValue;
|
||||
Assert.IsTrue(Int32.TryParse(zoneCount.Text, out editorZoneCountValue));
|
||||
@ -35,18 +34,18 @@ namespace PowerToysTests
|
||||
|
||||
if (j == 0 || i == -4)
|
||||
{
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
WaitSeconds(1);
|
||||
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
|
||||
minusButton = session.FindElementByAccessibilityId("decrementZones");
|
||||
zoneCount = session.FindElementByAccessibilityId("zoneCount");
|
||||
minusButton = editorWindow.FindElementByAccessibilityId("decrementZones");
|
||||
zoneCount = editorWindow.FindElementByAccessibilityId("zoneCount");
|
||||
}
|
||||
}
|
||||
|
||||
WindowsElement plusButton = session.FindElementByAccessibilityId("incrementZones");
|
||||
AppiumWebElement plusButton = editorWindow.FindElementByAccessibilityId("incrementZones");
|
||||
|
||||
for (int i = 2; i < 45; ++i)
|
||||
{
|
||||
@ -56,7 +55,7 @@ namespace PowerToysTests
|
||||
Assert.AreEqual(Math.Min(i, 40), editorZoneCountValue);
|
||||
}
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
WaitSeconds(1);
|
||||
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
|
||||
}
|
||||
@ -66,13 +65,13 @@ namespace PowerToysTests
|
||||
{
|
||||
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;
|
||||
spaceAroundSetting.Click();
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
WaitSeconds(1);
|
||||
|
||||
@ -83,25 +82,24 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void SpacingTestsValid()
|
||||
{
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
|
||||
WindowsElement spaceAroundSetting = session.FindElementByAccessibilityId("spaceAroundSetting");
|
||||
AppiumWebElement spaceAroundSetting = editorWindow.FindElementByAccessibilityId("spaceAroundSetting");
|
||||
bool editorShowSpacingValue = spaceAroundSetting.Selected;
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
WaitSeconds(1);
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
foreach (string editorSpacingValue in validValues)
|
||||
{
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
|
||||
WindowsElement paddingValue = WaitElementByAccessibilityId("paddingValue");
|
||||
AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
|
||||
ClearText(paddingValue);
|
||||
paddingValue.SendKeys(editorSpacingValue);
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
WaitSeconds(1);
|
||||
|
||||
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
|
||||
@ -112,13 +110,12 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void SpacingTestsInvalid()
|
||||
{
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
|
||||
WindowsElement spaceAroundSetting = session.FindElementByAccessibilityId("spaceAroundSetting");
|
||||
AppiumWebElement spaceAroundSetting = editorWindow.FindElementByAccessibilityId("spaceAroundSetting");
|
||||
bool editorShowSpacingValue = spaceAroundSetting.Selected;
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
WaitSeconds(1);
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" };
|
||||
|
||||
@ -126,14 +123,13 @@ namespace PowerToysTests
|
||||
|
||||
foreach (string value in invalidValues)
|
||||
{
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
|
||||
WindowsElement paddingValue = WaitElementByAccessibilityId("paddingValue");
|
||||
AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
|
||||
ClearText(paddingValue);
|
||||
paddingValue.SendKeys(value);
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
WaitSeconds(1);
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
|
||||
Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing));
|
||||
@ -143,19 +139,19 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void SpacingTestLargeValue()
|
||||
{
|
||||
OpenEditor();
|
||||
session.FindElementByXPath("//Text[@Name=\"Grid\"]").Click();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
editorWindow.FindElementByName("Grid").Click();
|
||||
|
||||
WindowsElement paddingValue = session.FindElementByAccessibilityId("paddingValue");
|
||||
AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
|
||||
ClearText(paddingValue);
|
||||
paddingValue.SendKeys("1000");
|
||||
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
editorWindow = null;
|
||||
|
||||
try
|
||||
{
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
}
|
||||
catch { }
|
||||
|
||||
@ -169,7 +165,7 @@ namespace PowerToysTests
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ClearText(WindowsElement windowsElement)
|
||||
private void ClearText(AppiumWebElement windowsElement)
|
||||
{
|
||||
windowsElement.SendKeys(Keys.Home);
|
||||
windowsElement.SendKeys(Keys.Control + Keys.Delete);
|
||||
@ -178,10 +174,9 @@ namespace PowerToysTests
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
ResetSettings();
|
||||
}
|
||||
|
||||
@ -189,19 +184,19 @@ namespace PowerToysTests
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
CloseSettings();
|
||||
ResetDefaultFancyZonesSettings(false);
|
||||
ResetDefaultZoneSettings(false);
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
ResetSettings();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@ -9,13 +9,12 @@ namespace PowerToysTests
|
||||
{
|
||||
private void ApplyLayout(string tabName)
|
||||
{
|
||||
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
|
||||
session.FindElementByXPath(elementXPath).Click();
|
||||
session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
editorWindow.FindElementByName(tabName).Click();
|
||||
editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();
|
||||
|
||||
try
|
||||
{
|
||||
Assert.IsNull(session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]"));
|
||||
Assert.IsNull(session.FindElementByName("FancyZones Editor"));
|
||||
}
|
||||
catch (OpenQA.Selenium.WebDriverException)
|
||||
{
|
||||
@ -67,9 +66,9 @@ namespace PowerToysTests
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
|
||||
ResetDefaultFancyZonesSettings(true);
|
||||
}
|
||||
@ -78,16 +77,14 @@ namespace PowerToysTests
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
CloseSettings();
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
OpenEditor();
|
||||
Assert.IsTrue(OpenEditor());
|
||||
OpenTemplates();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
|
||||
namespace PowerToysTests
|
||||
@ -11,13 +11,19 @@ namespace PowerToysTests
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
private void CancelTest(AppiumWebElement creatorWindow)
|
||||
{
|
||||
Cancel(creatorWindow);
|
||||
WaitSeconds(1);
|
||||
|
||||
Assert.AreEqual(_defaultZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed");
|
||||
@ -25,7 +31,7 @@ namespace PowerToysTests
|
||||
|
||||
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);
|
||||
|
||||
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
|
||||
@ -36,70 +42,70 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditFocusCancel()
|
||||
{
|
||||
OpenCreatorWindow("Focus", "Custom layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Focus", "EditTemplateButton");
|
||||
ZoneCountTest(3, 0);
|
||||
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
creatorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
ZoneCountTest(4, 0);
|
||||
|
||||
CancelTest();
|
||||
CancelTest(creatorWindow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EditColumnsCancel()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
ZoneCountTest(0, 4);
|
||||
|
||||
CancelTest();
|
||||
CancelTest(creatorWindow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EditRowsCancel()
|
||||
{
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
ZoneCountTest(0, 4);
|
||||
|
||||
CancelTest();
|
||||
CancelTest(creatorWindow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EditGridCancel()
|
||||
{
|
||||
OpenCreatorWindow("Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Grid", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
ZoneCountTest(0, 4);
|
||||
|
||||
CancelTest();
|
||||
CancelTest(creatorWindow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EditPriorityGridCancel()
|
||||
{
|
||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Priority Grid", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
ZoneCountTest(0, 4);
|
||||
|
||||
CancelTest();
|
||||
CancelTest(creatorWindow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EditFocusSave()
|
||||
{
|
||||
OpenCreatorWindow("Focus", "Custom layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Focus", "EditTemplateButton");
|
||||
ZoneCountTest(3, 0);
|
||||
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
creatorWindow.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
ZoneCountTest(4, 0);
|
||||
|
||||
SaveTest();
|
||||
@ -108,7 +114,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditColumnsSave()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Columns", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@ -120,7 +126,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditRowsSave()
|
||||
{
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Rows", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@ -132,7 +138,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditGridSave()
|
||||
{
|
||||
OpenCreatorWindow("Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Grid", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@ -144,7 +150,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditPriorityGridSave()
|
||||
{
|
||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
OpenCreatorWindow("Priority Grid", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@ -156,32 +162,26 @@ namespace PowerToysTests
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
if (session == null)
|
||||
return;
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, true, false, false, false, false, false, false);
|
||||
|
||||
ResetDefaultFancyZonesSettings(false);
|
||||
ResetDefaultZoneSettings(true);
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
CloseSettings();
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
if (!isPowerToysLaunched)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
OpenEditor();
|
||||
ResetDefaultZoneSettings(true);
|
||||
Assert.IsTrue(OpenEditor());
|
||||
OpenTemplates();
|
||||
}
|
||||
|
||||
@ -198,10 +198,8 @@ namespace PowerToysTests
|
||||
}
|
||||
catch (OpenQA.Selenium.WebDriverException)
|
||||
{
|
||||
//editor has already closed
|
||||
//editor was already closed
|
||||
}
|
||||
|
||||
ResetDefaultZoneSettings(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System;
|
||||
@ -8,6 +9,7 @@ namespace PowerToysTests
|
||||
public class FancyZonesEditor : PowerToysSession
|
||||
{
|
||||
protected static WindowsElement editorWindow;
|
||||
protected static AppiumWebElement creatorWindow;
|
||||
|
||||
protected static void ResetSettings()
|
||||
{
|
||||
@ -15,22 +17,24 @@ namespace PowerToysTests
|
||||
ResetDefaultZoneSettings(true);
|
||||
}
|
||||
|
||||
protected static void OpenEditor()
|
||||
protected static bool OpenEditor()
|
||||
{
|
||||
try
|
||||
{
|
||||
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
||||
WaitSeconds(2);
|
||||
|
||||
//editorWindow = WaitElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
|
||||
editorWindow = WaitElementByName("FancyZones Editor");
|
||||
//may not find editor by name in 0.16.1
|
||||
//editorWindow = WaitElementByAccessibilityId("MainWindow1");
|
||||
editorWindow = session.FindElementByName("FancyZones Editor");
|
||||
Assert.IsNotNull(editorWindow, "Couldn't find editor window");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
|
||||
WaitElementByXPath(elementXPath).Click();
|
||||
WaitElementByAccessibilityId(buttonId).Click();
|
||||
|
||||
WindowsElement creatorWindow = WaitElementByName(creatorWindowName);
|
||||
editorWindow.FindElementByName(tabName).Click();
|
||||
editorWindow.FindElementByAccessibilityId(buttonId).Click();
|
||||
creatorWindow = editorWindow.FindElementByXPath("//Window");
|
||||
Assert.IsNotNull(creatorWindow, "Creator window didn't open");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -12,6 +12,7 @@ using OpenQA.Selenium.Interactions;
|
||||
|
||||
namespace PowerToysTests
|
||||
{
|
||||
[Ignore]
|
||||
[TestClass]
|
||||
public class FancyZonesSettingsTests : PowerToysSession
|
||||
{
|
||||
@ -39,7 +40,7 @@ namespace PowerToysTests
|
||||
{
|
||||
try
|
||||
{
|
||||
JObject settings = JObject.Parse(File.ReadAllText(_settingsPath));
|
||||
JObject settings = JObject.Parse(File.ReadAllText(_fancyZonesSettingsPath));
|
||||
return settings["properties"].ToObject<JObject>();
|
||||
}
|
||||
catch (Newtonsoft.Json.JsonReaderException)
|
||||
@ -717,8 +718,7 @@ namespace PowerToysTests
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context);
|
||||
if (session == null)
|
||||
return;
|
||||
Assert.IsNotNull(session);
|
||||
|
||||
Init();
|
||||
}
|
||||
@ -741,6 +741,7 @@ namespace PowerToysTests
|
||||
//element couldn't be located
|
||||
}
|
||||
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
@ -752,7 +753,7 @@ namespace PowerToysTests
|
||||
|
||||
try
|
||||
{
|
||||
_initialSettingsJson = JObject.Parse(_initialSettings);
|
||||
_initialSettingsJson = JObject.Parse(_initialFancyZonesSettings);
|
||||
}
|
||||
catch (Newtonsoft.Json.JsonReaderException)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
@ -17,22 +18,27 @@ namespace PowerToysTests
|
||||
|
||||
protected static WindowsDriver<WindowsElement> session;
|
||||
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 _settingsPath = _settingsFolderPath + "\\settings.json";
|
||||
protected static string _fancyZonesSettingsPath = _settingsFolderPath + "\\settings.json";
|
||||
protected static string _zoneSettingsPath = _settingsFolderPath + "\\zones-settings.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 _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 _defaultZoneSettings = "{\"app-zone-history\":[],\"devices\":[],\"custom-zone-sets\":[]}";
|
||||
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 = "{\"devices\":[],\"custom-zone-sets\":[]}";
|
||||
|
||||
|
||||
public static void Setup(TestContext context, bool isLaunchRequired = true)
|
||||
public static void Setup(TestContext context)
|
||||
{
|
||||
if (session == null)
|
||||
{
|
||||
@ -45,13 +51,11 @@ namespace PowerToysTests
|
||||
try
|
||||
{
|
||||
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions);
|
||||
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
|
||||
|
||||
trayButton = session.FindElementByAccessibilityId("1502");
|
||||
|
||||
isPowerToysLaunched = CheckPowerToysLaunched();
|
||||
if (!isPowerToysLaunched && isLaunchRequired)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -66,6 +70,9 @@ namespace PowerToysTests
|
||||
|
||||
if (session != null)
|
||||
{
|
||||
trayButton = null;
|
||||
settingsWindow = null;
|
||||
|
||||
session.Quit();
|
||||
session = null;
|
||||
}
|
||||
@ -76,83 +83,32 @@ namespace PowerToysTests
|
||||
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()
|
||||
{
|
||||
trayButton.Click();
|
||||
|
||||
try
|
||||
{
|
||||
trayButton.Click();
|
||||
session.FindElementByXPath("//Button[@Name=\"PowerToys\"]").Click();
|
||||
trayButton.Click();
|
||||
PowerToysTrayButton().Click();
|
||||
settingsWindow = session.FindElementByName("PowerToys Settings");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
trayButton.Click(); //close
|
||||
Assert.IsNotNull(settingsWindow);
|
||||
}
|
||||
|
||||
public static void OpenFancyZonesSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
WindowsElement fzNavigationButton = WaitElementByXPath("//Button[@Name=\"FancyZones\"]");
|
||||
AppiumWebElement fzNavigationButton = settingsWindow.FindElementByName("FancyZones");
|
||||
Assert.IsNotNull(fzNavigationButton);
|
||||
|
||||
fzNavigationButton.Click();
|
||||
fzNavigationButton.Click();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -167,7 +123,9 @@ namespace PowerToysTests
|
||||
WindowsElement settings = session.FindElementByName("PowerToys Settings");
|
||||
if (settings != null)
|
||||
{
|
||||
settings.SendKeys(Keys.Alt + Keys.F4);
|
||||
settings.Click();
|
||||
settings.FindElementByName("Close").Click();
|
||||
//settings.SendKeys(Keys.Alt + Keys.F4);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -176,67 +134,96 @@ 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()
|
||||
{
|
||||
bool isLaunched = false;
|
||||
trayButton.Click();
|
||||
|
||||
try
|
||||
{
|
||||
trayButton.Click();
|
||||
WindowsElement pt = WaitElementByXPath("//Button[@Name=\"PowerToys\"]");
|
||||
AppiumWebElement pt = PowerToysTrayButton();
|
||||
isLaunched = (pt != null);
|
||||
trayButton.Click(); //close
|
||||
}
|
||||
catch (OpenQA.Selenium.WebDriverException)
|
||||
{
|
||||
//PowerToys not found
|
||||
}
|
||||
|
||||
trayButton.Click(); //close
|
||||
return isLaunched;
|
||||
}
|
||||
|
||||
public static void LaunchPowerToys()
|
||||
{
|
||||
try
|
||||
{
|
||||
AppiumOptions opts = new AppiumOptions();
|
||||
opts.PlatformName = "Windows";
|
||||
opts.AddAdditionalCapability("app", AppPath);
|
||||
|
||||
try
|
||||
{
|
||||
WindowsDriver<WindowsElement> driver = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts);
|
||||
Assert.IsNotNull(driver);
|
||||
driver.LaunchApp();
|
||||
}
|
||||
catch (OpenQA.Selenium.WebDriverException ex)
|
||||
catch (WebDriverException)
|
||||
{
|
||||
Console.WriteLine("Exception on PowerToys launch:" + ex.Message);
|
||||
//exception could be thrown even if app launched successfully
|
||||
//exception is expected since WinApDriver tries to find main app window
|
||||
}
|
||||
|
||||
isPowerToysLaunched = true;
|
||||
}
|
||||
|
||||
public static void ExitPowerToys()
|
||||
{
|
||||
try
|
||||
{
|
||||
trayButton.Click();
|
||||
|
||||
WindowsElement pt = WaitElementByXPath("//Button[@Name=\"PowerToys\"]");
|
||||
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
||||
try
|
||||
{
|
||||
AppiumWebElement pt = PowerToysTrayButton();
|
||||
Assert.IsNotNull(pt, "Could not exit PowerToys");
|
||||
|
||||
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;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ResetSettings(_settingsFolderPath, _settingsPath, _defaultSettings, relaunch);
|
||||
ResetSettings(_settingsFolderPath, _fancyZonesSettingsPath, _defaultFancyZonesSettings, relaunch);
|
||||
}
|
||||
|
||||
public static void ResetDefaultZoneSettings(bool relaunch)
|
||||
@ -252,11 +239,7 @@ namespace PowerToysTests
|
||||
}
|
||||
File.WriteAllText(filePath, data);
|
||||
|
||||
if (isPowerToysLaunched)
|
||||
{
|
||||
ExitPowerToys();
|
||||
}
|
||||
|
||||
if (relaunch)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
@ -267,9 +250,19 @@ namespace PowerToysTests
|
||||
{
|
||||
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)
|
||||
@ -298,13 +291,22 @@ namespace PowerToysTests
|
||||
|
||||
private static void RestoreUserSettings()
|
||||
{
|
||||
if (_initialSettings.Length > 0)
|
||||
if (_initialCommonSettings.Length > 0)
|
||||
{
|
||||
File.WriteAllText(_settingsPath, _initialSettings);
|
||||
File.WriteAllText(_commonSettingsPath, _initialCommonSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(_settingsPath);
|
||||
File.Delete(_commonSettingsPath);
|
||||
}
|
||||
|
||||
if (_initialFancyZonesSettings.Length > 0)
|
||||
{
|
||||
File.WriteAllText(_fancyZonesSettingsPath, _initialFancyZonesSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(_fancyZonesSettingsPath);
|
||||
}
|
||||
|
||||
if (_initialZoneSettings.Length > 0)
|
||||
|
@ -17,7 +17,7 @@ namespace PowerToysTests
|
||||
OpenSettings();
|
||||
|
||||
//check settings window opened
|
||||
WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
|
||||
WindowsElement settingsWindow = session.FindElementByName("PowerToys Settings");
|
||||
Assert.IsNotNull(settingsWindow);
|
||||
|
||||
isSettingsOpened = true;
|
||||
@ -28,19 +28,20 @@ namespace PowerToysTests
|
||||
{
|
||||
//open tray
|
||||
trayButton.Click();
|
||||
WaitSeconds(1);
|
||||
isTrayOpened = true;
|
||||
|
||||
//open PowerToys context menu
|
||||
WindowsElement pt = session.FindElementByName("PowerToys");
|
||||
AppiumWebElement pt = PowerToysTrayButton();
|
||||
Assert.IsNotNull(pt);
|
||||
|
||||
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
||||
|
||||
//open settings
|
||||
WaitElementByXPath("//MenuItem[@Name=\"Settings\"]").Click();
|
||||
session.FindElementByXPath("//MenuItem[@Name=\"Settings\"]").Click();
|
||||
|
||||
//check settings window opened
|
||||
WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
|
||||
WindowsElement settingsWindow = session.FindElementByName("PowerToys Settings");
|
||||
Assert.IsNotNull(settingsWindow);
|
||||
|
||||
isSettingsOpened = true;
|
||||
@ -52,24 +53,21 @@ namespace PowerToysTests
|
||||
//open PowerToys context menu
|
||||
trayButton.Click();
|
||||
isTrayOpened = true;
|
||||
WaitSeconds(1);
|
||||
|
||||
WindowsElement notificationOverflow = session.FindElementByName("Notification Overflow");
|
||||
AppiumWebElement overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
||||
AppiumWebElement powerToys = overflowArea.FindElementByName("PowerToys");
|
||||
AppiumWebElement powerToys = PowerToysTrayButton();
|
||||
Assert.IsNotNull(powerToys);
|
||||
|
||||
new Actions(session).MoveToElement(powerToys).ContextClick().Perform();
|
||||
|
||||
//exit
|
||||
WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
|
||||
session.FindElementByAccessibilityId("40001").Click();
|
||||
|
||||
//check PowerToys exited
|
||||
powerToys = null;
|
||||
try
|
||||
{
|
||||
notificationOverflow = session.FindElementByName("Notification Overflow");
|
||||
overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
||||
powerToys = overflowArea.FindElementByName("PowerToys");
|
||||
powerToys = PowerToysTrayButton();
|
||||
}
|
||||
catch (OpenQA.Selenium.WebDriverException)
|
||||
{
|
||||
@ -84,20 +82,24 @@ namespace PowerToysTests
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
|
||||
if (!isPowerToysLaunched)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
isSettingsOpened = false;
|
||||
isTrayOpened = false;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
@ -8,7 +7,7 @@ using OpenQA.Selenium.Interactions;
|
||||
namespace PowerToysTests
|
||||
{
|
||||
[TestClass]
|
||||
public class TestShortcutHelper : PowerToysSession
|
||||
public class TestShortcutGuideHelper : PowerToysSession
|
||||
{
|
||||
// Try to manage Press/Release of Windows Key here,
|
||||
// since Keyboard.PressKey seems to release the key if pressed
|
||||
@ -37,19 +36,26 @@ namespace PowerToysTests
|
||||
public void AppearsOnWinKeyPress()
|
||||
{
|
||||
PressWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
||||
WaitSeconds(3);
|
||||
|
||||
try
|
||||
{
|
||||
WindowsElement shortcutHelperWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Pane[@ClassName=\"PToyD2DPopup\"]");
|
||||
Assert.IsNotNull(shortcutHelperWindow);
|
||||
ReleaseWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
||||
}
|
||||
catch(OpenQA.Selenium.WebDriverException)
|
||||
{
|
||||
Assert.Fail("Shortcut Guide not found");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(InvalidOperationException),
|
||||
"The Shortcut Guide UI was still found after releasing the key.")]
|
||||
public void DisappearsOnWinKeyRelease()
|
||||
{
|
||||
PressWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
||||
WaitSeconds(2);
|
||||
WindowsElement shortcutHelperWindow;
|
||||
try
|
||||
{
|
||||
@ -61,20 +67,21 @@ namespace PowerToysTests
|
||||
// Not the exception we wanted to catch here.
|
||||
Assert.Fail("Shortcut Guide not found");
|
||||
}
|
||||
|
||||
ReleaseWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(0.5));
|
||||
shortcutHelperWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Pane[@ClassName=\"PToyD2DPopup\"]");
|
||||
Assert.IsNull(shortcutHelperWindow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DoesNotBlockStartMenuOnShortPress()
|
||||
{
|
||||
PressWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(0.4));
|
||||
WaitSeconds(0.4);
|
||||
// FindElementByClassName will be faster than using with XPath.
|
||||
WindowsElement shortcutHelperWindow = session.FindElementByClassName("PToyD2DPopup");
|
||||
Assert.IsNotNull(shortcutHelperWindow);
|
||||
ReleaseWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(0.5));
|
||||
WindowsElement startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]");
|
||||
}
|
||||
[TestMethod]
|
||||
@ -83,7 +90,7 @@ namespace PowerToysTests
|
||||
public void DoesNotSpawnStartMenuOnLongPress()
|
||||
{
|
||||
PressWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
||||
WaitSeconds(2);
|
||||
try
|
||||
{
|
||||
// FindElementByClassName will be faster than using with XPath.
|
||||
@ -96,25 +103,32 @@ namespace PowerToysTests
|
||||
Assert.Fail("Shortcut Guide not found");
|
||||
}
|
||||
ReleaseWinKey();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(0.5));
|
||||
WindowsElement startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]");
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context);
|
||||
Assert.IsNotNull(session);
|
||||
EnableModules(false, false, false, false, false, false, false, true);
|
||||
|
||||
if (!isPowerToysLaunched)
|
||||
{
|
||||
LaunchPowerToys();
|
||||
}
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
ExitPowerToys();
|
||||
TearDown();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
|
||||
isWinKeyPressed = false;
|
||||
|
||||
// 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">
|
||||
<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')" />
|
||||
@ -134,7 +134,7 @@
|
||||
</Compile>
|
||||
<Compile Include="PowerToysSession.cs" />
|
||||
<Compile Include="PowerToysTrayTests.cs" />
|
||||
<Compile Include="TestShortcutHelper.cs" />
|
||||
<Compile Include="TestShortcutGuideHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
|
Loading…
Reference in New Issue
Block a user