// Generated API outline. Implementation bodies omitted.
#nullable enable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using System;
namespace Xui.Runtime.Test
{
public enum TestRuntimeVariant
{
Desktop,
IPhoneEmulator,
IPhoneNotchEmulator,
AndroidPunchHoleEmulator,
AndroidWaterdropEmulator,
AndroidNoCutoutEmulator
}
}
namespace Xui.Runtime.Test
{
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text;
using Xui.Core.Abstract.Events;
using Xui.Core.Abstract;
using Xui.Core.Actual;
using Xui.Core.Math2D;
using Xui.Core.UI;
using Xui.Middleware.EmulatorLegacy.Actual;
using Xui.Middleware.EmulatorLegacy.Devices;
using Xui.Runtime.Software.Actual;
using Xui.Runtime.Software.Font;
using Xui.Runtime.Test.Actual;
///
/// A unit-test platform harness that boots a real subclass
/// via the host DI container and exposes synchronous methods to drive input, animation, and rendering.
///
/// Like the Browser platform, Run() calls Start() and returns immediately.
/// The test then drives events manually — no OS event loop is involved.
///
public class TestSinglePageApp : IDisposable where TApplication : Application where TWindow : Window
{
///
/// The first (and typically only) window created by the application.
///
public Window Window { get; }
///
/// The window size used for rendering.
///
public Size Size { get; }
/// Optional font emission policy for SVG snapshots; null preserves system-font output.
public SvgDrawingContext.SvgFontResolver? SvgFontResolver { get; set; }
public IClock Clock { get; }
public IRandom Random { get; }
///
/// Creates a test harness that boots via a host with
/// registered as .
/// and are registered
/// automatically as scoped services.
/// Snapshot artifacts are written to a Scenarios/{testName}/ folder next to the
/// calling test file.
///
public TestSinglePageApp(Size windowSize, Action? configure = null, TestRuntimeVariant runtimeVariant = TestRuntimeVariant.Desktop, DeviceProfile? emulatorDevice = null, EmulatorStatusBarStyle? emulatorStatusBarStyleOverride = null, string? snapshotSet = null, [CallerFilePath] string callerPath = "", [CallerMemberName] string testName = "", Xui.Core.Canvas.IFontSource? fontSource = null);
public void MouseMove(Point position);
public void MouseDown(Point position, MouseButton button = MouseButton.Left);
public void MouseUp(Point position, MouseButton button = MouseButton.Left);
/// Returns the view's layout center in window coordinates, including ancestor transforms.
public static Point ViewCenter(View view);
public void MouseMove(View view);
public void MouseDown(View view, MouseButton button = MouseButton.Left);
public void MouseUp(View view, MouseButton button = MouseButton.Left);
/// Finds a scenario target, or fails with its ID and the intended action.
public View RequireView(string id, string action);
///
/// Runs scenario assertions while preserving their original exception if snapshot
/// differences are subsequently reported during disposal. Snapshot-only failures still fail.
///
public void Run(Action scenario);
public void PointerDown(Point position, int index = 0, float radius = 0.5f);
public void PointerMove(Point position, int index = 0, float radius = 0.5f);
public void PointerUp(Point position, int index = 0, float radius = 0.5f);
public void Touches(params Touch[] touches);
public void KeyDown(VirtualKey key, bool shift = false);
public void Char(char character);
///
/// Simulates typing a string by sending a event for each character.
///
public void Type(string text);
///
/// Drains all pending callbacks from the dispatcher post queue.
///
public void HandlePostActions();
///
/// Sends a to the window, driving AnimateCore
/// on all views that requested an animation frame.
///
public void AnimationFrame(TimeSpan previous, TimeSpan next);
/// Advances the deterministic clock, initializing newly requested animations first.
public void Advance(TimeSpan elapsed);
///
/// Renders the window to SVG and returns the SVG string.
/// Use this for layout-only passes. For snapshot comparison, use .
///
public string Render();
///
/// Renders the window, injects a virtual cursor (if mouse events have been sent),
/// saves the result as {NN}.{name}.Render.DIFF.svg, and compares against
/// the corresponding expected SVG. Failures are collected and reported on
/// , along with a markdown report.
///
public string Snapshot(string name);
///
/// Appends a markdown heading to the test report.
///
public void MarkdownHeading(string text, int level = 2);
///
/// Appends a markdown paragraph to the test report.
///
public void MarkdownParagraph(string text);
///
/// Appends a markdown list to the test report.
///
public void MarkdownList(IEnumerable items, bool ordered = false);
///
/// Appends a fenced code block to the test report.
///
public void MarkdownCode(string code, string language = "");
///
/// Appends raw markdown content to the test report.
///
public void MarkdownRaw(string markdown);
public void SetClockNow(DateTime now);
public void AdvanceClock(TimeSpan delta);
///
/// Drains remaining post actions and closes all windows.
///
public void Quit();
public void Dispose();
}
}
namespace Xui.Runtime.Test.Actual
{
using Xui.Core.DI;
using nfloat = System.Runtime.InteropServices.NFloat;
/// A deterministic desktop identity, independent of the test host OS.
public sealed class TestDeviceInfo : IDeviceInfo
{
/// Raised on the UI thread when a device or system preference exposed by this service changes.
public event Action? Changed { add; remove; }
/// Gets the operating system the app is running on.
public DevicePlatform Platform { get; init; }
/// Gets the form factor of the current device.
public DeviceFormFactor FormFactor { get; }
/// Gets the primary pointing device available to the user.
public PointerModel PointerModel { get; }
/// Accessibility font scale multiplier (1.0 = default).
public nfloat AccessibilityFontScale { get; }
/// True if the user has requested reduced motion.
public bool PrefersReducedMotion { get; }
/// True if the user has requested high-contrast mode.
public bool PrefersHighContrast { get; }
/// Light or dark appearance preference.
public ColorScheme ColorScheme { get; }
}
}
namespace Xui.Runtime.Test.Actual
{
using Xui.Core.Actual;
using Xui.Core.Canvas;
public class TestPlatform : IRuntime, IDispatcher
{
public IDispatcher MainDispatcher { get; }
public IRunLoop CreateRunloop(Xui.Core.Abstract.Application applicationAbstract);
public IWindow CreateWindow(Xui.Core.Abstract.IWindow windowAbstract, IServiceProvider applicationServices);
public void Post(Action callback);
}
}
namespace Xui.Runtime.Test.Actual
{
using Xui.Core.Actual;
public class TestRunLoop : IRunLoop
{
public TestRunLoop(TestPlatform platform, Xui.Core.Abstract.Application application);
public int Run();
public void Quit();
}
}
namespace Xui.Runtime.Test.Actual
{
using Xui.Core.Canvas;
public class TestWindow : Xui.Core.Actual.IWindow
{
public Xui.Core.Abstract.IWindow Abstract { get; }
public TestWindow(TestPlatform platform, Xui.Core.Abstract.IWindow abstractWindow, IServiceProvider nextServiceProvider);
public string Title { get; set; }
public bool RequireKeyboard { get; set; }
public ITextMeasureContext? TextMeasureContext { get; set; }
public IServiceProvider NextServiceProvider { get; }
public void Show();
public void Invalidate();
public object? GetService(Type serviceType);
}
}