From c90f003519403b615dc6591c7768638e3f310f85 Mon Sep 17 00:00:00 2001 From: softworkz Date: Sat, 6 Dec 2025 20:11:27 +0100 Subject: [PATCH] GetSetZoomLevel: Don't use shared window Because we need a visible window and the main window visibility must not be mutated by tests --- .../Tests/WebContentsTests.cs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs b/src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs index 6c72705..64c4439 100644 --- a/src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs +++ b/src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs @@ -97,14 +97,32 @@ namespace ElectronNET.IntegrationTests.Tests [SkippableFact(Timeout = 20000)] public async Task GetSetZoomLevel_check() { - Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI."); - await fx.MainWindow.WebContents.GetZoomLevelAsync(); - var ok = await fx.MainWindow.WebContents.GetZoomLevelAsync(); - ok.Should().Be(0); - fx.MainWindow.WebContents.SetZoomLevel(2); - await Task.Delay(500); - ok = await fx.MainWindow.WebContents.GetZoomLevelAsync(); - ok.Should().Be(2); + BrowserWindow window = null; + + try + { + ////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI."); + + window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = true }, "about:blank"); + + await Task.Delay(100); + + window.WebContents.SetZoomLevel(0); + await Task.Delay(500); + + var ok = await window.WebContents.GetZoomLevelAsync(); + ok.Should().Be(0); + + window.WebContents.SetZoomLevel(2); + await Task.Delay(500); + + ok = await window.WebContents.GetZoomLevelAsync(); + ok.Should().Be(2); + } + finally + { + window?.Destroy(); + } } [SkippableFact(Timeout = 20000)]