| 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 375 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 }

References _channelHandler, _typeStorage, _typeStorageMask, and <FlutterMessageCodec>::sharedInstance.

## ◆ handleEmbedderEvent:callback:userData:

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

Definition at line 362 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 }

References _typeStorage, and _typeStorageMask.

## ◆ handleTextInputKeyEvent:

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

Definition at line 396 of file FlutterKeyboardManagerTest.mm.

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

References _textCallback, _typeStorage, and _typeStorageMask.

## ◆ init

- (nonnull instancetype) init |  |  |

Definition at line 251 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 }

References _currentLayout, _messengerMock, respondChannelCallsWith:, respondEmbedderCallsWith:, and respondTextInputWith:.

## ◆ lastKeyboardChannelResult

- (id) lastKeyboardChannelResult |  |  |

Definition at line 294 of file FlutterKeyboardManagerTest.mm.

294 {
295 return _keyboardChannelResult;
296 }

References _keyboardChannelResult.

Referenced by FlutterKeyboardManagerUnittestsObjC::keyboardChannelGetPressedState.

## ◆ recordCallTypesTo:forTypes:

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

Definition at line 343 of file FlutterKeyboardManagerTest.mm.

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

References _typeStorage, and _typeStorageMask.

Referenced by FlutterKeyboardManagerUnittestsObjC::racingConditionBetweenKeyAndText.

## ◆ recordChannelCallsTo:

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

Definition at line 331 of file FlutterKeyboardManagerTest.mm.

331 :(nonnull NSMutableArray<FlutterAsyncKeyCallback>*)storage {
332 _channelHandler = ^(FlutterAsyncKeyCallback callback) {
333 [storage addObject:callback];
334 };
335 }

References _channelHandler.

Referenced by FlutterKeyboardManagerUnittestsObjC::doublePrimaryResponder.

## ◆ recordEmbedderCallsTo:

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

Definition at line 304 of file FlutterKeyboardManagerTest.mm.

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

Referenced by FlutterKeyboardManagerUnittestsObjC::doublePrimaryResponder, FlutterKeyboardManagerUnittestsObjC::racingConditionBetweenKeyAndText, FlutterKeyboardManagerUnittestsObjC::singlePrimaryResponder, and FlutterKeyboardManagerUnittestsObjC::textInputPlugin.

## ◆ recordEmbedderEventsTo:returning:

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

Definition at line 310 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 }

Referenced by FlutterKeyboardManagerUnittestsObjC::correctLogicalKeyForLayouts.

## ◆ respondChannelCallsWith:

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

Definition at line 325 of file FlutterKeyboardManagerTest.mm.

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

References _channelHandler.

Referenced by FlutterKeyboardManagerUnittestsObjC::correctLogicalKeyForLayouts, FlutterKeyboardManagerUnittestsObjC::doublePrimaryResponder, FlutterKeyboardManagerUnittestsObjC::emptyNextResponder, FlutterKeyboardManagerUnittestsObjC::getPressedState, init, FlutterKeyboardManagerUnittestsObjC::keyboardChannelGetPressedState, and FlutterKeyboardManagerUnittestsObjC::textInputPlugin.

## ◆ respondEmbedderCallsWith:

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

Definition at line 298 of file FlutterKeyboardManagerTest.mm.

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

Referenced by FlutterKeyboardManagerUnittestsObjC::doublePrimaryResponder, FlutterKeyboardManagerUnittestsObjC::emptyNextResponder, FlutterKeyboardManagerUnittestsObjC::getPressedState, init, FlutterKeyboardManagerUnittestsObjC::keyboardChannelGetPressedState, and FlutterKeyboardManagerUnittestsObjC::textInputPlugin.

## ◆ respondTextInputWith:

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

Definition at line 337 of file FlutterKeyboardManagerTest.mm.

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

References _textCallback.

Referenced by FlutterKeyboardManagerUnittestsObjC::correctLogicalKeyForLayouts, FlutterKeyboardManagerUnittestsObjC::emptyNextResponder, FlutterKeyboardManagerUnittestsObjC::getPressedState, init, FlutterKeyboardManagerUnittestsObjC::keyboardChannelGetPressedState, and FlutterKeyboardManagerUnittestsObjC::textInputPlugin.

## ◆ sendKeyboardChannelMessage:

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

Definition at line 349 of file FlutterKeyboardManagerTest.mm.

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

Referenced by FlutterKeyboardManagerUnittestsObjC::keyboardChannelGetPressedState.

## 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.

Referenced by FlutterKeyboardManagerUnittestsObjC::correctLogicalKeyForLayouts, FlutterKeyboardManagerUnittestsObjC::doublePrimaryResponder, FlutterKeyboardManagerUnittestsObjC::emptyNextResponder, FlutterKeyboardManagerUnittestsObjC::singlePrimaryResponder, and FlutterKeyboardManagerUnittestsObjC::textInputPlugin.

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

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

FlutterKeyboardViewDelegate-p
Definition: FlutterKeyboardViewDelegate.h:39
_channelHandler
AsyncKeyCallbackHandler _channelHandler
Definition: FlutterKeyboardManagerTest.mm:235
KeyboardTester::nextResponder
NSResponder * nextResponder
Definition: FlutterKeyboardManagerTest.mm:220
FlutterAsyncKeyCallback
void(^ FlutterAsyncKeyCallback)(BOOL handled)
Definition: FlutterKeyPrimaryResponder.h:7
_typeStorageMask
uint32_t _typeStorageMask
Definition: FlutterKeyboardManagerTest.mm:241
_messengerMock
NSObject< FlutterBinaryMessenger > * _messengerMock
Definition: FlutterKeyboardManagerTest.mm:247
_keyboardChannelResult
id _keyboardChannelResult
Definition: FlutterKeyboardManagerTest.mm:246
FlutterKeyboardManager
Definition: FlutterKeyboardManager.h:24
_textCallback
TextInputCallback _textCallback
Definition: FlutterKeyboardManagerTest.mm:238
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:49
_typeStorage
NSMutableArray< NSNumber * > * _typeStorage
Definition: FlutterKeyboardManagerTest.mm:240
FlutterBinaryReply
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
+[FlutterMessageCodec-p sharedInstance]
instancetype sharedInstance()
FlutterJSONMessageCodec
Definition: FlutterCodecs.h:81
_currentLayout
const MockLayoutData * _currentLayout
Definition: FlutterKeyboardManagerTest.mm:244