From 388a1347580df120cead11f98516ceb911373316 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 6 Jul 2020 09:08:01 +0800 Subject: convert input handling to crosstermion --- src/interactive/app_test/journeys_readonly.rs | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/interactive/app_test/journeys_readonly.rs') diff --git a/src/interactive/app_test/journeys_readonly.rs b/src/interactive/app_test/journeys_readonly.rs index 595491a..f5337ca 100644 --- a/src/interactive/app_test/journeys_readonly.rs +++ b/src/interactive/app_test/journeys_readonly.rs @@ -1,7 +1,7 @@ use crate::interactive::{ app_test::utils::{ - fixture_str, index_by_name, initialized_app_and_terminal_from_fixture, node_by_index, - node_by_name, + adapt, fixture_str, index_by_name, initialized_app_and_terminal_from_fixture, + node_by_index, node_by_name, }, app_test::FIXTURE_PATH, SortMode, @@ -54,7 +54,7 @@ fn simple_user_journey_read_only() -> Result<()> { // SORTING { // when hitting the S key - app.process_events(&mut terminal, b"s".keys())?; + app.process_events(&mut terminal, adapt(b"s".keys()))?; assert_eq!( app.state.sorting, SortMode::SizeAscending, @@ -66,7 +66,7 @@ fn simple_user_journey_read_only() -> Result<()> { "it recomputes the cached entries" ); // when hitting the S key again - app.process_events(&mut terminal, b"s".keys())?; + app.process_events(&mut terminal, adapt(b"s".keys()))?; assert_eq!( app.state.sorting, SortMode::SizeDescending, @@ -82,35 +82,35 @@ fn simple_user_journey_read_only() -> Result<()> { // Entry-Navigation { // when hitting the j key - app.process_events(&mut terminal, b"j".keys())?; + app.process_events(&mut terminal, adapt(b"j".keys()))?; assert_eq!( node_by_name(&app, fixture_str(long_root)), node_by_index(&app, *app.state.selected.as_ref().unwrap()), "it moves the cursor down and selects the next entry based on the current sort mode" ); // when hitting it while there is nowhere to go - app.process_events(&mut terminal, b"j".keys())?; + app.process_events(&mut terminal, adapt(b"j".keys()))?; assert_eq!( node_by_name(&app, fixture_str(long_root)), node_by_index(&app, *app.state.selected.as_ref().unwrap()), "it stays at the previous position" ); // when hitting the k key - app.process_events(&mut terminal, b"k".keys())?; + app.process_events(&mut terminal, adapt(b"k".keys()))?; assert_eq!( node_by_name(&app, fixture_str(short_root)), node_by_index(&app, *app.state.selected.as_ref().unwrap()), "it moves the cursor up and selects the next entry based on the current sort mode" ); // when hitting the k key again - app.process_events(&mut terminal, b"k".keys())?; + app.process_events(&mut terminal, adapt(b"k".keys()))?; assert_eq!( node_by_name(&app, fixture_str(short_root)), node_by_index(&app, *app.state.selected.as_ref().unwrap()), "it stays at the current cursor position as there is nowhere to go" ); // when hitting the o key with a directory selected - app.process_events(&mut terminal, b"o".keys())?; + app.process_events(&mut terminal, adapt(b"o".keys()))?; { let new_root_idx = index_by_name(&app, fixture_str(short_root)); assert_eq!( @@ -124,7 +124,7 @@ fn simple_user_journey_read_only() -> Result<()> { ); // when hitting the u key while inside a sub-directory - app.process_events(&mut terminal, b"u".keys())?; + app.process_events(&mut terminal, adapt(b"u".keys()))?; { assert_eq!( app.traversal.root_index, app.state.root, @@ -139,7 +139,7 @@ fn simple_user_journey_read_only() -> Result<()> { } // when hitting the u key while inside of the root directory // We are moving the cursor down just to have a non-default selection - app.process_events(&mut terminal, b"ju".keys())?; + app.process_events(&mut terminal, adapt(b"ju".keys()))?; { assert_eq!( app.traversal.root_index, app.state.root, @@ -156,9 +156,9 @@ fn simple_user_journey_read_only() -> Result<()> { // Deletion { // when hitting the 'd' key (also move cursor back to start) - app.process_events(&mut terminal, b"k".keys())?; + app.process_events(&mut terminal, adapt(b"k".keys()))?; let previously_selected_index = *app.state.selected.as_ref().unwrap(); - app.process_events(&mut terminal, b"d".keys())?; + app.process_events(&mut terminal, adapt(b"d".keys()))?; { assert_eq!( Some(1), @@ -180,7 +180,7 @@ fn simple_user_journey_read_only() -> Result<()> { // when hitting the 'd' key again { - app.process_events(&mut terminal, b"d".keys())?; + app.process_events(&mut terminal, adapt(b"d".keys()))?; assert_eq!( Some(2), @@ -197,7 +197,7 @@ fn simple_user_journey_read_only() -> Result<()> { // when hitting the 'd' key once again { - app.process_events(&mut terminal, b"d".keys())?; + app.process_events(&mut terminal, adapt(b"d".keys()))?; assert_eq!( Some(1), @@ -214,7 +214,7 @@ fn simple_user_journey_read_only() -> Result<()> { } // when hitting the spacebar (after moving up to the first entry) { - app.process_events(&mut terminal, b"k ".keys())?; + app.process_events(&mut terminal, adapt(b"k ".keys()))?; assert_eq!( None, @@ -233,7 +233,7 @@ fn simple_user_journey_read_only() -> Result<()> { // Marking { // select something - app.process_events(&mut terminal, b" j ".keys())?; + app.process_events(&mut terminal, adapt(b" j ".keys()))?; assert_eq!( Some(false), app.window.mark_pane.as_ref().map(|p| p.has_focus()), @@ -247,7 +247,7 @@ fn simple_user_journey_read_only() -> Result<()> { ); // when advancing the selection to the marker pane - app.process_events(&mut terminal, b"\t".keys())?; + app.process_events(&mut terminal, adapt(b"\t".keys()))?; { assert_eq!( Some(true), -- cgit v1.2.3