From 8291e2e4e00e6290838ad5dfdac6a48295cef032 Mon Sep 17 00:00:00 2001 From: Mengyuan <162882040+chenmy77@users.noreply.github.com> Date: Wed, 28 May 2025 10:38:38 +0800 Subject: [PATCH] [UITestAutomation > Fancyzones] Add Retry logic for launching the FancyZones Editor (#39765) * fancytest oneswitch test * add GetActiveWindowTitle * testcase1 add set layout * change shortcut to win pgdn * add hold key * Snap several windows to one zone, verify switching works. * pack snaptoonezone * pack snaptoonezone * Add Fancy Zone Switch tests * Add Fancyzones switch zones * remove code and change zoneuuid to zonesets * fix spell error and remove files * remove unuse keyup in elements * fix spell error * fix spell error * remove to common api * fix spell error * fix pipeline fail * add annotations on exe and process * add dragging tests case * add dragging tests case TestShowZonesOnDragDuringShift * change get out window pixel color * add non-primary mouse test cases * add make drag window transparent * clean test initialize code * fix spell error * fix make drag setting conflicts with shift and non primary mouse setting tests issue * add annotations for testmethod and GetWindowRect * fix spell error * fix spell error * change assert prompt * fix testcase name not match * set fancyzones tests only in pipeline * fix pipeline error fancyzones * add get highlight and inactivate zone color from ui * add window pre post * add rect func * remove keydown and drag * FIX JSON GETSTRING BUG * change scrolling times * fix get out window * add drag window * make c file explorer window larger * remove drag window * one switch tests change explorer exe to hosts file exe * set restart in drag * recover switch tests * fix scroll position error * add clean * clean host * clean layouts file * remove during drag case * resolve conflicts * fix get pixel color * add delay when get pixel color * add delay and make maximize the window * change onezone to twozone * add restart scope exe * add annotations for OneZoneSwitchTests.cs * clean logger and add annotations * merge windows helper and pane element * add test name and test category * reduce delay time * resolve conflicts and remove ununsed namespace * fix spell error * fix the restart position * add clean desktop windows and remove unuse code * clear open window * only run fancyzones related dll * add log on customlayouts data * remove clean the window in switchwindow tests * rename namespace * set fancyzones only pipeline * remove restore * set layouts without restart * remove restart * add delay and retry * add delay and retry * fix relaunch error * add delay time * tests all uitests * extend delay time * close window in onezone switch * clean console write * fix conflicts * test all ui tests * retry launch * fix spell error * move release drag to pane element * address cannot found custom layouts * move restart to set customlayouts * move restart to set customlayouts * fix spell error * move restart * restore data * add delay time * test all ui tests * add clean fancyzones editor window * remove log * change get active window Title * change get active window Title * align onezone switch tests initialize and try catch with dragwindow * remove unuse code * add appzone history deletefile --- .../UITests-FancyZones/DragWindowTests.cs | 4 +- .../UITests-FancyZones/OneZoneSwitchTests.cs | 45 +++++++++---------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/modules/fancyzones/UITests-FancyZones/DragWindowTests.cs b/src/modules/fancyzones/UITests-FancyZones/DragWindowTests.cs index 504d8bb5a7..61d88e2121 100644 --- a/src/modules/fancyzones/UITests-FancyZones/DragWindowTests.cs +++ b/src/modules/fancyzones/UITests-FancyZones/DragWindowTests.cs @@ -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("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. diff --git a/src/modules/fancyzones/UITests-FancyZones/OneZoneSwitchTests.cs b/src/modules/fancyzones/UITests-FancyZones/OneZoneSwitchTests.cs index 1f16e337d8..9a10c621a2 100644 --- a/src/modules/fancyzones/UITests-FancyZones/OneZoneSwitchTests.cs +++ b/src/modules/fancyzones/UITests-FancyZones/OneZoneSwitchTests.cs @@ -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,19 +32,17 @@ 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(); + + // Set a custom layout with 1 subzones and clear app zone history + SetupCustomLayouts(); // get PowerToys window Name powertoysWindowName = ZoneSwitchHelper.GetActiveWindowTitle(); - // clear the app zone history - AppZoneHistory.DeleteFile(); - FancyZonesEditorHelper.Files.CustomLayoutsIOHelper.DeleteFile(); - - this.RestartScopeExe(); - - // set a custom layout with 2 subzones - SetupCustomLayouts(); - // Launch FancyZones LaunchFancyZones(); @@ -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