MCPcopy Create free account
hub / github.com/TyberiusPrime/KeyToKey / test_rewrite_shifted_string

Function test_rewrite_shifted_string

src/handlers/layer.rs:389–421  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

387
388 #[test]
389 fn test_rewrite_shifted_string() {
390 use crate::handlers::LayerAction::SendStringShifted;
391 let mut keyboard = Keyboard::new(KeyOutCatcher::new());
392 let l = Layer::new(vec![(KeyCode::A, SendStringShifted("a", "A"))], AutoOff::No);
393 let layer_id = keyboard.add_handler(Box::new(l));
394 assert!(!keyboard.output.state().is_handler_enabled(layer_id));
395 keyboard.output.state().enable_handler(layer_id);
396 keyboard.output.state().unicode_mode = UnicodeSendMode::Debug;
397 keyboard.add_handler(Box::new(crate::test_helpers::Debugger::new("A")));
398 keyboard.add_handler(Box::new(UnicodeKeyboard::new()));
399 keyboard.add_handler(Box::new(USBKeyboard::new()));
400
401 keyboard.add_keypress(KeyCode::A, 0);
402 keyboard.handle_keys().unwrap();
403 check_output(&keyboard, &[&[]]);
404 keyboard.output.clear();
405
406 keyboard.add_keyrelease(KeyCode::A, 0);
407 keyboard.handle_keys().unwrap();
408 check_output(&keyboard, &[&[KeyCode::Kp6], &[KeyCode::Kp1], &[]]);
409 keyboard.output.clear();
410
411 keyboard.output.state().set_modifier(Shift, true);
412 keyboard.add_keypress(KeyCode::A, 0);
413 keyboard.add_keyrelease(KeyCode::A, 0);
414
415 keyboard.handle_keys().unwrap();
416 check_output(
417 &keyboard,
418 &[&[KeyCode::Kp4], &[KeyCode::Kp1], &[KeyCode::LShift] ], //the shift get's send from the USBKeyboard instead of an empty report...
419 );
420 keyboard.output.clear();
421 }
422
423 #[test]
424 fn test_layer_auto_off_after_all() {

Callers

nothing calls this directly

Calls 9

check_outputFunction · 0.85
add_handlerMethod · 0.80
enable_handlerMethod · 0.80
stateMethod · 0.80
add_keypressMethod · 0.80
handle_keysMethod · 0.80
clearMethod · 0.80
add_keyreleaseMethod · 0.80
set_modifierMethod · 0.80

Tested by

no test coverage detected