Compare commits

...

49 Commits

Author SHA1 Message Date
Yu Leng (from Dev Box)
b2db376b1f Fix typo issue 2025-08-04 17:25:15 +08:00
Yu Leng (from Dev Box)
0a2e1f1424 Fix spelling issue 2025-08-04 17:22:46 +08:00
Yu Leng (from Dev Box)
0b739b45e6 Remove unused function 2025-08-04 17:10:34 +08:00
Yu Leng (from Dev Box)
f627fa823b fix some case 2025-08-04 17:10:16 +08:00
Yu Leng (from Dev Box)
11ca4a281f merge main 2025-08-04 16:10:32 +08:00
Yu Leng (from Dev Box)
15aa63bf79 merge main 2025-08-04 16:07:49 +08:00
Yu Leng (from Dev Box)
036fa957ab merge main 2025-07-30 14:11:01 +08:00
Yu Leng (from Dev Box)
a9b510e2dc update 2025-07-30 14:03:59 +08:00
Leilei Zhang
3206c0b073 add win 10 2025-07-30 12:10:23 +08:00
Leilei Zhang
82d031cf2a add comments 2025-07-30 11:39:44 +08:00
Leilei Zhang
5c7c8c3009 add buildid 2025-07-30 11:15:53 +08:00
Leilei Zhang
64a48fda97 update the indexer test 2025-07-30 10:36:07 +08:00
Leilei Zhang
75cbd2d577 fix ux 2025-07-29 18:11:24 +08:00
Yu Leng (from Dev Box)
77b0a93fc0 init 2025-07-29 16:18:41 +08:00
Leilei Zhang
dd47beabd8 Merge branch 'main' of https://github.com/microsoft/PowerToys into leilzh/pathissue 2025-07-29 15:44:07 +08:00
Leilei Zhang
29a8bbc40a remove unused 2025-07-29 14:32:07 +08:00
Yu Leng (from Dev Box)
35f7124756 merge main 2025-07-29 14:11:29 +08:00
Yu Leng (from Dev Box)
074a00faa8 merge main 2025-07-29 14:04:43 +08:00
Leilei Zhang
6607b60bd5 install xaml 2025-07-29 13:23:34 +08:00
Leilei Zhang
983591e4e0 use release 2025-07-29 12:31:38 +08:00
Leilei Zhang
0a2a3fea93 exit always 0 2025-07-29 11:58:15 +08:00
Leilei Zhang
30d67ec078 use steps 2025-07-29 10:52:27 +08:00
Leilei Zhang
4c87a78b1a use windows poweshell 2025-07-29 10:19:29 +08:00
Leilei Zhang
f12d983025 install terminal 2025-07-28 22:54:34 +08:00
Leilei Zhang
369babc0f8 update install steps 2025-07-28 21:53:12 +08:00
Leilei Zhang
6834fa24af common out the stange type behavior 2025-07-28 21:36:26 +08:00
Leilei Zhang
14f18f4b95 change cmdpal start logic 2025-07-28 19:17:47 +08:00
Leilei Zhang
4bf2342a09 update find 2025-07-28 17:50:26 +08:00
Leilei Zhang
20243c4b99 install termianl 2025-07-28 17:02:27 +08:00
Leilei Zhang
a19127bf49 check termianl 2025-07-28 13:25:33 +08:00
Leilei Zhang
aeaa5297f9 fix 2025-07-28 12:15:26 +08:00
Leilei Zhang
cd45bad9ce install terminal 2025-07-28 11:39:12 +08:00
Leilei Zhang
2ae636a860 refine find window 2025-07-28 11:34:34 +08:00
Leilei Zhang
3bf8a63dd8 update setText 2025-07-27 11:24:21 +08:00
Leilei Zhang
11b6e15869 update cmdpal start options 2025-07-25 22:35:12 +08:00
Leilei Zhang
f59063d285 update the path 2025-07-25 19:20:11 +08:00
Leilei Zhang
83703d2cf2 fix path issue 2025-07-25 18:12:19 +08:00
Yu Leng (from Dev Box)
205ca7645e Merge main 2025-07-25 15:47:43 +08:00
Yu Leng (from Dev Box)
2e0d5d0786 Add Windows Settings and Windows Terminal 2025-07-25 15:44:07 +08:00
Yu Leng (from Dev Box)
de1d1b4020 merge branch 2025-07-25 14:26:26 +08:00
Yu Leng (from Dev Box)
2c01dcd5af init 2025-07-25 14:21:55 +08:00
Yu Leng (from Dev Box)
599a927d8a Merge branch 'main' into yuleng/cmdpal/tests/ui/apps 2025-07-25 14:02:40 +08:00
Yu Leng (from Dev Box)
803d65cf98 disable uac test case 2025-07-24 16:33:30 +08:00
Yu Leng (from Dev Box)
3fce8697f3 Update 2025-07-24 16:01:36 +08:00
Yu Leng (from Dev Box)
925d5b030e init 2025-07-24 15:42:38 +08:00
Yu Leng (from Dev Box)
37256aca56 update some cases 2025-07-24 15:23:43 +08:00
Yu Leng (from Dev Box)
f9c1fd8d62 add more cases 2025-07-24 14:42:22 +08:00
Yu Leng (from Dev Box)
04aa0a07ed Add hide window key 2025-07-23 17:17:57 +08:00
Yu Leng (from Dev Box)
d450e06bf9 init 2025-07-23 17:03:45 +08:00
7 changed files with 682 additions and 15 deletions

