diff --git a/PowerToys.sln b/PowerToys.sln index 960ed0ffe57c..d9187911482f 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -628,7 +628,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedPaste.UnitTests", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedPaste.FuzzTests", "src\modules\AdvancedPaste\AdvancedPaste.FuzzTests\AdvancedPaste.FuzzTests.csproj", "{7F5B9557-5878-4438-A721-3E28296BA193}" EndProject -<<<<<<< HEAD Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ZoomIt", "ZoomIt", "{DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomIt", "src\modules\ZoomIt\ZoomIt\ZoomIt.vcxproj", "{0A84F764-3A88-44CD-AA96-41BDBD48627B}" @@ -636,9 +635,10 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomItModuleInterface", "src\modules\ZoomIt\ZoomItModuleInterface\ZoomItModuleInterface.vcxproj", "{E4585179-2AC1-4D5F-A3FF-CFC5392F694C}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomItSettingsInterop", "src\modules\ZoomIt\ZoomItSettingsInterop\ZoomItSettingsInterop.vcxproj", "{CA7D8106-30B9-4AEC-9D05-B69B31B8C461}" -======= +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITestAPI", "src\UITestAPI\UITestAPI.csproj", "{6190BD46-AF95-49E6-8B7E-89B923CDE845}" ->>>>>>> 11da69271 (add UI test framework code) +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyboardManagerUITests", "src\modules\keyboardmanager\KeyboardManagerUITests\KeyboardManagerUITests.csproj", "{A62BA56B-0A0B-4BBE-B570-F1CF80003274}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -2802,7 +2802,6 @@ Global {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x64.Build.0 = Release|x64 {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x86.ActiveCfg = Release|x64 {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x86.Build.0 = Release|x64 -<<<<<<< HEAD {0A84F764-3A88-44CD-AA96-41BDBD48627B}.Debug|ARM64.ActiveCfg = Debug|ARM64 {0A84F764-3A88-44CD-AA96-41BDBD48627B}.Debug|ARM64.Build.0 = Debug|ARM64 {0A84F764-3A88-44CD-AA96-41BDBD48627B}.Debug|x64.ActiveCfg = Debug|x64 @@ -2839,7 +2838,6 @@ Global {CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x64.Build.0 = Release|x64 {CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x86.ActiveCfg = Release|x64 {CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x86.Build.0 = Release|x64 -======= {6190BD46-AF95-49E6-8B7E-89B923CDE845}.Debug|ARM64.ActiveCfg = Debug|ARM64 {6190BD46-AF95-49E6-8B7E-89B923CDE845}.Debug|ARM64.Build.0 = Debug|ARM64 {6190BD46-AF95-49E6-8B7E-89B923CDE845}.Debug|x64.ActiveCfg = Debug|x64 @@ -2852,7 +2850,18 @@ Global {6190BD46-AF95-49E6-8B7E-89B923CDE845}.Release|x64.Build.0 = Release|x64 {6190BD46-AF95-49E6-8B7E-89B923CDE845}.Release|x86.ActiveCfg = Release|x64 {6190BD46-AF95-49E6-8B7E-89B923CDE845}.Release|x86.Build.0 = Release|x64 ->>>>>>> 11da69271 (add UI test framework code) + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Debug|ARM64.Build.0 = Debug|ARM64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Debug|x64.ActiveCfg = Debug|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Debug|x64.Build.0 = Debug|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Debug|x86.ActiveCfg = Debug|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Debug|x86.Build.0 = Debug|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Release|ARM64.ActiveCfg = Release|ARM64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Release|ARM64.Build.0 = Release|ARM64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Release|x64.ActiveCfg = Release|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Release|x64.Build.0 = Release|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Release|x86.ActiveCfg = Release|x64 + {A62BA56B-0A0B-4BBE-B570-F1CF80003274}.Release|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3084,14 +3093,12 @@ Global {0DB0F63A-D2F8-4DA3-A650-2D0B8724218E} = {CA716AE6-FE5C-40AC-BB8F-2C87912687AC} {D5E5F5EA-1B6C-4A73-88BE-304F36C9E4EE} = {9873BA05-4C41-4819-9283-CF45D795431B} {7F5B9557-5878-4438-A721-3E28296BA193} = {9873BA05-4C41-4819-9283-CF45D795431B} -<<<<<<< HEAD {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {0A84F764-3A88-44CD-AA96-41BDBD48627B} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} {E4585179-2AC1-4D5F-A3FF-CFC5392F694C} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} {CA7D8106-30B9-4AEC-9D05-B69B31B8C461} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} -======= {6190BD46-AF95-49E6-8B7E-89B923CDE845} = {1AFB6476-670D-4E80-A464-657E01DFF482} ->>>>>>> 11da69271 (add UI test framework code) + {A62BA56B-0A0B-4BBE-B570-F1CF80003274} = {38BDB927-829B-4C65-9CD9-93FB05D66D65} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/src/UITestAPI/src/UITestAPI.cs b/src/UITestAPI/src/UITestAPI.cs index a43ae2a55041..e590797b4f9f 100644 --- a/src/UITestAPI/src/UITestAPI.cs +++ b/src/UITestAPI/src/UITestAPI.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -89,7 +90,14 @@ public void Close(TestContext testContext) private WindowsElement? GetElement(string elementName) { - var listItem = Session?.FindElementByName(elementName); + var item = Session?.FindElementByName(elementName); + Assert.IsNotNull(item, "ElementName " + elementName + " not found"); + return item; + } + + private ReadOnlyCollection GetElements(string elementName) + { + var listItem = Session?.FindElementsByName(elementName); Assert.IsNotNull(listItem, "ElementName " + elementName + " not found"); return listItem; } @@ -107,11 +115,45 @@ public void Click_Element(string elementName) var element = GetElement(elementName); Actions actions = new Actions(Session); actions.MoveToElement(element); - actions.MoveByOffset(30, 30); actions.Click(); actions.Build().Perform(); } + public void Click_Elements(string elementName) + { + var elements = GetElements(elementName); + Actions actions = new Actions(Session); + foreach (var element in elements) + { + actions.MoveToElement(element); + + actions.MoveByOffset(5, 5); + actions.Click(); + actions.Build().Perform(); + } + } + + public void Click_Element(string elementName, string helpText) + { + var elements = GetElements(elementName); + Actions actions = new Actions(Session); + bool buttonClicked = false; + foreach (var element in elements) + { + if (element.GetAttribute("HelpText") == helpText) + { + actions.MoveToElement(element); + actions.Click(); + actions.Build().Perform(); + actions.MoveByOffset(5, 5); + buttonClicked = true; + break; + } + } + + Assert.IsTrue(buttonClicked, $"No button with elementName '{elementName}' and HelpText '{helpText}' was found."); + } + public void RightClick_Element(string elementName) { var element = GetElement(elementName); diff --git a/src/modules/keyboardmanager/KeyboardManagerUITests/KeyboardManagerUITests.csproj b/src/modules/keyboardmanager/KeyboardManagerUITests/KeyboardManagerUITests.csproj new file mode 100644 index 000000000000..8dfa79e0e773 --- /dev/null +++ b/src/modules/keyboardmanager/KeyboardManagerUITests/KeyboardManagerUITests.csproj @@ -0,0 +1,32 @@ + + + + + + {6F8C7C5A-130A-48C2-A245-3132A4121E24} + Microsoft.KeyboardManager.UITests + false + enable + Library + + + false + + + + ..\..\..\..\$(Platform)\$(Configuration)\tests\KeyboardManagerUITests\ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/modules/keyboardmanager/KeyboardManagerUITests/RunKeyboardManagerUITests.cs b/src/modules/keyboardmanager/KeyboardManagerUITests/RunKeyboardManagerUITests.cs new file mode 100644 index 000000000000..6a8b4a7d92e9 --- /dev/null +++ b/src/modules/keyboardmanager/KeyboardManagerUITests/RunKeyboardManagerUITests.cs @@ -0,0 +1,73 @@ +// 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; +using System.Collections.Generic; +using System.Diagnostics; +using Microsoft.UITests.API; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace UITests_KeyboardManager +{ + [TestClass] + public class RunKeyboardManagerUITests + { + private const string PowerToysSettingsPath = @"\..\..\..\WinUI3Apps\PowerToys.Settings.exe"; + private static UITestAPI? _uITestAPI; + + private static TestContext? _context; + + [AssemblyInitialize] + public static void SetupAll(TestContext context) + { + Debug.WriteLine("AssemblyInitialize executed"); + } + + [AssemblyCleanup] + public static void CleanupAll() + { + Debug.WriteLine("AssemblyCleanup executed"); + } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + _uITestAPI = new UITestAPI(); + _uITestAPI.Init(PowerToysSettingsPath); + Debug.WriteLine("ClassInitialize executed"); + } + + [ClassCleanup] + public static void ClassCleanup() + { + if (_uITestAPI != null && _context != null) + { + _uITestAPI.Close(_context); + } + + _context = null; + Debug.WriteLine("ClassCleanup executed"); + } + + [TestInitialize] + public void TestInitialize() + { + Debug.WriteLine("TestInitialize executed"); + } + + [TestCleanup] + public void TestCleanup() + { + Debug.WriteLine("TestCleanup executed"); + } + + [TestMethod] + public void EnableKeyboardManager() // verify the session is initialized + { + Debug.WriteLine("Test method executed"); + Assert.IsNotNull(_uITestAPI); + _uITestAPI.Click_Element("Enable module", "Keyboard Manager"); + } + } +}