mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 13:35:31 +02:00
Editor custom layouts tests (#1757)
This commit is contained in:
@@ -1,42 +1,13 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
|
||||
namespace PowerToysTests
|
||||
{
|
||||
[TestClass]
|
||||
public class FancyZonesEditorTemplatesEditTests : PowerToysSession
|
||||
public class FancyZonesEditorTemplatesEditTests : FancyZonesEditor
|
||||
{
|
||||
WindowsElement editorWindow;
|
||||
|
||||
private void OpenEditor()
|
||||
{
|
||||
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
|
||||
ShortWait();
|
||||
|
||||
editorWindow = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
|
||||
}
|
||||
|
||||
private void OpenTemplates()
|
||||
{
|
||||
WindowsElement templatesTab = session.FindElementByName("Templates");
|
||||
templatesTab.Click();
|
||||
string isSelected = templatesTab.GetAttribute("SelectionItem.IsSelected");
|
||||
Assert.AreEqual("True", isSelected, "Templates tab cannot be opened");
|
||||
}
|
||||
|
||||
private void OpenCreatorWindow(string tabName, string creatorWindowName)
|
||||
{
|
||||
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
|
||||
session.FindElementByXPath(elementXPath).Click();
|
||||
session.FindElementByAccessibilityId("EditTemplateButton").Click();
|
||||
|
||||
WindowsElement creatorWindow = session.FindElementByName(creatorWindowName);
|
||||
Assert.IsNotNull(creatorWindow, "Creator window didn't open");
|
||||
}
|
||||
|
||||
private void ChangeLayout()
|
||||
{
|
||||
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_TitleBar")).MoveByOffset(0, -50).Click().Perform();
|
||||
@@ -60,16 +31,10 @@ namespace PowerToysTests
|
||||
Assert.AreEqual(settings["custom-zone-sets"][0]["uuid"], settings["devices"][0]["active-zoneset"]["uuid"]);
|
||||
}
|
||||
|
||||
private void ZoneCountTest(int canvasZonesCount, int gridZonesCount)
|
||||
{
|
||||
Assert.AreEqual(canvasZonesCount, session.FindElementsByClassName("CanvasZone").Count);
|
||||
Assert.AreEqual(gridZonesCount, session.FindElementsByClassName("GridZone").Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EditFocusCancel()
|
||||
{
|
||||
OpenCreatorWindow("Focus", "Custom layout creator");
|
||||
OpenCreatorWindow("Focus", "Custom layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(3, 0);
|
||||
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
@@ -81,7 +46,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditColumnsCancel()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator");
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -93,7 +58,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditRowsCancel()
|
||||
{
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator");
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -105,7 +70,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditGridCancel()
|
||||
{
|
||||
OpenCreatorWindow("Grid", "Custom table layout creator");
|
||||
OpenCreatorWindow("Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -117,7 +82,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditPriorityGridCancel()
|
||||
{
|
||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator");
|
||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -129,7 +94,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditFocusSave()
|
||||
{
|
||||
OpenCreatorWindow("Focus", "Custom layout creator");
|
||||
OpenCreatorWindow("Focus", "Custom layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(3, 0);
|
||||
|
||||
session.FindElementByAccessibilityId("newZoneButton").Click();
|
||||
@@ -141,7 +106,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditColumnsSave()
|
||||
{
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator");
|
||||
OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -153,7 +118,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditRowsSave()
|
||||
{
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator");
|
||||
OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -165,7 +130,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditGridSave()
|
||||
{
|
||||
OpenCreatorWindow("Grid", "Custom table layout creator");
|
||||
OpenCreatorWindow("Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -177,7 +142,7 @@ namespace PowerToysTests
|
||||
[TestMethod]
|
||||
public void EditPriorityGridSave()
|
||||
{
|
||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator");
|
||||
OpenCreatorWindow("Priority Grid", "Custom table layout creator", "EditTemplateButton");
|
||||
ZoneCountTest(0, 3);
|
||||
|
||||
ChangeLayout();
|
||||
@@ -190,12 +155,8 @@ namespace PowerToysTests
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
Setup(context, false);
|
||||
|
||||
if (isPowerToysLaunched)
|
||||
{
|
||||
ExitPowerToys();
|
||||
}
|
||||
ResetDefaultFancyZonesSettings(true);
|
||||
ResetDefaultFancyZonesSettings(false);
|
||||
ResetDefautZoneSettings(true);
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
|
||||
Reference in New Issue
Block a user