View File

@@ -33,10 +33,11 @@ namespace Microsoft.PowerToys.UITest
private readonly PowerToysModule scope;
private readonly WindowSize size;
private readonly string[]? commandLineArgs;
private readonly bool hideAllWindowBeforeStart;
private SessionHelper? sessionHelper;
private System.Threading.Timer? screenshotTimer;
public UITestBase(PowerToysModule scope = PowerToysModule.PowerToysSettings, WindowSize size = WindowSize.UnSpecified, string[]? commandLineArgs = null)
public UITestBase(PowerToysModule scope = PowerToysModule.PowerToysSettings, WindowSize size = WindowSize.UnSpecified, string[]? commandLineArgs = null, bool hideAllWindowBeforeStart = false)
{
this.IsInPipeline = EnvironmentConfig.IsInPipeline;
Console.WriteLine($"Running tests on platform: {EnvironmentConfig.Platform}");
@@ -52,6 +53,7 @@ namespace Microsoft.PowerToys.UITest
this.scope = scope;
this.size = size;
this.commandLineArgs = commandLineArgs;
this.hideAllWindowBeforeStart = hideAllWindowBeforeStart;
}
/// <summary>
@@ -74,6 +76,12 @@ namespace Microsoft.PowerToys.UITest
System.Windows.Forms.SendKeys.SendWait("{ESC}");
}
if (hideAllWindowBeforeStart)
{
KeyboardHelper.SendKeys([Key.Win, Key.M]);
Task.Delay(2000).Wait(); // Wait for a second to ensure all windows are minimized
}
this.sessionHelper = new SessionHelper(scope, commandLineArgs).Init();
this.Session = new Session(this.sessionHelper.GetRoot(), this.sessionHelper.GetDriver(), scope, size);
}
@@ -578,13 +586,31 @@ namespace Microsoft.PowerToys.UITest
}
/// <summary>
    /// Moves the mouse cursor to the specified screen coordinates.
    /// </summary>
    /// <param name="x">The new x-coordinate of the cursor.</param>
    /// <param name="y">The new y-coordinate of the cursor.</param
/// Moves the mouse cursor to the specified screen coordinates.
/// </summary>
/// <param name="x">The new x-coordinate of the cursor.</param>
/// <param name="y">The new y-coordinate of the cursor.</param>
public void MoveMouseTo(int x, int y)
{
        this.Session.MoveMouseTo(x, y);
this.Session.MoveMouseTo(x, y);
}
/// <summary>
/// Moves the mouse cursor to the center of the screen.
/// </summary>
public void MoveMouseToCenter()
{
var (centerX, centerY) = this.GetScreenCenter();
this.MoveMouseTo(centerX, centerY);
}
/// <summary>
/// Moves the mouse cursor to the center of the screen and performs a left click.
/// </summary>
public void FocusOnCenter()
{
this.MoveMouseToCenter();
this.Session.PerformMouseAction(MouseActionType.LeftClick);
}
protected void AddScreenShotsToTestResultsDirectory()

