Also test changing of title when running command

This commit is contained in:
Kovid Goyal 2022-02-21 20:44:10 +05:30
parent 261057396c
commit da5e37620e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 11 additions and 8 deletions

View File

@ -31,7 +31,7 @@ class Callbacks:
self.wtcbuf += data self.wtcbuf += data
def title_changed(self, data) -> None: def title_changed(self, data) -> None:
self.titlebuf += data self.titlebuf.append(data)
def icon_changed(self, data) -> None: def icon_changed(self, data) -> None:
self.iconbuf += data self.iconbuf += data
@ -61,7 +61,8 @@ class Callbacks:
def clear(self) -> None: def clear(self) -> None:
self.wtcbuf = b'' self.wtcbuf = b''
self.iconbuf = self.titlebuf = self.colorbuf = self.ctbuf = '' self.iconbuf = self.colorbuf = self.ctbuf = ''
self.titlebuf = []
self.iutf8 = True self.iutf8 = True
self.notifications = [] self.notifications = []
self.open_urls = [] self.open_urls = []

View File

@ -213,18 +213,18 @@ class TestParser(BaseTest):
c = s.callbacks c = s.callbacks
pb('a\033]2;x\\ryz\x9cbcde', 'a', ('set_title', 'x\\ryz'), 'bcde') pb('a\033]2;x\\ryz\x9cbcde', 'a', ('set_title', 'x\\ryz'), 'bcde')
self.ae(str(s.line(0)), 'abcde') self.ae(str(s.line(0)), 'abcde')
self.ae(c.titlebuf, 'x\\ryz') self.ae(c.titlebuf, ['x\\ryz'])
c.clear() c.clear()
pb('\033]\x07', ('set_title', ''), ('set_icon', '')) pb('\033]\x07', ('set_title', ''), ('set_icon', ''))
self.ae(c.titlebuf, ''), self.ae(c.iconbuf, '') self.ae(c.titlebuf, ['']), self.ae(c.iconbuf, '')
pb('\033]ab\x07', ('set_title', 'ab'), ('set_icon', 'ab')) pb('\033]ab\x07', ('set_title', 'ab'), ('set_icon', 'ab'))
self.ae(c.titlebuf, 'ab'), self.ae(c.iconbuf, 'ab') self.ae(c.titlebuf, ['', 'ab']), self.ae(c.iconbuf, 'ab')
c.clear() c.clear()
pb('\033]2;;;;\x07', ('set_title', ';;;')) pb('\033]2;;;;\x07', ('set_title', ';;;'))
self.ae(c.titlebuf, ';;;') self.ae(c.titlebuf, [';;;'])
c.clear() c.clear()
pb('\033]2;\x07', ('set_title', '')) pb('\033]2;\x07', ('set_title', ''))
self.ae(c.titlebuf, '') self.ae(c.titlebuf, [''])
pb('\033]110\x07', ('set_dynamic_color', 110, '')) pb('\033]110\x07', ('set_dynamic_color', 110, ''))
self.ae(c.colorbuf, '') self.ae(c.colorbuf, '')
c.clear() c.clear()

View File

@ -67,8 +67,10 @@ RPS1="{rps1}"
except TimeoutError: except TimeoutError:
raise AssertionError(f'Cursor was not changed to beam. Screen contents: {repr(pty.screen_contents())}') raise AssertionError(f'Cursor was not changed to beam. Screen contents: {repr(pty.screen_contents())}')
self.ae(pty.screen_contents(), q) self.ae(pty.screen_contents(), q)
self.ae(pty.callbacks.titlebuf, '~') self.ae(pty.callbacks.titlebuf, ['~'])
pty.callbacks.clear()
pty.send_cmd_to_child('mkdir test && ls -a') pty.send_cmd_to_child('mkdir test && ls -a')
pty.wait_till(lambda: pty.screen_contents().count(ps1) == 2) pty.wait_till(lambda: pty.screen_contents().count(ps1) == 2)
self.ae(pty.callbacks.titlebuf, ['mkdir test && ls -a', '~'])
q = '\n'.join(str(pty.screen.line(i)) for i in range(1, pty.screen.cursor.y)) q = '\n'.join(str(pty.screen.line(i)) for i in range(1, pty.screen.cursor.y))
self.ae(pty.last_cmd_output(), q) self.ae(pty.last_cmd_output(), q)