()
| 400 | } |
| 401 | #[test] |
| 402 | fn test_oneshot_shift() { |
| 403 | use crate::handlers; |
| 404 | //use crate::debug_handlers; |
| 405 | use crate::premade; |
| 406 | let mut keyboard = Keyboard::new(KeyOutCatcher::new()); |
| 407 | keyboard.add_handler(premade::one_shot_shift(0, 0)); |
| 408 | keyboard.add_handler(Box::new(handlers::USBKeyboard::new())); |
| 409 | keyboard.add_keypress(KeyCode::RShift, 0); |
| 410 | keyboard.handle_keys().unwrap(); |
| 411 | check_output(&keyboard, &[&[KeyCode::LShift]]); //note that the one shots always output the L variants |
| 412 | keyboard.output.clear(); |
| 413 | assert!(keyboard.output.state().modifier(Shift)); |
| 414 | keyboard.add_keyrelease(KeyCode::RShift, 0); |
| 415 | keyboard.handle_keys().unwrap(); |
| 416 | assert!(keyboard.output.state().modifier(Shift)); |
| 417 | check_output(&keyboard, &[&[KeyCode::LShift]]); //key is released, but shift is still set |
| 418 | keyboard.output.clear(); |
| 419 | keyboard.add_keypress(KeyCode::A, 0); |
| 420 | keyboard.handle_keys().unwrap(); |
| 421 | assert!(keyboard.output.state().modifier(Shift)); |
| 422 | check_output(&keyboard, &[&[KeyCode::LShift, KeyCode::A]]); //shift still set |
| 423 | keyboard.output.clear(); |
| 424 | keyboard.add_keyrelease(KeyCode::A, 0); |
| 425 | keyboard.handle_keys().unwrap(); |
| 426 | assert!(!keyboard.output.state().modifier(Shift)); |
| 427 | check_output(&keyboard, &[&[]]); |
| 428 | keyboard.output.clear(); |
| 429 | keyboard.add_keypress(KeyCode::RShift, 0); |
| 430 | keyboard.handle_keys().unwrap(); |
| 431 | check_output(&keyboard, &[&[KeyCode::LShift]]); //note that the one shots always output the L variants |
| 432 | keyboard.output.clear(); |
| 433 | assert!(keyboard.output.state().modifier(Shift)); |
| 434 | keyboard.add_keypress(KeyCode::A, 0); |
| 435 | keyboard.handle_keys().unwrap(); |
| 436 | assert!(keyboard.output.state().modifier(Shift)); |
| 437 | check_output(&keyboard, &[&[KeyCode::LShift, KeyCode::A]]); //key is released, but shift is still set |
| 438 | keyboard.output.clear(); |
| 439 | keyboard.add_keyrelease(KeyCode::A, 0); |
| 440 | keyboard.handle_keys().unwrap(); |
| 441 | assert!(keyboard.output.state().modifier(Shift)); |
| 442 | check_output(&keyboard, &[&[KeyCode::LShift]]); |
| 443 | keyboard.output.clear(); |
| 444 | //we have not released the shift key! |
| 445 | keyboard.add_keyrelease(KeyCode::RShift, 0); |
| 446 | keyboard.handle_keys().unwrap(); |
| 447 | assert!(!keyboard.output.state().modifier(Shift)); |
| 448 | check_output(&keyboard, &[&[]]); //now we're good |
| 449 | keyboard.output.clear(); |
| 450 | } |
| 451 | #[test] |
| 452 | fn test_oneshot_interaction() { |
| 453 | use crate::handlers; |
nothing calls this directly
no test coverage detected