Skip to content

Commit 03e584a

Browse files
committed
test: verify submitted lines remain in scrollback without mouse capture
1 parent ab51f23 commit 03e584a

3 files changed

Lines changed: 102 additions & 3 deletions

File tree

‎tests/readline/src/readline_fixture.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ use readline_example::Readline;
66

77
#[tokio::main]
88
async fn main() -> anyhow::Result<()> {
9+
let mut modes = TerminalModes::RAW_MODE | TerminalModes::HIDDEN_CURSOR;
10+
if !std::env::args().skip(1).any(|arg| arg == "--no-mouse") {
11+
modes |= TerminalModes::MOUSE_CAPTURE;
12+
}
13+
914
loop {
1015
let result = {
11-
let modes = TerminalModes::RAW_MODE
12-
| TerminalModes::HIDDEN_CURSOR
13-
| TerminalModes::MOUSE_CAPTURE;
1416
let _terminal_session = TerminalSession::try_new(modes)?;
1517
Readline::default().run().await
1618
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Scenario "mouse_disabled_submitted_lines_remain_in_scrollback"
2+
Command "CARGO_BIN_EXE_readline-fixture"
3+
Arg "--no-mouse"
4+
Terminal rows 4 cols 24
5+
Cursor row 4 col 1
6+
7+
Step "start with mouse capture disabled"
8+
WaitFrontendLineStartsWith "❯❯" timeout 1000ms
9+
Settle 0ms
10+
Expect:
11+
r00 |························|
12+
r01 |························|
13+
r02 |························|
14+
r03 |❯❯······················|
15+
16+
Step "submit line 1 and display its result"
17+
Input "01-aaaaaaaaa"
18+
Input enter
19+
Settle 100ms
20+
Expect:
21+
r00 |························|
22+
r01 |❯❯·01-aaaaaaaaa·········|
23+
r02 |result:·"01-aaaaaaaaa"··|
24+
r03 |❯❯······················|
25+
26+
Step "submit line 2 and display its result"
27+
Input "02-bbbbbbbbb"
28+
Input enter
29+
Settle 100ms
30+
Expect:
31+
r00 |result:·"01-aaaaaaaaa"··|
32+
r01 |❯❯·02-bbbbbbbbb·········|
33+
r02 |result:·"02-bbbbbbbbb"··|
34+
r03 |❯❯······················|
35+
36+
Step "submit line 3 and display its result"
37+
Input "03-ccccccccc"
38+
Input enter
39+
Settle 100ms
40+
Expect:
41+
r00 |result:·"02-bbbbbbbbb"··|
42+
r01 |❯❯·03-ccccccccc·········|
43+
r02 |result:·"03-ccccccccc"··|
44+
r03 |❯❯······················|
45+
46+
Step "submit line 4 and display its result"
47+
Input "04-ddddddddd"
48+
Input enter
49+
Settle 100ms
50+
Expect:
51+
r00 |result:·"03-ccccccccc"··|
52+
r01 |❯❯·04-ddddddddd·········|
53+
r02 |result:·"04-ddddddddd"··|
54+
r03 |❯❯······················|
55+
56+
Step "scroll back to the first two submitted lines and their results"
57+
Scroll up 5
58+
Settle 0ms
59+
Expect:
60+
r00 |❯❯·01-aaaaaaaaa·········|
61+
r01 |result:·"01-aaaaaaaaa"··|
62+
r02 |❯❯·02-bbbbbbbbb·········|
63+
r03 |result:·"02-bbbbbbbbb"··|
64+
65+
Step "read the next submitted line without missing or duplicated rows"
66+
Scroll down 2
67+
Settle 0ms
68+
Expect:
69+
r00 |❯❯·02-bbbbbbbbb·········|
70+
r01 |result:·"02-bbbbbbbbb"··|
71+
r02 |❯❯·03-ccccccccc·········|
72+
r03 |result:·"03-ccccccccc"··|
73+
74+
Step "read the last submitted line and its result"
75+
Scroll down 2
76+
Settle 0ms
77+
Expect:
78+
r00 |❯❯·03-ccccccccc·········|
79+
r01 |result:·"03-ccccccccc"··|
80+
r02 |❯❯·04-ddddddddd·········|
81+
r03 |result:·"04-ddddddddd"··|
82+
83+
Step "return to the current empty prompt"
84+
Scroll down 1
85+
Settle 0ms
86+
Expect:
87+
r00 |result:·"03-ccccccccc"··|
88+
r01 |❯❯·04-ddddddddd·········|
89+
r02 |result:·"04-ddddddddd"··|
90+
r03 |❯❯······················|

‎tests/readline/tests/terminal_scenarios.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ fn tiny_viewport_overflow_wrap_scroll() -> Result<()> {
3131
))
3232
}
3333

34+
#[test]
35+
fn mouse_disabled_submitted_lines_remain_in_scrollback() -> Result<()> {
36+
run(include_str!(
37+
"scenarios/mouse_disabled_submitted_lines_remain_in_scrollback.th"
38+
))
39+
}
40+
3441
fn run(document: &str) -> Result<()> {
3542
scenario::run_document(document)?;
3643
Ok(())

0 commit comments

Comments
 (0)