| Flutter macOS Embedder |

Instance Methods | Properties | List of all members
KeyboardTester Class Reference
Inheritance diagram for KeyboardTester:

## Instance Methods
(nonnull instancetype) | - init
(void) | - respondEmbedderCallsWith:
(void) | - recordEmbedderCallsTo:
(void) | - recordEmbedderEventsTo:returning:
(void) | - respondChannelCallsWith:
(void) | - recordChannelCallsTo:
(void) | - respondTextInputWith:
(void) | - recordCallTypesTo:forTypes:
(id) | - lastKeyboardChannelResult
(void) | - sendKeyboardChannelMessage:
(void) | - handleEmbedderEvent:callback:userData:
(void) | - handleChannelMessage:message:binaryReply:
(BOOL) | - handleTextInputKeyEvent:

## Properties
FlutterKeyboardManager * | manager
NSResponder * | nextResponder

## Detailed Description

Definition at line 180 of file FlutterKeyboardManagerTest.mm.

## Method Documentation

## ◆ handleChannelMessage:message:binaryReply:

- (void) handleChannelMessage: |  | (NSString*) | channel
message: |  | (NSData* _Nullable) | message
binaryReply: |  | (FlutterBinaryReply _Nullable) | callback

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

375 :(NSString*)channel
376 message:(NSData* _Nullable)message
377 binaryReply:(FlutterBinaryReply _Nullable)callback {
378 if (_typeStorage != nil && (_typeStorageMask & kChannelCall) != 0) {
379 [_typeStorage addObject:@(kChannelCall)];
380 }
381 _channelHandler(^(BOOL handled) {
382 NSDictionary* result = @{
383 @"handled" : @(handled),
384 };
385 NSData* encodedKeyEvent = [[FlutterJSONMessageCodec sharedInstance] encode:result];
386 callback(encodedKeyEvent);
387 });
388 }
FlutterBinaryReply
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
_typeStorageMask
uint32_t _typeStorageMask
Definition: FlutterKeyboardManagerTest.mm:241
_channelHandler
AsyncKeyCallbackHandler _channelHandler
Definition: FlutterKeyboardManagerTest.mm:235
_typeStorage
NSMutableArray< NSNumber * > * _typeStorage
Definition: FlutterKeyboardManagerTest.mm:240
FlutterJSONMessageCodec
Definition: FlutterCodecs.h:81
+[FlutterMessageCodec-p sharedInstance]
instancetype sharedInstance()

## ◆ handleEmbedderEvent:callback:userData:

- (void) handleEmbedderEvent: |  | (const FlutterKeyEvent&) | event
callback: |  | (nullable FlutterKeyEventCallback) | callback
userData: |  | (nullable void*) | userData

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

362 :(const FlutterKeyEvent&)event
363 callback:(nullable FlutterKeyEventCallback)callback
364 userData:(nullable void*)userData {
365 if (_typeStorage != nil && (_typeStorageMask & kEmbedderCall) != 0) {
366 [_typeStorage addObject:@(kEmbedderCall)];
367 }
368 if (callback != nullptr) {
369 _embedderHandler(&event, ^(BOOL handled) {
370 callback(handled, userData);
371 });
372 }
373 }

## ◆ handleTextInputKeyEvent:

- (BOOL) handleTextInputKeyEvent: |  | (NSEvent*) | event |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

396 :(NSEvent*)event {
397 if (_typeStorage != nil && (_typeStorageMask & kTextCall) != 0) {
398 [_typeStorage addObject:@(kTextCall)];
399 }
400 return _textCallback(event);
401 }
_textCallback
TextInputCallback _textCallback
Definition: FlutterKeyboardManagerTest.mm:238

## ◆ init

- (nonnull instancetype) init |  |  |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

251 {
252 self = [super init];
253 if (self == nil) {
254 return nil;
255 }
256
257 _nextResponder = OCMClassMock([NSResponder class]);
258 [self respondChannelCallsWith:FALSE];
259 [self respondEmbedderCallsWith:FALSE];
260 [self respondTextInputWith:FALSE];
261
262 _currentLayout = &kUsLayout;
263
264 _messengerMock = OCMStrictProtocolMock(@protocol(FlutterBinaryMessenger));
265 OCMStub([_messengerMock sendOnChannel:@"flutter/keyevent"
266 message:[OCMArg any]
267 binaryReply:[OCMArg any]])
268 .andCall(self, @selector(handleChannelMessage:message:binaryReply:));
269 OCMStub([_messengerMock setMessageHandlerOnChannel:@"flutter/keyboard"
270 binaryMessageHandler:[OCMArg any]])
271 .andCall(self, @selector(setKeyboardChannelHandler:handler:));
272 OCMStub([_messengerMock sendOnChannel:@"flutter/keyboard" message:[OCMArg any]])
273 .andCall(self, @selector(handleKeyboardChannelMessage:message:));
274 id viewDelegateMock = OCMStrictProtocolMock(@protocol(FlutterKeyboardViewDelegate));
275 OCMStub([viewDelegateMock nextResponder]).andReturn(_nextResponder);
276 OCMStub([viewDelegateMock onTextInputKeyEvent:[OCMArg any]])
277 .andCall(self, @selector(handleTextInputKeyEvent:));
278 OCMStub([viewDelegateMock getBinaryMessenger]).andReturn(_messengerMock);
279 OCMStub([viewDelegateMock sendKeyEvent:*(const FlutterKeyEvent*)[OCMArg anyPointer]
280 callback:nil
281 userData:nil])
282 .ignoringNonObjectArgs()
283 .andCall(self, @selector(handleEmbedderEvent:callback:userData:));
284 OCMStub([viewDelegateMock subscribeToKeyboardLayoutChange:[OCMArg any]])
285 .andCall(self, @selector(onSetKeyboardLayoutNotifier:));
286 OCMStub([viewDelegateMock lookUpLayoutForKeyCode:0 shift:false])
287 .ignoringNonObjectArgs()
288 .andCall(self, @selector(lookUpLayoutForKeyCode:shift:));
289
290 _manager = [[FlutterKeyboardManager alloc] initWithViewDelegate:viewDelegateMock];
291 return self;
292 }
_currentLayout
const MockLayoutData * _currentLayout
Definition: FlutterKeyboardManagerTest.mm:244
_messengerMock
NSObject< FlutterBinaryMessenger > * _messengerMock
Definition: FlutterKeyboardManagerTest.mm:247
FlutterKeyboardManager
Definition: FlutterKeyboardManager.h:28
KeyboardTester::nextResponder
NSResponder * nextResponder
Definition: FlutterKeyboardManagerTest.mm:220
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:49
FlutterKeyboardViewDelegate-p
Definition: FlutterKeyboardViewDelegate.h:42

