Graphics: Fix deletion of images by id not working for images with no placements

This commit is contained in:
Kovid Goyal
2024-12-24 09:39:01 +05:30
parent 6103224a7d
commit 24a195c7c7
3 changed files with 32 additions and 2 deletions

View File

@@ -137,10 +137,11 @@ def put_helpers(self, cw, ch, cols=10, lines=5):
iid += 1
imgid = kw.pop('id', None) or iid
no_id = kw.pop('no_id', False)
a = kw.pop('a', 'T')
if no_id:
cmd = 'a=T,f=24,s=%d,v=%d,%s' % (w, h, put_cmd(**kw))
cmd = f'a={a},f=24,s=%d,v=%d,%s' % (w, h, put_cmd(**kw))
else:
cmd = 'a=T,f=24,i=%d,s=%d,v=%d,%s' % (imgid, w, h, put_cmd(**kw))
cmd = f'a={a},f=24,i=%d,s=%d,v=%d,%s' % (imgid, w, h, put_cmd(**kw))
data = b'x' * w * h * 3
res = send_command(screen, cmd, data)
return imgid, parse_response(res)
@@ -1051,6 +1052,16 @@ class TestGraphics(BaseTest):
cmd += ',' + ','.join(f'{k}={v}' for k, v in kw.items())
send_command(s, cmd)
iid = put_image(s, cw, ch, a='t')[0]
self.ae(s.grman.image_count, 1)
delete('I', i=iid)
self.ae(s.grman.image_count, 0)
iid1 = put_image(s, cw, ch, a='t')[0]
iid2 = put_image(s, cw, ch, a='t')[0]
self.ae(s.grman.image_count, 2)
delete('R', x=iid1, y=iid2)
self.ae(s.grman.image_count, 0)
put_image(s, cw, ch)
delete()
self.ae(s.grman.image_count, 1)