mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
### Summary This pull request includes the following updates: 1. Improvements and stabilization of the UI automation framework 2. Setup of the UI automation pipeline 3. Add UI test cases for FancyZones 4. Add UI test cases for MouseUtils 5. Improvements of Hosts Editor UI tests --- ### Related Links - **Current Release checklist coverage**: https://github.com/microsoft/PowerToys/blob/feature/UITestAutomation/src/common/UITestAutomation/Doc/ui-automation-cover-list.md - **UI Automation pipeline**: https://microsoft.visualstudio.com/Dart/_build?definitionId=161438&_a=summary --------- Signed-off-by: Shawn Yuan <shuai.yuan.zju@gmail.com> Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Jerry Xu <n.xu@outlook.com> Co-authored-by: Zhaopeng Wang <zhaopengwang@microsoft.com> Co-authored-by: Xiaofeng Wang (from Dev Box) <xiaofengwang@microsoft.com> Co-authored-by: Mengyuan <162882040+chenmy77@users.noreply.github.com> Co-authored-by: yaqingmi <miyaqing01@gmail.com> Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Yaqing Mi (from Dev Box) <yaqingmi@microsoft.com> Co-authored-by: Kai Tao <69313318+vanzue@users.noreply.github.com> Co-authored-by: zhaopeng wang <33367956+wang563681252@users.noreply.github.com> Co-authored-by: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com> Co-authored-by: RokyZevon <12629919+RokyZevon@users.noreply.github.com> Co-authored-by: Yu Leng <42196638+moooyo@users.noreply.github.com> Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> Co-authored-by: Davide Giacometti <25966642+davidegiacometti@users.noreply.github.com> Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> Co-authored-by: ruslanlap <106077551+ruslanlap@users.noreply.github.com> Co-authored-by: Muhammad Danish <mdanishkhdev@gmail.com> Co-authored-by: Bennett Blodinger <benwa@users.noreply.github.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Ionuț Manța <ionut@janeasystems.com> Co-authored-by: Hao Liu <liuhaobupt@163.com> Co-authored-by: OlegHarchevkin <40352094+OlegKharchevkin@users.noreply.github.com> Co-authored-by: dcog989 <89043002+dcog989@users.noreply.github.com> Co-authored-by: PesBandi <127593627+PesBandi@users.noreply.github.com> Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Co-authored-by: vanzue <vanzue@outlook.com> Co-authored-by: Typpi <20943337+Nick2bad4u@users.noreply.github.com> Co-authored-by: Mike Griese <migrie@microsoft.com> Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com> Co-authored-by: Abhyudit <64366765+bitmap4@users.noreply.github.com> Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Ved Nig <vednig12@outlook.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Aung Khaing Khant <aungkhaingkhant.dev@gmail.com> Co-authored-by: Aung Khaing Khant <aungkhaingkhant@advent-soft.com> Co-authored-by: Dustin L. Howett <duhowett@microsoft.com> Co-authored-by: leileizhang <leilzh@microsoft.com> Co-authored-by: Dustin L. Howett <dustin@howett.net> Co-authored-by: Shawn Yuan <128874481+shuaiyuanxx@users.noreply.github.com> Co-authored-by: Shawn Yuan <shuai.yuan.zju@gmail.com> Co-authored-by: cryolithic <cryolithic@gmail.com> Co-authored-by: Lemonyte <49930425+lemonyte@users.noreply.github.com> Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com> Co-authored-by: Corey Hayward <72159232+CoreyHayward@users.noreply.github.com> Co-authored-by: Jerry Xu <nxu@microsoft.com> Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com> Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
233 lines
11 KiB
C#
233 lines
11 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.Collections.Generic;
|
|
using FancyZonesEditor.Models;
|
|
using FancyZonesEditorCommon.Data;
|
|
using Microsoft.FancyZonesEditor.UITests;
|
|
using Microsoft.FancyZonesEditor.UnitTests.Utils;
|
|
using Microsoft.PowerToys.UITest;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using OpenQA.Selenium.Appium.Windows;
|
|
using static Microsoft.FancyZonesEditor.UnitTests.Utils.FancyZonesEditorHelper;
|
|
|
|
namespace Microsoft.FancyZonesEditor.UITests
|
|
{
|
|
[TestClass]
|
|
public class RunFancyZonesEditorTest : UITestBase
|
|
{
|
|
public RunFancyZonesEditorTest()
|
|
: base(PowerToysModule.FancyZone, WindowSize.UnSpecified)
|
|
{
|
|
}
|
|
|
|
[TestInitialize]
|
|
public void TestInitialize()
|
|
{
|
|
FancyZonesEditorHelper.Files.Restore();
|
|
|
|
// prepare test editor parameters with 2 monitors before launching the editor
|
|
EditorParameters editorParameters = new EditorParameters();
|
|
EditorParameters.ParamsWrapper parameters = new EditorParameters.ParamsWrapper
|
|
{
|
|
ProcessId = 1,
|
|
SpanZonesAcrossMonitors = false,
|
|
Monitors = new List<EditorParameters.NativeMonitorDataWrapper>
|
|
{
|
|
new EditorParameters.NativeMonitorDataWrapper
|
|
{
|
|
Monitor = "monitor-1",
|
|
MonitorInstanceId = "instance-id-1",
|
|
MonitorSerialNumber = "serial-number-1",
|
|
MonitorNumber = 1,
|
|
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}",
|
|
Dpi = 96,
|
|
LeftCoordinate = 0,
|
|
TopCoordinate = 0,
|
|
WorkAreaHeight = 1040,
|
|
WorkAreaWidth = 1920,
|
|
MonitorHeight = 1080,
|
|
MonitorWidth = 1920,
|
|
IsSelected = true,
|
|
},
|
|
new EditorParameters.NativeMonitorDataWrapper
|
|
{
|
|
Monitor = "monitor-2",
|
|
MonitorInstanceId = "instance-id-2",
|
|
MonitorSerialNumber = "serial-number-2",
|
|
MonitorNumber = 2,
|
|
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}",
|
|
Dpi = 96,
|
|
LeftCoordinate = 1920,
|
|
TopCoordinate = 0,
|
|
WorkAreaHeight = 1040,
|
|
WorkAreaWidth = 1920,
|
|
MonitorHeight = 1080,
|
|
MonitorWidth = 1920,
|
|
IsSelected = false,
|
|
},
|
|
},
|
|
};
|
|
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters));
|
|
|
|
LayoutTemplates layoutTemplates = new LayoutTemplates();
|
|
LayoutTemplates.TemplateLayoutsListWrapper templateLayoutsListWrapper = new LayoutTemplates.TemplateLayoutsListWrapper
|
|
{
|
|
LayoutTemplates = new List<LayoutTemplates.TemplateLayoutWrapper>
|
|
{
|
|
new LayoutTemplates.TemplateLayoutWrapper
|
|
{
|
|
Type = LayoutType.Blank.TypeToString(),
|
|
},
|
|
new LayoutTemplates.TemplateLayoutWrapper
|
|
{
|
|
Type = LayoutType.Focus.TypeToString(),
|
|
ZoneCount = 10,
|
|
},
|
|
new LayoutTemplates.TemplateLayoutWrapper
|
|
{
|
|
Type = LayoutType.Rows.TypeToString(),
|
|
ZoneCount = 2,
|
|
ShowSpacing = true,
|
|
Spacing = 10,
|
|
SensitivityRadius = 10,
|
|
},
|
|
new LayoutTemplates.TemplateLayoutWrapper
|
|
{
|
|
Type = LayoutType.Columns.TypeToString(),
|
|
ZoneCount = 2,
|
|
ShowSpacing = true,
|
|
Spacing = 20,
|
|
SensitivityRadius = 20,
|
|
},
|
|
new LayoutTemplates.TemplateLayoutWrapper
|
|
{
|
|
Type = LayoutType.Grid.TypeToString(),
|
|
ZoneCount = 4,
|
|
ShowSpacing = false,
|
|
Spacing = 10,
|
|
SensitivityRadius = 30,
|
|
},
|
|
new LayoutTemplates.TemplateLayoutWrapper
|
|
{
|
|
Type = LayoutType.PriorityGrid.TypeToString(),
|
|
ZoneCount = 3,
|
|
ShowSpacing = true,
|
|
Spacing = 1,
|
|
SensitivityRadius = 40,
|
|
},
|
|
},
|
|
};
|
|
FancyZonesEditorHelper.Files.LayoutTemplatesIOHelper.WriteData(layoutTemplates.Serialize(templateLayoutsListWrapper));
|
|
|
|
CustomLayouts customLayouts = new CustomLayouts();
|
|
CustomLayouts.CustomLayoutListWrapper customLayoutListWrapper = new CustomLayouts.CustomLayoutListWrapper
|
|
{
|
|
CustomLayouts = new List<CustomLayouts.CustomLayoutWrapper>
|
|
{
|
|
new CustomLayouts.CustomLayoutWrapper
|
|
{
|
|
Uuid = "{E7807D0D-6223-4883-B15B-1F3883944C09}",
|
|
Type = CustomLayout.Canvas.TypeToString(),
|
|
Name = "Custom layout",
|
|
Info = new CustomLayouts().ToJsonElement(new CustomLayouts.CanvasInfoWrapper
|
|
{
|
|
RefHeight = 952,
|
|
RefWidth = 1500,
|
|
SensitivityRadius = 10,
|
|
Zones = new List<CustomLayouts.CanvasInfoWrapper.CanvasZoneWrapper> { },
|
|
}),
|
|
},
|
|
},
|
|
};
|
|
FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.WriteData(customLayouts.Serialize(customLayoutListWrapper));
|
|
|
|
DefaultLayouts defaultLayouts = new DefaultLayouts();
|
|
DefaultLayouts.DefaultLayoutsListWrapper defaultLayoutsListWrapper = new DefaultLayouts.DefaultLayoutsListWrapper
|
|
{
|
|
DefaultLayouts = new List<DefaultLayouts.DefaultLayoutWrapper> { },
|
|
};
|
|
FancyZonesEditorHelper.Files.DefaultLayoutsIOHelper.WriteData(defaultLayouts.Serialize(defaultLayoutsListWrapper));
|
|
|
|
LayoutHotkeys layoutHotkeys = new LayoutHotkeys();
|
|
LayoutHotkeys.LayoutHotkeysWrapper layoutHotkeysWrapper = new LayoutHotkeys.LayoutHotkeysWrapper
|
|
{
|
|
LayoutHotkeys = new List<LayoutHotkeys.LayoutHotkeyWrapper> { },
|
|
};
|
|
FancyZonesEditorHelper.Files.LayoutHotkeysIOHelper.WriteData(layoutHotkeys.Serialize(layoutHotkeysWrapper));
|
|
|
|
AppliedLayouts appliedLayouts = new AppliedLayouts();
|
|
AppliedLayouts.AppliedLayoutsListWrapper appliedLayoutsWrapper = new AppliedLayouts.AppliedLayoutsListWrapper
|
|
{
|
|
AppliedLayouts = new List<AppliedLayouts.AppliedLayoutWrapper> { },
|
|
};
|
|
FancyZonesEditorHelper.Files.AppliedLayoutsIOHelper.WriteData(appliedLayouts.Serialize(appliedLayoutsWrapper));
|
|
|
|
this.RestartScopeExe();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OpenNewLayoutDialog() // verify the new layout dialog is opened
|
|
{
|
|
Session.Find<Button>(By.AccessibilityId(AccessibilityId.NewLayoutButton)).Click();
|
|
Assert.IsNotNull(Session.Find<Element>("Choose layout type")); // check the pane header
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OpenEditLayoutDialog() // verify the edit layout dialog is opened
|
|
{
|
|
Session.Find<Button>(TestConstants.TemplateLayoutNames[LayoutType.Grid]).Click();
|
|
Assert.IsNotNull(Session.Find<Element>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.DialogTitle))); // check the pane header
|
|
Assert.IsNotNull(Session.Find<Element>($"Edit '{TestConstants.TemplateLayoutNames[LayoutType.Grid]}'")); // verify it's opened for the correct layout
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OpenEditLayoutDialog_ByContextMenu_TemplateLayout() // verify the edit layout dialog is opened
|
|
{
|
|
Session.Find<Button>(TestConstants.TemplateLayoutNames[LayoutType.Grid]).Click(true);
|
|
var menu = Session.Find<Element>(By.ClassName(ClassName.ContextMenu));
|
|
menu.Find<Element>(FancyZonesEditorHelper.ElementName.Edit).Click();
|
|
|
|
Assert.IsNotNull(Session.Find<Element>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.DialogTitle))); // check the pane header
|
|
Assert.IsNotNull(Session.Find<Element>($"Edit '{TestConstants.TemplateLayoutNames[LayoutType.Grid]}'")); // verify it's opened for the correct layout
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OpenEditLayoutDialog_ByContextMenu_CustomLayout() // verify the edit layout dialog is opened
|
|
{
|
|
string layoutName = "Custom layout";
|
|
Session.Find<Button>(layoutName).Click(true);
|
|
var menu = Session.Find<Element>(By.ClassName(ClassName.ContextMenu));
|
|
menu.Find<Element>(FancyZonesEditorHelper.ElementName.Edit).Click();
|
|
|
|
Assert.IsNotNull(Session.Find<Element>(By.AccessibilityId(FancyZonesEditorHelper.AccessibilityId.DialogTitle))); // check the pane header
|
|
Assert.IsNotNull(Session.Find<Element>($"Edit '{layoutName}'")); // verify it's opened for the correct layout
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OpenContextMenu() // verify the context menu is opened
|
|
{
|
|
Session.Find<Button>(TestConstants.TemplateLayoutNames[LayoutType.Columns]).Click(true);
|
|
Assert.IsNotNull(Session.Find<Element>(By.ClassName(ClassName.ContextMenu)));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ClickMonitor()
|
|
{
|
|
Assert.IsNotNull(Session.Find<Element>("Monitor 1"));
|
|
Assert.IsNotNull(Session.Find<Element>("Monitor 2"));
|
|
|
|
// verify that the monitor 1 is selected initially
|
|
Assert.IsTrue(Session.Find<Element>("Monitor 1").Selected);
|
|
Assert.IsFalse(Session.Find<Element>("Monitor 2").Selected);
|
|
|
|
Session.Find<Element>("Monitor 2").Click();
|
|
|
|
// verify that the monitor 2 is selected after click
|
|
Assert.IsFalse(Session.Find<Element>("Monitor 1").Selected);
|
|
Assert.IsTrue(Session.Find<Element>("Monitor 2").Selected);
|
|
}
|
|
}
|
|
}
|