Introduce IntegrationFactAttribute

This commit is contained in:
softworkz
2025-12-07 11:29:50 +01:00
parent c97f914e7a
commit 153625ba51
24 changed files with 221 additions and 156 deletions

View File

@@ -0,0 +1,101 @@
namespace ElectronNET.IntegrationTests.Common
{
using System.Runtime.InteropServices;
using Xunit.Sdk;
/// <summary>
/// Custom fact attribute with a default timeout of 20 seconds, allowing tests to be skipped on specific environments.
/// </summary>
/// <seealso cref="Xunit.FactAttribute" />
[AttributeUsage(AttributeTargets.Method)]
[XunitTestCaseDiscoverer("Xunit.Sdk.SkippableFactDiscoverer", "Xunit.SkippableFact")]
internal sealed class IntegrationFactAttribute : FactAttribute
{
private static readonly bool IsOnWsl;
private static readonly bool IsOnCI;
static IntegrationFactAttribute()
{
IsOnWsl = DetectWsl();
IsOnCI = DetectCI();
}
/// <summary>
/// Initializes a new instance of the <see cref="IntegrationFactAttribute" /> class.
/// </summary>
public IntegrationFactAttribute()
{
this.Timeout = 20_000;
}
public bool SkipOnWsl { get; set; }
public bool SkipOnCI { get; set; }
/// <summary>
/// Marks the test so that it will not be run, and gets or sets the skip reason
/// </summary>
public override string Skip {
get
{
if (IsOnWsl && this.SkipOnWsl)
{
return "Skipping test on WSL environment.";
}
if (IsOnCI && this.SkipOnCI)
{
return "Skipping test on CI environment.";
}
return base.Skip;
}
set
{
base.Skip = value;
}
}
private static bool DetectWsl()
{
try
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return false;
}
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WSL_DISTRO_NAME")) ||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WSL_INTEROP")))
{
return true;
}
return false;
}
catch
{
return false;
}
}
private static bool DetectCI()
{
try
{
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TF_BUILD")) ||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS")))
{
return true;
}
return false;
}
catch
{
return false;
}
}
}
}

View File

@@ -1,49 +0,0 @@
namespace ElectronNET.IntegrationTests.Common
{
using System.Runtime.InteropServices;
[AttributeUsage(AttributeTargets.Method)]
internal sealed class SkipOnWslFactAttribute : FactAttribute
{
private static readonly bool IsOnWsl;
static SkipOnWslFactAttribute()
{
IsOnWsl = DetectWsl();
}
/// <summary>
/// Initializes a new instance of the <see cref="SkipOnWslFactAttribute" /> class.
/// </summary>
public SkipOnWslFactAttribute()
{
if (IsOnWsl)
{
this.Skip = "Skipping test on WSL environment.";
}
}
private static bool DetectWsl()
{
try
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return false;
}
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WSL_DISTRO_NAME")) ||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WSL_INTEROP")))
{
return true;
}
return false;
}
catch
{
return false;
}
}
}
}

View File

