// 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.E2E
{
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text;
using Xui.Middleware.DevTools.Client;
///
/// An end-to-end test harness that launches a Xui app as a real process in Debug mode
/// with DevTools enabled, then connects to the DevTools named-pipe to drive input and
/// inspect the running UI.
///
/// Usage:
///
/// await using var app = await RealApp.StartAsync("Xui/Apps/DemoApp/DemoApp.Desktop.csproj");
/// var root = await app.InspectAsync();
/// await app.ClickAsync(root!.FindById("GridLayout")!.CenterX, root.FindById("GridLayout")!.CenterY);
/// var svg = await app.ScreenshotAsync();
///
public sealed class RealApp : IAsyncDisposable
{
///
/// Launches a Xui app in Debug mode and waits for DevTools to be ready.
///
///
/// Path to the app's .csproj file. Can be absolute or relative to
/// (or the current directory when not specified).
/// Example: "Xui/Apps/DemoApp/DemoApp.Desktop.csproj"
///
/// Working directory for the process. Defaults to .
///
///
/// How long to wait for the DevTools pipe to become ready. Defaults to 90 seconds.
///
///
/// Thrown when the process exits before printing DEVTOOLS_READY: or when
/// connecting to the DevTools pipe fails.
///
public static async Task StartAsync(string projectPath, string? workingDirectory = null, TimeSpan? timeout = null, TestLog? testLog = null);
/// Returns the recent stdout/stderr output captured from the running app.
public string GetLog();
///
/// Returns true if the app process has exited unexpectedly.
///
public bool HasCrashed { get; }
///
/// Polls until the root node is a real window (not the
/// no-window fallback). This accounts for the delay between the DevTools pipe
/// becoming ready and the first window being fully created.
///
/// Maximum wait time. Defaults to 10 seconds.
public async Task WaitForWindowAsync(TimeSpan? timeout = null);
///
/// Polls the UI tree until an element with the given appears.
/// Returns the root of the tree that contains the element.
/// Throws if the element does not appear in time.
///
/// The element ID to wait for.
/// Maximum wait time. Defaults to 10 seconds.
public async Task WaitForElementAsync(string id, TimeSpan? timeout = null);
///
/// Inspects the visual UI tree of the running app and returns the root .
/// Returns null when the result cannot be parsed.
///
public async Task InspectAsync();
///
/// Takes an SVG screenshot of the running app and returns the SVG markup string.
///
public async Task ScreenshotAsync();
/// Sends a mouse click (down + up) at coordinates (, ).
public Task ClickAsync(NFloat x, NFloat y);
/// Sends a mouse move event to coordinates (, ).
public Task MouseMoveAsync(NFloat x, NFloat y);
/// Sends a tap at coordinates (, ).
public Task TapAsync(NFloat x, NFloat y);
///
/// Sends a pointer event. must be one of
/// "start", "move", "end", or "cancel".
///
public Task PointerAsync(string phase, NFloat x, NFloat y, int index = 0);
/// Forces an immediate redraw of the app window.
public Task InvalidateAsync();
///
/// Sets the identity label shown next to the AI pointer overlay
/// (e.g. "Claude, VSCode"). Pass an empty string to clear.
///
public Task IdentifyAsync(string label);
///
/// Stops the running app process and disposes all resources.
///
public async ValueTask DisposeAsync();
///
/// Walks up from (typically the calling test file's directory)
/// until it finds a directory that contains a .sln file, and returns that directory.
///
///
/// Thrown when no solution directory is found before reaching the filesystem root.
///
public static string FindSolutionRoot(string startPath);
}
///
/// Records all E2E test operations and writes a diagnostic markdown file.
///
/// Usage:
///
/// await using var log = new TestLog("Can_Navigate_To_GridLayout_And_Back");
/// await using var app = await RealApp.StartAsync(project, testLog: log);
/// // ... test steps ...
///
/// The .md file is written to Xui/Tests/E2E/TestResults/ on dispose,
/// containing all DevTools commands, view tree XML, and the app's stdout/stderr log.
///
public sealed class TestLog : IAsyncDisposable
{
public TestLog(string testName, [CallerFilePath] string callerPath = "");
public void LogSection(string title, string body);
public ValueTask DisposeAsync();
}
}