106 {
107 final InputDevice
device = mock(InputDevice.class);
108 when(
device.isVirtual()).thenReturn(
false);
109 when(
device.getName()).thenReturn(
"keyboard");
110 ShadowInputDevice.sDeviceIds = new int[] {0};
111 ShadowInputDevice.addDevice(0,
device);
112
113 keyEvent =
new FakeKeyEvent(KeyEvent.ACTION_UP, 65);
114 KeyEventChannel.FlutterKeyEvent flutterKeyEvent =
115 new KeyEventChannel.FlutterKeyEvent(
keyEvent,
null);
117 flutterKeyEvent,
118 false,
119 (isHandled) -> {
121 });
122
123 ArgumentCaptor<ByteBuffer> byteBufferArgumentCaptor = ArgumentCaptor.forClass(ByteBuffer.class);
124 ArgumentCaptor<BinaryMessenger.BinaryReply> replyArgumentCaptor =
125 ArgumentCaptor.forClass(BinaryMessenger.BinaryReply.class);
127 .send(
any(), byteBufferArgumentCaptor.capture(), replyArgumentCaptor.capture());
128 ByteBuffer capturedMessage = byteBufferArgumentCaptor.getValue();
129 capturedMessage.rewind();
130 JSONObject
message = (JSONObject) JSONMessageCodec.INSTANCE.decodeMessage(capturedMessage);
132 assertEquals(
"keydown",
message.get(
"type"));
133
134
135 sendReply(true, replyArgumentCaptor.getValue());
137 }