|
| 1 | +// Copyright (c) Microsoft Corporation |
| 2 | +// The Microsoft Corporation licenses this file to you under the MIT license. |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +using System.Collections.Generic; |
| 6 | + |
| 7 | +using FancyZonesEditorCommon.Data; |
| 8 | +using Microsoft.FancyZonesEditor.UITests; |
| 9 | +using Microsoft.FancyZonesEditor.UITests.Utils; |
| 10 | +using Microsoft.FancyZonesEditor.UnitTests.Utils; |
| 11 | +using Microsoft.PowerToys.UITest; |
| 12 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 13 | +using Windows.UI; |
| 14 | +using static FancyZonesEditorCommon.Data.EditorParameters; |
| 15 | +using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext; |
| 16 | + |
| 17 | +namespace UITests_FancyZonesEditor |
| 18 | +{ |
| 19 | + [TestClass] |
| 20 | + public class UIInitializaionTest : UITestBase |
| 21 | + { |
| 22 | + public UIInitializaionTest() |
| 23 | + : base(PowerToysModule.FancyZone) |
| 24 | + { |
| 25 | + } |
| 26 | + |
| 27 | + [TestInitialize] |
| 28 | + public void TestInitialize() |
| 29 | + { |
| 30 | + FancyZonesEditorHelper.Files.ParamsIOHelper.RestoreData(); |
| 31 | + } |
| 32 | + |
| 33 | + [TestCleanup] |
| 34 | + public void TestCleanup() |
| 35 | + { |
| 36 | + this.ExitScopeExe(); |
| 37 | + } |
| 38 | + |
| 39 | + [TestMethod] |
| 40 | + public void EditorParams_VerifySelectedMonitor() |
| 41 | + { |
| 42 | + EditorParameters editorParameters = new EditorParameters(); |
| 43 | + ParamsWrapper parameters = new ParamsWrapper |
| 44 | + { |
| 45 | + ProcessId = 1, |
| 46 | + SpanZonesAcrossMonitors = false, |
| 47 | + Monitors = new List<NativeMonitorDataWrapper> |
| 48 | + { |
| 49 | + new NativeMonitorDataWrapper |
| 50 | + { |
| 51 | + Monitor = "monitor-1", |
| 52 | + MonitorInstanceId = "instance-id-1", |
| 53 | + MonitorSerialNumber = "serial-number-1", |
| 54 | + MonitorNumber = 1, |
| 55 | + VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", |
| 56 | + Dpi = 96, |
| 57 | + LeftCoordinate = 0, |
| 58 | + TopCoordinate = 0, |
| 59 | + WorkAreaHeight = 1040, |
| 60 | + WorkAreaWidth = 1920, |
| 61 | + MonitorHeight = 1080, |
| 62 | + MonitorWidth = 1920, |
| 63 | + IsSelected = false, |
| 64 | + }, |
| 65 | + new NativeMonitorDataWrapper |
| 66 | + { |
| 67 | + Monitor = "monitor-2", |
| 68 | + MonitorInstanceId = "instance-id-2", |
| 69 | + MonitorSerialNumber = "serial-number-2", |
| 70 | + MonitorNumber = 2, |
| 71 | + VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", |
| 72 | + Dpi = 96, |
| 73 | + LeftCoordinate = 1920, |
| 74 | + TopCoordinate = 0, |
| 75 | + WorkAreaHeight = 1040, |
| 76 | + WorkAreaWidth = 1920, |
| 77 | + MonitorHeight = 1080, |
| 78 | + MonitorWidth = 1920, |
| 79 | + IsSelected = true, |
| 80 | + }, |
| 81 | + }, |
| 82 | + }; |
| 83 | + FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); |
| 84 | + this.RestartScopeExe(); |
| 85 | + |
| 86 | + Assert.IsFalse(Session.Find<Element>("Monitor 1").Selected); |
| 87 | + Assert.IsTrue(Session.Find<Element>("Monitor 2").Selected); |
| 88 | + } |
| 89 | + |
| 90 | + [TestMethod] |
| 91 | + public void EditorParams_VerifyMonitorScaling() |
| 92 | + { |
| 93 | + EditorParameters editorParameters = new EditorParameters(); |
| 94 | + ParamsWrapper parameters = new ParamsWrapper |
| 95 | + { |
| 96 | + ProcessId = 1, |
| 97 | + SpanZonesAcrossMonitors = false, |
| 98 | + Monitors = new List<NativeMonitorDataWrapper> |
| 99 | + { |
| 100 | + new NativeMonitorDataWrapper |
| 101 | + { |
| 102 | + Monitor = "monitor-1", |
| 103 | + MonitorInstanceId = "instance-id-1", |
| 104 | + MonitorSerialNumber = "serial-number-1", |
| 105 | + MonitorNumber = 1, |
| 106 | + VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", |
| 107 | + Dpi = 192, // 200% scaling |
| 108 | + LeftCoordinate = 0, |
| 109 | + TopCoordinate = 0, |
| 110 | + WorkAreaHeight = 1040, |
| 111 | + WorkAreaWidth = 1920, |
| 112 | + MonitorHeight = 1080, |
| 113 | + MonitorWidth = 1920, |
| 114 | + IsSelected = true, |
| 115 | + }, |
| 116 | + }, |
| 117 | + }; |
| 118 | + FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); |
| 119 | + this.RestartScopeExe(); |
| 120 | + |
| 121 | + var monitor = Session.Find<Element>("Monitor 1"); |
| 122 | + var scaling = monitor.FindByAccessibilityId<Element>("ScalingText"); |
| 123 | + Assert.AreEqual("200%", scaling.Text); |
| 124 | + } |
| 125 | + |
| 126 | + [TestMethod] |
| 127 | + public void EditorParams_VerifyMonitorResolution() |
| 128 | + { |
| 129 | + EditorParameters editorParameters = new EditorParameters(); |
| 130 | + ParamsWrapper parameters = new ParamsWrapper |
| 131 | + { |
| 132 | + ProcessId = 1, |
| 133 | + SpanZonesAcrossMonitors = false, |
| 134 | + Monitors = new List<NativeMonitorDataWrapper> |
| 135 | + { |
| 136 | + new NativeMonitorDataWrapper |
| 137 | + { |
| 138 | + Monitor = "monitor-1", |
| 139 | + MonitorInstanceId = "instance-id-1", |
| 140 | + MonitorSerialNumber = "serial-number-1", |
| 141 | + MonitorNumber = 1, |
| 142 | + VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", |
| 143 | + Dpi = 192, |
| 144 | + LeftCoordinate = 0, |
| 145 | + TopCoordinate = 0, |
| 146 | + WorkAreaHeight = 1040, |
| 147 | + WorkAreaWidth = 1920, |
| 148 | + MonitorHeight = 1080, |
| 149 | + MonitorWidth = 1920, |
| 150 | + IsSelected = true, |
| 151 | + }, |
| 152 | + }, |
| 153 | + }; |
| 154 | + FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); |
| 155 | + this.RestartScopeExe(); |
| 156 | + |
| 157 | + var monitor = Session.Find<Element>("Monitor 1"); |
| 158 | + var resolution = monitor.FindByAccessibilityId<Element>("ResolutionText"); |
| 159 | + Assert.AreEqual("1920 × 1080", resolution.Text); |
| 160 | + } |
| 161 | + |
| 162 | + [TestMethod] |
| 163 | + public void EditorParams_SpanAcrossMonitors() |
| 164 | + { |
| 165 | + EditorParameters editorParameters = new EditorParameters(); |
| 166 | + ParamsWrapper parameters = new ParamsWrapper |
| 167 | + { |
| 168 | + ProcessId = 1, |
| 169 | + SpanZonesAcrossMonitors = true, |
| 170 | + Monitors = new List<NativeMonitorDataWrapper> |
| 171 | + { |
| 172 | + new NativeMonitorDataWrapper |
| 173 | + { |
| 174 | + Monitor = "monitor-1", |
| 175 | + MonitorInstanceId = "instance-id-1", |
| 176 | + MonitorSerialNumber = "serial-number-1", |
| 177 | + MonitorNumber = 1, |
| 178 | + VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", |
| 179 | + Dpi = 192, |
| 180 | + LeftCoordinate = 0, |
| 181 | + TopCoordinate = 0, |
| 182 | + WorkAreaHeight = 1040, |
| 183 | + WorkAreaWidth = 1920, |
| 184 | + MonitorHeight = 1080, |
| 185 | + MonitorWidth = 1920, |
| 186 | + IsSelected = true, |
| 187 | + }, |
| 188 | + }, |
| 189 | + }; |
| 190 | + FancyZonesEditorHelper.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); |
| 191 | + this.RestartScopeExe(); |
| 192 | + |
| 193 | + var monitor = Session.Find<Element>("Monitor 1"); |
| 194 | + Assert.IsNotNull(monitor); |
| 195 | + Assert.IsTrue(monitor.Selected); |
| 196 | + } |
| 197 | + } |
| 198 | +} |
0 commit comments