View File

@@ -0,0 +1,264 @@
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.PowerToys.UITest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.CmdPal.UITests;
[TestClass]
public class AppsTests : CommandPaletteTestBase
{
public void EnterAppsExtension()
{
SetSearchBox("All Apps");
var searchFileItem = this.Find<NavigationViewItem>("All Apps");
Assert.AreEqual(searchFileItem.Name, "All Apps");
searchFileItem.DoubleClick();
}
public NavigationViewItem SearchAppByName(string name)
{
EnterAppsExtension();
SetAppsExtensionSearchBox(name);
var item = this.Find<NavigationViewItem>(name);
Assert.IsNotNull(item, $"{name} app not found.");
return item;
}
[TestMethod]
public void OpenWin32AppTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.DoubleClick();
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}
[TestMethod]
public void OpenUWPAppTest()
{
const string appName = "Calculator";
var calculatorItem = SearchAppByName(appName);
calculatorItem.DoubleClick();
var calculatorWindow = this.Find<Window>("Calculator", global: true);
Assert.IsNotNull(calculatorWindow, "Calculator window not found.");
}
[TestMethod]
public void ClickPrimaryButtonTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
var primaryButton = this.Find<Button>("Run");
Assert.IsNotNull(primaryButton, "Primary button not found.");
primaryButton.Click();
var calculatorWindow = this.Find<Window>(By.ClassName("Notepad"), global: true, timeoutMS: 10000);
Assert.IsNotNull(calculatorWindow, "Notepad window not found.");
}
[STATestMethod]
[TestMethod]
public void ClickSecondaryButtonUWPAppTest()
{
const string appName = "Calculator";
var calculatorItem = SearchAppByName(appName);
calculatorItem.Click();
var secondaryButton = this.Find<Button>("Copy path");
Assert.IsNotNull(secondaryButton, "Secondary button not found.");
secondaryButton.Click();
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
Assert.IsTrue(clipboardContent.Contains("Calculator"), $"Clipboard content does not contain the expected file name. clipboard: {clipboardContent}");
}
/*
[TestMethod]
public void ClickSecondaryButtonWin32AppTest()
{
const string appName = "Registry Editor";
var calculatorItem = SearchAppByName(appName);
calculatorItem.Click();
var secondaryButton = this.Find<Button>("Run as administrator");
Assert.IsNotNull(secondaryButton, "Secondary button not found.");
secondaryButton.Click();
UACConfirm();
var fileExplorerWindow = this.Find<Window>(By.ClassName("RegEdit_RegEdit"), global: true);
Assert.IsNotNull(fileExplorerWindow, "Registry Editor window not found.");
}*/
[TestMethod]
public void OpenContextMenuTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var pinButton = this.Find<NavigationViewItem>("Pin");
Assert.IsNotNull(pinButton);
}
[TestMethod]
public void ContextMenuRunButtonTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var runButton = this.Find<NavigationViewItem>("Run");
Assert.IsNotNull(runButton);
runButton.Click();
var notepadWindow = this.Find<Window>(By.ClassName("Notepad"), global: true);
Assert.IsNotNull(notepadWindow, "Notepad window not found.");
}
/*
[TestMethod]
public void ContextMenuRunAsAdminButtonTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var runButton = this.Find<NavigationViewItem>("Run as administrator");
Assert.IsNotNull(runButton);
runButton.Click();
UACConfirm();
var notepadWindow = this.Find<Window>(By.ClassName("Notepad"), global: true);
Assert.IsNotNull(notepadWindow, "Notepad window not found.");
}*/
[STATestMethod]
[TestMethod]
public void ContextMenuCopyPathButtonTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var copyPathButton = this.Find<NavigationViewItem>("Copy path");
Assert.IsNotNull(copyPathButton);
copyPathButton.Click();
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
Assert.IsTrue(clipboardContent.Contains("Notepad"), $"Clipboard content does not contain the expected file name. clipboard: {clipboardContent}");
}
[TestMethod]
public void ContextMenuPinTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var pinButton = this.Find<NavigationViewItem>("Pin");
Assert.IsNotNull(pinButton);
pinButton.Click();
SetAppsExtensionSearchBox(string.Empty);
var item = this.Find<NavigationViewItem>(appName);
Assert.IsNotNull(item, $"{appName} app not found.");
OpenContextMenu();
var unPinButton = this.Find<NavigationViewItem>("Unpin");
Assert.IsNotNull(unPinButton);
unPinButton.Click();
SetAppsExtensionSearchBox(string.Empty);
}
[TestMethod]
public void ContextMenuOpenContainingFolderTest()
{
const string appName = "Calculator";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var openContainingFolderButton = this.Find<NavigationViewItem>("Open containing folder");
Assert.IsNotNull(openContainingFolderButton);
openContainingFolderButton.Click();
var fileExplorerWindow = FindFileExplorerWindow();
Assert.IsNotNull(fileExplorerWindow);
}
[TestMethod]
public void ContextMenuOpenPathInConsoleTest()
{
const string appName = "Notepad";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var openInConsoleButton = this.Find<NavigationViewItem>("Open path in console");
Assert.IsNotNull(openInConsoleButton);
openInConsoleButton.Click();
Task.Delay(2000).Wait(); // Wait for the console to open
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}
[TestMethod]
public void ContextMenuOpenLocationTest()
{
const string appName = "Command Prompt";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var openLocationButton = this.Find<NavigationViewItem>("Open location");
Assert.IsNotNull(openLocationButton, "Open location button not found.");
openLocationButton.Click();
var fileExplorerWindow = FindFileExplorerWindow();
Assert.IsNotNull(fileExplorerWindow, "File Explorer window not found.");
}
[TestMethod]
public void ContextMenuSearchTest()
{
const string appName = "Command Prompt";
var notepadItem = SearchAppByName(appName);
notepadItem.Click();
OpenContextMenu();
var contextMenuSearchBox = this.Find<TextBox>("Search commands...");
Assert.IsNotNull(contextMenuSearchBox, "Context menu search box not found.");
Assert.AreEqual(contextMenuSearchBox.SetText("Open location", true).Text, "Open location");
var openLocationButton = this.Find<NavigationViewItem>("Open location");
Assert.IsNotNull(openLocationButton, "Open location button not found.");
openLocationButton.Click();
var fileExplore = FindFileExplorerWindow();
Assert.IsNotNull(fileExplore, "File Explorer window not found.");
}
}

