fix(app): game detection finds Battle.net games where they are installed and takes any letters in a path
- Battle.net installs anywhere: its games come from the machine's uninstall entries (removed by its Blizzard Uninstaller or published by Blizzard Entertainment, with an install folder, not Battle.net itself), read when the watch starts; a program inside one is a game named after the entry - launcher folders are matched part by part with ASCII case ignored; the name was cut by byte positions of a lower-cased copy, which panicked the detection thread on a path such as D:\İ\steamapps\common\하데스\game.exe - checked on the win-ci VM: a Steam game under a non-ASCII path and a Battle.net game (test uninstall entry) turn game mode on with their names and off when they end Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
//! Game detection on Windows (admin.spec.md, "Game detection"): a program started from a launcher's
|
||||
//! game folder turns game mode on with the folder's name, and off once it ends. Runs only with
|
||||
//! `JARVIS_TEST_GAME_EXE=<a windowed program under ...\steamapps\common\<Game>\>`; elsewhere it skips.
|
||||
//! For a game installed elsewhere (Battle.net) also set `JARVIS_TEST_GAME_LAUNCHER=Battle.net` and
|
||||
//! `JARVIS_TEST_GAME_NAME=<its uninstall entry's name>`.
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -31,7 +33,9 @@ fn a_launcher_game_turns_game_mode_on_until_it_ends() {
|
||||
let on = wait_for(&w, |v| !v.is_null(), 15);
|
||||
eprintln!("on after {:?}: {on}", t0.elapsed());
|
||||
let folder = std::path::Path::new(&exe).parent().unwrap().file_name().unwrap().to_string_lossy().into_owned();
|
||||
assert_eq!(on, serde_json::json!({"name": folder, "reason": {"kind": "launcher", "launcher": "Steam"}}));
|
||||
let name = std::env::var("JARVIS_TEST_GAME_NAME").unwrap_or(folder);
|
||||
let launcher = std::env::var("JARVIS_TEST_GAME_LAUNCHER").unwrap_or("Steam".into());
|
||||
assert_eq!(on, serde_json::json!({"name": name, "reason": {"kind": "launcher", "launcher": launcher}}));
|
||||
game.kill().unwrap();
|
||||
let _ = game.wait();
|
||||
let t1 = Instant::now();
|
||||
|
||||
Reference in New Issue
Block a user