mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
update test
This commit is contained in:
@@ -11,6 +11,9 @@ parameters:
|
||||
- name: useLatestWebView2
|
||||
type: boolean
|
||||
default: false
|
||||
- name: useLatestOfficialBuild
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
jobs:
|
||||
- job: Test${{ parameters.platform }}${{ parameters.configuration }}
|
||||
@@ -102,10 +105,11 @@ jobs:
|
||||
definition: '76541'
|
||||
buildVersionToDownload: 'latest'
|
||||
branchName: 'refs/heads/main'
|
||||
artifactName: 'build-${{ parameters.platform }}-Release'
|
||||
artifactName: 'build-$(BuildPlatform)-Release'
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)'
|
||||
patterns: |
|
||||
**/PowerToysSetup-*.exe
|
||||
|
||||
- pwsh: |-
|
||||
& "$(build.sourcesdirectory)\.pipelines\installPowerToys.ps1"
|
||||
displayName: Install PowerToys
|
||||
@@ -125,6 +129,7 @@ jobs:
|
||||
vsTestVersion: 'toolsInstaller'
|
||||
uiTests: true
|
||||
rerunFailedTests: true
|
||||
useInstallerForTest: ${{ parameters.useLatestOfficialBuild }}
|
||||
# Since UITests-FancyZonesEditor.dll is generated in both UITests-FancyZonesEditor and UITests-FancyZones, removed one to avoid duplicate test runs
|
||||
testAssemblyVer2: |
|
||||
**\*UITest*.dll
|
||||
|
||||
@@ -83,6 +83,7 @@ stages:
|
||||
platform: x64Win10
|
||||
configuration: Release
|
||||
useLatestWebView2: ${{ parameters.useLatestWebView2 }}
|
||||
useLatestOfficialBuild: ${{ parameters.useLatestOfficialBuild }}
|
||||
|
||||
- ${{ if eq(platform, 'x64') }}:
|
||||
- stage: Test_x64Win11
|
||||
@@ -99,6 +100,7 @@ stages:
|
||||
platform: x64Win11
|
||||
configuration: Release
|
||||
useLatestWebView2: ${{ parameters.useLatestWebView2 }}
|
||||
useLatestOfficialBuild: ${{ parameters.useLatestOfficialBuild }}
|
||||
|
||||
- ${{ if ne(platform, 'x64') }}:
|
||||
- stage: Test_${{ platform }}
|
||||
@@ -115,3 +117,4 @@ stages:
|
||||
platform: ${{ platform }}
|
||||
configuration: Release
|
||||
useLatestWebView2: ${{ parameters.useLatestWebView2 }}
|
||||
useLatestOfficialBuild: ${{ parameters.useLatestOfficialBuild }}
|
||||
|
||||
@@ -89,6 +89,11 @@ namespace Microsoft.PowerToys.UITest
|
||||
|
||||
private ModuleConfigData()
|
||||
{
|
||||
// Check if we should use installer paths from environment variable
|
||||
string useInstallerForTestEnv = Environment.GetEnvironmentVariable("useInstallerForTest") ??
|
||||
Environment.GetEnvironmentVariable("USEINSTALLERFORTEST");
|
||||
UseInstallerForTest = bool.TryParse(useInstallerForTestEnv, out bool result) && result;
|
||||
|
||||
// The exe window name for each module.
|
||||
ModuleWindowName = new Dictionary<PowerToysModule, string>
|
||||
{
|
||||
@@ -108,9 +113,59 @@ namespace Microsoft.PowerToys.UITest
|
||||
[PowerToysModule.Runner] = @"\..\..\..\PowerToys.exe",
|
||||
[PowerToysModule.Workspaces] = @"\..\..\..\PowerToys.WorkspacesEditor.exe",
|
||||
};
|
||||
|
||||
// Installed PowerToys paths
|
||||
string powerToysInstallPath = GetPowerToysInstallPath();
|
||||
InstalledModulePath = new Dictionary<PowerToysModule, string>
|
||||
{
|
||||
[PowerToysModule.PowerToysSettings] = Path.Combine(powerToysInstallPath, "WinUI3Apps", "PowerToys.Settings.exe"),
|
||||
[PowerToysModule.FancyZone] = Path.Combine(powerToysInstallPath, "PowerToys.FancyZonesEditor.exe"),
|
||||
[PowerToysModule.Hosts] = Path.Combine(powerToysInstallPath, "WinUI3Apps", "PowerToys.Hosts.exe"),
|
||||
[PowerToysModule.Runner] = Path.Combine(powerToysInstallPath, "PowerToys.exe"),
|
||||
[PowerToysModule.Workspaces] = Path.Combine(powerToysInstallPath, "PowerToys.WorkspacesEditor.exe"),
|
||||
};
|
||||
}
|
||||
|
||||
public string GetModulePath(PowerToysModule scope) => ModulePath[scope];
|
||||
private string GetPowerToysInstallPath()
|
||||
{
|
||||
// Try common installation paths
|
||||
string[] possiblePaths = {
|
||||
@"C:\Program Files\PowerToys",
|
||||
@"C:\Program Files (x86)\PowerToys",
|
||||
Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Microsoft\PowerToys"),
|
||||
Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\PowerToys")
|
||||
};
|
||||
|
||||
foreach (string path in possiblePaths)
|
||||
{
|
||||
if (Directory.Exists(path) && File.Exists(Path.Combine(path, "PowerToys.exe")))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to Program Files if not found
|
||||
return @"C:\Program Files\PowerToys";
|
||||
}
|
||||
|
||||
public string GetModulePath(PowerToysModule scope)
|
||||
{
|
||||
if (UseInstallerForTest)
|
||||
{
|
||||
string installedPath = InstalledModulePath[scope];
|
||||
if (File.Exists(installedPath))
|
||||
{
|
||||
return installedPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Log warning and fallback to development path
|
||||
Console.WriteLine($"Warning: Installed module not found at {installedPath}, using development path");
|
||||
}
|
||||
}
|
||||
|
||||
return ModulePath[scope];
|
||||
}
|
||||
|
||||
public string GetWindowsApplicationDriverUrl() => WindowsApplicationDriverUrl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user