Skip to content

Commit 88d2daa

Browse files
committed
WebContentsTests: Experiment!
Re-enable some tests for CI as experiment
1 parent c90f003 commit 88d2daa

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ElectronNET.IntegrationTests.Tests
44
{
5+
using ElectronNET.API;
56
using ElectronNET.API.Entities;
67

78
[Collection("ElectronCollection")]
@@ -77,7 +78,7 @@ public async Task Can_basic_print()
7778
[SkippableFact(Timeout = 20000)]
7879
public async Task GetPrintersAsync_check()
7980
{
80-
Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null, "Skipping printer test in CI environment.");
81+
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null, "Skipping printer test in CI environment.");
8182
var info = await fx.MainWindow.WebContents.GetPrintersAsync();
8283
info.Should().NotBeNull();
8384
}
@@ -128,17 +129,30 @@ public async Task GetSetZoomLevel_check()
128129
[SkippableFact(Timeout = 20000)]
129130
public async Task DevTools_check()
130131
{
131-
Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.OSX), "Skipping test on macOS CI.");
132-
fx.MainWindow.WebContents.IsDevToolsOpened().Should().BeFalse();
133-
fx.MainWindow.WebContents.OpenDevTools();
134-
await Task.Delay(500);
135-
fx.MainWindow.WebContents.IsDevToolsOpened().Should().BeTrue();
136-
fx.MainWindow.WebContents.CloseDevTools();
137-
await Task.Delay(500);
138-
fx.MainWindow.WebContents.IsDevToolsOpened().Should().BeFalse();
139-
fx.MainWindow.WebContents.ToggleDevTools();
140-
await Task.Delay(500);
141-
fx.MainWindow.WebContents.IsDevToolsOpened().Should().BeTrue();
132+
BrowserWindow window = null;
133+
134+
try
135+
{
136+
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
137+
138+
window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = true }, "about:blank");
139+
140+
await Task.Delay(3000);
141+
142+
window.WebContents.IsDevToolsOpened().Should().BeFalse();
143+
window.WebContents.OpenDevTools();
144+
await Task.Delay(5000);
145+
146+
window.WebContents.IsDevToolsOpened().Should().BeTrue();
147+
window.WebContents.CloseDevTools();
148+
await Task.Delay(2000);
149+
150+
window.WebContents.IsDevToolsOpened().Should().BeFalse();
151+
}
152+
finally
153+
{
154+
window?.Destroy();
155+
}
142156
}
143157

144158
[Fact(Timeout = 20000)]
@@ -162,12 +176,11 @@ public async Task GetSetAudioMuted_check()
162176
[SkippableFact(Timeout = 20000)]
163177
public async Task GetSetUserAgent_check()
164178
{
165-
Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
166-
var ok = await fx.MainWindow.WebContents.GetUserAgentAsync();
167-
ok.Should().NotBeNullOrEmpty();
179+
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
180+
168181
fx.MainWindow.WebContents.SetUserAgent("MyUserAgent/1.0");
169182
await Task.Delay(1000);
170-
ok = await fx.MainWindow.WebContents.GetUserAgentAsync();
183+
var ok = await fx.MainWindow.WebContents.GetUserAgentAsync();
171184
ok.Should().Be("MyUserAgent/1.0");
172185
}
173186

0 commit comments

Comments
 (0)