Flutter Engine
 
Loading...
Searching...
No Matches
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

FlutterKeyboardManagermanager
 
id< FlutterKeyboardManagerEventContexteventContextMock
 
NSResponder * nextResponder
 

Detailed Description

Definition at line 181 of file FlutterKeyboardManagerTest.mm.

Method Documentation

◆ handleChannelMessage:message:binaryReply:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

382 :(NSString*)channel
383 message:(NSData* _Nullable)message
384 binaryReply:(FlutterBinaryReply _Nullable)callback {
385 if (_typeStorage != nil && (_typeStorageMask & kChannelCall) != 0) {
386 [_typeStorage addObject:@(kChannelCall)];
387 }
388 _channelHandler(^(BOOL handled) {
389 NSDictionary* result = @{
390 @"handled" : @(handled),
391 };
392 NSData* encodedKeyEvent = [[FlutterJSONMessageCodec sharedInstance] encode:result];
393 callback(encodedKeyEvent);
394 });
395}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
if(end==-1)
const gchar * channel
G_BEGIN_DECLS GBytes * message
FlutterDesktopBinaryReply callback
uint32_t _typeStorageMask
AsyncKeyCallbackHandler _channelHandler
NSMutableArray< NSNumber * > * _typeStorage
instancetype sharedInstance()
int BOOL

◆ handleEmbedderEvent:callback:userData:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

369 :(const FlutterKeyEvent&)event
371 userData:(nullable void*)userData {
372 if (_typeStorage != nil && (_typeStorageMask & kEmbedderCall) != 0) {
373 [_typeStorage addObject:@(kEmbedderCall)];
374 }
375 if (callback != nullptr) {
376 _embedderHandler(&event, ^(BOOL handled) {
377 callback(handled, userData);
378 });
379 }
380}
void(* FlutterKeyEventCallback)(bool, void *)
Definition embedder.h:1427

◆ handleTextInputKeyEvent:

- (BOOL) handleTextInputKeyEvent: (NSEvent*)  event

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

403 :(NSEvent*)event {
404 if (_typeStorage != nil && (_typeStorageMask & kTextCall) != 0) {
405 [_typeStorage addObject:@(kTextCall)];
406 }
407 return _textCallback(event);
408}
TextInputCallback _textCallback

◆ init

- (nonnull instancetype) init

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

255 {
256 self = [super init];
257 if (self == nil) {
258 return nil;
259 }
260
261 _nextResponder = OCMClassMock([NSResponder class]);
262 [self respondChannelCallsWith:FALSE];
263 [self respondEmbedderCallsWith:FALSE];
264 [self respondTextInputWith:FALSE];
265
266 _currentLayout = &kUsLayout;
267
268 _messengerMock = OCMStrictProtocolMock(@protocol(FlutterBinaryMessenger));
269 OCMStub([_messengerMock sendOnChannel:@"flutter/keyevent"
270 message:[OCMArg any]
271 binaryReply:[OCMArg any]])
272 .andCall(self, @selector(handleChannelMessage:message:binaryReply:));
273 OCMStub([_messengerMock setMessageHandlerOnChannel:@"flutter/keyboard"
274 binaryMessageHandler:[OCMArg any]])
275 .andCall(self, @selector(setKeyboardChannelHandler:handler:));
276 OCMStub([_messengerMock sendOnChannel:@"flutter/keyboard" message:[OCMArg any]])
277 .andCall(self, @selector(handleKeyboardChannelMessage:message:));
278 id managerDelegateMock = OCMStrictProtocolMock(@protocol(FlutterKeyboardManagerDelegate));
279 OCMStub([managerDelegateMock binaryMessenger]).andReturn(_messengerMock);
280 OCMStub([managerDelegateMock sendKeyEvent:*(const FlutterKeyEvent*)[OCMArg anyPointer]
281 callback:nil
282 userData:nil])
283 .ignoringNonObjectArgs()
284 .andCall(self, @selector(handleEmbedderEvent:callback:userData:));
285
286 _eventContextMock = OCMStrictProtocolMock(@protocol(FlutterKeyboardManagerEventContext));
287 OCMStub([_eventContextMock nextResponder]).andReturn(_nextResponder);
288 OCMStub([_eventContextMock onTextInputKeyEvent:[OCMArg any]])
289 .andCall(self, @selector(handleTextInputKeyEvent:));
290
291 id keyboardLayoutMock = OCMStrictClassMock([FlutterKeyboardLayout class]);
292 OCMStub([keyboardLayoutMock lookUpLayoutForKeyCode:0 shift:false])
293 .ignoringNonObjectArgs()
294 .andCall(self, @selector(lookUpLayoutForKeyCode:shift:));
295 OCMStub([keyboardLayoutMock setDelegate:[OCMArg any]])
296 .andCall(self, @selector(onSetKeyboardLayoutDelegate:));
297
298 _manager = [[FlutterKeyboardManager alloc] initWithDelegate:managerDelegateMock
299 keyboardLayout:keyboardLayoutMock];
300 return self;
301}
const gchar FlBinaryMessengerMessageHandler handler
NSObject< FlutterKeyboardManagerEventContext > * _eventContextMock
const MockLayoutData * _currentLayout
NSObject< FlutterBinaryMessenger > * _messengerMock

