RunicTestHostOptions record

Namespace Runic.Application.Testing in Runic.Application.Testing 0.23.0

public sealed record RunicTestHostOptions : IEquatable<RunicTestHostOptions>

Inherits or implements IEquatable.

The options of a RunicTestHost.

Constructors

RunicTestHostOptions

public RunicTestHostOptions()

No documentation.

Properties

AllowElevatedGuest

public bool AllowElevatedGuest { get; init; }

Whether the offer allows an elevated guest, as a host's RunicGuestStartInfo.AllowElevatedGuest does; false by default. With it the test host plays an elevated host for a guest that sets RunicGuestOptions.AllowElevatedHost.

Remarks

The guest checks its parent, this test process, itself: an elevated guest is hosted only when the test process runs elevated as the same user, and refuses with guest-elevated-host-not-elevated otherwise. A guest that does not run elevated ignores the offer's opt-in. Unlike Runic's host, the test host does not check that it runs elevated itself, so it can also show that a guest ignores the opt-in when it does not run elevated.

Appearance

public DesktopAppearance? Appearance { get; init; }

The host's appearance in its hello, which the guest's Windows show; null, the default, for an unknown appearance.

ClipboardReadsOnlyActiveWindow

public bool ClipboardReadsOnlyActiveWindow { get; init; }

Whether a clipboard read for a window that is not active is refused, as Runic's host does by default; true by default. Each window is active when it opens; RunicTestHostedWindow.SetActivityAsync changes it.

Remarks

Runic's host is stricter: it also refuses clipboard writes and launches for a window the user is not working in, and treats a window the guest opened or presented itself as not the user's until the user switches to it (RunicHostedServiceRequest.IsGuestActivated). The test host does not model the user's activation; test those rules against Runic's host.

ContextMenu

public Func<RunicTestDialogRequest, CancellationToken, Task<RunicTestDialogAnswer>>? ContextMenu { get; init; }

Answers each context menu (show-context-menu): RunicTestDialogAnswer.Choose with the id of the item the user chose, which RunicTestHostedWindow.FindMenuItem finds by its title, RunicTestDialogAnswer.Dismiss, or another answer. null, the default, dismisses every menu.

EmbedWindow

public Func<RunicTestHostedWindow, bool>? EmbedWindow { get; init; }

Chooses the windows that show in a region of a host page instead of a window of their own (region/1), as a host's policy does: their window-open reply names presentation: "region", and RunicTestHostedWindow.AttachRegionAsync attaches them. Needs region/1 in RunicTestHostOptions.Features and in the guest's hello. null, the default, shows every window in a window.

Features

public IReadOnlyList<string> Features { get; init; }

The protocol features the host's hello lists: menus/1, dialogs/1 and window-services/1 by default. A guest's menus, dialogs and window services of a feature that is not listed report OwnerUnavailable, as in serve-only mode.

FileDialog

public Func<RunicTestDialogRequest, CancellationToken, Task<RunicTestDialogAnswer>>? FileDialog { get; init; }

Answers each file dialog (file-dialog): RunicTestDialogAnswer.Select with the absolute paths the user selected, and the filter they chose, or another answer, such as RunicTestDialogAnswer.Dismiss or RunicTestDialogAnswer.Refuse. The token is cancelled when the guest gives the dialog up or closes the window. null, the default, dismisses every dialog.

Remarks

The guest opens the paths itself, as with its own dialogs: an open dialog's files must exist. The request's typed members (RunicTestDialogRequest.Kind, RunicTestDialogRequest.Title, RunicTestDialogRequest.SuggestedName and others) describe the dialog. An answer that does not fit the request, or a callback that throws, fails the guest's dialog and the test host's next wait.

HostName

public string HostName { get; init; }

The host's name in the offer; Runic.Application.Testing by default.

HostVersion

public string HostVersion { get; init; }

The host's version in the offer; this package's version by default.

Languages

public IReadOnlyList<string> Languages { get; init; }

The languages the host's user prefers, in its hello; empty by default.

Launch

public Func<RunicTestLaunchRequest, PlatformResult<PlatformUnit>>? Launch { get; init; }

Answers each file or link the guest asks the host to open (launch) with a platform outcome; null, the default, answers success. Every request is recorded in RunicTestHostedWindow.LaunchRequests; nothing is opened.

Locale

public string? Locale { get; init; }

The host's application locale in its hello, which the guest's IRunicApplicationLocale follows unless the guest sets a locale of its own; null, the default, for none.

MessageBox

public Func<RunicTestDialogRequest, CancellationToken, Task<RunicTestDialogAnswer>>? MessageBox { get; init; }

Answers each message box (message-box): RunicTestDialogAnswer.Choose with the id of the button the user chose, RunicTestDialogAnswer.Dismiss for a box closed without one, or another answer. The token is cancelled when the guest gives the box up or closes the window. null, the default, chooses the box's cancel button, or none.

Monitors

public IReadOnlyList<DesktopMonitor> Monitors { get; init; }

The host's monitors that the guest lists (monitors), the first one the window's: one primary 1920 × 1080 monitor, test-monitor, by default. RunicTestHost.SetMonitorsAsync changes them.

OpenWindow

public Func<RunicTestHostedWindow, bool>? OpenWindow { get; init; }

Decides each window-open: false refuses the window, as a host's policy does. null, the default, allows every window.

Presentation

public Func<RunicTestPresentationRequest, PlatformResult<PlatformUnit>>? Presentation { get; init; }

Answers each presentation request with a platform outcome; null, the default, answers success.

Protocols

public IReadOnlyList<int> Protocols { get; init; }

The protocol versions the offer lists; [1] by default. Other values test a guest's refusal.

RegionAppearance

public Func<RunicTestHostedWindow, DesktopAppearance?>? RegionAppearance { get; init; }

The appearance override of each region window from its open (region-appearance/1), as a host's RunicHostedRegionOptions.Appearance gives it: the guest merges it with RunicTestHostOptions.Appearance for that window's pages only. Each known member replaces the host's value; an unknown one, such as DesktopColorScheme.NoPreference or null, keeps it. Needs region-appearance/1 and region/1 in RunicTestHostOptions.Features and in the guest's hello. null, the default, or a null result opens the window without an override; RunicTestHost.SetRegionAppearanceAsync changes it later.

StartTimeout

public TimeSpan StartTimeout { get; init; }

How long the guest may take to write its channel line and answer the hello; 30 seconds by default.

WindowFeatures

public RunicWindowPresentationFeatures WindowFeatures { get; init; }

What each window can do, as the window-open reply lists it: every presentation feature but RunicWindowPresentationFeatures.PerWindowColorScheme by default.