mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-23 15:34:37 +00:00
BrowserWindowTests: Add delays everywhere
This commit is contained in:
@@ -21,6 +21,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
{
|
||||
const string title = "Integration Test Title";
|
||||
this.fx.MainWindow.SetTitle(title);
|
||||
await Task.Delay(500);
|
||||
var roundTrip = await this.fx.MainWindow.GetTitleAsync();
|
||||
roundTrip.Should().Be(title);
|
||||
}
|
||||
@@ -29,6 +30,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
public async Task Can_resize_and_get_size()
|
||||
{
|
||||
this.fx.MainWindow.SetSize(643, 482);
|
||||
await Task.Delay(500);
|
||||
var size = await this.fx.MainWindow.GetSizeAsync();
|
||||
size.Should().HaveCount(2);
|
||||
size[0].Should().Be(643);
|
||||
@@ -58,6 +60,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
{
|
||||
var bounds = new Rectangle { X = 10, Y = 20, Width = 400, Height = 300 };
|
||||
this.fx.MainWindow.SetBounds(bounds);
|
||||
await Task.Delay(500);
|
||||
var round = await this.fx.MainWindow.GetBoundsAsync();
|
||||
|
||||
round.Should().BeEquivalentTo(bounds);
|
||||
@@ -70,6 +73,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
{
|
||||
var bounds = new Rectangle { X = 0, Y = 0, Width = 300, Height = 200 };
|
||||
this.fx.MainWindow.SetContentBounds(bounds);
|
||||
await Task.Delay(500);
|
||||
var round = await this.fx.MainWindow.GetContentBoundsAsync();
|
||||
round.Width.Should().BeGreaterThan(0);
|
||||
round.Height.Should().BeGreaterThan(0);
|
||||
@@ -79,8 +83,10 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
public async Task Show_hide_visibility_roundtrip()
|
||||
{
|
||||
this.fx.MainWindow.Show();
|
||||
await Task.Delay(500);
|
||||
(await this.fx.MainWindow.IsVisibleAsync()).Should().BeTrue();
|
||||
this.fx.MainWindow.Hide();
|
||||
await Task.Delay(500);
|
||||
(await this.fx.MainWindow.IsVisibleAsync()).Should().BeFalse();
|
||||
}
|
||||
|
||||
@@ -88,8 +94,10 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
public async Task AlwaysOnTop_toggle_and_query()
|
||||
{
|
||||
this.fx.MainWindow.SetAlwaysOnTop(true);
|
||||
await Task.Delay(500);
|
||||
(await this.fx.MainWindow.IsAlwaysOnTopAsync()).Should().BeTrue();
|
||||
this.fx.MainWindow.SetAlwaysOnTop(false);
|
||||
await Task.Delay(500);
|
||||
(await this.fx.MainWindow.IsAlwaysOnTopAsync()).Should().BeFalse();
|
||||
}
|
||||
|
||||
@@ -119,6 +127,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
// Trigger a navigation and wait for DOM ready so the renderer paints, which emits ready-to-show
|
||||
var domReadyTcs = new TaskCompletionSource();
|
||||
window.WebContents.OnDomReady += () => domReadyTcs.TrySetResult();
|
||||
await Task.Delay(500);
|
||||
await window.WebContents.LoadURLAsync("about:blank");
|
||||
await domReadyTcs.Task;
|
||||
|
||||
@@ -139,6 +148,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
// Navigate and wait for DOM ready, then change the document.title to trigger the event
|
||||
var domReadyTcs = new TaskCompletionSource();
|
||||
window.WebContents.OnDomReady += () => domReadyTcs.TrySetResult();
|
||||
await Task.Delay(500);
|
||||
await window.WebContents.LoadURLAsync("about:blank");
|
||||
await domReadyTcs.Task;
|
||||
await window.WebContents.ExecuteJavaScriptAsync<string>("document.title='NewTitle';");
|
||||
@@ -155,6 +165,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false }, "about:blank");
|
||||
var resized = false;
|
||||
window.OnResize += () => resized = true;
|
||||
await Task.Delay(500);
|
||||
window.SetSize(500, 400);
|
||||
await Task.Delay(300);
|
||||
resized.Should().BeTrue();
|
||||
@@ -183,8 +194,10 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
{
|
||||
var win = this.fx.MainWindow;
|
||||
win.SetAutoHideMenuBar(true);
|
||||
await Task.Delay(500);
|
||||
(await win.IsMenuBarAutoHideAsync()).Should().BeTrue();
|
||||
win.SetMenuBarVisibility(true);
|
||||
await Task.Delay(500);
|
||||
(await win.IsMenuBarVisibleAsync()).Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -194,6 +207,7 @@ namespace ElectronNET.IntegrationTests.Tests
|
||||
var child = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false, Width = 300, Height = 200 }, "about:blank");
|
||||
this.fx.MainWindow.SetParentWindow(null); // ensure top-level
|
||||
child.SetParentWindow(this.fx.MainWindow);
|
||||
await Task.Delay(500);
|
||||
var parent = await child.GetParentWindowAsync();
|
||||
parent.Id.Should().Be(this.fx.MainWindow.Id);
|
||||
var kids = await this.fx.MainWindow.GetChildWindowsAsync();
|
||||
|
||||
Reference in New Issue
Block a user