aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/integration/basic.rs
diff options
context:
space:
mode:
authorKyle Sutherland-Cash <kyle.sutherlandcash@gmail.com>2021-02-05 10:28:34 +0000
committerGitHub <noreply@github.com>2021-02-05 11:28:34 +0100
commitb6fb330da3820dcb1959c1ce749b59f0150c9e21 (patch)
treebf6d83e64dfbc716d1a82f2b48401bdeb57e3453 /src/tests/integration/basic.rs
parentMerge pull request #157 from mosaic-org/restructure (diff)
downloadsl0ppij-b6fb330da3820dcb1959c1ce749b59f0150c9e21.tar.gz
sl0ppij-b6fb330da3820dcb1959c1ce749b59f0150c9e21.tar.xz
sl0ppij-b6fb330da3820dcb1959c1ce749b59f0150c9e21.zip
refactor(input): hotkeys (#132)
* Initial definitions and thoughts for hotkeys * Actually document InputKey properly * Add a to string function for input keys * Define keybinds and actions; restructure * Implement hash and start on defining key bindings * Derive Serialize for input keys * Store the key strings as tuples for two-way mapping * Some string to key functions * Use termion's Key definition and implement action dispatch * Fix some borrow-checker errors * Missing keybind and command mode switching * Fix incorrect handling of spawn terminal command * fix(plugins): work with new input - tests not passing * fix(infra): stabilize tests and properly close pty sessions * style(fmt): rustfmt Co-authored-by: Brooks J Rady <b.j.rady@gmail.com> Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'src/tests/integration/basic.rs')
-rw-r--r--src/tests/integration/basic.rs113
1 files changed, 41 insertions, 72 deletions
diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs
index 67f66eb0..a48871a1 100644
--- a/src/tests/integration/basic.rs
+++ b/src/tests/integration/basic.rs
@@ -3,10 +3,10 @@ use ::insta::assert_snapshot;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::utils::commands::{
- COMMAND_TOGGLE, MOVE_FOCUS, QUIT, RESIZE_LEFT, RESIZE_RIGHT, RESIZE_UP, SCROLL_DOWN, SCROLL_UP,
- SPAWN_TERMINAL, SPLIT_HORIZONTALLY, SPLIT_VERTICALLY, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN,
+ COMMAND_TOGGLE, QUIT, SCROLL_DOWN, SCROLL_UP, SPAWN_TERMINAL, SPLIT_HORIZONTALLY,
+ SPLIT_VERTICALLY, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN,
};
-use crate::tests::utils::get_output_frame_snapshots;
+use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs};
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
@@ -30,9 +30,9 @@ pub fn starts_with_one_terminal() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -57,9 +57,9 @@ pub fn split_terminals_vertically() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -84,9 +84,9 @@ pub fn split_terminals_horizontally() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -114,9 +114,9 @@ pub fn split_largest_terminal() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -141,9 +141,9 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -168,9 +168,9 @@ pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -195,48 +195,27 @@ pub fn cannot_split_largest_terminal_when_there_is_no_room() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
-pub fn resize_right_and_up_on_the_same_axis() {
- // this is a specific test to explicitly ensure that a tmux-like pane-container algorithm is not
- // implemented (this test can never pass with such an algorithm)
- //
- // ┌─────┬─────┐ ┌─────┬─────┐
- // │ │ │ │ │ │
- // ├─────┼─────┤ ==resize=right==> ├─────┴─┬───┤ ==resize-left==>
- // │█████│ │ │███████│ │
- // └─────┴─────┘ └───────┴───┘
- //
- // ┌─────┬─────┐ ┌─────┬─────┐
- // │ │ │ ├─────┤ │
- // ├─────┼─────┤ ==resize=up==> │█████├─────┤
- // │█████│ │ │█████│ │
- // └─────┴─────┘ └─────┴─────┘
- // █ == focused pane
+pub fn scrolling_up_inside_a_pane() {
let fake_win_size = PositionAndSize {
columns: 121,
- rows: 40,
+ rows: 20,
x: 0,
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
-
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&COMMAND_TOGGLE,
&SPLIT_HORIZONTALLY,
&SPLIT_VERTICALLY,
- &MOVE_FOCUS,
- &SPLIT_VERTICALLY,
- &MOVE_FOCUS,
- &MOVE_FOCUS,
- &RESIZE_RIGHT,
- &RESIZE_LEFT,
- &RESIZE_UP,
+ &SCROLL_UP,
+ &SCROLL_UP,
&QUIT,
]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
@@ -246,13 +225,13 @@ pub fn resize_right_and_up_on_the_same_axis() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
-pub fn scrolling_inside_a_pane() {
+pub fn scrolling_down_inside_a_pane() {
let fake_win_size = PositionAndSize {
columns: 121,
rows: 20,
@@ -278,9 +257,9 @@ pub fn scrolling_inside_a_pane() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -312,9 +291,9 @@ pub fn max_panes() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}
#[test]
@@ -333,16 +312,6 @@ pub fn toggle_focused_pane_fullscreen() {
&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 = CliArgs::default();
@@ -354,7 +323,7 @@ pub fn toggle_focused_pane_fullscreen() {
.lock()
.unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
- for snapshot in snapshots {
- assert_snapshot!(snapshot);
- }
+ let snapshot_before_quit =
+ get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
+ assert_snapshot!(snapshot_before_quit);
}