View File

@@ -0,0 +1,167 @@
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.PowerToys.UITest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.CmdPal.UITests;
[TestClass]
public class CalculatorTests : CommandPaletteTestBase
{
public CalculatorTests()
: base()
{
}
public void EnterCalculatorExtension()
{
SetSearchBox("Calculator");
var calculatorItem = this.Find<NavigationViewItem>("Calculator");
Assert.AreEqual(calculatorItem.Name, "Calculator");
calculatorItem.DoubleClick();
}
private string ConvertResult(string originalResult, int originalBase, int convertToBase)
{
Assert.IsNotEmpty(originalResult, "Original result cannot be empty.");
Assert.IsTrue(originalBase is 2 or 10 or 16, "Original base must be one of the following: 2, 8, 10, or 16.");
Assert.IsTrue(convertToBase is 2 or 10 or 16, "Convert to base must be one of the following: 2, 8, 10, or 16.");
var originalDecimal = Convert.ToInt32(originalResult, originalBase);
// support base two, decimal, hexadecimal, and octal
return convertToBase switch
{
2 => $"0b{Convert.ToString(originalDecimal, 2)}",
10 => Convert.ToString(originalDecimal, 10),
16 => $"0x{Convert.ToString(originalDecimal, 16).ToUpper(System.Globalization.CultureInfo.CurrentCulture)}",
_ => throw new ArgumentOutOfRangeException(nameof(convertToBase), "Unsupported base conversion"),
};
}
[TestMethod]
[DataRow("2+2", "4")]
[DataRow("2*3", "6")]
[DataRow("2^3", "8")]
public void CalculatorBasicTests(string expression, string expectation)
{
EnterCalculatorExtension();
SetCalculatorExtensionSearchBox(expression);
var resultItem = this.Find<NavigationViewItem>(expectation);
Assert.IsNotNull(resultItem);
Assert.AreEqual(resultItem.Name, expectation, $"Expected result '{expectation}' not found for expression '{expression}'.");
}
[TestMethod]
[DataRow("2+2", "4")]
public void CalculatorResultDoubleClickTests(string expression, string expectation)
{
EnterCalculatorExtension();
SetCalculatorExtensionSearchBox(expression);
var resultItem = this.Find<NavigationViewItem>(expectation);
Assert.IsNotNull(resultItem);
Assert.AreEqual(resultItem.Name, expectation, $"Expected result '{expectation}' not found for expression '{expression}'.");
resultItem.DoubleClick();
var resultItems = this.FindAll<NavigationViewItem>(expectation);
Assert.AreEqual(2, resultItems.Count, $"Expected exactly two result item for '{expectation}' after double-clicking, but found {resultItems.Count}.");
}
[TestMethod]
[DataRow("2+2", "4")]
public void CalculatorPrimaryButtonTests(string expression, string expectation)
{
EnterCalculatorExtension();
SetCalculatorExtensionSearchBox(expression);
var resultItem = this.Find<NavigationViewItem>(expectation);
Assert.IsNotNull(resultItem);
Assert.AreEqual(resultItem.Name, expectation, $"Expected result '{expectation}' not found for expression '{expression}'.");
var primaryButton = this.Find<Button>("Save");
primaryButton.Click();
var resultItems = this.FindAll<NavigationViewItem>(expectation);
Assert.AreEqual(2, resultItems.Count, $"Expected exactly two result item for '{expectation}' after click primary button, but found {resultItems.Count}.");
}
[STATestMethod]
[TestMethod]
[DataRow("2+2", "4")]
public void CalculatorSecondaryButtonTests(string expression, string expectation)
{
EnterCalculatorExtension();
SetCalculatorExtensionSearchBox(expression);
var resultItem = this.Find<NavigationViewItem>(expectation);
Assert.IsNotNull(resultItem);
Assert.AreEqual(resultItem.Name, expectation, $"Expected result '{expectation}' not found for expression '{expression}'.");
var secondaryButton = this.Find<Button>("Copy");
secondaryButton.Click();
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
Assert.IsTrue(clipboardContent.Equals(expectation, StringComparison.Ordinal), $"Clipboard content does not equal the expected result. clipboard: {clipboardContent}");
}
[STATestMethod]
[TestMethod]
[DataRow("2+2", "4")]
public void CalculatorContextMenuSaveTests(string expression, string expectation)
{
EnterCalculatorExtension();
SetCalculatorExtensionSearchBox(expression);
var resultItem = this.Find<NavigationViewItem>(expectation);
Assert.IsNotNull(resultItem);
Assert.AreEqual(resultItem.Name, expectation, $"Expected result '{expectation}' not found for expression '{expression}'.");
OpenContextMenu();
var saveItem = this.Find<NavigationViewItem>("Save");
saveItem.Click();
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
Assert.IsTrue(clipboardContent.Equals(expectation, StringComparison.Ordinal), $"Clipboard content does not equal the expected result. clipboard: {clipboardContent}");
}
[STATestMethod]
[TestMethod]
[DataRow("2+2", "4", 10)]
[DataRow("0b10 * 0b10", "4", 2)]
[DataRow("0xa * 0xa", "100", 16)]
public void CalculatorContextMenuBaseConvertTests(string expression, string expectation, int originalBase)
{
EnterCalculatorExtension();
SetCalculatorExtensionSearchBox(expression);
var resultItem = this.Find<NavigationViewItem>(expectation);
Assert.IsNotNull(resultItem);
Assert.AreEqual(resultItem.Name, expectation, $"Expected result '{expectation}' not found for expression '{expression}'.");
OpenContextMenu();
var testBaseList = new List<int> { 2, 10, 16 };
foreach (var convertToBase in testBaseList)
{
var convertedResult = ConvertResult(expectation, 10, convertToBase);
var convertedItem = this.Find<NavigationViewItem>(convertedResult);
Assert.IsNotNull(convertedItem, $"Convert to base {convertToBase} item not found.");
}
var binaryResult = ConvertResult(expectation, 10, 2);
var binaryItem = this.Find<NavigationViewItem>(binaryResult);
binaryItem.Click();
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
Assert.IsTrue(clipboardContent.Equals(binaryResult, StringComparison.Ordinal), $"Clipboard content does not equal the expected result. clipboard: {clipboardContent}");
}
}