## ◆ lastKeyboardChannelResult

- (id) lastKeyboardChannelResult |  |  |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

294 {
295 return _keyboardChannelResult;
296 }
_keyboardChannelResult
id _keyboardChannelResult
Definition: FlutterKeyboardManagerTest.mm:246

## ◆ recordCallTypesTo:forTypes:

- (void) recordCallTypesTo: |  | (nonnull NSMutableArray<NSNumber*>*) | typeStorage
forTypes: |  | (uint32_t) | typeMask

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

343 :(nonnull NSMutableArray<NSNumber*>*)typeStorage
344 forTypes:(uint32_t)typeMask {
345 _typeStorage = typeStorage;
346 _typeStorageMask = typeMask;
347 }

## ◆ recordChannelCallsTo:

- (void) recordChannelCallsTo: |  | (nonnull NSMutableArray<FlutterAsyncKeyCallback>*) | storage |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

331 :(nonnull NSMutableArray<FlutterAsyncKeyCallback>*)storage {
332 _channelHandler = ^(FlutterAsyncKeyCallback callback) {
333 [storage addObject:callback];
334 };
335 }
FlutterAsyncKeyCallback
void(^ FlutterAsyncKeyCallback)(BOOL handled)
Definition: FlutterKeyPrimaryResponder.h:10

## ◆ recordEmbedderCallsTo:

- (void) recordEmbedderCallsTo: |  | (nonnull NSMutableArray<FlutterAsyncKeyCallback>*) | storage |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

304 :(nonnull NSMutableArray<FlutterAsyncKeyCallback>*)storage {
305 _embedderHandler = ^(const FlutterKeyEvent* event, FlutterAsyncKeyCallback callback) {
306 [storage addObject:callback];
307 };
308 }

## ◆ recordEmbedderEventsTo:returning:

- (void) recordEmbedderEventsTo: |  | (nonnull std::vector<FlutterKeyEvent>*) | storage
returning: |  | (bool) | handled

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

310 :(nonnull std::vector<FlutterKeyEvent>*)storage
311 returning:(bool)handled {
312 _embedderHandler = ^(const FlutterKeyEvent* event, FlutterAsyncKeyCallback callback) {
313 FlutterKeyEvent newEvent = *event;
314 if (event->character != nullptr) {
315 size_t charLen = strlen(event->character);
316 char* newCharacter = new char[charLen + 1];
317 strlcpy(newCharacter, event->character, charLen + 1);
318 newEvent.character = newCharacter;
319 }
320 storage->push_back(newEvent);
321 callback(handled);
322 };
323 }

## ◆ respondChannelCallsWith:

- (void) respondChannelCallsWith: |  | (BOOL) | response |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

325 :(BOOL)response {
326 _channelHandler = ^(FlutterAsyncKeyCallback callback) {
327 callback(response);
328 };
329 }

## ◆ respondEmbedderCallsWith:

- (void) respondEmbedderCallsWith: |  | (BOOL) | response |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

298 :(BOOL)response {
299 _embedderHandler = ^(const FlutterKeyEvent* event, FlutterAsyncKeyCallback callback) {
300 callback(response);
301 };
302 }

## ◆ respondTextInputWith:

- (void) respondTextInputWith: |  | (BOOL) | response |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

337 :(BOOL)response {
338 _textCallback = ^(NSEvent* event) {
339 return response;
340 };
341 }

## ◆ sendKeyboardChannelMessage:

- (void) sendKeyboardChannelMessage: |  | (NSData* _Nullable) | message |

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

349 :(NSData* _Nullable)message {
350 [_messengerMock sendOnChannel:@"flutter/keyboard" message:message];
351 }

## Property Documentation

## ◆ manager

- (FlutterKeyboardManager*) manager
| readnonatomicstrong

Definition at line 219 of file FlutterKeyboardManagerTest.mm.

## ◆ nextResponder

- (NSResponder*) nextResponder
| readwritenonatomicstrong

Definition at line 220 of file FlutterKeyboardManagerTest.mm.

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

- shell/platform/darwin/macos/framework/Source/FlutterKeyboardManagerTest.mm