1- use crate :: interactive:: app_test:: utils:: {
2- fixture_str, index_by_name, initialized_app_and_terminal_from_fixture, node_by_index,
3- node_by_name,
1+ use crate :: {
2+ interactive:: app_test:: utils:: {
3+ fixture_str, index_by_name, initialized_app_and_terminal_from_fixture, new_test_terminal,
4+ node_by_index, node_by_name,
5+ } ,
6+ interactive:: app_test:: FIXTURE_PATH ,
7+ interactive:: SortMode ,
48} ;
5- use crate :: interactive:: app_test:: FIXTURE_PATH ;
6- use crate :: interactive:: SortMode ;
79use failure:: Error ;
810use pretty_assertions:: assert_eq;
911use std:: ffi:: OsString ;
@@ -13,8 +15,7 @@ use termion::input::TermRead;
1315fn simple_user_journey_read_only ( ) -> Result < ( ) , Error > {
1416 let long_root = "sample-02/dir" ;
1517 let short_root = "sample-01" ;
16- let ( mut terminal, mut app) =
17- initialized_app_and_terminal_from_fixture ( & [ short_root, long_root] ) ?;
18+ let ( terminal, mut app) = initialized_app_and_terminal_from_fixture ( & [ short_root, long_root] ) ?;
1819
1920 // POST-INIT
2021 // after initialization, we expect that...
@@ -47,7 +48,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
4748 // SORTING
4849 {
4950 // when hitting the S key
50- app. process_events ( & mut terminal, b"s" . keys ( ) ) ?;
51+ app. process_events ( terminal, b"s" . keys ( ) ) ?;
5152 assert_eq ! (
5253 app. state. sorting,
5354 SortMode :: SizeAscending ,
@@ -59,7 +60,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
5960 "it recomputes the cached entries"
6061 ) ;
6162 // when hitting the S key again
62- app. process_events ( & mut terminal , b"s" . keys ( ) ) ?;
63+ app. process_events ( new_test_terminal ( ) ? , b"s" . keys ( ) ) ?;
6364 assert_eq ! (
6465 app. state. sorting,
6566 SortMode :: SizeDescending ,
@@ -75,35 +76,35 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
7576 // Entry-Navigation
7677 {
7778 // when hitting the j key
78- app. process_events ( & mut terminal , b"j" . keys ( ) ) ?;
79+ app. process_events ( new_test_terminal ( ) ? , b"j" . keys ( ) ) ?;
7980 assert_eq ! (
8081 node_by_name( & app, fixture_str( long_root) ) ,
8182 node_by_index( & app, * app. state. selected. as_ref( ) . unwrap( ) ) ,
8283 "it moves the cursor down and selects the next entry based on the current sort mode"
8384 ) ;
8485 // when hitting it while there is nowhere to go
85- app. process_events ( & mut terminal , b"j" . keys ( ) ) ?;
86+ app. process_events ( new_test_terminal ( ) ? , b"j" . keys ( ) ) ?;
8687 assert_eq ! (
8788 node_by_name( & app, fixture_str( long_root) ) ,
8889 node_by_index( & app, * app. state. selected. as_ref( ) . unwrap( ) ) ,
8990 "it stays at the previous position"
9091 ) ;
9192 // when hitting the k key
92- app. process_events ( & mut terminal , b"k" . keys ( ) ) ?;
93+ app. process_events ( new_test_terminal ( ) ? , b"k" . keys ( ) ) ?;
9394 assert_eq ! (
9495 node_by_name( & app, fixture_str( short_root) ) ,
9596 node_by_index( & app, * app. state. selected. as_ref( ) . unwrap( ) ) ,
9697 "it moves the cursor up and selects the next entry based on the current sort mode"
9798 ) ;
9899 // when hitting the k key again
99- app. process_events ( & mut terminal , b"k" . keys ( ) ) ?;
100+ app. process_events ( new_test_terminal ( ) ? , b"k" . keys ( ) ) ?;
100101 assert_eq ! (
101102 node_by_name( & app, fixture_str( short_root) ) ,
102103 node_by_index( & app, * app. state. selected. as_ref( ) . unwrap( ) ) ,
103104 "it stays at the current cursor position as there is nowhere to go"
104105 ) ;
105106 // when hitting the o key with a directory selected
106- app. process_events ( & mut terminal , b"o" . keys ( ) ) ?;
107+ app. process_events ( new_test_terminal ( ) ? , b"o" . keys ( ) ) ?;
107108 {
108109 let new_root_idx = index_by_name ( & app, fixture_str ( short_root) ) ;
109110 assert_eq ! (
@@ -117,7 +118,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
117118 ) ;
118119
119120 // when hitting the u key while inside a sub-directory
120- app. process_events ( & mut terminal , b"u" . keys ( ) ) ?;
121+ app. process_events ( new_test_terminal ( ) ? , b"u" . keys ( ) ) ?;
121122 {
122123 assert_eq ! (
123124 app. traversal. root_index, app. state. root,
@@ -132,7 +133,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
132133 }
133134 // when hitting the u key while inside of the root directory
134135 // We are moving the cursor down just to have a non-default selection
135- app. process_events ( & mut terminal , b"ju" . keys ( ) ) ?;
136+ app. process_events ( new_test_terminal ( ) ? , b"ju" . keys ( ) ) ?;
136137 {
137138 assert_eq ! (
138139 app. traversal. root_index, app. state. root,
@@ -149,9 +150,9 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
149150 // Deletion
150151 {
151152 // when hitting the 'd' key (also move cursor back to start)
152- app. process_events ( & mut terminal , b"k" . keys ( ) ) ?;
153+ app. process_events ( new_test_terminal ( ) ? , b"k" . keys ( ) ) ?;
153154 let previously_selected_index = * app. state . selected . as_ref ( ) . unwrap ( ) ;
154- app. process_events ( & mut terminal , b"d" . keys ( ) ) ?;
155+ app. process_events ( new_test_terminal ( ) ? , b"d" . keys ( ) ) ?;
155156 {
156157 assert_eq ! (
157158 Some ( 1 ) ,
@@ -173,7 +174,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
173174
174175 // when hitting the 'd' key again
175176 {
176- app. process_events ( & mut terminal , b"d" . keys ( ) ) ?;
177+ app. process_events ( new_test_terminal ( ) ? , b"d" . keys ( ) ) ?;
177178
178179 assert_eq ! (
179180 Some ( 2 ) ,
@@ -190,7 +191,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
190191
191192 // when hitting the 'd' key once again
192193 {
193- app. process_events ( & mut terminal , b"d" . keys ( ) ) ?;
194+ app. process_events ( new_test_terminal ( ) ? , b"d" . keys ( ) ) ?;
194195
195196 assert_eq ! (
196197 Some ( 1 ) ,
@@ -207,7 +208,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
207208 }
208209 // when hitting the spacebar (after moving up to the first entry)
209210 {
210- app. process_events ( & mut terminal , b"k " . keys ( ) ) ?;
211+ app. process_events ( new_test_terminal ( ) ? , b"k " . keys ( ) ) ?;
211212
212213 assert_eq ! (
213214 None ,
@@ -226,7 +227,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
226227 // Marking
227228 {
228229 // select something
229- app. process_events ( & mut terminal , b" j " . keys ( ) ) ?;
230+ app. process_events ( new_test_terminal ( ) ? , b" j " . keys ( ) ) ?;
230231 assert_eq ! (
231232 Some ( false ) ,
232233 app. window. mark_pane. as_ref( ) . map( |p| p. has_focus( ) ) ,
@@ -240,7 +241,7 @@ fn simple_user_journey_read_only() -> Result<(), Error> {
240241 ) ;
241242
242243 // when advancing the selection to the marker pane
243- app. process_events ( & mut terminal , b"\t " . keys ( ) ) ?;
244+ app. process_events ( new_test_terminal ( ) ? , b"\t " . keys ( ) ) ?;
244245 {
245246 assert_eq ! (
246247 Some ( true ) ,
0 commit comments