Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions tests/OpenClaw.Tray.UITests/UIThreadFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ private void UIThreadProc()

if (!IsSlow)
{
// Default: hide the window so CI runs are silent.
_startupPhase = "hiding test window";
TryHide(TestWindow);
// Default: keep the window live but off-screen so CI runs are silent.
_startupPhase = "moving test window off-screen";
MoveOffScreen(TestWindow);
}

_startupPhase = "ready";
Expand All @@ -248,17 +248,14 @@ private void UIThreadProc()
}
}

private static void TryHide(Window w)
private static void MoveOffScreen(Window w)
{
try
{
// WindowsAppSDK 1.5+ supports AppWindow.Hide via WinUIEx, but to keep
// deps minimal we just move the window off-screen. It's still a real
// Window — XamlRoot is attached, the visual tree lays out — but the
// user never sees it during tests.
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(w);
// SW_HIDE = 0
ShowWindow(hwnd, 0);
// Move off-screen so CI runs are silent while keeping the window
// live in the WinUI compositor. XamlRoot stays attached, the visual
// tree lays out, but the user never sees it during tests.
w.AppWindow.MoveAndResize(new Windows.Graphics.RectInt32(-32000, -32000, 1, 1));
}
// slopwatch-ignore: SW003 Test cleanup or fixture teardown is best-effort and must not hide the test outcome.
catch
Expand All @@ -267,10 +264,6 @@ private static void TryHide(Window w)
}
}

[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

public void Dispose()
{
try
Expand Down
Loading