Bug fixes in -x, things should read better now.
This commit is contained in:
@@ -39,6 +39,29 @@ def test_private_sgr_sequence_from_fullscreen_apps_does_not_crash():
|
||||
assert screen["text"].splitlines()[0] == "X "
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_dcs_terminal_queries_do_not_render_as_text():
|
||||
terminal = Terminal(20, 3, DummyProcessInput())
|
||||
|
||||
terminal.feed(b"\x1bP+q6b32\x1b\\X")
|
||||
screen = terminal.get_screen_content()
|
||||
|
||||
assert screen["text"].splitlines()[0] == "X "
|
||||
assert "+q6b32" not in screen["text"]
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_split_dcs_terminal_query_does_not_render_as_text():
|
||||
terminal = Terminal(20, 3, DummyProcessInput())
|
||||
|
||||
terminal.feed(b"\x1bP+q6")
|
||||
terminal.feed(b"b32\x1b\\X")
|
||||
screen = terminal.get_screen_content()
|
||||
|
||||
assert screen["text"].splitlines()[0] == "X "
|
||||
assert "+q6b32" not in screen["text"]
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_optional_float_setting_uses_default_when_missing():
|
||||
settings_manager = type(
|
||||
@@ -79,6 +102,35 @@ def test_pty_stdin_input_interrupts_output_when_all_keys_interrupt_enabled():
|
||||
output_manager.interrupt_output.assert_called_once_with()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize(
|
||||
"sequence",
|
||||
[
|
||||
b"\x1b[12;40R",
|
||||
b"\x1b[?1;2c",
|
||||
b"\x1b[>85;95;0c",
|
||||
b"\x1b[4;80;24t",
|
||||
b"\x1b]10;rgb:ffff/ffff/ffff\x1b\\",
|
||||
],
|
||||
)
|
||||
def test_pty_terminal_response_stdin_does_not_interrupt_output(sequence):
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
settings_manager.get_setting.return_value = ""
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"runtime": {
|
||||
"SettingsManager": settings_manager,
|
||||
"OutputManager": output_manager,
|
||||
}
|
||||
}
|
||||
|
||||
pty_driver.interrupt_output_on_stdin_input(sequence)
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_input_interrupt_does_not_block_input_injection():
|
||||
pty_driver = PtyDriver()
|
||||
@@ -160,6 +212,325 @@ def test_pty_plain_stdin_does_not_record_tab_keypress():
|
||||
pty_driver.inject_text_to_screen.assert_called_once_with(b"a")
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_consumes_fenrir_shortcut_input():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, ["KEY_KP9"]]),
|
||||
get_command_for_shortcut=Mock(return_value="REVIEW_NEXT_LINE"),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": ["KEY_KP9"]},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b[6~", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_consumes_late_fenrir_shortcut_tail_after_release():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.last_fenrir_stdin_command_time = time.monotonic()
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b[6~", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_consumes_split_fenrir_shortcut_tail_after_release():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(
|
||||
side_effect=[
|
||||
[1, ["KEY_KP7"]],
|
||||
[1, []],
|
||||
]
|
||||
),
|
||||
get_command_for_shortcut=Mock(
|
||||
side_effect=[
|
||||
"REVIEW_PREV_LINE",
|
||||
"",
|
||||
]
|
||||
),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": ["KEY_KP7"]},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b", Mock())
|
||||
pty_driver.env["input"]["curr_input"] = []
|
||||
pty_driver.handle_stdin_input(b"[H", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_consumes_split_ss3_fenrir_shortcut_tail_after_release():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(
|
||||
side_effect=[
|
||||
[1, ["KEY_KP7"]],
|
||||
[1, []],
|
||||
[1, []],
|
||||
]
|
||||
),
|
||||
get_command_for_shortcut=Mock(
|
||||
side_effect=[
|
||||
"REVIEW_PREV_LINE",
|
||||
"",
|
||||
"",
|
||||
]
|
||||
),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": ["KEY_KP7"]},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b", Mock())
|
||||
pty_driver.env["input"]["curr_input"] = []
|
||||
pty_driver.handle_stdin_input(b"O", Mock())
|
||||
pty_driver.handle_stdin_input(b"w", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_does_not_consume_printable_input_after_fenrir_shortcut():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = False
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.last_fenrir_stdin_command_time = time.monotonic()
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"a", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_called_once_with(b"a")
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_does_not_consume_stale_fenrir_shortcut_tail():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = False
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.last_fenrir_stdin_command_time = (
|
||||
time.monotonic()
|
||||
- PTYConstants.FENRIR_SHORTCUT_STDIN_TAIL_TIMEOUT
|
||||
- 0.1
|
||||
)
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b[6~", Mock())
|
||||
|
||||
pty_driver.inject_text_to_screen.assert_called_once_with(b"\x1b[6~")
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_consumes_late_tail_after_recent_review_command():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"commandInfo": {
|
||||
"lastCommand": "REVIEW_NEXT_LINE",
|
||||
"lastCommandSection": "commands",
|
||||
"lastCommandRunTime": time.time(),
|
||||
},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b[6~", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize("sequence", [b"[H", b"[1~", b"Ow"])
|
||||
def test_pty_stdin_consumes_split_tail_after_recent_review_command(sequence):
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"commandInfo": {
|
||||
"lastCommand": "REVIEW_NEXT_LINE",
|
||||
"lastCommandSection": "commands",
|
||||
"lastCommandRunTime": time.time(),
|
||||
},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(sequence, Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_consumes_lone_escape_after_recent_review_command():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = True
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
output_manager = Mock()
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"commandInfo": {
|
||||
"lastCommand": "REVIEW_CURR_LINE",
|
||||
"lastCommandSection": "commands",
|
||||
"lastCommandRunTime": time.time(),
|
||||
},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"OutputManager": output_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b", Mock())
|
||||
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
pty_driver.inject_text_to_screen.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_stdin_does_not_consume_late_tail_after_non_review_command():
|
||||
pty_driver = PtyDriver()
|
||||
settings_manager = Mock()
|
||||
settings_manager.get_setting_as_bool.return_value = False
|
||||
input_manager = Mock(
|
||||
get_curr_shortcut=Mock(return_value=[1, []]),
|
||||
get_command_for_shortcut=Mock(return_value=""),
|
||||
)
|
||||
pty_driver.env = {
|
||||
"input": {"curr_input": []},
|
||||
"commandInfo": {
|
||||
"lastCommand": "CURSOR_POSITION",
|
||||
"lastCommandSection": "commands",
|
||||
"lastCommandRunTime": time.time(),
|
||||
},
|
||||
"runtime": {
|
||||
"DebugManager": Mock(write_debug_out=Mock()),
|
||||
"InputManager": input_manager,
|
||||
"SettingsManager": settings_manager,
|
||||
},
|
||||
}
|
||||
pty_driver.inject_text_to_screen = Mock()
|
||||
|
||||
pty_driver.handle_stdin_input(b"\x1b[6~", Mock())
|
||||
|
||||
pty_driver.inject_text_to_screen.assert_called_once_with(b"\x1b[6~")
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize(
|
||||
("sequence", "key_name"),
|
||||
@@ -281,6 +652,22 @@ def test_pty_stdin_input_leaves_filtered_interrupts_to_key_events():
|
||||
output_manager.interrupt_output.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_terminal_attributes_use_fenrir_attribute_shape():
|
||||
terminal = Terminal(10, 2, DummyProcessInput())
|
||||
|
||||
terminal.feed(b"plain\r\n\x1b[7mfocus\x1b[0m")
|
||||
screen_content = terminal.get_screen_content()
|
||||
|
||||
plain_attribute = screen_content["attributes"][0][0]
|
||||
focused_attribute = screen_content["attributes"][1][0]
|
||||
assert len(plain_attribute) == 10
|
||||
assert len(focused_attribute) == 10
|
||||
assert plain_attribute[1] == "default"
|
||||
assert focused_attribute[1] == "reverse"
|
||||
assert focused_attribute[6] is True
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pty_backspace_with_fenrir_key_synthesizes_shortcut_events():
|
||||
pty_driver = PtyDriver()
|
||||
|
||||
Reference in New Issue
Block a user