@@ -6,6 +6,7 @@ namespace ElectronNET.IntegrationTests.Tests
using System.IO;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class AppTests
@@ -18,7 +19,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_get_app_path()
{
var path = await Electron.App.GetAppPathAsync();
@@ -26,7 +27,7 @@ namespace ElectronNET.IntegrationTests.Tests
Directory.Exists(path).Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_get_version_and_locale()
{
var version = await Electron.App.GetVersionAsync();
@@ -35,7 +36,7 @@ namespace ElectronNET.IntegrationTests.Tests
locale.Should().NotBeNullOrWhiteSpace();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_get_special_paths()
{
var userData = await Electron.App.GetPathAsync(PathName.UserData);
@@ -47,7 +48,7 @@ namespace ElectronNET.IntegrationTests.Tests
Directory.Exists(temp).Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_get_app_metrics()
{
var metrics = await Electron.App.GetAppMetricsAsync();
@@ -55,14 +56,14 @@ namespace ElectronNET.IntegrationTests.Tests
metrics.Length.Should().BeGreaterThan(0);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_get_gpu_feature_status()
{
var status = await Electron.App.GetGpuFeatureStatusAsync();
status.Should().NotBeNull();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public async Task Can_get_login_item_settings()
@@ -71,7 +72,7 @@ namespace ElectronNET.IntegrationTests.Tests
settings.Should().NotBeNull();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task CommandLine_append_and_query_switch()
{
var switchName = "integration-switch";
@@ -80,7 +81,7 @@ namespace ElectronNET.IntegrationTests.Tests
(await Electron.App.CommandLine.GetSwitchValueAsync(switchName)).Should().Be("value123");
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public async Task Accessibility_support_toggle()
@@ -91,7 +92,7 @@ namespace ElectronNET.IntegrationTests.Tests
Electron.App.SetAccessibilitySupportEnabled(false);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task UserAgentFallback_roundtrip()
{
var original = await Electron.App.UserAgentFallbackAsync;
@@ -101,7 +102,7 @@ namespace ElectronNET.IntegrationTests.Tests
Electron.App.UserAgentFallback = original; // restore
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("macOS")]
public async Task BadgeCount_set_and_reset_where_supported()
@@ -113,14 +114,14 @@ namespace ElectronNET.IntegrationTests.Tests
await Electron.App.SetBadgeCountAsync(0);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task App_metrics_have_cpu_info()
{
var metrics = await Electron.App.GetAppMetricsAsync();
metrics[0].Cpu.Should().NotBeNull();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task App_gpu_feature_status_has_some_fields()
{
var status = await Electron.App.GetGpuFeatureStatusAsync();

View File

@@ -3,6 +3,7 @@
using API;
using System.Threading.Tasks;
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class AutoUpdaterTests
@@ -14,7 +15,7 @@
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task AutoDownload_check()
{
Electron.AutoUpdater.AutoDownload = false;
@@ -25,7 +26,7 @@
test2.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task AutoInstallOnAppQuit_check()
{
Electron.AutoUpdater.AutoInstallOnAppQuit = false;
@@ -36,7 +37,7 @@
test2.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task AllowPrerelease_check()
{
Electron.AutoUpdater.AllowPrerelease = false;
@@ -47,7 +48,7 @@
test2.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task FullChangelog_check()
{
Electron.AutoUpdater.FullChangelog = false;
@@ -58,7 +59,7 @@
test2.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task AllowDowngrade_check()
{
Electron.AutoUpdater.AllowDowngrade = false;
@@ -69,14 +70,14 @@
test2.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task UpdateConfigPath_check()
{
var test1 = Electron.AutoUpdater.UpdateConfigPath;
test1.Should().Be(string.Empty);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task CurrentVersionAsync_check()
{
var semver = await Electron.AutoUpdater.CurrentVersionAsync;
@@ -84,7 +85,7 @@
semver.Major.Should().BeGreaterThan(0);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task ChannelAsync_check()
{
var test = await Electron.AutoUpdater.ChannelAsync;
@@ -95,7 +96,7 @@
test.Should().Be("beta");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task RequestHeadersAsync_check()
{
var headers = new Dictionary<string, string>
@@ -112,21 +113,21 @@
test["key1"].Should().Be("value1");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task CheckForUpdatesAsync_check()
{
var test = await Electron.AutoUpdater.CheckForUpdatesAsync();
test.Should().BeNull();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task CheckForUpdatesAndNotifyAsync_check()
{
var test = await Electron.AutoUpdater.CheckForUpdatesAsync();
test.Should().BeNull();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task GetFeedURLAsync_check()
{
var test = await Electron.AutoUpdater.GetFeedURLAsync();

View File

@@ -2,6 +2,7 @@ namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API;
using ElectronNET.API.Entities;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class BrowserViewTests
@@ -13,7 +14,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Create_browser_view_and_adjust_bounds()
{
var view = await Electron.WindowManager.CreateBrowserViewAsync(new BrowserViewConstructorOptions());

View File

@@ -16,7 +16,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_set_and_get_title()
{
const string title = "Integration Test Title";
@@ -26,7 +26,7 @@ namespace ElectronNET.IntegrationTests.Tests
roundTrip.Should().Be(title);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_resize_and_get_size()
{
this.fx.MainWindow.SetSize(643, 482);
@@ -37,7 +37,7 @@ namespace ElectronNET.IntegrationTests.Tests
size[1].Should().Be(482);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_set_progress_bar_and_clear()
{
this.fx.MainWindow.SetProgressBar(0.5);
@@ -46,7 +46,7 @@ namespace ElectronNET.IntegrationTests.Tests
await Task.Delay(50.ms());
}
[SkipOnWslFact(Timeout = 20000)]
[IntegrationFact(SkipOnWsl = true)]
public async Task Can_set_and_get_position()
{
this.fx.MainWindow.SetPosition(134, 246);
@@ -55,7 +55,7 @@ namespace ElectronNET.IntegrationTests.Tests
pos.Should().BeEquivalentTo([134, 246]);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_set_and_get_bounds()
{
var bounds = new Rectangle { X = 10, Y = 20, Width = 400, Height = 300 };
@@ -68,7 +68,7 @@ namespace ElectronNET.IntegrationTests.Tests
round.Height.Should().Be(300);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_set_and_get_content_bounds()
{
var bounds = new Rectangle { X = 0, Y = 0, Width = 300, Height = 200 };
@@ -79,7 +79,7 @@ namespace ElectronNET.IntegrationTests.Tests
round.Height.Should().BeGreaterThan(0);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Show_hide_visibility_roundtrip()
{
BrowserWindow window = null;
@@ -106,7 +106,7 @@ namespace ElectronNET.IntegrationTests.Tests
}
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task AlwaysOnTop_toggle_and_query()
{
this.fx.MainWindow.SetAlwaysOnTop(true);
@@ -117,7 +117,7 @@ namespace ElectronNET.IntegrationTests.Tests
(await this.fx.MainWindow.IsAlwaysOnTopAsync()).Should().BeFalse();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public async Task MenuBar_auto_hide_and_visibility()
@@ -133,7 +133,7 @@ namespace ElectronNET.IntegrationTests.Tests
(await this.fx.MainWindow.IsMenuBarVisibleAsync()).Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task ReadyToShow_event_fires_after_content_ready()
{
BrowserWindow window = null;
@@ -160,7 +160,7 @@ namespace ElectronNET.IntegrationTests.Tests
}
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task PageTitleUpdated_event_fires_on_title_change()
{
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = true }, "about:blank");
@@ -181,7 +181,7 @@ namespace ElectronNET.IntegrationTests.Tests
(await tcs.Task).Should().Be("NewTitle");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Resize_event_fires_on_size_change()
{
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false }, "about:blank");
@@ -193,7 +193,7 @@ namespace ElectronNET.IntegrationTests.Tests
resized.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Progress_bar_and_always_on_top_toggle()
{
var win = this.fx.MainWindow;
@@ -209,7 +209,7 @@ namespace ElectronNET.IntegrationTests.Tests
(await win.IsAlwaysOnTopAsync()).Should().BeFalse();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public async Task Menu_bar_visibility_and_auto_hide()
@@ -223,7 +223,7 @@ namespace ElectronNET.IntegrationTests.Tests
(await win.IsMenuBarVisibleAsync()).Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Parent_child_relationship_roundtrip()
{
var child = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false, Width = 300, Height = 200 }, "about:blank");
@@ -237,7 +237,7 @@ namespace ElectronNET.IntegrationTests.Tests
child.Destroy();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
public async Task Represented_filename_and_edited_flags()
{

View File

@@ -2,6 +2,7 @@ namespace ElectronNET.IntegrationTests.Tests
{
using System.Runtime.Versioning;
using ElectronNET.API;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class ClipboardTests
@@ -14,7 +15,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Clipboard_text_roundtrip()
{
var text = $"Hello Electron {Guid.NewGuid()}";
@@ -23,7 +24,7 @@ namespace ElectronNET.IntegrationTests.Tests
read.Should().Be(text);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Available_formats_contains_text_after_write()
{
var text = "FormatsTest";
@@ -32,7 +33,7 @@ namespace ElectronNET.IntegrationTests.Tests
formats.Should().Contain(f => f.Contains("text") || f.Contains("TEXT") || f.Contains("plain"));
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public async Task Bookmark_write_and_read()

View File

@@ -1,6 +1,7 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class CookiesTests
@@ -12,7 +13,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Skip = "Cookie set/get requires navigation to domain; skipping until test harness serves page")]
[IntegrationFact(Skip = "Cookie set/get requires navigation to domain; skipping until test harness serves page")]
public async Task Cookie_set_get_remove_sequence()
{
var session = this.fx.MainWindow.WebContents.Session;

View File

@@ -2,11 +2,12 @@ namespace ElectronNET.IntegrationTests.Tests
{
using System.Runtime.InteropServices;
using ElectronNET.API;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class GlobalShortcutTests
{
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_register_and_unregister()
{
var accel = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "Cmd+Alt+G" : "Ctrl+Alt+G";

View File

@@ -1,11 +1,12 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class HostHookTests
{
[Fact(Skip = "Requires HostHook setup; skipping")]
[IntegrationFact(Skip = "Requires HostHook setup; skipping")]
public async Task HostHook_call_returns_value()
{
var result = await Electron.HostHook.CallAsync<string>("create-excel-file", ".");

View File

@@ -2,6 +2,7 @@ namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API;
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class IpcMainTests
@@ -13,7 +14,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Ipc_On_receives_message_from_renderer()
{
object received = null;
@@ -34,7 +35,7 @@ namespace ElectronNET.IntegrationTests.Tests
result.Should().Be("payload123");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Ipc_Once_only_fires_once()
{
var count = 0;
@@ -44,7 +45,7 @@ namespace ElectronNET.IntegrationTests.Tests
count.Should().Be(1);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Ipc_RemoveAllListeners_stops_receiving()
{
var fired = false;
@@ -55,7 +56,7 @@ namespace ElectronNET.IntegrationTests.Tests
fired.Should().BeFalse();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Ipc_OnSync_returns_value()
{
object received = null;
@@ -73,7 +74,7 @@ namespace ElectronNET.IntegrationTests.Tests
ret.Should().Be("pong");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Ipc_Send_from_main_reaches_renderer()
{
// Listener: store raw arg; if Electron packs differently we will normalize later

View File

@@ -3,6 +3,7 @@ namespace ElectronNET.IntegrationTests.Tests
using ElectronNET.API;
using ElectronNET.API.Entities;
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class MenuTests
@@ -14,7 +15,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task ApplicationMenu_click_invokes_handler()
{
var clicked = false;
@@ -40,7 +41,7 @@ namespace ElectronNET.IntegrationTests.Tests
clicked.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task ContextMenu_popup_registers_items()
{
var win = this.fx.MainWindow;

View File

@@ -1,5 +1,7 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class MultiEventRegistrationTests
{
@@ -17,7 +19,7 @@ namespace ElectronNET.IntegrationTests.Tests
return ReferenceEquals(completed, all) && all.IsCompletedSuccessfully;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task BrowserWindow_OnResize_multiple_handlers_called()
{
var win = this.fx.MainWindow;
@@ -41,7 +43,7 @@ namespace ElectronNET.IntegrationTests.Tests
}
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task WebContents_OnDomReady_multiple_handlers_called()
{
var wc = this.fx.MainWindow.WebContents;

View File

@@ -5,11 +5,12 @@ namespace ElectronNET.IntegrationTests.Tests
{
using System.Drawing;
using ElectronNET.API.Entities;
using ElectronNET.IntegrationTests.Common;
[SupportedOSPlatform("Windows")]
public class NativeImageTests
{
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task Create_from_bitmap_and_to_png()
{
using var bmp = new Bitmap(10, 10);
@@ -27,7 +28,7 @@ namespace ElectronNET.IntegrationTests.Tests
png!.Length.Should().BeGreaterThan(0);
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task Create_from_buffer_and_to_data_url()
{
// Prepare PNG bytes
@@ -46,7 +47,7 @@ namespace ElectronNET.IntegrationTests.Tests
dataUrl!.StartsWith("data:image/", StringComparison.Ordinal).Should().BeTrue();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task Resize_and_crop_produce_expected_sizes()
{
using var bmp = new Bitmap(12, 10);
@@ -66,7 +67,7 @@ namespace ElectronNET.IntegrationTests.Tests
csize.Height.Should().Be(3);
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task Add_representation_for_scale_factor()
{
using var bmp = new Bitmap(5, 5);

View File

@@ -4,11 +4,12 @@ namespace ElectronNET.IntegrationTests.Tests
using ElectronNET.API;
using ElectronNET.API.Entities;
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class NativeThemeTests
{
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task ThemeSource_roundtrip()
{
// Capture initial
@@ -36,7 +37,7 @@ namespace ElectronNET.IntegrationTests.Tests
themeSourceSystem.Should().Be(ThemeSourceMode.System);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Updated_event_fires_on_change()
{
var fired = false;
@@ -52,7 +53,7 @@ namespace ElectronNET.IntegrationTests.Tests
fired.Should().BeTrue();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public async Task Should_use_high_contrast_colors_check()
@@ -61,7 +62,7 @@ namespace ElectronNET.IntegrationTests.Tests
metrics.Should().Be(false);
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public async Task Should_use_inverted_colors_check()

View File

@@ -4,11 +4,12 @@ namespace ElectronNET.IntegrationTests.Tests
using ElectronNET.API;
using ElectronNET.API.Entities;
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class NotificationTests
{
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task Notification_create_check()
{
Skip.If(RuntimeInformation.IsOSPlatform(OSPlatform.Linux), "Always returns false. Might need full-blown desktop environment");
@@ -27,7 +28,7 @@ namespace ElectronNET.IntegrationTests.Tests
tcs.Task.IsCompletedSuccessfully.Should().BeTrue();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task Notification_is_supported_check()
{
Skip.If(RuntimeInformation.IsOSPlatform(OSPlatform.Linux), "Always returns false. Might need full-blown desktop environment");

View File

@@ -1,11 +1,12 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class ProcessTests
{
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Process_info_is_accessible()
{
// Use renderer to fetch process info and round-trip
@@ -14,7 +15,7 @@ namespace ElectronNET.IntegrationTests.Tests
result.Should().Be("ok");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Process_properties_are_populated()
{
var execPath = await Electron.Process.ExecPathAsync;

View File

@@ -16,7 +16,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[SkipOnWslFact(Timeout = 20000)]
[IntegrationFact(SkipOnWsl = true)]
public async Task Primary_display_has_positive_dimensions()
{
var display = await Electron.Screen.GetPrimaryDisplayAsync();
@@ -24,7 +24,7 @@ namespace ElectronNET.IntegrationTests.Tests
display.Size.Height.Should().BeGreaterThan(0);
}
[SkipOnWslFact(Timeout = 20000)]
[IntegrationFact(SkipOnWsl = true)]
public async Task GetAllDisplays_returns_at_least_one()
{
var displays = await Electron.Screen.GetAllDisplaysAsync();
@@ -32,14 +32,14 @@ namespace ElectronNET.IntegrationTests.Tests
displays.Length.Should().BeGreaterThan(0);
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task GetCursorScreenPoint_check()
{
var point = await Electron.Screen.GetCursorScreenPointAsync();
point.Should().NotBeNull();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("macOS")]
public async Task GetMenuBarWorkArea_check()
{
@@ -51,7 +51,7 @@ namespace ElectronNET.IntegrationTests.Tests
area.Width.Should().BeGreaterThan(0);
}
[SkipOnWslFact(Timeout = 20000)]
[IntegrationFact(SkipOnWsl = true)]
public async Task GetDisplayNearestPoint_check()
{
var point = new Point
@@ -65,7 +65,7 @@ namespace ElectronNET.IntegrationTests.Tests
display.Size.Height.Should().BeGreaterThan(0);
}
[SkipOnWslFact(Timeout = 20000)]
[IntegrationFact(SkipOnWsl = true)]
public async Task GetDisplayMatching_check()
{
var rectangle = new Rectangle

View File

@@ -1,6 +1,7 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API.Entities;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class SessionTests
@@ -12,7 +13,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Session_preloads_roundtrip()
{
var session = this.fx.MainWindow.WebContents.Session;
@@ -23,7 +24,7 @@ namespace ElectronNET.IntegrationTests.Tests
preloadsAfter.Should().Contain("/tmp/preload_dummy.js");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Session_proxy_set_and_resolve()
{
var session = this.fx.MainWindow.WebContents.Session;
@@ -34,7 +35,7 @@ namespace ElectronNET.IntegrationTests.Tests
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Session_clear_cache_and_storage_completes()
{
var session = this.fx.MainWindow.WebContents.Session;
@@ -46,7 +47,7 @@ namespace ElectronNET.IntegrationTests.Tests
ua.Should().NotBeNullOrWhiteSpace();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Session_preloads_set_multiple_and_clear()
{
var session = this.fx.MainWindow.WebContents.Session;
@@ -59,7 +60,7 @@ namespace ElectronNET.IntegrationTests.Tests
empty.Should().NotContain("/tmp/a.js");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Clear_auth_cache_overloads()
{
var session = this.fx.MainWindow.WebContents.Session;
@@ -67,14 +68,14 @@ namespace ElectronNET.IntegrationTests.Tests
await session.ClearAuthCacheAsync(new RemovePassword("password") { Origin = "https://example.com", Username = "user", Password = "pw", Realm = "realm", Scheme = Scheme.basic });
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Clear_storage_with_options()
{
var session = this.fx.MainWindow.WebContents.Session;
await session.ClearStorageDataAsync(new ClearStorageDataOptions { Storages = new[] { "cookies" }, Quotas = new[] { "temporary" } });
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Enable_disable_network_emulation()
{
var session = this.fx.MainWindow.WebContents.Session;
@@ -82,14 +83,14 @@ namespace ElectronNET.IntegrationTests.Tests
session.DisableNetworkEmulation();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Flush_storage_data_does_not_throw()
{
var session = this.fx.MainWindow.WebContents.Session;
session.FlushStorageData();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Set_user_agent_affects_new_navigation()
{
var session = this.fx.MainWindow.WebContents.Session;

View File

@@ -1,11 +1,12 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class ShellTests
{
[Fact(Skip = "This can keep the test process hanging until the e-mail window is closed")]
[IntegrationFact(Skip = "This can keep the test process hanging until the e-mail window is closed")]
public async Task OpenExternal_invalid_scheme_returns_error_or_empty()
{
var error = await Electron.Shell.OpenExternalAsync("mailto:test@example.com");

View File

@@ -2,6 +2,7 @@ namespace ElectronNET.IntegrationTests.Tests
{
using System.Runtime.Versioning;
using ElectronNET.API.Entities;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class ThumbarButtonTests
@@ -13,7 +14,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("Windows")]
public async Task SetThumbarButtons_returns_success()
{
@@ -22,7 +23,7 @@ namespace ElectronNET.IntegrationTests.Tests
success.Should().BeTrue();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
[SupportedOSPlatform("Windows")]
public async Task Thumbar_button_click_invokes_callback()
{

View File

@@ -1,6 +1,7 @@
namespace ElectronNET.IntegrationTests.Tests
{
using ElectronNET.API;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class TrayTests
@@ -13,7 +14,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_create_tray_and_destroy()
{
//await Electron.Tray.Show("assets/icon.png");

View File

@@ -5,6 +5,7 @@ namespace ElectronNET.IntegrationTests.Tests
using ElectronNET.API;
using ElectronNET.API.Entities;
using ElectronNET.Common;
using ElectronNET.IntegrationTests.Common;
[Collection("ElectronCollection")]
public class WebContentsTests
@@ -16,7 +17,7 @@ namespace ElectronNET.IntegrationTests.Tests
this.fx = fx;
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_get_url_after_navigation()
{
var wc = this.fx.MainWindow.WebContents;
@@ -25,7 +26,7 @@ namespace ElectronNET.IntegrationTests.Tests
url.Should().Contain("example.com");
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task ExecuteJavaScript_returns_title()
{
var wc = this.fx.MainWindow.WebContents;
@@ -34,7 +35,7 @@ namespace ElectronNET.IntegrationTests.Tests
title.Should().NotBeNull();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task DomReady_event_fires()
{
var wc = this.fx.MainWindow.WebContents;
@@ -45,7 +46,7 @@ namespace ElectronNET.IntegrationTests.Tests
fired.Should().BeTrue();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_print_to_pdf()
{
var html = "data:text/html,<html><body><h1>PDF Test</h1><p>Electron.NET</p></body></html>";
@@ -67,7 +68,7 @@ namespace ElectronNET.IntegrationTests.Tests
}
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task Can_basic_print()
{
var html = "data:text/html,<html><body><h2>Print Test</h2></body></html>";
@@ -76,15 +77,14 @@ namespace ElectronNET.IntegrationTests.Tests
ok.Should().BeTrue();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task GetPrintersAsync_check()
{
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null, "Skipping printer test in CI environment.");
var info = await fx.MainWindow.WebContents.GetPrintersAsync();
info.Should().NotBeNull();
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task GetSetZoomFactor_check()
{
await fx.MainWindow.WebContents.GetZoomFactorAsync();
@@ -96,15 +96,13 @@ namespace ElectronNET.IntegrationTests.Tests
ok.Should().Be(2.0);
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task GetSetZoomLevel_check()
{
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.ms());
@@ -127,15 +125,13 @@ namespace ElectronNET.IntegrationTests.Tests
}
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task DevTools_check()
{
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(3.seconds());
@@ -156,7 +152,7 @@ namespace ElectronNET.IntegrationTests.Tests
}
}
[Fact(Timeout = 20000)]
[IntegrationFact]
public async Task GetSetAudioMuted_check()
{
fx.MainWindow.WebContents.SetAudioMuted(true);
@@ -174,17 +170,13 @@ namespace ElectronNET.IntegrationTests.Tests
ok.Should().BeFalse();
}
[SkippableFact(Timeout = 20000)]
[IntegrationFact]
public async Task GetSetUserAgent_check()
{
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
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(3.seconds());

View File

@@ -1,6 +1,8 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToExtensionBlock/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CI/@EntryIndexedValue">CI</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>