mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
name constants
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// 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.
|
||||
|
||||
@@ -7,6 +7,7 @@ using FancyZonesEditorCommon.Data;
|
||||
using Microsoft.FancyZonesEditor.UnitTests.Utils;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using static FancyZonesEditorCommon.Data.EditorParameters;
|
||||
using static Microsoft.FancyZonesEditor.UnitTests.Utils.FancyZonesEditorSession;
|
||||
|
||||
namespace Microsoft.FancyZonesEditor.UITests
|
||||
{
|
||||
@@ -207,7 +208,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void CopyTemplate_FromContextMenu()
|
||||
{
|
||||
string copiedLayoutName = Constants.TemplateLayoutNames[Constants.TemplateLayouts.Rows] + " (1)";
|
||||
_session?.ClickContextMenuItem(Constants.TemplateLayoutNames[Constants.TemplateLayouts.Rows], "Create custom layout");
|
||||
_session?.ClickContextMenuItem(Constants.TemplateLayoutNames[Constants.TemplateLayouts.Rows], ElementName.CreateCustomLayout);
|
||||
|
||||
// verify the layout is copied
|
||||
_session?.WaitElementDisplayedByName(copiedLayoutName);
|
||||
@@ -274,7 +275,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void CopyCustomLayout_FromContextMenu()
|
||||
{
|
||||
string copiedLayoutName = CustomLayouts.CustomLayouts[0].Name + " (1)";
|
||||
_session?.ClickContextMenuItem(CustomLayouts.CustomLayouts[0].Name, "Duplicate");
|
||||
_session?.ClickContextMenuItem(CustomLayouts.CustomLayouts[0].Name, ElementName.Duplicate);
|
||||
|
||||
// verify the layout is copied
|
||||
_session?.WaitElementDisplayedByName(copiedLayoutName);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// 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.
|
||||
|
||||
@@ -10,6 +10,7 @@ using static FancyZonesEditorCommon.Data.CustomLayouts;
|
||||
using static FancyZonesEditorCommon.Data.DefaultLayouts;
|
||||
using static FancyZonesEditorCommon.Data.EditorParameters;
|
||||
using static FancyZonesEditorCommon.Data.LayoutHotkeys;
|
||||
using static Microsoft.FancyZonesEditor.UnitTests.Utils.FancyZonesEditorSession;
|
||||
|
||||
namespace Microsoft.FancyZonesEditor.UITests
|
||||
{
|
||||
@@ -295,7 +296,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void DeleteFromContextMenu()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
_session?.ClickContextMenuItem(deletedLayout, "Delete");
|
||||
_session?.ClickContextMenuItem(deletedLayout, ElementName.Delete);
|
||||
_session?.ClickConfirmDialog();
|
||||
_session?.WaitFor(1);
|
||||
|
||||
@@ -313,7 +314,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void DeleteDefaultLayout()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
_session?.ClickContextMenuItem(deletedLayout, "Delete");
|
||||
_session?.ClickContextMenuItem(deletedLayout, ElementName.Delete);
|
||||
_session?.ClickConfirmDialog();
|
||||
_session?.WaitFor(1);
|
||||
|
||||
@@ -333,7 +334,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void DeleteLayoutWithHotkey()
|
||||
{
|
||||
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
|
||||
_session?.ClickContextMenuItem(deletedLayout, "Delete");
|
||||
_session?.ClickContextMenuItem(deletedLayout, ElementName.Delete);
|
||||
_session?.ClickConfirmDialog();
|
||||
_session?.WaitFor(1);
|
||||
|
||||
|
||||
@@ -188,24 +188,27 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void OpenEditLayoutDialog() // verify the edit layout dialog is opened
|
||||
{
|
||||
_session?.ClickEditLayout(Constants.TemplateLayoutNames[Constants.TemplateLayouts.Grid]);
|
||||
Assert.IsNotNull(_session?.FindByAccessibilityId("EditLayoutDialogTitle")); // check the pane header
|
||||
Assert.IsNotNull(_session?.FindByName("Edit 'Grid'")); // verify it's opened for the correct layout
|
||||
Assert.IsNotNull(_session?.FindByAccessibilityId(FancyZonesEditorSession.AccessibilityId.DialogTitle)); // check the pane header
|
||||
Assert.IsNotNull(_session?.FindByName($"Edit '{Constants.TemplateLayoutNames[Constants.TemplateLayouts.Grid]}'")); // verify it's opened for the correct layout
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenEditLayoutDialog_ByContextMenu_TemplateLayout() // verify the edit layout dialog is opened
|
||||
{
|
||||
_session?.ClickContextMenuItem(Constants.TemplateLayoutNames[Constants.TemplateLayouts.Grid], "Edit");
|
||||
Assert.IsNotNull(_session?.FindByAccessibilityId("EditLayoutDialogTitle")); // check the pane header
|
||||
Assert.IsNotNull(_session?.FindByName("Edit 'Grid'")); // verify it's opened for the correct layout
|
||||
_session?.ClickContextMenuItem(Constants.TemplateLayoutNames[Constants.TemplateLayouts.Grid], FancyZonesEditorSession.ElementName.Edit);
|
||||
_session?.WaitElementDisplayedById(FancyZonesEditorSession.AccessibilityId.DialogTitle);
|
||||
Assert.IsNotNull(_session?.FindByAccessibilityId(FancyZonesEditorSession.AccessibilityId.DialogTitle)); // check the pane header
|
||||
Assert.IsNotNull(_session?.FindByName($"Edit '{Constants.TemplateLayoutNames[Constants.TemplateLayouts.Grid]}'")); // verify it's opened for the correct layout
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenEditLayoutDialog_ByContextMenu_CustomLayout() // verify the edit layout dialog is opened
|
||||
{
|
||||
_session?.ClickContextMenuItem("Custom layout", "Edit");
|
||||
Assert.IsNotNull(_session?.FindByAccessibilityId("EditLayoutDialogTitle")); // check the pane header
|
||||
Assert.IsNotNull(_session?.FindByName("Edit 'Grid'")); // verify it's opened for the correct layout
|
||||
string layoutName = "Custom layout";
|
||||
_session?.ClickContextMenuItem(layoutName, FancyZonesEditorSession.ElementName.Edit);
|
||||
_session?.WaitElementDisplayedById(FancyZonesEditorSession.AccessibilityId.DialogTitle);
|
||||
Assert.IsNotNull(_session?.FindByAccessibilityId(FancyZonesEditorSession.AccessibilityId.DialogTitle)); // check the pane header
|
||||
Assert.IsNotNull(_session?.FindByName($"Edit '{layoutName}'")); // verify it's opened for the correct layout
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
public const string EditLayoutButton = "EditLayoutButton";
|
||||
|
||||
// edit layout window: common for template and custom layouts
|
||||
public const string DialogTitle = "EditLayoutDialogTitle";
|
||||
public const string SensitivitySlider = "SensitivityInput";
|
||||
public const string SpacingSlider = "Spacing";
|
||||
public const string SpacingToggle = "spaceAroundSetting";
|
||||
@@ -87,21 +88,35 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
|
||||
public static class ElementName
|
||||
{
|
||||
public const string Save = "Save";
|
||||
public const string Cancel = "Cancel";
|
||||
|
||||
// context menu
|
||||
public const string Edit = "Edit";
|
||||
public const string EditZones = "Edit zones";
|
||||
public const string Delete = "Delete";
|
||||
public const string Duplicate = "Duplicate";
|
||||
public const string CreateCustomLayout = "Create custom layout";
|
||||
|
||||
// canvas layout editor
|
||||
public const string CanvasEditorWindow = "Canvas layout editor";
|
||||
|
||||
// grid layout editor
|
||||
public const string GridLayoutEditor = "Grid layout editor";
|
||||
public const string MergeZonesButton = "Merge zones";
|
||||
}
|
||||
|
||||
public static class ClassName
|
||||
{
|
||||
public const string ContextMenu = "ContextMenu";
|
||||
public const string TextBox = "TextBox";
|
||||
public const string Popup = "Popup";
|
||||
|
||||
// layout editor
|
||||
public const string CanvasZone = "CanvasZone";
|
||||
public const string GridZone = "GridZone";
|
||||
public const string Button = "Button";
|
||||
public const string Thumb = "Thumb";
|
||||
}
|
||||
|
||||
public FancyZonesEditorSession(TestContext testContext)
|
||||
@@ -185,7 +200,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
public WindowsElement OpenContextMenu(string layoutName)
|
||||
{
|
||||
RightClickLayout(layoutName);
|
||||
return Session.FindElementByClassName("ContextMenu");
|
||||
return Session.FindElementByClassName(ClassName.ContextMenu);
|
||||
}
|
||||
|
||||
public WindowsElement? GetMonitorsList()
|
||||
@@ -234,7 +249,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
{
|
||||
try
|
||||
{
|
||||
return Session.FindElementByClassName("TextBox");
|
||||
return Session.FindElementByClassName(ClassName.TextBox);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -252,7 +267,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
{
|
||||
try
|
||||
{
|
||||
return Session.FindElementByClassName("Popup");
|
||||
return Session.FindElementByClassName(ClassName.Popup);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -289,7 +304,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
{
|
||||
try
|
||||
{
|
||||
return Session.FindElementByName("Grid layout editor");
|
||||
return Session.FindElementByName(ElementName.GridLayoutEditor);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -366,14 +381,14 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
|
||||
public void ClickSave()
|
||||
{
|
||||
var button = Session.FindElementByName("Save");
|
||||
var button = Session.FindElementByName(ElementName.Save);
|
||||
Assert.IsNotNull(button, "No Save button");
|
||||
button.Click();
|
||||
}
|
||||
|
||||
public void ClickCancel()
|
||||
{
|
||||
var button = Session.FindElementByName("Cancel");
|
||||
var button = Session.FindElementByName(ElementName.Cancel);
|
||||
Assert.IsNotNull(button, "No Cancel button");
|
||||
button.Click();
|
||||
}
|
||||
@@ -477,7 +492,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
|
||||
public void MoveSplitter(int xOffset, int yOffset)
|
||||
{
|
||||
ReadOnlyCollection<WindowsElement>? thumbs = Session?.FindElementsByClassName("Thumb");
|
||||
ReadOnlyCollection<WindowsElement> thumbs = Session.FindElementsByClassName(ClassName.Thumb);
|
||||
if (thumbs.Count == 0)
|
||||
{
|
||||
return;
|
||||
@@ -538,6 +553,19 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public WindowsElement? FindByClassName(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Session.FindElementByClassName(name);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
context.WriteLine($"{name} not found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool WaitElementDisplayedByName(string name)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user