Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/webdriver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ impl KeyInputState {
let mut actions: Vec<_> = undo_actions.drain().collect();
actions.sort_unstable();
for action in actions {
result.push(self.dispatch_keyup(action).unwrap().into());
// When we `dispatch_typeable`, we may have already dispatched keyup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens at

result.push(self.dispatch_keyup('\u{E008}').unwrap().into());
.

// but did not update `undo_actions`.
if let Some(event) = self.dispatch_keyup(action) {
result.push(event.into());
}
}
assert!(undo_actions.is_empty());
}
Expand Down Expand Up @@ -510,3 +514,29 @@ pub fn send_keys(text: &str) -> Vec<Event> {
state.clear(&mut undo_actions, &mut result);
result
}

#[cfg(test)]
mod test {
use super::*;
use std::vec;

#[test]
fn test_send_key_with_shift() {
let result: Vec<(KeyState, Key)> = send_keys("\u{e008}y")
.iter()
.map(|e| match e {
Event::Keyboard(key_event) => (key_event.state, key_event.key.clone()),
_ => unreachable!("Unexpected event"),
})
.collect();

let expected = vec![
(KeyState::Down, Key::Named(NamedKey::Shift)),
(KeyState::Up, Key::Named(NamedKey::Shift)),
(KeyState::Down, Key::Character("y".to_string())),
(KeyState::Up, Key::Character("y".to_string())),
];

assert_eq!(result, expected);
}
}
Loading