Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Package Attributes | List of all members
io.flutter.embedding.engine.systemchannels.KeyEventChannelTest Class Reference

Classes

class  ShadowInputDevice
 

Public Member Functions

void setUp ()
 
void tearDown ()
 
void keyDownEventIsSentToFramework () throws JSONException
 
void keyUpEventIsSentToFramework () throws JSONException
 

Package Attributes

KeyEvent keyEvent
 
BinaryMessenger fakeMessenger
 
boolean[] handled
 
KeyEventChannel keyEventChannel
 

Detailed Description

Definition at line 40 of file KeyEventChannelTest.java.

Member Function Documentation

◆ keyDownEventIsSentToFramework()

void io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.keyDownEventIsSentToFramework ( ) throws JSONException
inline

Definition at line 72 of file KeyEventChannelTest.java.

72 {
73 final InputDevice device = mock(InputDevice.class);
74 when(device.isVirtual()).thenReturn(false);
75 when(device.getName()).thenReturn("keyboard");
76 ShadowInputDevice.sDeviceIds = new int[] {0};
77 ShadowInputDevice.addDevice(0, device);
78
79 KeyEventChannel.FlutterKeyEvent flutterKeyEvent =
80 new KeyEventChannel.FlutterKeyEvent(keyEvent, null);
82 flutterKeyEvent,
83 false,
84 (isHandled) -> {
85 handled[0] = isHandled;
86 });
87
88 ArgumentCaptor<ByteBuffer> byteBufferArgumentCaptor = ArgumentCaptor.forClass(ByteBuffer.class);
89 ArgumentCaptor<BinaryMessenger.BinaryReply> replyArgumentCaptor =
90 ArgumentCaptor.forClass(BinaryMessenger.BinaryReply.class);
91 verify(fakeMessenger, times(1))
92 .send(any(), byteBufferArgumentCaptor.capture(), replyArgumentCaptor.capture());
93 ByteBuffer capturedMessage = byteBufferArgumentCaptor.getValue();
94 capturedMessage.rewind();
95 JSONObject message = (JSONObject) JSONMessageCodec.INSTANCE.decodeMessage(capturedMessage);
96 assertNotNull(message);
97 assertEquals("keydown", message.get("type"));
98
99 // Simulate a reply, and see that it is handled.
100 sendReply(true, replyArgumentCaptor.getValue());
101 assertTrue(handled[0]);
102 }
static SkISize times(const SkISize &size, float factor)
void sendFlutterKeyEvent( @NonNull FlutterKeyEvent keyEvent, boolean isKeyUp, @NonNull EventResponseHandler responseHandler)
VkDevice device
Definition: main.cc:53
Win32Message message
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530

◆ keyUpEventIsSentToFramework()

void io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.keyUpEventIsSentToFramework ( ) throws JSONException
inline

Definition at line 106 of file KeyEventChannelTest.java.

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) -> {
120 handled[0] = isHandled;
121 });
122
123 ArgumentCaptor<ByteBuffer> byteBufferArgumentCaptor = ArgumentCaptor.forClass(ByteBuffer.class);
124 ArgumentCaptor<BinaryMessenger.BinaryReply> replyArgumentCaptor =
125 ArgumentCaptor.forClass(BinaryMessenger.BinaryReply.class);
126 verify(fakeMessenger, times(1))
127 .send(any(), byteBufferArgumentCaptor.capture(), replyArgumentCaptor.capture());
128 ByteBuffer capturedMessage = byteBufferArgumentCaptor.getValue();
129 capturedMessage.rewind();
130 JSONObject message = (JSONObject) JSONMessageCodec.INSTANCE.decodeMessage(capturedMessage);
131 assertNotNull(message);
132 assertEquals("keydown", message.get("type"));
133
134 // Simulate a reply, and see that it is handled.
135 sendReply(true, replyArgumentCaptor.getValue());
136 assertTrue(handled[0]);
137 }

◆ setUp()

void io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.setUp ( )
inline

Definition at line 58 of file KeyEventChannelTest.java.

58 {
59 MockitoAnnotations.openMocks(this);
60 keyEvent = new FakeKeyEvent(KeyEvent.ACTION_DOWN, 65);
61 handled = new boolean[] {false};
62 keyEventChannel = new KeyEventChannel(fakeMessenger);
63 }

◆ tearDown()

void io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.tearDown ( )
inline

Definition at line 66 of file KeyEventChannelTest.java.

66 {
67 ShadowInputDevice.reset();
68 }

Member Data Documentation

◆ fakeMessenger

BinaryMessenger io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.fakeMessenger
package

Definition at line 43 of file KeyEventChannelTest.java.

◆ handled

boolean [] io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.handled
package

Definition at line 44 of file KeyEventChannelTest.java.

◆ keyEvent

KeyEvent io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.keyEvent
package

Definition at line 42 of file KeyEventChannelTest.java.

◆ keyEventChannel

KeyEventChannel io.flutter.embedding.engine.systemchannels.KeyEventChannelTest.keyEventChannel
package

Definition at line 45 of file KeyEventChannelTest.java.


The documentation for this class was generated from the following file: