Pty reads a command's output and feeds it to Screen using an unbounded queue. However, if the command produces output faster than what `Screen` can render, `Pty` still pushes it on the queue, causing it to grow indefinitely, resulting in high memory usage and latency. This patch fixes this by using a bounded queue between Pty and Screen, so if Screen can't keep up with Pty, the queue will fill up, exerting back pressure on Pty, making it read the command's output only as fast as Screen renders it. The unbounded queue is kept between Screen and producers other than Pty to avoid a deadlock such as this scenario: * pty thread filling up screen queue as soon as screen thread pops something from it * wasm thread is processing a Render instruction, blocking on the screen queue * screen thread is trying to render a plugin pane. It attempts to send a Render insturction to the blocked wasm thread running the plugin. This patch also adds a generous amount of sleeps to the integration tests as having backpressure changes the timing of how instructions are processed. Fixes #525.
688 lines
24 KiB
Rust
688 lines
24 KiB
Rust
use ::insta::assert_snapshot;
|
|
|
|
use crate::tests::fakes::FakeInputOutput;
|
|
use crate::tests::start;
|
|
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
|
|
use crate::CliArgs;
|
|
use zellij_utils::pane_size::PositionAndSize;
|
|
|
|
use crate::tests::utils::commands::{
|
|
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE, RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
|
};
|
|
use zellij_utils::input::config::Config;
|
|
|
|
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
|
FakeInputOutput::new(*fake_win_size)
|
|
}
|
|
|
|
#[test]
|
|
pub fn resize_right_with_pane_to_the_left() {
|
|
// ┌─────┬─────┐ ┌───────┬───┐
|
|
// │ │█████│ │ │███│
|
|
// │ │█████│ ==resize=right==> │ │███│
|
|
// │ │█████│ │ │███│
|
|
// └─────┴─────┘ └───────┴───┘
|
|
// █ == focused pane
|
|
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,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_pane_to_the_right() {
|
|
// ┌─────┬─────┐ ┌───────┬───┐
|
|
// │█████│ │ │███████│ │
|
|
// │█████│ │ ==resize=right==> │███████│ │
|
|
// │█████│ │ │███████│ │
|
|
// └─────┴─────┘ └───────┴───┘
|
|
// █ == focused pane
|
|
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,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_left_and_right() {
|
|
// ┌─────┬─────┬─────┐ ┌─────┬───────┬───┐
|
|
// │ │█████│ │ │ │███████│ │
|
|
// │ │█████│ │ ==resize=right==> │ │███████│ │
|
|
// │ │█████│ │ │ │███████│ │
|
|
// └─────┴─────┴─────┘ └─────┴───────┴───┘
|
|
// █ == focused pane
|
|
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_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_multiple_panes_to_the_left() {
|
|
// ┌─────┬─────┐ ┌───────┬───┐
|
|
// │ │█████│ │ │███│
|
|
// ├─────┤█████│ ==resize=right==> ├───────┤███│
|
|
// │ │█████│ │ │███│
|
|
// └─────┴─────┘ └───────┴───┘
|
|
// █ == focused pane
|
|
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,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_left_aligned_top_with_current_pane() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// │ │ │ │ │ │
|
|
// ├─────┼─────┤ ==resize=right==> ├─────┴─┬───┤
|
|
// │ │█████│ │ │███│
|
|
// └─────┴─────┘ └───────┴───┘
|
|
// █ == focused pane
|
|
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,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_right_aligned_top_with_current_pane() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// │ │ │ │ │ │
|
|
// ├─────┼─────┤ ==resize=right==> ├─────┴─┬───┤
|
|
// │█████│ │ │███████│ │
|
|
// └─────┴─────┘ └───────┴───┘
|
|
// █ == focused pane
|
|
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,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane() {
|
|
// ┌─────┬─────┐ ┌───────┬───┐
|
|
// │ │█████│ │ │███│
|
|
// ├─────┼─────┤ ==resize=right==> ├─────┬─┴───┤
|
|
// │ │ │ │ │ │
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == focused pane
|
|
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,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_right_aligned_bottom_with_current_pane() {
|
|
// ┌─────┬─────┐ ┌───────┬───┐
|
|
// │█████│ │ │███████│ │
|
|
// ├─────┼─────┤ ==resize=right==> ├─────┬─┴───┤
|
|
// │ │ │ │ │ │
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == focused pane
|
|
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,
|
|
&SPLIT_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_pane() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// │ │ │ │ │ │
|
|
// ├─────┼─────┤ ├─────┴─┬───┤
|
|
// │ │█████│ ==resize=right==> │ │███│
|
|
// ├─────┼─────┤ ├─────┬─┴───┤
|
|
// │ │ │ │ │ │
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == focused pane
|
|
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_DOWN_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SLEEP,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_pane() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// │ │ │ │ │ │
|
|
// ├─────┼─────┤ ├─────┴─┬───┤
|
|
// │█████│ │ ==resize=right==> │███████│ │
|
|
// ├─────┼─────┤ ├─────┬─┴───┤
|
|
// │ │ │ │ │ │
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == focused pane
|
|
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_DOWN_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SLEEP,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_above_and_below() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// ├─────┼─────┤ ├─────┴─┬───┤
|
|
// │ ├─────┤ │ ├───┤
|
|
// │ │█████│ ==resize=right==> │ │███│
|
|
// │ ├─────┤ │ ├───┤
|
|
// ├─────┼─────┤ ├─────┬─┴───┤
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == focused pane
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 40,
|
|
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_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SLEEP,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&SPLIT_DOWN_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,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_above_and_below() {
|
|
// ┌─────┬─────┐ ┌─────┬─────┐
|
|
// ├─────┼─────┤ ├─────┴─┬───┤
|
|
// ├─────┤ │ ├───────┤ │
|
|
// │█████│ │ ==resize=right==> │███████│ │
|
|
// ├─────┤ │ ├───────┤ │
|
|
// ├─────┼─────┤ ├─────┬─┴───┤
|
|
// └─────┴─────┘ └─────┴─────┘
|
|
// █ == focused pane
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 40,
|
|
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_DOWN_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&PANE_MODE,
|
|
&SPLIT_RIGHT_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,
|
|
&SPLIT_RIGHT_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&SPLIT_DOWN_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,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&MOVE_FOCUS_IN_PANE_MODE,
|
|
&RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_UP_IN_RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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 cannot_resize_right_when_pane_to_the_left_is_at_minimum_width() {
|
|
// ┌─┬─┐ ┌─┬─┐
|
|
// │ │█│ │ │█│
|
|
// │ │█│ ==resize=right==> │ │█│
|
|
// │ │█│ │ │█│
|
|
// └─┴─┘ └─┴─┘
|
|
// █ == focused pane
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 9,
|
|
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,
|
|
&RESIZE_MODE,
|
|
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
|
&SLEEP,
|
|
&QUIT,
|
|
]);
|
|
start(
|
|
Box::new(fake_input_output.clone()),
|
|
CliArgs::default(),
|
|
Box::new(fake_input_output.clone()),
|
|
Config::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);
|
|
}
|