diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index bea9a82d88..f3aa483cf4 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -765,6 +765,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) # LEONIDA_TITLE_HUD's counters in the title bar of another thread's window (shims/title_hud.h): user32 and DXGI. add_executable(title_hud_test test/title_hud_test.cpp) 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 b441868ba5..f94bf3ccc9 100644 --- a/runtime/test/xgameruntime_offline_test.cpp +++ b/runtime/test/xgameruntime_offline_test.cpp @@ -15,6 +15,7 @@ #include #include "shims.h" +#include "window_station.h" namespace rt::shims { long xgameruntime_offline_game_events(); @@ -379,13 +380,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;