Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbrad committed Aug 25, 2023
1 parent 98b5340 commit f67eed1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
15 changes: 12 additions & 3 deletions clafrica/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,20 @@ impl Frontend for Console {

#[test]
fn test_console() {
let mut console = Console::default();
let mut none = None;
none.set_input("hello");
none.update_screen((64, 64));
none.update_position((64.0, 64.0));
none.set_input("input");
none.set_page_size(10);
none.add_predicate("hey", "y", "hello");
none.display();
none.clear_predicates();
none.previous_predicate();
none.next_predicate();
none.get_selected_predicate();

let mut console = Console::default();
console.set_page_size(10);
console.update_screen((0, 0));
console.update_position((0.0, 0.0));
Expand All @@ -128,6 +139,4 @@ fn test_console() {
console.previous_predicate();
console.next_predicate();
assert!(console.get_selected_predicate().is_none());

none.set_input("hello");
}
5 changes: 5 additions & 0 deletions clafrica/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ mod tests {
input_field.pack().layout();
root.geometry(200, 200, 0, 0);
rstk::tell_wish("chan configure stdout -encoding utf-8;");
rstk::tell_wish(&format!(
"bind . <Key> {{ puts stderr [{} get 1.0 end]; }};",
input_field.id
));
thread::sleep(Duration::from_secs(1));
input_field
}
Expand Down Expand Up @@ -261,6 +265,7 @@ mod tests {
rdev::simulate(&KeyRelease(ControlLeft)).unwrap();

input!(KeyL KeyL, typing_speed_ms);
thread::sleep(Duration::from_millis(100));
rdev::simulate(&KeyPress(ControlLeft)).unwrap();
input!(Space, typing_speed_ms);
rdev::simulate(&KeyRelease(ControlLeft)).unwrap();
Expand Down
3 changes: 1 addition & 2 deletions clafrica/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ impl Processor {
self.pause();
rdev::simulate(&EventType::KeyRelease(E_Key::ControlLeft)).unwrap();
rdev::simulate(&EventType::KeyRelease(E_Key::ControlRight)).unwrap();
dbg!(0..code.len() - remaining_code.len());

(0..code.len() - remaining_code.len())
.for_each(|_| self.keyboard.key_click(Key::Backspace));
self.keyboard.key_sequence(text);
self.resume();

// We clear the buffer
self.cursor.clear();
}
Expand Down

0 comments on commit f67eed1

Please sign in to comment.