diff options
Diffstat (limited to 'tests/mode.rs')
-rw-r--r-- | tests/mode.rs | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/tests/mode.rs b/tests/mode.rs new file mode 100644 index 0000000..19658b2 --- /dev/null +++ b/tests/mode.rs @@ -0,0 +1,209 @@ +extern crate vt100; + +mod support; +use support::TestHelpers; + +#[test] +fn modes() { + let mut screen = vt100::Screen::new(24, 80); + assert!(!screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1h"); + + assert!(!screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?9h"); + + assert!(!screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?25l"); + + assert!(screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1000h"); + + assert!(screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1002h"); + + assert!(screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1006h"); + + assert!(screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?2004h"); + + assert!(screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b="); + + assert!(screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1l"); + + assert!(screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?9l"); + + assert!(screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?25h"); + + assert!(!screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1000l"); + + assert!(!screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1002l"); + + assert!(!screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?1006l"); + + assert!(!screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(screen.bracketed_paste()); + + screen.assert_process(b"\x1b[?2004l"); + + assert!(!screen.hide_cursor()); + assert!(screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); + + screen.assert_process(b"\x1b>"); + + assert!(!screen.hide_cursor()); + assert!(!screen.application_keypad()); + assert!(!screen.application_cursor()); + assert!(!screen.mouse_reporting_press()); + assert!(!screen.mouse_reporting_press_release()); + assert!(!screen.mouse_reporting_button_motion()); + assert!(!screen.mouse_reporting_sgr_mode()); + assert!(!screen.bracketed_paste()); +} + +#[test] +fn alternate_buffer() { + let mut screen = vt100::Screen::new(24, 80); + screen.assert_process(b"\x1b[m\x1b[2J\x1b[H1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24"); + assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n"); + assert!(!screen.alternate_buffer_active()); + screen.assert_process(b"\x1b[?1049h"); + assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert!(screen.alternate_buffer_active()); + screen.assert_process(b"foobar"); + assert_eq!(screen.window_contents(0, 0, 23, 79), "foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + screen.assert_process(b"\x1b[?1049l"); + assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n"); + assert!(!screen.alternate_buffer_active()); +} |