diff options
| author | SHAURYASANYAL3 <shauryasanya.21jun@gmail.com> | 2026-11-22 19:44:11 +0530 |
|---|---|---|
| committer | SHAURYASANYAL3 <shauryasanya.21jun@gmail.com> | 2026-11-22 19:45:12 +0530 |
| commit | ea2f274a27b143b2fdd638bbee2ff0a8ca21b781 (patch) | |
| tree | 878152a577094d687fe5a41d40e82db4924c6e74 /runtime/test | |
| parent | 003e78129303643a3fdc9e5f0e31a01b09759236 (diff) | |
xgameruntime: implement XPackageGetCurrentProcessPackagePath, XPackageIsPackagedProcess, XSystemGetAnalyticsInfo
Diffstat (limited to 'runtime/test')
| -rw-r--r-- | runtime/test/xgameruntime_test.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/runtime/test/xgameruntime_test.cpp b/runtime/test/xgameruntime_test.cpp index ac36f40d9..2508cd123 100644 --- a/runtime/test/xgameruntime_test.cpp +++ b/runtime/test/xgameruntime_test.cpp | |||
| @@ -51,8 +51,20 @@ using AsyncCompleteFn = void(__stdcall*)(XAsyncBlock*, HRESULT, size_t); | |||
| 51 | using AsyncResultSizeFn = HRESULT(__stdcall*)(XAsyncBlock*, size_t*); | 51 | using AsyncResultSizeFn = HRESULT(__stdcall*)(XAsyncBlock*, size_t*); |
| 52 | using AsyncResultFn = HRESULT(__stdcall*)(XAsyncBlock*, const void*, size_t, void*, size_t*); | 52 | using AsyncResultFn = HRESULT(__stdcall*)(XAsyncBlock*, const void*, size_t, void*, size_t*); |
| 53 | 53 | ||
| 54 | struct XSystemAnalyticsInfo { | ||
| 55 | char osVersion[128]; | ||
| 56 | char hostingOsVersion[128]; | ||
| 57 | char family[64]; | ||
| 58 | char form[64]; | ||
| 59 | }; | ||
| 60 | |||
| 61 | using AnalyticsInfoFn = HRESULT(__stdcall*)(XSystemAnalyticsInfo*); | ||
| 62 | using PackagePathFn = HRESULT(__stdcall*)(size_t, char*); | ||
| 63 | using PackagedProcessFn = bool(__stdcall*)(); | ||
| 64 | |||
| 54 | const char* const kNames[] = { | 65 | const char* const kNames[] = { |
| 55 | "XGameRuntimeInitialize", "XGameRuntimeUninitialize", "XSystemGetDeviceType", "XSystemGetConsoleId", | 66 | "XGameRuntimeInitialize", "XGameRuntimeUninitialize", "XSystemGetDeviceType", "XSystemGetConsoleId", |
| 67 | "XSystemGetAnalyticsInfo", "XPackageGetCurrentProcessPackagePath", "XPackageIsPackagedProcess", | ||
| 56 | "XTaskQueueCreate", "XTaskQueueCreateComposite", "XTaskQueueGetPort", "XTaskQueueDuplicateHandle", | 68 | "XTaskQueueCreate", "XTaskQueueCreateComposite", "XTaskQueueGetPort", "XTaskQueueDuplicateHandle", |
| 57 | "XTaskQueueCloseHandle", "XTaskQueueTerminate", "XTaskQueueDispatch", "XTaskQueueSubmitCallback", | 69 | "XTaskQueueCloseHandle", "XTaskQueueTerminate", "XTaskQueueDispatch", "XTaskQueueSubmitCallback", |
| 58 | "XTaskQueueSubmitDelayedCallback", "XTaskQueueRegisterWaiter", "XTaskQueueUnregisterWaiter", | 70 | "XTaskQueueSubmitDelayedCallback", "XTaskQueueRegisterWaiter", "XTaskQueueUnregisterWaiter", |
| @@ -229,6 +241,32 @@ int main() { | |||
| 229 | check(console_id(sizeof(id), id, &used) == S_OK && used == 39 && std::strlen(id) == 38, | 241 | check(console_id(sizeof(id), id, &used) == S_OK && used == 39 && std::strlen(id) == 38, |
| 230 | "XSystemGetConsoleId fills 39 bytes (38 characters and the terminator)"); | 242 | "XSystemGetConsoleId fills 39 bytes (38 characters and the terminator)"); |
| 231 | 243 | ||
| 244 | auto analytics_info = get<AnalyticsInfoFn>("XSystemGetAnalyticsInfo"); | ||
| 245 | check(analytics_info(nullptr) == E_INVALIDARG, "XSystemGetAnalyticsInfo rejects null pointer"); | ||
| 246 | XSystemAnalyticsInfo info{}; | ||
| 247 | check(analytics_info(&info) == S_OK && std::strcmp(info.family, "Xbox") == 0 && | ||
| 248 | std::strcmp(info.osVersion, "10.0.22000.0") == 0 && std::strcmp(info.form, "Anaconda") == 0, | ||
| 249 | "XSystemGetAnalyticsInfo populates Xbox Anaconda analytics info"); | ||
| 250 | |||
| 251 | auto package_path = get<PackagePathFn>("XPackageGetCurrentProcessPackagePath"); | ||
| 252 | check(package_path(0, nullptr) == E_INVALIDARG, "XPackageGetCurrentProcessPackagePath rejects null pointer and size 0"); | ||
| 253 | char pkg_path[MAX_PATH] = {}; | ||
| 254 | check(package_path(0, pkg_path) == E_INVALIDARG, "XPackageGetCurrentProcessPackagePath rejects size 0 with buffer"); | ||
| 255 | check(package_path(10, nullptr) == E_INVALIDARG, "XPackageGetCurrentProcessPackagePath rejects null pointer with size"); | ||
| 256 | |||
| 257 | SetEnvironmentVariableA("LEONIDA_GAME_DIR", "C:\\LeonidaGameDir"); | ||
| 258 | check(package_path(5, pkg_path) == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), | ||
| 259 | "XPackageGetCurrentProcessPackagePath rejects insufficient buffer"); | ||
| 260 | check(package_path(sizeof(pkg_path), pkg_path) == S_OK && std::strcmp(pkg_path, "C:\\LeonidaGameDir") == 0, | ||
| 261 | "XPackageGetCurrentProcessPackagePath returns configured game directory"); | ||
| 262 | SetEnvironmentVariableA("LEONIDA_GAME_DIR", nullptr); | ||
| 263 | |||
| 264 | auto is_packaged = get<PackagedProcessFn>("XPackageIsPackagedProcess"); | ||
| 265 | check(is_packaged() == true, "XPackageIsPackagedProcess returns true by default"); | ||
| 266 | SetEnvironmentVariableA("LEONIDA_PACKAGED", "0"); | ||
| 267 | check(is_packaged() == false, "XPackageIsPackagedProcess respects LEONIDA_PACKAGED=0 override"); | ||
| 268 | SetEnvironmentVariableA("LEONIDA_PACKAGED", nullptr); | ||
| 269 | |||
| 232 | // Work on the thread pool, completions dispatched by the "game loop" on this thread. | 270 | // Work on the thread pool, completions dispatched by the "game loop" on this thread. |
| 233 | auto create = get<QueueCreateFn>("XTaskQueueCreate"); | 271 | auto create = get<QueueCreateFn>("XTaskQueueCreate"); |
| 234 | auto close = get<QueueCloseFn>("XTaskQueueCloseHandle"); | 272 | auto close = get<QueueCloseFn>("XTaskQueueCloseHandle"); |