Expand shared Sprinter MCP with managed launch, raw reads and key input
This commit is contained in:
@@ -22,6 +22,7 @@ class DummyBridge:
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
self.state = 'stopped'
|
||||
self.generation = 1
|
||||
def close(self): pass
|
||||
def request(self, command, **arguments):
|
||||
self.calls.append((command, arguments))
|
||||
@@ -189,8 +190,26 @@ class ServerTests(unittest.TestCase):
|
||||
try:
|
||||
status = rpc_call(server.path, 'status')
|
||||
self.assertEqual(status['build_id'], 'test')
|
||||
events = rpc_call(server.path, 'events', {'after': 0})
|
||||
identity = {'session_id': status['session_id'],
|
||||
'build_id': status['build_id']}
|
||||
events = rpc_call(server.path, 'events', {'after': 0}, **identity)
|
||||
self.assertEqual(events['events'][0]['event'], 'stopped')
|
||||
with self.assertRaisesRegex(SessionError, 'Устаревшая RPC-сессия'):
|
||||
rpc_call(server.path, 'events', {'after': 0})
|
||||
with self.assertRaisesRegex(SessionError, 'Устаревшая RPC-сессия'):
|
||||
rpc_call(server.path, 'events', {'after': 0},
|
||||
session_id='old', build_id=status['build_id'])
|
||||
with self.assertRaisesRegex(SessionError, 'Устаревшая RPC-сессия'):
|
||||
rpc_call(server.path, 'events', {'after': 0},
|
||||
session_id=status['session_id'], build_id='old-build')
|
||||
with self.assertRaisesRegex(SessionError, 'Устаревшая generation'):
|
||||
rpc_call(server.path, 'break_line',
|
||||
{'file': '/src/main.c', 'line': 3},
|
||||
generation=0, **identity)
|
||||
point = rpc_call(server.path, 'break_line',
|
||||
{'file': '/src/main.c', 'line': 3},
|
||||
generation=status['generation'], **identity)
|
||||
self.assertEqual(point['id'], 1)
|
||||
with self.assertRaisesRegex(SessionError, 'Неизвестный'):
|
||||
rpc_call(server.path, 'unknown')
|
||||
finally:
|
||||
@@ -290,6 +309,21 @@ class ServerTests(unittest.TestCase):
|
||||
finally:
|
||||
controller.close()
|
||||
|
||||
def test_screen_and_share_reads_reject_oversized_requests(self):
|
||||
controller = SessionController(DummySession())
|
||||
try:
|
||||
with self.assertRaisesRegex(SessionError, 'длина 1..4096'):
|
||||
controller.call('read_share', {'tag': ':vram', 'address': 0,
|
||||
'length': 4097})
|
||||
with self.assertRaisesRegex(SessionError, 'точный tag'):
|
||||
controller.call('read_share', {'tag': '', 'address': 0,
|
||||
'length': 1})
|
||||
with self.assertRaisesRegex(SessionError, '8192 пикселей'):
|
||||
controller.call('read_screen_pixels', {'x': 0, 'y': 0,
|
||||
'width': 128, 'height': 128})
|
||||
finally:
|
||||
controller.close()
|
||||
|
||||
def test_idle_snapshot_detects_invalidation(self):
|
||||
session = DummySession()
|
||||
controller = SessionController(session)
|
||||
|
||||
Reference in New Issue
Block a user