diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index f6cb8f6fbd..958102fdb2 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -911,6 +911,7 @@ if(BUILD_TESTING) endif() target_link_libraries(title_window_test PRIVATE user32) add_test(NAME title_window COMMAND title_window_test) + set_tests_properties(title_window PROPERTIES SKIP_RETURN_CODE 77) # no interactive window station (SSH, service) endif() # LEONIDA_DEV_OVERLAY's text and the phase bookkeeping behind it (src/dev_overlay.h): no window, GPU or game file. diff --git a/runtime/test/title_window_test.cpp b/runtime/test/title_window_test.cpp index b3ea9ac825..c6edce94b2 100644 --- a/runtime/test/title_window_test.cpp +++ b/runtime/test/title_window_test.cpp @@ -5,6 +5,7 @@ // sent message (WM_GETTEXT, what GetWindowTextW sends across threads, times out), so a lookup that sent one would block. #include "title_window.h" +#include "window_station.h" #include #include @@ -32,6 +33,10 @@ HWND make(const wchar_t* name, DWORD ex_style, DWORD style, int width, int heigh } // namespace int main() { + if (!has_interactive_window_station()) { + std::printf("SKIP: no interactive window station (an SSH or service session): no window is visible here\n"); + return 77; + } WNDCLASSW window_class{}; window_class.lpfnWndProc = DefWindowProcW; window_class.hInstance = GetModuleHandleW(nullptr); diff --git a/runtime/test/xgameruntime_offline_test.cpp b/runtime/test/xgameruntime_offline_test.cpp index 92a6238060..288c0b7388 100644 --- a/runtime/test/xgameruntime_offline_test.cpp +++ b/runtime/test/xgameruntime_offline_test.cpp @@ -16,6 +16,7 @@ #include #include "shims.h" +#include "window_station.h" namespace rt::shims { long xgameruntime_offline_game_events(); @@ -427,13 +428,20 @@ int main() { "XLaunchUri is not available offline"); check(at(launcher, 4)(launcher, nullptr) == E_POINTER, "XDisplayAcquireTimeoutDeferral rejects null out pointer"); - check(at(launcher, 4)(launcher, &deferral) == S_OK && deferral != nullptr, - "XDisplayAcquireTimeoutDeferral acquires a display power request handle"); - void* second = nullptr; - check(at(launcher, 4)(launcher, &second) == S_OK && second && second != deferral, - "concurrent display deferrals have distinct handles"); - at(launcher, 5)(launcher, second); - at(launcher, 5)(launcher, deferral); + const HRESULT acquired = at(launcher, 4)(launcher, &deferral); + if (acquired == HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) && !has_interactive_window_station()) { + // No desktop to keep on: the request is refused, and the shim passes that on with nothing to close. + check(deferral == nullptr, "a refused display deferral leaves no handle"); + std::printf("SKIP display deferral handles: no interactive window station (an SSH or service session)\n"); + } else { + check(acquired == S_OK && deferral != nullptr, + "XDisplayAcquireTimeoutDeferral acquires a display power request handle"); + void* second = nullptr; + check(at(launcher, 4)(launcher, &second) == S_OK && second && second != deferral, + "concurrent display deferrals have distinct handles"); + at(launcher, 5)(launcher, second); + at(launcher, 5)(launcher, deferral); + } at(launcher, 5)(launcher, nullptr); check(true, "XDisplayCloseTimeoutDeferralHandle closes handle and ignores null"); GUID other = kLauncherClass;