mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
merge feature
This commit is contained in:
@@ -34,7 +34,6 @@ namespace UITests_FancyZones
|
||||
private static int screenMarginLeft;
|
||||
private static int screenMarginRight;
|
||||
private static int screenMarginBottom;
|
||||
private static string setCustomLayoutData = string.Empty; // set custom layout data
|
||||
|
||||
// set 1/4 margin
|
||||
private static int quarterX;
|
||||
@@ -56,6 +55,7 @@ namespace UITests_FancyZones
|
||||
// kill all processes related to FancyZones Editor to ensure a clean state
|
||||
Session.KillAllProcessesByName("PowerToys.FancyZonesEditor");
|
||||
|
||||
AppZoneHistory.DeleteFile();
|
||||
this.RestartScopeExe();
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
|
||||
@@ -367,7 +367,6 @@ namespace UITests_FancyZones
|
||||
}
|
||||
|
||||
FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.WriteData(customLayouts.Serialize(customLayoutListWrapper));
|
||||
setCustomLayoutData = FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.GetData();
|
||||
}
|
||||
|
||||
// launch FancyZones settings page
|
||||
@@ -387,7 +386,6 @@ namespace UITests_FancyZones
|
||||
ZoneBehaviourSettings(TestContext.TestName);
|
||||
|
||||
this.Find<Microsoft.PowerToys.UITest.Button>("Launch layout editor").Click(false, 500, 10000);
|
||||
string customLayoutData = FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.GetData();
|
||||
this.Session.Attach(PowerToysModule.FancyZone);
|
||||
|
||||
// pipeline machine may have an unstable delays, causing the custom layout to be unavailable as we set. then A retry is required.
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace UITests_FancyZones
|
||||
private static readonly int SubZones = 2;
|
||||
private static readonly IOTestHelper AppZoneHistory = new FancyZonesEditorFiles().AppZoneHistoryIOHelper;
|
||||
private static string powertoysWindowName = "PowerToys Settings"; // set powertoys settings window name
|
||||
private string setCustomLayoutData = string.Empty; // custom layout data for test
|
||||
|
||||
public OneZoneSwitchTests()
|
||||
: base(PowerToysModule.PowerToysSettings, WindowSize.Medium)
|
||||
@@ -33,14 +32,12 @@ namespace UITests_FancyZones
|
||||
{
|
||||
// kill all processes related to FancyZones Editor to ensure a clean state
|
||||
Session.KillAllProcessesByName("PowerToys.FancyZonesEditor");
|
||||
|
||||
// clear the app zone history
|
||||
AppZoneHistory.DeleteFile();
|
||||
FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.DeleteFile();
|
||||
|
||||
this.RestartScopeExe();
|
||||
FancyZonesEditorHelper.Files.Restore();
|
||||
|
||||
// set a custom layout with 2 subzones
|
||||
// Set a custom layout with 1 subzones and clear app zone history
|
||||
SetupCustomLayouts();
|
||||
|
||||
// get PowerToys window Name
|
||||
@@ -221,6 +218,9 @@ namespace UITests_FancyZones
|
||||
|
||||
// Close Second window
|
||||
SendKeys(Key.Alt, Key.F4);
|
||||
|
||||
// clean app zone history file
|
||||
AppZoneHistory.DeleteFile();
|
||||
}
|
||||
|
||||
// Setup custom layout with 1 subzones
|
||||
@@ -229,7 +229,6 @@ namespace UITests_FancyZones
|
||||
var customLayouts = new CustomLayouts();
|
||||
var customLayoutListWrapper = CustomLayoutsList;
|
||||
FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.WriteData(customLayouts.Serialize(customLayoutListWrapper));
|
||||
setCustomLayoutData = FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.GetData();
|
||||
}
|
||||
|
||||
// launch FancyZones settings page
|
||||
@@ -259,28 +258,23 @@ namespace UITests_FancyZones
|
||||
Task.Delay(500).Wait(); // Wait for the setting to be applied
|
||||
this.Scroll(9, "Up"); // Pull the setting page down to make sure the setting is visible
|
||||
this.Find<Button>("Launch layout editor").Click(false, 500, 5000);
|
||||
string customLayoutData = FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.GetData();
|
||||
this.Session.Attach(PowerToysModule.FancyZone);
|
||||
|
||||
// pipeline machine may have an unstable delays, causing the custom layout to be unavailable as we set. then A retry is required.
|
||||
// Console.WriteLine($"after launch, Custom layout data: {customLayoutData}");
|
||||
if (customLayoutData == setCustomLayoutData)
|
||||
try
|
||||
{
|
||||
this.Session.Attach(PowerToysModule.FancyZone);
|
||||
this.Find<Button>("Maximize").Click();
|
||||
Task.Delay(1000).Wait(); // Optional: Wait for a moment to ensure the window is in position
|
||||
|
||||
// Set the FancyZones layout to a custom layout
|
||||
this.Find<Element>(By.Name("Custom Column")).Click();
|
||||
}
|
||||
else
|
||||
catch (Exception)
|
||||
{
|
||||
// Console.WriteLine($"[Exception] Failed to attach to FancyZones window. Retrying...");
|
||||
this.Find<Button>("Close").Click();
|
||||
SetupCustomLayouts();
|
||||
// Console.WriteLine($"[Exception] Failed to attach to FancyZones window. Retrying...{ex.Message}");
|
||||
this.Find<Microsoft.PowerToys.UITest.Button>("Close").Click();
|
||||
this.Session.Attach(PowerToysModule.PowerToysSettings);
|
||||
this.Find<Button>("Launch layout editor").Click(false, 5000, 5000);
|
||||
SetupCustomLayouts();
|
||||
this.Find<Microsoft.PowerToys.UITest.Button>("Launch layout editor").Click(false, 5000, 5000);
|
||||
this.Session.Attach(PowerToysModule.FancyZone);
|
||||
this.Find<Button>("Maximize").Click();
|
||||
|
||||
// customLayoutData = FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.GetData();
|
||||
// Console.WriteLine($"after retry, Custom layout data: {customLayoutData}");
|
||||
@@ -289,8 +283,9 @@ namespace UITests_FancyZones
|
||||
this.Find<Element>(By.Name("Custom Column")).Click();
|
||||
}
|
||||
|
||||
this.Find<Button>("Close").Click();
|
||||
this.Session.Attach(PowerToysModule.PowerToysSettings);
|
||||
// Close layout editor window
|
||||
SendKeys(Key.Alt, Key.F4);
|
||||
this.Session.Attach(powertoysWindowName);
|
||||
}
|
||||
|
||||
private void LaunchFromSetting(bool showWarning = false, bool launchAsAdmin = false)
|
||||
|
||||
Reference in New Issue
Block a user