View File

@@ -12,10 +12,11 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.CmdPal.UITests;
[TestClass]
public class CommandPaletteTestBase : UITestBase
{
public CommandPaletteTestBase()
: base(PowerToysModule.CommandPalette)
: base(PowerToysModule.CommandPalette, hideAllWindowBeforeStart: true)
{
}
@@ -39,6 +40,21 @@ public class CommandPaletteTestBase : UITestBase
Assert.AreEqual(this.Find<TextBox>("Search values or type a custom time stamp...").SetText(text, true).Text, text);
}
protected void SetAppsExtensionSearchBox(string text)
{
Assert.AreEqual(this.Find<TextBox>("Search installed apps...").SetText(text, true).Text, text);
}
protected void SetWindowsTerminalExtensionSearchBox(string text)
{
Assert.AreEqual(this.Find<TextBox>("Type here to search...").SetText(text, true).Text, text);
}
protected void SetWindowsSettingsExtensionSearchBox(string text)
{
Assert.AreEqual(this.Find<TextBox>("Type here to search...").SetText(text, true).Text, text);
}
protected void OpenContextMenu()
{
var contextMenuButton = this.Find<Button>("More");
@@ -46,6 +62,24 @@ public class CommandPaletteTestBase : UITestBase
contextMenuButton.Click();
}
protected Window FindFileExplorerWindow()
{
var fileExplorerWindow = this.Find<Window>(By.ClassName("CabinetWClass"), global: true, timeoutMS: 5000);
return fileExplorerWindow;
}
protected Window FindWindowsTerminalWindow()
{
var terminalWindow = this.Find<Window>(By.ClassName("CASCADIA_HOSTING_WINDOW_CLASS"), global: true, timeoutMS: 5000);
return terminalWindow;
}
protected Window FindWindowsSettingsWindow()
{
var settingsWindow = this.Find<Window>("Settings", global: true, timeoutMS: 5000);
return settingsWindow;
}
protected void FindDefaultAppDialogAndClickButton()
{
try

View File

@@ -114,9 +114,10 @@ public class IndexerTests : CommandPaletteTestBase
Assert.IsNotNull(openButton);
openButton.Click();
var fileExplorer = FindExplorerWindow(TestFolderName, global: true);
Assert.IsNotNull(fileExplorer);
var fileExplorerWindow = FindFileExplorerWindow();
Assert.IsNotNull(fileExplorerWindow);
}
[TestMethod]
@@ -129,9 +130,9 @@ public class IndexerTests : CommandPaletteTestBase
Assert.IsNotNull(searchItem);
searchItem.DoubleClick();
var fileExplorer = FindExplorerWindow(TestFolderName, global: true);
var fileExplorerWindow = FindFileExplorerWindow();
Assert.IsNotNull(fileExplorer);
Assert.IsNotNull(fileExplorerWindow);
}
[TestMethod]
@@ -188,9 +189,9 @@ public class IndexerTests : CommandPaletteTestBase
Assert.IsNotNull(showInFolderButton);
showInFolderButton.Click();
var fileExplorer = FindExplorerWindow(TestFolderName, global: true, timeoutMS: 20000);
var fileExplorerWindow = FindFileExplorerWindow();
Assert.IsNotNull(fileExplorer);
Assert.IsNotNull(fileExplorerWindow);
}
[TestMethod]
@@ -208,8 +209,8 @@ public class IndexerTests : CommandPaletteTestBase
Assert.IsNotNull(copyPathButton);
copyPathButton.Click();
var textItem = FindByPartialName("C:\\Windows\\system32\\cmd.exe", global: true);
Assert.IsNotNull(textItem, "The console did not open with the expected path.");
var terminalWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(terminalWindow, "The console did not open with the expected path.");
}
[TestMethod]

