diff options
| author | Aram Drevekenin <aram@poor.dev> | 2020-11-08 21:22:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-08 21:22:46 +0100 |
| commit | ee0167f3afe616a48e454ec748c0e95ccf7ed8dd (patch) | |
| tree | a99be866511764c9810cfdbe84202e2fada2a4d9 /src/tests/integration/basic.rs | |
| parent | fix(compatibility): better stdin reading to fix various issues (#28) (diff) | |
| download | sl0ppij-ee0167f3afe616a48e454ec748c0e95ccf7ed8dd.tar.gz sl0ppij-ee0167f3afe616a48e454ec748c0e95ccf7ed8dd.tar.xz sl0ppij-ee0167f3afe616a48e454ec748c0e95ccf7ed8dd.zip | |
fix(compatibility): do not interpret esc as scroll-up (#29)
Diffstat (limited to 'src/tests/integration/basic.rs')
| -rw-r--r-- | src/tests/integration/basic.rs | 102 |
1 files changed, 81 insertions, 21 deletions
diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs index eb542f95..a7e84ad0 100644 --- a/src/tests/integration/basic.rs +++ b/src/tests/integration/basic.rs @@ -4,6 +4,19 @@ use ::insta::assert_snapshot; use crate::{start, Opt}; use crate::tests::fakes::{FakeInputOutput}; use crate::tests::utils::get_output_frame_snapshots; +use crate::tests::utils::commands::{ + SPLIT_HORIZONTALLY, + SPLIT_VERTICALLY, + RESIZE_UP, + MOVE_FOCUS, + RESIZE_LEFT, + RESIZE_RIGHT, + SPAWN_TERMINAL, + QUIT, + SCROLL_UP, + SCROLL_DOWN, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, +}; fn get_fake_os_input (fake_win_size: &Winsize) -> FakeInputOutput { FakeInputOutput::new(fake_win_size.clone()) @@ -11,14 +24,14 @@ fn get_fake_os_input (fake_win_size: &Winsize) -> FakeInputOutput { #[test] pub fn starts_with_one_terminal () { - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q) + fake_input_output.add_terminal_input(&[QUIT]); start(Box::new(fake_input_output.clone()), Opt::default()); let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap(); let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); @@ -29,14 +42,17 @@ pub fn starts_with_one_terminal () { #[test] pub fn split_terminals_vertically() { - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[14, 17]); // split-vertically and quit (ctrl-n + ctrl-q) + fake_input_output.add_terminal_input(&[ + SPLIT_VERTICALLY, + QUIT, + ]); start(Box::new(fake_input_output.clone()), Opt::default()); let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap(); let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); @@ -47,14 +63,17 @@ pub fn split_terminals_vertically() { #[test] pub fn split_terminals_horizontally() { - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[2, 17]); // split-horizontally and quit (ctrl-b + ctrl-q) + fake_input_output.add_terminal_input(&[ + SPLIT_HORIZONTALLY, + QUIT, + ]); start(Box::new(fake_input_output.clone()), Opt::default()); let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap(); let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); @@ -66,14 +85,19 @@ pub fn split_terminals_horizontally() { #[test] pub fn split_largest_terminal () { // this finds the largest pane and splits along its longest edge (vertically or horizontally) - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[26, 26, 26, 17]); // split-largest_terminal * 3 and quit (ctrl-z + ctrl-z + ctrl-z + ctrl-z + ctrl-q) + fake_input_output.add_terminal_input(&[ + SPAWN_TERMINAL, + SPAWN_TERMINAL, + SPAWN_TERMINAL, + QUIT, + ]); start(Box::new(fake_input_output.clone()), Opt::default()); let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap(); let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); @@ -99,7 +123,7 @@ pub fn resize_right_and_up_on_the_same_axis() { // │█████│ │ │█████│ │ // └─────┴─────┘ └─────┴─────┘ // █ == focused pane - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 40, ws_xpixel: 0, @@ -107,9 +131,18 @@ pub fn resize_right_and_up_on_the_same_axis() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - // (ctrl-b + ctrl-n + ctrl-p + ctrl-n + ctrl-p * 2 + ctrl-l + ctrl-h + ctrl-k + ctrl-q) - fake_input_output.add_terminal_input(&[2, 14, 16, 14, 16, 16, 12, 8, 11, 17]); - + fake_input_output.add_terminal_input(&[ + SPLIT_HORIZONTALLY, + SPLIT_VERTICALLY, + MOVE_FOCUS, + SPLIT_VERTICALLY, + MOVE_FOCUS, + MOVE_FOCUS, + RESIZE_RIGHT, + RESIZE_LEFT, + RESIZE_UP, + QUIT, + ]); start(Box::new(fake_input_output.clone()), Opt::default()); let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap(); let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); @@ -120,14 +153,22 @@ pub fn resize_right_and_up_on_the_same_axis() { #[test] pub fn scrolling_inside_a_pane() { - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[2, 14, 27, 27, 29, 29, 17]); // split-horizontally, split-vertically, scroll up twice, scroll down twice and quit (ctrl-b + ctrl+[ * 2 + ctrl+] * 2, ctrl-q) + fake_input_output.add_terminal_input(&[ + SPLIT_HORIZONTALLY, + SPLIT_VERTICALLY, + SCROLL_UP, + SCROLL_UP, + SCROLL_DOWN, + SCROLL_DOWN, + QUIT, + ]); start(Box::new(fake_input_output.clone()), Opt::default()); let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap(); let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); @@ -140,14 +181,20 @@ pub fn scrolling_inside_a_pane() { pub fn max_panes () { // with the --max-panes option, we only allow a certain amount of panes on screen // simultaneously, new panes beyond this limit will close older panes on screen - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[26, 26, 26, 26, 17]); // split-largest_terminal * 4 and quit (ctrl-z + ctrl-z + ctrl-z + ctrl-z + ctrl-q) + fake_input_output.add_terminal_input(&[ + SPAWN_TERMINAL, + SPAWN_TERMINAL, + SPAWN_TERMINAL, + SPAWN_TERMINAL, + QUIT + ]); let mut opts = Opt::default(); opts.max_panes = Some(4); start(Box::new(fake_input_output.clone()), opts); @@ -160,17 +207,30 @@ pub fn max_panes () { #[test] pub fn toggle_focused_pane_fullscreen () { - let fake_win_size = Winsize { // TODO: combine with above + let fake_win_size = Winsize { ws_col: 121, ws_row: 20, ws_xpixel: 0, ws_ypixel: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - // split-largest_terminal * 3, toggle-fullscreen * 2, ctrl-p, toggle-fullscreen * 2, ctrl-p, toggle-fullscreen * 2, ctrl-p, toggle-fullscreen * 2 and quit - // (ctrl-z + ctrl-z + ctrl-z + ctrl-z + ctrl-f, ctrl-f, ctrl-p, ctrl-f, ctrl-f, ctrl-p, ctrl-f, - // ctrl-f, ctrl-p, ctrl-f, ctrl-f, ctrl-q) - fake_input_output.add_terminal_input(&[26, 26, 26, 5, 5, 16, 5, 5, 16, 5, 5, 16, 5, 5, 17]); + fake_input_output.add_terminal_input(&[ + SPAWN_TERMINAL, + SPAWN_TERMINAL, + SPAWN_TERMINAL, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + MOVE_FOCUS, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + MOVE_FOCUS, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + MOVE_FOCUS, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + TOGGLE_ACTIVE_TERMINAL_FULLSCREEN, + QUIT + ]); let mut opts = Opt::default(); opts.max_panes = Some(4); start(Box::new(fake_input_output.clone()), opts); |
