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

Function test_oneshot_released_timeout

src/premade.rs:553–583  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

551 }
552 #[test]
553 fn test_oneshot_released_timeout() {
554 use crate::handlers;
555 //use crate::debug_handlers;
556 use crate::premade;
557
558 let mut keyboard = Keyboard::new(KeyOutCatcher::new());
559 keyboard.add_handler(premade::one_shot_shift(0, 1000));
560 keyboard.add_handler(Box::new(handlers::USBKeyboard::new()));
561
562 keyboard.add_keypress(KeyCode::RShift, 0);
563 keyboard.handle_keys().unwrap();
564 check_output(&keyboard, &[&[KeyCode::LShift]]); //note that the one shots always output the L variants
565 keyboard.output.clear();
566 assert!(keyboard.output.state().modifier(Shift));
567
568 keyboard.add_timeout(1000);
569 keyboard.handle_keys().unwrap();
570 check_output(&keyboard, &[&[KeyCode::LShift]]); //note that the one shots always output the L variants
571 keyboard.output.clear();
572 assert!(keyboard.output.state().modifier(Shift));
573
574 keyboard.add_keyrelease(KeyCode::RShift, 0);
575 keyboard.handle_keys().unwrap();
576 check_output(&keyboard, &[&[KeyCode::LShift]]); //note that the one shots always output the L variants
577 keyboard.output.clear();
578
579 keyboard.add_timeout(1000);
580 keyboard.handle_keys().unwrap();
581 assert!(!keyboard.output.state().modifier(Shift));
582 check_output(&keyboard, &[&[]]); //note that the one shots always output the L variants
583 }
584
585 #[test]
586 fn test_abort() {

Callers

nothing calls this directly

Calls 8

one_shot_shiftFunction · 0.85
check_outputFunction · 0.85
add_handlerMethod · 0.80
add_keypressMethod · 0.80
handle_keysMethod · 0.80
clearMethod · 0.80
add_timeoutMethod · 0.80
add_keyreleaseMethod · 0.80

Tested by

no test coverage detected