View File

@@ -0,0 +1,76 @@
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.PowerToys.UITest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Windows.Graphics;
namespace Microsoft.CmdPal.UITests;
public class WindowsSettingsTests : CommandPaletteTestBase
{
public void EnterWindowsSettingsExtension()
{
SetSearchBox("Windows Settings");
var searchFileItem = this.Find<NavigationViewItem>("Windows Settings");
Assert.AreEqual(searchFileItem.Name, "Windows Settings");
searchFileItem.DoubleClick();
}
public NavigationViewItem SearchWindowsSettingsByName(string name)
{
EnterWindowsSettingsExtension();
SetWindowsSettingsExtensionSearchBox(name);
var item = this.Find<NavigationViewItem>(name);
Assert.IsNotNull(item, $"{name} setting not found.");
return item;
}
[TestMethod]
public void OpenDisplaySettingsTest()
{
const string settingName = "Display";
var displaySettingItem = SearchWindowsSettingsByName(settingName);
displaySettingItem.DoubleClick();
var settings = FindWindowsSettingsWindow();
Assert.IsNotNull(settings, "Display settings window not found.");
}
[TestMethod]
public void OpenDisplaySettingsByPrimaryButtonTest()
{
const string settingName = "Display";
var displaySettingItem = SearchWindowsSettingsByName(settingName);
displaySettingItem.Click();
var primaryButton = this.Find<Button>("Open Settings");
Assert.IsNotNull(primaryButton, "Primary button not found.");
primaryButton.Click();
var settings = FindWindowsSettingsWindow();
Assert.IsNotNull(settings, "Display settings window not found.");
}
[TestMethod]
[STATestMethod]
public void OpenDisplaySettingsSecondaryButtonTest()
{
const string settingName = "Display";
var displaySettingItem = SearchWindowsSettingsByName(settingName);
displaySettingItem.Click();
var secondaryButton = this.Find<Button>("Copy command");
Assert.IsNotNull(secondaryButton, "Secondary button not found.");
secondaryButton.Click();
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
Assert.IsTrue(clipboardContent.Contains("ms - settings:easeofaccess - display"), $"Clipboard content does not contain the expected command. clipboard: {clipboardContent}");
}
}

