Exemplo n.º 1
0
async def hid(client: CompanionClient, event_iterator: AsyncIterable[HIDEvent]) -> None:
    async with client.stub.hid.open() as stream:
        grpc_event_iterator = (event_to_grpc(event) async for event in event_iterator)
        await drain_to_stream(
            stream=stream, generator=grpc_event_iterator, logger=client.logger
        )
        await stream.recv_message()
Exemplo n.º 2
0
 async def hid(self, event_iterator: AsyncIterable[HIDEvent]) -> None:
     async with self.get_stub() as stub, stub.hid.open() as stream:
         grpc_event_iterator = (event_to_grpc(event)
                                async for event in event_iterator)
         await drain_to_stream(stream=stream,
                               generator=grpc_event_iterator,
                               logger=self.logger)
         await stream.recv_message()
Exemplo n.º 3
0
 def test_swipe(self) -> None:
     deltas = [None, 5]
     for delta in deltas:
         self.assertEqual(
             event_to_grpc(
                 HIDSwipe(start=Point(x=1, y=2),
                          end=Point(x=3, y=4),
                          delta=delta)),
             GrpcHIDEvent(swipe=GrpcHIDSwipe(start=GrpcPoint(x=1, y=2),
                                             end=GrpcPoint(x=3, y=4),
                                             delta=delta)),
         )
Exemplo n.º 4
0
 def test_press(self) -> None:
     actions = [
         HIDTouch(point=Point(x=1, y=2)),
         HIDButton(button=HIDButtonType.HOME),
         HIDKey(keycode=3),
     ]
     expected = [
         GrpcHIDPressAction(touch=GrpcHIDTouch(point=GrpcPoint(x=1, y=2))),
         GrpcHIDPressAction(button=GrpcHIDButton(button=GrpcHIDEvent.HOME)),
         GrpcHIDPressAction(key=GrpcHIDKey(keycode=3)),
     ]
     for action, expected in zip(actions, expected):
         self.assertEqual(
             event_to_grpc(
                 HIDPress(action=action, direction=HIDDirection.UP)),
             GrpcHIDEvent(press=GrpcHIDPress(action=expected,
                                             direction=GrpcHIDEvent.UP)),
         )
Exemplo n.º 5
0
 def test_delay(self) -> None:
     self.assertEqual(
         event_to_grpc(HIDDelay(duration=1)),
         GrpcHIDEvent(delay=GrpcHIDDelay(duration=1)),
     )