Skip to content

Commit 4166e0f

Browse files
shanselmanCopilot
andauthored
Keep Tray UI test window live off-screen (#897)
Move the WinUI UI-test fixture window off-screen instead of hiding it with SW_HIDE so XamlRoot remains attached for layout smoke tests in CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 1823f19 commit 4166e0f

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

tests/OpenClaw.Tray.UITests/UIThreadFixture.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ private void UIThreadProc()
226226

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

234234
_startupPhase = "ready";
@@ -248,17 +248,14 @@ private void UIThreadProc()
248248
}
249249
}
250250

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

270-
[System.Runtime.InteropServices.DllImport("user32.dll")]
271-
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
272-
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
273-
274267
public void Dispose()
275268
{
276269
try

0 commit comments

Comments
 (0)