Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

test(cua-driver): pin Shift for mixed-case and symbol keystrokes on Linux (#5067)

injaneity7a1dcd018746
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/input/mod.rs b/libs/cua-driver/rust/crates/platform-linux/src/input/mod.rs
index d1cd425be4..a48abbfb0e 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/input/mod.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/input/mod.rs
@@ -4101,7 +4101,36 @@ pub(crate) fn key_name_to_keysym(key: &str) -> Result<u32> {
#[cfg(test)]
mod key_name_alias_tests {
- use super::key_name_to_keysym;
+ use super::{char_to_keycode_shift, key_name_to_keysym, GetKeyboardMappingReply};
+
+ #[test]
+ fn shifted_column_glyphs_need_shift_and_base_glyphs_do_not() {
+ let per = 2usize;
+ let mut keysyms = vec![0u32; (248 - 8 + 1) * per];
+ let mut set = |keycode: usize, syms: [u32; 2]| {
+ let idx = (keycode - 8) * per;
+ keysyms[idx..idx + per].copy_from_slice(&syms);
+ };
+ set(43, [0x68, 0x48]);
+ set(11, [0x32, 0x40]);
+ let mapping = GetKeyboardMappingReply {
+ keysyms_per_keycode: per as u8,
+ sequence: 0,
+ keysyms,
+ };
+ for (ch, keycode, needs_shift) in [
+ ('H', 43, true),
+ ('@', 11, true),
+ ('h', 43, false),
+ ('2', 11, false),
+ ] {
+ assert_eq!(
+ char_to_keycode_shift(&mapping, ch as u32),
+ Some((keycode, needs_shift)),
+ "{ch:?}"
+ );
+ }
+ }
#[test]
fn common_key_name_aliases_resolve_to_the_expected_keysym() {
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs b/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs
index e455c98b2c..b62a3983b0 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/input/mpx_keyboard.rs
@@ -787,7 +787,7 @@ mod tests {
#[test]
fn text_plan_taps_keys_and_wraps_shifted_glyphs_in_shift() {
- let (steps, missing) = plan_text_with_fallback(&mapping(), Some(50), "a!\n", |_| None);
+ let (steps, missing) = plan_text_with_fallback(&mapping(), Some(50), "aA1!\n", |_| None);
assert!(missing.is_empty());
assert_eq!(
steps,
@@ -795,6 +795,12 @@ mod tests {
step(30, true),
step(30, false),
step(42, true),
+ step(30, true),
+ step(30, false),
+ step(42, false),
+ step(2, true),
+ step(2, false),
+ step(42, true),
step(2, true),
step(2, false),
step(42, false),