Skip to content

Commit e2651fe

Browse files
author
Zhaopeng Wang
committed
add cleanup test function and change file init
1 parent 3fa0a74 commit e2651fe

File tree

5 files changed

+64
-10
lines changed

5 files changed

+64
-10
lines changed

src/common/UITestAutomation/SessionHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public SessionHelper Init()
7171
/// </summary>
7272
public void Cleanup()
7373
{
74+
ExitScopeExe();
7475
try
7576
{
7677
appDriver?.Kill();

src/common/UITestAutomation/UITestBase.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Diagnostics;
77
using System.Diagnostics.CodeAnalysis;
88
using System.Reflection;
9+
using System.Xml.Linq;
910
using Microsoft.VisualStudio.TestTools.UnitTesting;
1011
using OpenQA.Selenium.Appium;
1112
using OpenQA.Selenium.Appium.Windows;
@@ -31,12 +32,6 @@ public UITestBase(PowerToysModule scope = PowerToysModule.PowerToysSettings)
3132
this.Session = new Session(this.sessionHelper.GetRoot(), this.sessionHelper.GetDriver());
3233
}
3334

34-
~UITestBase()
35-
{
36-
this.ExitScopeExe();
37-
this.sessionHelper.Cleanup();
38-
}
39-
4035
/// <summary>
4136
/// Initializes the test.
4237
/// </summary>
@@ -54,6 +49,14 @@ public void TestInit()
5449
}
5550
}
5651

52+
/// <summary>
53+
/// UnInitializes the test.
54+
/// </summary>
55+
public void TestClean()
56+
{
57+
this.sessionHelper.Cleanup();
58+
}
59+
5760
/// <summary>
5861
/// Finds an element by selector.
5962
/// Shortcut for this.Session.Find<T>(by, timeoutMS)
@@ -160,7 +163,7 @@ protected ReadOnlyCollection<Element> FindAll(string name, int timeoutMS = 3000)
160163
/// </summary>
161164
public void RestartScopeExe()
162165
{
163-
sessionHelper.RestartScopeExe();
166+
this.sessionHelper.RestartScopeExe();
164167
this.Session = new Session(this.sessionHelper.GetRoot(), this.sessionHelper.GetDriver());
165168
return;
166169
}
@@ -170,7 +173,7 @@ public void RestartScopeExe()
170173
/// </summary>
171174
public void ExitScopeExe()
172175
{
173-
sessionHelper.ExitScopeExe();
176+
this.sessionHelper.ExitScopeExe();
174177
return;
175178
}
176179
}

src/modules/fancyzones/UITests-FancyZonesEditor/DefaultLayoutsTest.cs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.PowerToys.UITest;
1111
using Microsoft.VisualStudio.TestTools.UnitTesting;
1212
using Windows.UI;
13+
using static FancyZonesEditorCommon.Data.EditorParameters;
1314
using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;
1415

1516
namespace UITests_FancyZonesEditor
@@ -20,7 +21,55 @@ public class DefaultLayoutsTest : UITestBase
2021
public DefaultLayoutsTest()
2122
: base(PowerToysModule.FancyZone)
2223
{
23-
// FancyZonesEditorHelper.InitFancyZonesLayout();
24+
FancyZonesEditorHelper.Files.ParamsIOHelper.RestoreData();
25+
EditorParameters editorParameters = new EditorParameters();
26+
ParamsWrapper parameters = new ParamsWrapper
27+
{
28+
ProcessId = 1,
29+
SpanZonesAcrossMonitors = false,
30+
Monitors = new List<NativeMonitorDataWrapper>
31+
{
32+
new NativeMonitorDataWrapper
33+
{
34+
Monitor = "monitor-1",
35+
MonitorInstanceId = "instance-id-1",
36+
MonitorSerialNumber = "serial-number-1",
37+
MonitorNumber = 1,
38+
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}",
39+
Dpi = 96,
40+
LeftCoordinate = 0,
41+
TopCoordinate = 0,
42+
WorkAreaHeight = 1040,
43+
WorkAreaWidth = 1920,
44+
MonitorHeight = 1080,
45+
MonitorWidth = 1920,
46+
IsSelected = true,
47+
},
48+
new NativeMonitorDataWrapper
49+
{
50+
Monitor = "monitor-2",
51+
MonitorInstanceId = "instance-id-2",
52+
MonitorSerialNumber = "serial-number-2",
53+
MonitorNumber = 2,
54+
VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}",
55+
Dpi = 96,
56+
LeftCoordinate = 1920,
57+
TopCoordinate = 0,
58+
WorkAreaHeight = 1040,
59+
WorkAreaWidth = 1920,
60+
MonitorHeight = 1080,
61+
MonitorWidth = 1920,
62+
IsSelected = false,
63+
},
64+
},
65+
};
66+
FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters));
67+
}
68+
69+
[TestCleanup]
70+
public void TestCleanup()
71+
{
72+
this.TestClean();
2473
}
2574

2675
[TestMethod]

src/modules/fancyzones/UITests-FancyZonesEditor/NewFancyZonesEditorTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void TestInitialize()
4343
[TestCleanup]
4444
public void TestCleanup()
4545
{
46+
this.TestClean();
4647
}
4748

4849
[TestMethod]

src/modules/fancyzones/UITests-FancyZonesEditor/UIInitializaionTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void TestInitialize()
3333
[TestCleanup]
3434
public void TestCleanup()
3535
{
36-
this.ExitScopeExe();
36+
this.TestClean();
3737
}
3838

3939
[TestMethod]

0 commit comments

Comments
 (0)