Skip to content

Commit c90f003

Browse files
committed
GetSetZoomLevel: Don't use shared window
Because we need a visible window and the main window visibility must not be mutated by tests
1 parent daa9f39 commit c90f003

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,32 @@ public async Task GetSetZoomFactor_check()
9797
[SkippableFact(Timeout = 20000)]
9898
public async Task GetSetZoomLevel_check()
9999
{
100-
Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
101-
await fx.MainWindow.WebContents.GetZoomLevelAsync();
102-
var ok = await fx.MainWindow.WebContents.GetZoomLevelAsync();
103-
ok.Should().Be(0);
104-
fx.MainWindow.WebContents.SetZoomLevel(2);
105-
await Task.Delay(500);
106-
ok = await fx.MainWindow.WebContents.GetZoomLevelAsync();
107-
ok.Should().Be(2);
100+
BrowserWindow window = null;
101+
102+
try
103+
{
104+
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
105+
106+
window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = true }, "about:blank");
107+
108+
await Task.Delay(100);
109+
110+
window.WebContents.SetZoomLevel(0);
111+
await Task.Delay(500);
112+
113+
var ok = await window.WebContents.GetZoomLevelAsync();
114+
ok.Should().Be(0);
115+
116+
window.WebContents.SetZoomLevel(2);
117+
await Task.Delay(500);
118+
119+
ok = await window.WebContents.GetZoomLevelAsync();
120+
ok.Should().Be(2);
121+
}
122+
finally
123+
{
124+
window?.Destroy();
125+
}
108126
}
109127

110128
[SkippableFact(Timeout = 20000)]

0 commit comments

Comments
 (0)