Make dnd kitten testing infra a bit more robust

This commit is contained in:
Kovid Goyal 2026-04-19 21:00:09 +05:30
parent 0ddbffdf79
commit 36e8094afe
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 4 deletions

View file

@ -61,12 +61,13 @@ func run_loop(opts *Options, drop_dests map[string]drop_dest, drag_sources map[s
return err
}
send_test_response := func(payload string) {
in_test_mode = true
lp.DebugPrintln(payload)
}
render_screen := func() error {
lp.StartAtomicUpdate()
defer lp.EndAtomicUpdate()
if !in_test_mode {
lp.StartAtomicUpdate()
defer lp.EndAtomicUpdate()
}
lp.ClearScreen()
if allow_drags {
if drag_started {
@ -157,6 +158,9 @@ func run_loop(opts *Options, drop_dests map[string]drop_dest, drag_sources map[s
switch string(cmd.Payload) {
case "PING":
send_test_response("PONG")
case "SETUP":
in_test_mode = true
lp.NoRoundtripToTerminalOnExit()
default:
send_test_response("UNKNOWN TEST COMMAND: " + string(cmd.Payload))
}

View file

@ -5,7 +5,13 @@ import tempfile
from base64 import standard_b64encode
from kitty.constants import kitten_exe
from kitty.fast_data_types import DND_CODE, dnd_set_test_write_func, dnd_test_cleanup_fake_window, dnd_test_create_fake_window, dnd_test_probe_state
from kitty.fast_data_types import (
DND_CODE,
dnd_set_test_write_func,
dnd_test_cleanup_fake_window,
dnd_test_create_fake_window,
dnd_test_probe_state,
)
from . import PTY, BaseTest
from .dnd import WriteCapture
@ -28,6 +34,7 @@ class TestDnDKitten(BaseTest):
self.capture = capture
self.test_dir = self.enterContext(tempfile.TemporaryDirectory())
self.messages_from_kitten = ''
self.set_options({'tab_bar_style': 'hidden'})
def send_dnd_command_to_kitten(self, payload=b'', as_base64=False, flush=False, **metadata):
header = f'\x1b]{DND_CODE};'
@ -63,6 +70,7 @@ class TestDnDKitten(BaseTest):
self.assertEqual(remote_client, self.probe_state('drop_is_remote_client'))
if self.probe_state('drag_can_offer'):
self.assertEqual(remote_client, self.probe_state('drag_is_remote_client'))
self.send_dnd_command_to_kitten('SETUP', t='T')
def append(self, text):
self.messages_from_kitten += text