test(input): exercise the stop chord on an isolated Windows desktop
The explicitly gated ignored test sends real modifier chords only on the hosted CI desktop, verifies consent revocation and held-key release, and releases injected keys on exit. It includes Shift, Win and both, plus listener reuse. Local compilation passed without running the hook or desktop input; actual CI execution follows. The existing Windows job owns its finite runtime.
This commit is contained in:
1 parent
fbc7265009
commit
0b2519be07
2 files changed
+97
-1
No files matched your search
@@ -9,7 +9,7 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel_native:
|
||||
description: Run macOS Native builds and codec checks plus the Windows WebView2 lifecycle check
|
||||
description: Run Native builds, macOS codec checks and Windows window/input checks
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
@@ -224,6 +224,25 @@ jobs:
|
||||
-- --ignored --exact --test-threads=1 --nocapture | Tee-Object -Variable testOutput
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
if ($testOutput -notcontains 'running 1 test') { throw "Expected to run $testName" }
|
||||
- name: Compile the Windows input tests
|
||||
if: runner.os == 'Windows'
|
||||
env:
|
||||
_LINK_: '/DEBUG:NONE'
|
||||
run: cargo +1.91.0 test --locked --manifest-path prototype/channel-native/Cargo.toml --features capture --lib --no-run
|
||||
- name: Verify stopping control on the isolated Windows desktop
|
||||
if: runner.os == 'Windows'
|
||||
timeout-minutes: 2
|
||||
shell: pwsh
|
||||
env:
|
||||
_LINK_: '/DEBUG:NONE'
|
||||
PIIK_ISOLATED_WINDOWS_DESKTOP: '1'
|
||||
run: |
|
||||
if (-not [Environment]::UserInteractive) { throw 'The input check requires an isolated interactive desktop' }
|
||||
$testName = 'input::tests::windows_stop_shortcut_on_isolated_desktop'
|
||||
cargo +1.91.0 test --locked --manifest-path prototype/channel-native/Cargo.toml --features capture --lib $testName `
|
||||
-- --ignored --exact --test-threads=1 --nocapture | Tee-Object -Variable testOutput
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
if ($testOutput -notcontains 'running 1 test') { throw "Expected to run $testName" }
|
||||
|
||||
release-notes:
|
||||
if: github.event_name == 'pull_request'
|
||||
|
||||
@@ -1368,6 +1368,83 @@ async fn windows_hotkey_revokes_and_unregisters_on_process_close() {
|
||||
other.close();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[tokio::test]
|
||||
#[ignore = "injects actual Windows keys on an explicitly isolated CI desktop"]
|
||||
async fn windows_stop_shortcut_on_isolated_desktop() -> Result<()> {
|
||||
ensure!(
|
||||
std::env::var("CI").as_deref() == Ok("true")
|
||||
&& std::env::var("PIIK_ISOLATED_WINDOWS_DESKTOP").as_deref() == Ok("1"),
|
||||
"requires an isolated interactive Windows CI desktop"
|
||||
);
|
||||
|
||||
struct Chord(Vec<Held>);
|
||||
impl Chord {
|
||||
fn press(&mut self, code: &str) -> Result<()> {
|
||||
let key = Held::Key(keyboard::scan(code).expect("known fixture key"));
|
||||
windows::System.apply(Bounds::default(), &Action::Held(key, true))?;
|
||||
self.0.push(key);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn release(&mut self) -> Result<()> {
|
||||
self.0.reverse();
|
||||
self.0.retain(|key| {
|
||||
windows::System.apply(Bounds::default(), &Action::Held(*key, false)).is_err()
|
||||
});
|
||||
ensure!(self.0.is_empty(), "Windows rejected fixture key release");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
impl Drop for Chord {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.release();
|
||||
}
|
||||
}
|
||||
|
||||
let mut selected = None;
|
||||
for (shift, win) in [(false, false), (true, false), (false, true), (true, true)] {
|
||||
let (desktop, recorded) = desktop();
|
||||
let key = match selected {
|
||||
Some(key) => {
|
||||
desktop.set_shortcut(key)?;
|
||||
key
|
||||
}
|
||||
None => (1..=11).rev().find(|key| desktop.set_shortcut(*key).is_ok())
|
||||
.ok_or_else(|| anyhow!("no available Windows fixture shortcut"))?,
|
||||
};
|
||||
selected = Some(key);
|
||||
let (source, mut replies, view) = source(&desktop);
|
||||
source.set_mode(Mode::Room)?;
|
||||
let mut client = Client::new(&source);
|
||||
client.send(&source, json!({"type":"request","intent":Uuid::new_v4()}));
|
||||
let grant = client.state(&mut replies)["grant"].as_str().unwrap().to_owned();
|
||||
client.send(&source, json!({"type":"key","code":"KeyA","down":true,"grant":grant}));
|
||||
|
||||
let mut chord = Chord(Vec::new());
|
||||
if shift { chord.press("ShiftLeft")?; }
|
||||
if win { chord.press("MetaLeft")?; }
|
||||
chord.press("ControlLeft")?;
|
||||
chord.press("AltLeft")?;
|
||||
chord.press(&format!("F{key}"))?;
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
let mut timer = None;
|
||||
while desktop.0.lock().unwrap().owner.is_some() {
|
||||
desktop.tick_when_needed(&mut timer).await;
|
||||
}
|
||||
}).await.map_err(|_| anyhow!("stop timed out with Shift={shift}, Win={win}"))?;
|
||||
chord.release()?;
|
||||
assert_eq!(view.borrow().mode, Mode::Ask);
|
||||
let held = Held::Key(keyboard::scan("KeyA").unwrap());
|
||||
assert_eq!(recorded.lock().unwrap().events, [Action::Held(held, true), Action::Held(held, false)]);
|
||||
desktop.close();
|
||||
}
|
||||
let (again, _) = desktop();
|
||||
again.set_shortcut(selected.unwrap())?;
|
||||
again.close();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "capture", target_os = "linux"))]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
#[ignore = "requires isolated desktop Portal consent, cancellation marker and actual shortcut activation"]
|
||||
|
||||
Reference in new issue
Block a user