View File

@@ -0,0 +1,99 @@
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.PowerToys.UITest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.CmdPal.UITests;
[TestClass]
public class WindowsTerminalTests : CommandPaletteTestBase
{
public void EnterWindowsTerminalExtension()
{
SetSearchBox("Open Windows Terminal Profiles");
var searchFileItem = this.Find<NavigationViewItem>("Open Windows Terminal Profiles");
Assert.AreEqual(searchFileItem.Name, "Open Windows Terminal Profiles");
searchFileItem.DoubleClick();
}
public NavigationViewItem SearchTerminalProfileName(string name)
{
EnterWindowsTerminalExtension();
SetWindowsTerminalExtensionSearchBox(name);
var item = this.Find<NavigationViewItem>(name);
Assert.IsNotNull(item, $"{name} profile not found.");
return item;
}
[TestMethod]
public void OpenCommandPromptTest()
{
const string profileName = "Command Prompt";
var terminalProfileItem = SearchTerminalProfileName(profileName);
terminalProfileItem.DoubleClick();
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}
[TestMethod]
public void OpenCommandPromptByPrimaryButtonTest()
{
const string profileName = "Command Prompt";
var terminalProfileItem = SearchTerminalProfileName(profileName);
terminalProfileItem.Click();
var primaryButton = this.Find<Button>("Launch profile");
Assert.IsNotNull(primaryButton, "Primary button not found.");
primaryButton.Click();
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}
/*
[TestMethod]
public void OpenCommandPromptBySecondaryButtonTest()
{
const string profileName = "Command Prompt";
var terminalProfileItem = SearchTerminalProfileName(profileName);
terminalProfileItem.Click();
var secondaryButton = this.Find<Button>("Launch profile as administrator");
Assert.IsNotNull(secondaryButton, "Secondary button not found.");
secondaryButton.Click();
UACConfirm();
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}*/
[TestMethod]
public void OpenDeveloperCommandPromptTest()
{
const string profileName = "Developer Command Prompt for VS 2022";
var terminalProfileItem = SearchTerminalProfileName(profileName);
terminalProfileItem.DoubleClick();
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}
[TestMethod]
public void OpenGitBashTest()
{
const string profileName = "Git Bash";
var terminalProfileItem = SearchTerminalProfileName(profileName);
terminalProfileItem.DoubleClick();
var commandPromptWindow = FindWindowsTerminalWindow();
Assert.IsNotNull(commandPromptWindow, "Command Prompt window not found.");
}
}