mirror of
https://github.com/apognu/tuigreet.git
synced 2024-09-11 07:25:29 +03:00
Fixed tests for custom keybindings.
This commit is contained in:
parent
ddaa111a2d
commit
18d5090082
@ -152,8 +152,11 @@ pub struct Greeter {
|
||||
// Whether to prefix the power commands with `setsid`.
|
||||
pub power_setsid: bool,
|
||||
|
||||
#[default(2)]
|
||||
pub kb_command: u8,
|
||||
#[default(3)]
|
||||
pub kb_sessions: u8,
|
||||
#[default(12)]
|
||||
pub kb_power: u8,
|
||||
|
||||
// The software is waiting for a response from `greetd`.
|
||||
|
@ -589,6 +589,50 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn f_menu_rebinded() {
|
||||
let greeter = Arc::new(RwLock::new(Greeter::default()));
|
||||
|
||||
for (key, mode) in [(KeyCode::F(1), Mode::Sessions), (KeyCode::F(11), Mode::Power)] {
|
||||
{
|
||||
let mut greeter = greeter.write().await;
|
||||
greeter.kb_command = 3;
|
||||
greeter.kb_sessions = 1;
|
||||
greeter.kb_power = 11;
|
||||
greeter.mode = Mode::Username;
|
||||
greeter.buffer = "apognu".to_string();
|
||||
}
|
||||
|
||||
let result = handle(greeter.clone(), KeyEvent::new(key, KeyModifiers::empty()), Ipc::new()).await;
|
||||
|
||||
{
|
||||
let status = greeter.read().await;
|
||||
|
||||
assert!(matches!(result, Ok(_)));
|
||||
assert_eq!(status.mode, mode);
|
||||
assert_eq!(status.buffer, "apognu".to_string());
|
||||
}
|
||||
|
||||
for mode in [Mode::Users, Mode::Sessions, Mode::Power] {
|
||||
{
|
||||
let mut greeter = greeter.write().await;
|
||||
greeter.previous_mode = Mode::Username;
|
||||
greeter.mode = mode;
|
||||
}
|
||||
|
||||
let result = handle(greeter.clone(), KeyEvent::new(KeyCode::F(3), KeyModifiers::empty()), Ipc::new()).await;
|
||||
|
||||
{
|
||||
let status = greeter.read().await;
|
||||
|
||||
assert!(matches!(result, Ok(_)));
|
||||
assert_eq!(status.mode, Mode::Command);
|
||||
assert_eq!(status.previous_mode, Mode::Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ctrl_a_e() {
|
||||
let greeter = Arc::new(RwLock::new(Greeter::default()));
|
||||
|
Loading…
Reference in New Issue
Block a user