Flutter Engine
The Flutter Engine
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:
 
(void) - setLayout: [implementation]
 
(void) - handleKeyboardChannelMessage:message: [implementation]
 
(void) - onSetKeyboardLayoutNotifier: [implementation]
 
(LayoutClue) - lookUpLayoutForKeyCode:shift: [implementation]
 
(void) - setKeyboardChannelHandler:handler: [implementation]
 

Properties

FlutterKeyboardManagermanager
 
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}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
instancetype sharedInstance()
Win32Message message
uint32_t _typeStorageMask
AsyncKeyCallbackHandler _channelHandler
NSMutableArray< NSNumber * > * _typeStorage
int BOOL
Definition: windows_types.h:37

◆ 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
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}
void(* FlutterKeyEventCallback)(bool, void *)
Definition: embedder.h:1155
FlKeyEvent * event

◆ handleKeyboardChannelMessage:message:

- (void) handleKeyboardChannelMessage: (NSString*)  channel
message: (NSData* _Nullable)  message 
implementation

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

390 :(NSString*)channel message:(NSData* _Nullable)message {
393 });
394}
FlutterBinaryMessageHandler _keyboardHandler
id _keyboardChannelResult

◆ 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}
TextInputCallback _textCallback

◆ 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}
const MockLayoutData * _currentLayout
NSObject< FlutterBinaryMessenger > * _messengerMock
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530

◆ lastKeyboardChannelResult

- (id) lastKeyboardChannelResult

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

294 {
296}

◆ lookUpLayoutForKeyCode:shift:

- (LayoutClue) lookUpLayoutForKeyCode: (uint16_t)  keyCode
shift: (BOOL shift 
implementation

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

407 :(uint16_t)keyCode shift:(BOOL)shift {
408 uint32_t cluePair = (*_currentLayout)[(keyCode * 2) + (shift ? 1 : 0)];
409 const uint32_t kCharMask = 0xffff;
410 const uint32_t kDeadKeyMask = 0x10000;
411 return LayoutClue{cluePair & kCharMask, (cluePair & kDeadKeyMask) != 0};
412}

◆ onSetKeyboardLayoutNotifier:

- (void) onSetKeyboardLayoutNotifier: (nullable flutter::KeyboardLayoutNotifier callback
implementation

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

405}
flutter::KeyboardLayoutNotifier _keyboardLayoutNotifier
void(^ KeyboardLayoutNotifier)()

◆ 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 {
333 [storage addObject:callback];
334 };
335}
void(^ FlutterAsyncKeyCallback)(BOOL handled)

◆ 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}
const char * character
Definition: embedder.h:1137

◆ respondChannelCallsWith:

- (void) respondChannelCallsWith: (BOOL response

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

325 :(BOOL)response {
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}

◆ setKeyboardChannelHandler:handler:

- (void) setKeyboardChannelHandler: (NSString*)  channel
handler: (FlutterBinaryMessageHandler handler 
implementation

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

414 :(NSString*)channel handler:(FlutterBinaryMessageHandler)handler {
415 _keyboardHandler = handler;
416}
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)

◆ setLayout:

- (void) setLayout: (const MockLayoutData&)  layout
implementation

Definition at line 248 of file FlutterKeyboardManagerTest.mm.

353 :(const MockLayoutData&)layout {
354 _currentLayout = &layout;
355 if (_keyboardLayoutNotifier != nil) {
357 }
358}

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: