Skip to content

Commit 2cf3095

Browse files
committed
BrowserWindowTests: Add delays everywhere
1 parent 0ec791d commit 2cf3095

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ElectronNET.IntegrationTests/Tests/BrowserWindowTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public async Task Can_set_and_get_title()
2121
{
2222
const string title = "Integration Test Title";
2323
this.fx.MainWindow.SetTitle(title);
24+
await Task.Delay(500);
2425
var roundTrip = await this.fx.MainWindow.GetTitleAsync();
2526
roundTrip.Should().Be(title);
2627
}
@@ -29,6 +30,7 @@ public async Task Can_set_and_get_title()
2930
public async Task Can_resize_and_get_size()
3031
{
3132
this.fx.MainWindow.SetSize(643, 482);
33+
await Task.Delay(500);
3234
var size = await this.fx.MainWindow.GetSizeAsync();
3335
size.Should().HaveCount(2);
3436
size[0].Should().Be(643);
@@ -58,6 +60,7 @@ public async Task Can_set_and_get_bounds()
5860
{
5961
var bounds = new Rectangle { X = 10, Y = 20, Width = 400, Height = 300 };
6062
this.fx.MainWindow.SetBounds(bounds);
63+
await Task.Delay(500);
6164
var round = await this.fx.MainWindow.GetBoundsAsync();
6265

6366
round.Should().BeEquivalentTo(bounds);
@@ -70,6 +73,7 @@ public async Task Can_set_and_get_content_bounds()
7073
{
7174
var bounds = new Rectangle { X = 0, Y = 0, Width = 300, Height = 200 };
7275
this.fx.MainWindow.SetContentBounds(bounds);
76+
await Task.Delay(500);
7377
var round = await this.fx.MainWindow.GetContentBoundsAsync();
7478
round.Width.Should().BeGreaterThan(0);
7579
round.Height.Should().BeGreaterThan(0);
@@ -79,17 +83,21 @@ public async Task Can_set_and_get_content_bounds()
7983
public async Task Show_hide_visibility_roundtrip()
8084
{
8185
this.fx.MainWindow.Show();
86+
await Task.Delay(500);
8287
(await this.fx.MainWindow.IsVisibleAsync()).Should().BeTrue();
8388
this.fx.MainWindow.Hide();
89+
await Task.Delay(500);
8490
(await this.fx.MainWindow.IsVisibleAsync()).Should().BeFalse();
8591
}
8692

8793
[Fact(Timeout = 20000)]
8894
public async Task AlwaysOnTop_toggle_and_query()
8995
{
9096
this.fx.MainWindow.SetAlwaysOnTop(true);
97+
await Task.Delay(500);
9198
(await this.fx.MainWindow.IsAlwaysOnTopAsync()).Should().BeTrue();
9299
this.fx.MainWindow.SetAlwaysOnTop(false);
100+
await Task.Delay(500);
93101
(await this.fx.MainWindow.IsAlwaysOnTopAsync()).Should().BeFalse();
94102
}
95103

@@ -119,6 +127,7 @@ public async Task ReadyToShow_event_fires_after_content_ready()
119127
// Trigger a navigation and wait for DOM ready so the renderer paints, which emits ready-to-show
120128
var domReadyTcs = new TaskCompletionSource();
121129
window.WebContents.OnDomReady += () => domReadyTcs.TrySetResult();
130+
await Task.Delay(500);
122131
await window.WebContents.LoadURLAsync("about:blank");
123132
await domReadyTcs.Task;
124133

@@ -139,6 +148,7 @@ public async Task PageTitleUpdated_event_fires_on_title_change()
139148
// Navigate and wait for DOM ready, then change the document.title to trigger the event
140149
var domReadyTcs = new TaskCompletionSource();
141150
window.WebContents.OnDomReady += () => domReadyTcs.TrySetResult();
151+
await Task.Delay(500);
142152
await window.WebContents.LoadURLAsync("about:blank");
143153
await domReadyTcs.Task;
144154
await window.WebContents.ExecuteJavaScriptAsync<string>("document.title='NewTitle';");
@@ -155,6 +165,7 @@ public async Task Resize_event_fires_on_size_change()
155165
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false }, "about:blank");
156166
var resized = false;
157167
window.OnResize += () => resized = true;
168+
await Task.Delay(500);
158169
window.SetSize(500, 400);
159170
await Task.Delay(300);
160171
resized.Should().BeTrue();
@@ -183,8 +194,10 @@ public async Task Menu_bar_visibility_and_auto_hide()
183194
{
184195
var win = this.fx.MainWindow;
185196
win.SetAutoHideMenuBar(true);
197+
await Task.Delay(500);
186198
(await win.IsMenuBarAutoHideAsync()).Should().BeTrue();
187199
win.SetMenuBarVisibility(true);
200+
await Task.Delay(500);
188201
(await win.IsMenuBarVisibleAsync()).Should().BeTrue();
189202
}
190203

@@ -194,6 +207,7 @@ public async Task Parent_child_relationship_roundtrip()
194207
var child = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false, Width = 300, Height = 200 }, "about:blank");
195208
this.fx.MainWindow.SetParentWindow(null); // ensure top-level
196209
child.SetParentWindow(this.fx.MainWindow);
210+
await Task.Delay(500);
197211
var parent = await child.GetParentWindowAsync();
198212
parent.Id.Should().Be(this.fx.MainWindow.Id);
199213
var kids = await this.fx.MainWindow.GetChildWindowsAsync();

0 commit comments

Comments
 (0)