669 lines
23 KiB
Rust
669 lines
23 KiB
Rust
use crate::panes::PositionAndSize;
|
|
use ::insta::assert_snapshot;
|
|
|
|
use crate::tests::fakes::FakeInputOutput;
|
|
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
|
|
use crate::{start, CliArgs};
|
|
|
|
use crate::common::input::{config::Config, options::Options};
|
|
use crate::tests::utils::commands::{
|
|
CLOSE_PANE_IN_PANE_MODE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT,
|
|
RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE,
|
|
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
|
};
|
|
|
|
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
|
FakeInputOutput::new(fake_win_size.clone())
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_another_pane_above_it() {
|
|
// ┌───────────┐ ┌───────────┐
|
|
// │xxxxxxxxxxx│ │xxxxxxxxxxx│
|
|
// │xxxxxxxxxxx│ │xxxxxxxxxxx│
|
|
// ├───────────┤ ==close==> │xxxxxxxxxxx│
|
|
// │███████████│ │xxxxxxxxxxx│
|
|
// │███████████│ │xxxxxxxxxxx│
|
|
// └───────────┘ └───────────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_another_pane_below_it() {
|
|
// ┌───────────┐ ┌───────────┐
|
|
// │███████████│ │xxxxxxxxxxx│
|
|
// │███████████│ │xxxxxxxxxxx│
|
|
// ├───────────┤ ==close==> │xxxxxxxxxxx│
|
|
// │xxxxxxxxxxx│ │xxxxxxxxxxx│
|
|
// │xxxxxxxxxxx│ │xxxxxxxxxxx│
|
|
// └───────────┘ └───────────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_another_pane_to_the_left() {
|
|
// ┌─────┬─────┐ ┌──────────┐
|
|
// │xxxxx│█████│ │xxxxxxxxxx│
|
|
// │xxxxx│█████│ ==close==> │xxxxxxxxxx│
|
|
// │xxxxx│█████│ │xxxxxxxxxx│
|
|
// └─────┴─────┘ └──────────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_another_pane_to_the_right() {
|
|
// ┌─────┬─────┐ ┌──────────┐
|
|
// │█████│xxxxx│ │xxxxxxxxxx│
|
|
// │█████│xxxxx│ ==close==> │xxxxxxxxxx│
|
|
// │█████│xxxxx│ │xxxxxxxxxx│
|
|
// └─────┴─────┘ └──────────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_above_it() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// │xxxxx│xxxxx│ │xxxxx│xxxxx│
|
|
// │xxxxx│xxxxx│ │xxxxx│xxxxx│
|
|
// ├─────┴─────┤ ==close==> │xxxxx│xxxxx│
|
|
// │███████████│ │xxxxx│xxxxx│
|
|
// │███████████│ │xxxxx│xxxxx│
|
|
// └───────────┘ └─────┴─────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_below_it() {
|
|
// ┌───────────┐ ┌─────┬─────┐
|
|
// │███████████│ │xxxxx│xxxxx│
|
|
// │███████████│ │xxxxx│xxxxx│
|
|
// ├─────┬─────┤ ==close==> │xxxxx│xxxxx│
|
|
// │xxxxx│xxxxx│ │xxxxx│xxxxx│
|
|
// │xxxxx│xxxxx│ │xxxxx│xxxxx│
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_to_the_left() {
|
|
// ┌─────┬─────┐ ┌──────────┐
|
|
// │xxxxx│█████│ │xxxxxxxxxx│
|
|
// │xxxxx│█████│ │xxxxxxxxxx│
|
|
// ├─────┤█████│ ==close==> ├──────────┤
|
|
// │xxxxx│█████│ │xxxxxxxxxx│
|
|
// │xxxxx│█████│ │xxxxxxxxxx│
|
|
// └─────┴─────┘ └──────────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_to_the_right() {
|
|
// ┌─────┬─────┐ ┌──────────┐
|
|
// │█████│xxxxx│ │xxxxxxxxxx│
|
|
// │█████│xxxxx│ │xxxxxxxxxx│
|
|
// │█████├─────┤ ==close==> ├──────────┤
|
|
// │█████│xxxxx│ │xxxxxxxxxx│
|
|
// │█████│xxxxx│ │xxxxxxxxxx│
|
|
// └─────┴─────┘ └──────────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_above_it_away_from_screen_edges() {
|
|
// ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐
|
|
// │xxx│xxx│xxx│xxx│ │xxx│xxx│xxx│xxx│
|
|
// ├───┤xxx│xxx├───┤ ├───┤xxx│xxx├───┤
|
|
// │xxx├───┴───┤xxx│ ==close==> │xxx│xxx│xxx│xxx│
|
|
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
|
|
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
|
|
// └───┴───────┴───┘ └───┴───┴───┴───┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&ESC,
|
|
&RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&ESC,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&ESC,
|
|
&RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&ESC,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() {
|
|
// ┌───┬───────┬───┐ ┌───┬───┬───┬───┐
|
|
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
|
|
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
|
|
// │xxx├───┬───┤xxx│ ==close==> │xxx│xxx│xxx│xxx│
|
|
// ├───┤xxx│xxx├───┤ ├───┤xxx│xxx├───┤
|
|
// │xxx│xxx│xxx│xxx│ │xxx│xxx│xxx│xxx│
|
|
// └───┴───┴───┴───┘ └───┴───┴───┴───┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_DOWN_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_DOWN_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() {
|
|
// ┌────┬──────┐ ┌────┬──────┐
|
|
// │xxxx│xxxxxx│ │xxxx│xxxxxx│
|
|
// ├────┴┬─────┤ ├────┴──────┤
|
|
// │xxxxx│█████│ │xxxxxxxxxxx│
|
|
// ├─────┤█████│ ==close==> ├───────────┤
|
|
// │xxxxx│█████│ │xxxxxxxxxxx│
|
|
// ├────┬┴─────┤ ├────┬──────┤
|
|
// │xxxx│xxxxxx│ │xxxx│xxxxxx│
|
|
// └────┴──────┘ └────┴──────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 30,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_LEFT_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_LEFT_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() {
|
|
// ┌────┬──────┐ ┌────┬──────┐
|
|
// │xxxx│xxxxxx│ │xxxx│xxxxxx│
|
|
// ├────┴┬─────┤ ├────┴──────┤
|
|
// │█████│xxxxx│ │xxxxxxxxxxx│
|
|
// │█████├─────┤ ==close==> ├───────────┤
|
|
// │█████│xxxxx│ │xxxxxxxxxxx│
|
|
// ├────┬┴─────┤ ├────┬──────┤
|
|
// │xxxx│xxxxxx│ │xxxx│xxxxxx│
|
|
// └────┴──────┘ └────┴──────┘
|
|
// █ == pane being closed
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 30,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_LEFT_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_LEFT_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|
|
|
|
#[test]
|
|
pub fn closing_last_pane_exits_app() {
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
..Default::default()
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
&CLOSE_PANE_IN_PANE_MODE,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::default(),
|
|
Options::default(),
|
|
);
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
let snapshot_before_quit =
|
|
get_next_to_last_snapshot(snapshots).expect("could not find snapshot");
|
|
assert_snapshot!(snapshot_before_quit);
|
|
}
|