Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions runtime/test/title_window_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <chrono>
#include <cstdio>
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 15 additions & 7 deletions runtime/test/xgameruntime_offline_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <XTaskQueue.h>

#include "shims.h"
#include "window_station.h"

namespace rt::shims {
long xgameruntime_offline_game_events();
Expand Down Expand Up @@ -379,13 +380,20 @@ int main() {
"XLaunchUri is not available offline");
check(at<AcquireDeferral>(launcher, 4)(launcher, nullptr) == E_POINTER,
"XDisplayAcquireTimeoutDeferral rejects null out pointer");
check(at<AcquireDeferral>(launcher, 4)(launcher, &deferral) == S_OK && deferral != nullptr,
"XDisplayAcquireTimeoutDeferral acquires a display power request handle");
void* second = nullptr;
check(at<AcquireDeferral>(launcher, 4)(launcher, &second) == S_OK && second && second != deferral,
"concurrent display deferrals have distinct handles");
at<CloseDeferral>(launcher, 5)(launcher, second);
at<CloseDeferral>(launcher, 5)(launcher, deferral);
const HRESULT acquired = at<AcquireDeferral>(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<AcquireDeferral>(launcher, 4)(launcher, &second) == S_OK && second && second != deferral,
"concurrent display deferrals have distinct handles");
at<CloseDeferral>(launcher, 5)(launcher, second);
at<CloseDeferral>(launcher, 5)(launcher, deferral);
}
at<CloseDeferral>(launcher, 5)(launcher, nullptr);
check(true, "XDisplayCloseTimeoutDeferralHandle closes handle and ignores null");
GUID other = kLauncherClass;
Expand Down
Loading