-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ui initialization tests and add exit scope exe function
- Loading branch information
Zhaopeng Wang
committed
Mar 4, 2025
1 parent
b96bcf1
commit 3fa0a74
Showing
4 changed files
with
270 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 198 additions & 0 deletions
198
src/modules/fancyzones/UITests-FancyZonesEditor/UIInitializaionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
// 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.Collections.Generic; | ||
|
||
using FancyZonesEditorCommon.Data; | ||
using Microsoft.FancyZonesEditor.UITests; | ||
using Microsoft.FancyZonesEditor.UITests.Utils; | ||
using Microsoft.FancyZonesEditor.UnitTests.Utils; | ||
using Microsoft.PowerToys.UITest; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Windows.UI; | ||
using static FancyZonesEditorCommon.Data.EditorParameters; | ||
using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext; | ||
|
||
namespace UITests_FancyZonesEditor | ||
{ | ||
[TestClass] | ||
public class UIInitializaionTest : UITestBase | ||
{ | ||
public UIInitializaionTest() | ||
: base(PowerToysModule.FancyZone) | ||
{ | ||
} | ||
|
||
[TestInitialize] | ||
public void TestInitialize() | ||
{ | ||
FancyZonesEditorHelper.Files.ParamsIOHelper.RestoreData(); | ||
} | ||
|
||
[TestCleanup] | ||
public void TestCleanup() | ||
{ | ||
this.ExitScopeExe(); | ||
} | ||
|
||
[TestMethod] | ||
public void EditorParams_VerifySelectedMonitor() | ||
{ | ||
EditorParameters editorParameters = new EditorParameters(); | ||
ParamsWrapper parameters = new ParamsWrapper | ||
{ | ||
ProcessId = 1, | ||
SpanZonesAcrossMonitors = false, | ||
Monitors = new List<NativeMonitorDataWrapper> | ||
{ | ||
new NativeMonitorDataWrapper | ||
{ | ||
Monitor = "monitor-1", | ||
MonitorInstanceId = "instance-id-1", | ||
MonitorSerialNumber = "serial-number-1", | ||
MonitorNumber = 1, | ||
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", | ||
Dpi = 96, | ||
LeftCoordinate = 0, | ||
TopCoordinate = 0, | ||
WorkAreaHeight = 1040, | ||
WorkAreaWidth = 1920, | ||
MonitorHeight = 1080, | ||
MonitorWidth = 1920, | ||
IsSelected = false, | ||
}, | ||
new NativeMonitorDataWrapper | ||
{ | ||
Monitor = "monitor-2", | ||
MonitorInstanceId = "instance-id-2", | ||
MonitorSerialNumber = "serial-number-2", | ||
MonitorNumber = 2, | ||
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", | ||
Dpi = 96, | ||
LeftCoordinate = 1920, | ||
TopCoordinate = 0, | ||
WorkAreaHeight = 1040, | ||
WorkAreaWidth = 1920, | ||
MonitorHeight = 1080, | ||
MonitorWidth = 1920, | ||
IsSelected = true, | ||
}, | ||
}, | ||
}; | ||
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); | ||
this.RestartScopeExe(); | ||
|
||
Assert.IsFalse(Session.Find<Element>("Monitor 1").Selected); | ||
Assert.IsTrue(Session.Find<Element>("Monitor 2").Selected); | ||
} | ||
|
||
[TestMethod] | ||
public void EditorParams_VerifyMonitorScaling() | ||
{ | ||
EditorParameters editorParameters = new EditorParameters(); | ||
ParamsWrapper parameters = new ParamsWrapper | ||
{ | ||
ProcessId = 1, | ||
SpanZonesAcrossMonitors = false, | ||
Monitors = new List<NativeMonitorDataWrapper> | ||
{ | ||
new NativeMonitorDataWrapper | ||
{ | ||
Monitor = "monitor-1", | ||
MonitorInstanceId = "instance-id-1", | ||
MonitorSerialNumber = "serial-number-1", | ||
MonitorNumber = 1, | ||
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", | ||
Dpi = 192, // 200% scaling | ||
LeftCoordinate = 0, | ||
TopCoordinate = 0, | ||
WorkAreaHeight = 1040, | ||
WorkAreaWidth = 1920, | ||
MonitorHeight = 1080, | ||
MonitorWidth = 1920, | ||
IsSelected = true, | ||
}, | ||
}, | ||
}; | ||
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); | ||
this.RestartScopeExe(); | ||
|
||
var monitor = Session.Find<Element>("Monitor 1"); | ||
var scaling = monitor.FindByAccessibilityId<Element>("ScalingText"); | ||
Assert.AreEqual("200%", scaling.Text); | ||
} | ||
|
||
[TestMethod] | ||
public void EditorParams_VerifyMonitorResolution() | ||
{ | ||
EditorParameters editorParameters = new EditorParameters(); | ||
ParamsWrapper parameters = new ParamsWrapper | ||
{ | ||
ProcessId = 1, | ||
SpanZonesAcrossMonitors = false, | ||
Monitors = new List<NativeMonitorDataWrapper> | ||
{ | ||
new NativeMonitorDataWrapper | ||
{ | ||
Monitor = "monitor-1", | ||
MonitorInstanceId = "instance-id-1", | ||
MonitorSerialNumber = "serial-number-1", | ||
MonitorNumber = 1, | ||
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", | ||
Dpi = 192, | ||
LeftCoordinate = 0, | ||
TopCoordinate = 0, | ||
WorkAreaHeight = 1040, | ||
WorkAreaWidth = 1920, | ||
MonitorHeight = 1080, | ||
MonitorWidth = 1920, | ||
IsSelected = true, | ||
}, | ||
}, | ||
}; | ||
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); | ||
this.RestartScopeExe(); | ||
|
||
var monitor = Session.Find<Element>("Monitor 1"); | ||
var resolution = monitor.FindByAccessibilityId<Element>("ResolutionText"); | ||
Assert.AreEqual("1920 × 1080", resolution.Text); | ||
} | ||
|
||
[TestMethod] | ||
public void EditorParams_SpanAcrossMonitors() | ||
{ | ||
EditorParameters editorParameters = new EditorParameters(); | ||
ParamsWrapper parameters = new ParamsWrapper | ||
{ | ||
ProcessId = 1, | ||
SpanZonesAcrossMonitors = true, | ||
Monitors = new List<NativeMonitorDataWrapper> | ||
{ | ||
new NativeMonitorDataWrapper | ||
{ | ||
Monitor = "monitor-1", | ||
MonitorInstanceId = "instance-id-1", | ||
MonitorSerialNumber = "serial-number-1", | ||
MonitorNumber = 1, | ||
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", | ||
Dpi = 192, | ||
LeftCoordinate = 0, | ||
TopCoordinate = 0, | ||
WorkAreaHeight = 1040, | ||
WorkAreaWidth = 1920, | ||
MonitorHeight = 1080, | ||
MonitorWidth = 1920, | ||
IsSelected = true, | ||
}, | ||
}, | ||
}; | ||
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); | ||
this.RestartScopeExe(); | ||
|
||
var monitor = Session.Find<Element>("Monitor 1"); | ||
Assert.IsNotNull(monitor); | ||
Assert.IsTrue(monitor.Selected); | ||
} | ||
} | ||
} |
3fa0a74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@check-spelling-bot Report
🔴 Please review
See the 📜action log or 📝 job summary for details.
Unrecognized words (1)
Initializaion
These words are not needed and should be removed
ahk AMPROPERTY AMPROPSETID Breadcrumb CDEF comdef ddf devenum DEVMON DEVSOURCE DGR DIIRFLAG dshow DVH DVHD DVSD DVSL EData ERole fdw FILEINFOSIG Filtergraph Filterx HCERTSTORE IKs iljxck IYUV KSPROPERTY lcb ldx lld LONGLONG LTRB majortype makecab MEDIASUBTYPE mediatype mfplat mic mjpg Msimg msiquery ORAW outpin overlaywindow PAUDIO PINDIR Pnp ppmt previouscamera PROPBAG propvarutil reencoded REFGUID REGFILTER REGFILTERPINS REGPINTYPES regsvr shmem sizeread stl strsafe strutil subquery SYNCMFT TMPVAR vcdl vdi vid VIDCAP VIDEOINFOHEADER vih webcam wistd WVCTo accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the git@github.com:microsoft/PowerToys.git repository
on the
dev/zhaopengwang/test/37733-ui-test-fancyzones-editor
branch (ℹ️ how do I use this?):Errors (1)
See the 📜action log or 📝 job summary for details.
See ❌ Event descriptions for more information.
If the flagged items are 🤯 false positives
If items relate to a ...
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txt
file matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^
refers to the file's path from the root of the repository, so^README\.md$
would exclude README.md (on whichever branch you're using).well-formed pattern.
If you can write a pattern that would match it,
try adding it to the
patterns.txt
file.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.