Simulate calling of text-insertion APIs in TestAppContext::dispatch_keystroke

This commit is contained in:
Max Brunsfeld
2022-07-25 12:20:12 -07:00
parent a54d9f1697
commit ab037fe844
3 changed files with 30 additions and 19 deletions
+8 -8
View File
@@ -9917,7 +9917,7 @@ mod tests {
one|
two
three"});
cx.simulate_input(".");
cx.simulate_keystroke(".");
handle_completion_request(
&mut cx,
indoc! {"
@@ -9963,9 +9963,9 @@ mod tests {
two|
three|
additional edit"});
cx.simulate_input(" ");
cx.simulate_keystroke(" ");
assert!(cx.editor(|e, _| e.context_menu.is_none()));
cx.simulate_input("s");
cx.simulate_keystroke("s");
assert!(cx.editor(|e, _| e.context_menu.is_none()));
cx.assert_editor_state(indoc! {"
@@ -9986,7 +9986,7 @@ mod tests {
cx.condition(|editor, _| editor.context_menu_visible())
.await;
cx.simulate_input("i");
cx.simulate_keystroke("i");
handle_completion_request(
&mut cx,
@@ -10021,11 +10021,11 @@ mod tests {
})
});
cx.set_state("editor|");
cx.simulate_input(".");
cx.simulate_keystroke(".");
assert!(cx.editor(|e, _| e.context_menu.is_none()));
cx.simulate_input("c");
cx.simulate_input("l");
cx.simulate_input("o");
cx.simulate_keystroke("c");
cx.simulate_keystroke("l");
cx.simulate_keystroke("o");
cx.assert_editor_state("editor.clo|");
assert!(cx.editor(|e, _| e.context_menu.is_none()));
cx.update_editor(|editor, cx| {
-6
View File
@@ -165,12 +165,6 @@ impl<'a> EditorTestContext<'a> {
})
}
pub fn simulate_input(&mut self, input: &str) {
self.editor.update(self.cx, |editor, cx| {
editor.handle_input(input, cx);
});
}
pub fn update_buffer<F, T>(&mut self, update: F) -> T
where
F: FnOnce(&mut Buffer, &mut ModelContext<Buffer>) -> T,