◆ lastKeyboardChannelResult

- (id) lastKeyboardChannelResult

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

303 {
305}

◆ recordCallTypesTo:forTypes:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

352 :(nonnull NSMutableArray<NSNumber*>*)typeStorage
353 forTypes:(uint32_t)typeMask {
354 _typeStorage = typeStorage;
355 _typeStorageMask = typeMask;
356}

◆ recordChannelCallsTo:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

340 :(nonnull NSMutableArray<FlutterAsyncKeyCallback>*)storage {
342 [storage addObject:callback];
343 };
344}
void(^ FlutterAsyncKeyCallback)(BOOL handled)

◆ recordEmbedderCallsTo:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

313 :(nonnull NSMutableArray<FlutterAsyncKeyCallback>*)storage {
314 _embedderHandler = ^(const FlutterKeyEvent* event, FlutterAsyncKeyCallback callback) {
315 [storage addObject:callback];
316 };
317}

◆ recordEmbedderEventsTo:returning:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

319 :(nonnull std::vector<FlutterKeyEvent>*)storage
320 returning:(bool)handled {
321 _embedderHandler = ^(const FlutterKeyEvent* event, FlutterAsyncKeyCallback callback) {
322 FlutterKeyEvent newEvent = *event;
323 if (event->character != nullptr) {
324 size_t charLen = strlen(event->character);
325 char* newCharacter = new char[charLen + 1];
326 strlcpy(newCharacter, event->character, charLen + 1);
327 newEvent.character = newCharacter;
328 }
329 storage->push_back(newEvent);
330 callback(handled);
331 };
332}
const char * character
Definition embedder.h:1409

◆ respondChannelCallsWith:

- (void) respondChannelCallsWith: (BOOL response

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

334 :(BOOL)response {
336 callback(response);
337 };
338}

◆ respondEmbedderCallsWith:

- (void) respondEmbedderCallsWith: (BOOL response

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

307 :(BOOL)response {
308 _embedderHandler = ^(const FlutterKeyEvent* event, FlutterAsyncKeyCallback callback) {
309 callback(response);
310 };
311}

◆ respondTextInputWith:

- (void) respondTextInputWith: (BOOL response

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

346 :(BOOL)response {
347 _textCallback = ^(NSEvent* event) {
348 return response;
349 };
350}

◆ sendKeyboardChannelMessage:

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

Definition at line 252 of file FlutterKeyboardManagerTest.mm.

358 :(NSData* _Nullable)message {
359 [_messengerMock sendOnChannel:@"flutter/keyboard" message:message];
360}

Property Documentation

◆ eventContextMock

- (id<FlutterKeyboardManagerEventContext>) eventContextMock
readnonatomicstrong

Definition at line 221 of file FlutterKeyboardManagerTest.mm.

◆ manager

- (FlutterKeyboardManager*) manager
readnonatomicstrong

Definition at line 220 of file FlutterKeyboardManagerTest.mm.

◆ nextResponder

- (NSResponder*) nextResponder
readwritenonatomicstrong

Definition at line 222 of file FlutterKeyboardManagerTest.mm.


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