"""Exercise stamped input across the real worker process boundary.""" from pathlib import Path import select import shutil import sys import tempfile import time import unittest from types import SimpleNamespace SHELL=Path(__file__).resolve().parents[1]/'shell' sys.path.insert(0,str(SHELL)) from pointer_events import PointerEvent,SourceStamp from pointer_trace import PointerTrace from touch_process import ProcessTouchSource from runtime_codec import unpack class TouchWorkerTests(unittest.TestCase): def test_stamped_press_move_release_cross_worker(self): with tempfile.TemporaryDirectory() as directory: root=Path(directory) shutil.copyfile(SHELL/'pointer_events.py',root/'pointer_events.py') (root/'touch_evdev.py').write_text('''import os from pointer_events import PointerEvent,SourceStamp class TouchSource: def __init__(self,*args): self.r,self.w=os.pipe();os.write(self.w,b"x") def fileno(self):return self.r def drain(self): os.read(self.r,1) return [PointerEvent(("mouse",b,x,4,r),stamp=SourceStamp(100+i,"fixture")) for i,(b,x,r) in enumerate(((0,3,False),(32,4,False),(0,4,True)))] def diagnostics(self):return {} def close(self):os.close(self.r);os.close(self.w) ''') source=ProcessTouchSource('fixture','fixture',{},100,30,_source_root=root) events=[];deadline=time.monotonic()+20 try: while len(events)<3 and time.monotonic()