Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to default values when terminal rows/cols are 0 #1552

Merged
merged 4 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 15 additions & 56 deletions src/tests/e2e/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ pub fn scrolling_inside_a_pane() {
let last_snapshot = loop {
RemoteRunner::kill_running_sessions(fake_win_size);
let mut runner = RemoteRunner::new(fake_win_size)
.retry_pause_ms(1000) // we need a longer retry period here because it takes some time to fill the pty buffer
.add_step(Step {
name: "Split pane to the right",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
Expand All @@ -229,32 +228,7 @@ pub fn scrolling_inside_a_pane() {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(63, 2) && remote_terminal.tip_appears() {
// cursor is in the newly opened second pane
let mut content_to_send = String::new();
write!(&mut content_to_send, "{:0<56}", "line1 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line2 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line3 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line4 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line5 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line6 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line7 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line8 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line9 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line10 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line11 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line12 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line13 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line14 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line15 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line16 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line17 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line18 ").unwrap();
write!(&mut content_to_send, "{:0<58}", "line19 ").unwrap();
write!(&mut content_to_send, "{:0<57}", "line20 ").unwrap();

remote_terminal.send_key(&BRACKETED_PASTE_START);
remote_terminal.send_key(content_to_send.as_bytes());
remote_terminal.send_key(&BRACKETED_PASTE_END);

remote_terminal.load_fixture("e2e/scrolling_inside_a_pane");
step_is_complete = true;
}
step_is_complete
Expand All @@ -264,7 +238,9 @@ pub fn scrolling_inside_a_pane() {
name: "Scroll up inside pane",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(118, 20) {
if remote_terminal.cursor_position_is(63, 20)
&& remote_terminal.snapshot_contains("line21")
{
// all lines have been written to the pane
remote_terminal.send_key(&SCROLL_MODE);
remote_terminal.send_key(&SCROLL_UP_IN_SCROLL_MODE);
Expand All @@ -278,10 +254,11 @@ pub fn scrolling_inside_a_pane() {
name: "Wait for scroll to finish",
instruction: |remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(118, 20)
&& remote_terminal.snapshot_contains("line1 ")
if remote_terminal.cursor_position_is(63, 20)
&& remote_terminal.snapshot_contains("line3 ")
&& remote_terminal.snapshot_contains("SCROLL: 1/4")
{
// scrolled up one line
// keyboard scrolls up 1 line, scrollback is 4 lines: cat command + 2 extra lines from fixture + prompt
step_is_complete = true;
}
step_is_complete
Expand Down Expand Up @@ -1076,7 +1053,6 @@ pub fn scrolling_inside_a_pane_with_mouse() {
let last_snapshot = loop {
RemoteRunner::kill_running_sessions(fake_win_size);
let mut runner = RemoteRunner::new(fake_win_size)
.retry_pause_ms(1000) // we need a longer retry period here because it takes some time to fill the pty buffer
.add_step(Step {
name: "Split pane to the right",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
Expand All @@ -1096,27 +1072,7 @@ pub fn scrolling_inside_a_pane_with_mouse() {
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(63, 2) && remote_terminal.tip_appears() {
// cursor is in the newly opened second pane
remote_terminal.send_key(format!("{:0<56}", "line1 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line2 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line3 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line4 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line5 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line6 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line7 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line8 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line9 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line10 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line11 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line12 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line13 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line14 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line15 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line16 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line17 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line18 ").as_bytes());
remote_terminal.send_key(format!("{:0<58}", "line19 ").as_bytes());
remote_terminal.send_key(format!("{:0<57}", "line20 ").as_bytes());
remote_terminal.load_fixture("e2e/scrolling_inside_a_pane");
step_is_complete = true;
}
step_is_complete
Expand All @@ -1126,7 +1082,9 @@ pub fn scrolling_inside_a_pane_with_mouse() {
name: "Scroll up inside pane",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(118, 20) {
if remote_terminal.cursor_position_is(63, 20)
&& remote_terminal.snapshot_contains("line21")
{
// all lines have been written to the pane
remote_terminal.send_key(&sgr_mouse_report(Position::new(2, 64), 64));
step_is_complete = true;
Expand All @@ -1139,10 +1097,11 @@ pub fn scrolling_inside_a_pane_with_mouse() {
name: "Wait for scroll to finish",
instruction: |remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.cursor_position_is(118, 20)
if remote_terminal.cursor_position_is(63, 20)
&& remote_terminal.snapshot_contains("line1 ")
&& remote_terminal.snapshot_contains("SCROLL: 3/4")
{
// scrolled up one line
// mouse wheel scrolls up 3 lines, scrollback is 4 lines: cat command + 2 extra lines from fixture + prompt
step_is_complete = true;
}
step_is_complete
Expand Down
9 changes: 9 additions & 0 deletions src/tests/e2e/remote_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ZELLIJ_EXECUTABLE_LOCATION: &str = "/usr/src/zellij/x86_64-unknown-linux-m
const SET_ENV_VARIABLES: &str = "EDITOR=/usr/bin/vi";
const ZELLIJ_LAYOUT_PATH: &str = "/usr/src/zellij/fixtures/layouts";
const ZELLIJ_DATA_DIR: &str = "/usr/src/zellij/e2e-data";
const ZELLIJ_FIXTURE_PATH: &str = "/usr/src/zellij/fixtures";
const CONNECTION_STRING: &str = "127.0.0.1:2222";
const CONNECTION_USERNAME: &str = "test";
const CONNECTION_PASSWORD: &str = "test";
Expand Down Expand Up @@ -323,6 +324,13 @@ impl RemoteTerminal {
.unwrap();
channel.flush().unwrap();
}
pub fn load_fixture(&mut self, name: &str) {
let mut channel = self.channel.lock().unwrap();
channel
.write_all(format!("cat {ZELLIJ_FIXTURE_PATH}/{name}\n").as_bytes())
.unwrap();
channel.flush().unwrap();
}
}

#[derive(Clone)]
Expand Down Expand Up @@ -568,6 +576,7 @@ impl RemoteRunner {
self.panic_on_no_retries_left = false;
self
}
#[allow(unused)]
pub fn retry_pause_ms(mut self, retry_pause_ms: usize) -> Self {
self.retry_pause_ms = retry_pause_ms;
self
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 295
assertion_line: 276
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────── SCROLL: 1/1
│$ ││$ line1 00000000000000000000000000000000000000000000000000
│ ││line2 0000000000000000000000000000000000000000000000000000
│ ││line3 0000000000000000000000000000000000000000000000000000
│ ││line4 0000000000000000000000000000000000000000000000000000
│ ││line5 0000000000000000000000000000000000000000000000000000
│ ││line6 0000000000000000000000000000000000000000000000000000
│ ││line7 0000000000000000000000000000000000000000000000000000
│ ││line8 0000000000000000000000000000000000000000000000000000
│ ││line9 0000000000000000000000000000000000000000000000000000
│ ││line10 000000000000000000000000000000000000000000000000000
│ ││line11 000000000000000000000000000000000000000000000000000
│ ││line12 000000000000000000000000000000000000000000000000000
│ ││line13 000000000000000000000000000000000000000000000000000
│ ││line14 000000000000000000000000000000000000000000000000000
│ ││line15 000000000000000000000000000000000000000000000000000
│ ││line16 000000000000000000000000000000000000000000000000000
│ ││line17 000000000000000000000000000000000000000000000000000
│ ││line18 000000000000000000000000000000000000000000000000000
│ ││line19 00000000000000000000000000000000000000000000000000█
┌ Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────── SCROLL: 1/4
│$ ││line3
│ ││line4
│ ││line5
│ ││line6
│ ││line7
│ ││line8
│ ││line9
│ ││line10
│ ││line11
│ ││line12
│ ││line13
│ ││line14
│ ││line15
│ ││line16
│ ││line17
│ ││line18
│ ││line19
│ ││line20
│ ││li█e21
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SCROLL  <o> SESSION  <q> QUIT 
<↓↑> Scroll / <PgDn/PgUp> Scroll / <d/u> Scroll / <e> Edit / <ENTER> Select pane
Loading