| Flutter macOS Embedder |

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

## Instance Methods
(bool) | - testKeyEventsAreSentToFramework
(bool) | - testKeyEventsArePropagatedIfNotHandled
(bool) | - testKeyEventsAreNotPropagatedIfHandled
(bool) | - testCtrlTabKeyEventIsPropagated
(bool) | - testKeyEquivalentIsPassedToTextInputPlugin
(bool) | - testFlagsChangedEventsArePropagatedIfNotHandled
(bool) | - testKeyboardIsRestartedOnEngineRestart
(bool) | - testTrackpadGesturesAreSentToFramework
(bool) | - testMouseDownUpEventsSentToNextResponder
(bool) | - testModifierKeysAreSynthesizedOnMouseMove
(bool) | - testViewWillAppearCalledMultipleTimes
(bool) | - testFlutterViewIsConfigured
(bool) | - testLookupKeyAssets
(bool) | - testLookupKeyAssetsWithPackage
(bool) | - testViewControllerIsReleased

## Class Methods
(void) | + respondFalseForSendEvent:callback:userData:

## Detailed Description

Definition at line 58 of file FlutterViewControllerTest.mm.

## Method Documentation

## ◆ respondFalseForSendEvent:callback:userData:

+ (void) respondFalseForSendEvent: |  | (const FlutterKeyEvent&) | event
callback: |  | (nullable FlutterKeyEventCallback) | callback
userData: |  | (nullable void*) | userData

Definition at line 643 of file FlutterViewControllerTest.mm.

643 :(const FlutterKeyEvent&)event
644 callback:(nullable FlutterKeyEventCallback)callback
645 userData:(nullable void*)userData {
646 if (callback != nullptr) {
647 callback(false, userData);
648 }
649 }

## ◆ testCtrlTabKeyEventIsPropagated

- (bool) testCtrlTabKeyEventIsPropagated |  |  |

Definition at line 309 of file FlutterViewControllerTest.mm.

309 {
310 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
311 __block bool called = false;
312 __block FlutterKeyEvent last_event;
313 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
314 callback:nil
315 userData:nil])
316 .andDo((^(NSInvocation* invocation) {
317 FlutterKeyEvent* event;
318 [invocation getArgument:&event atIndex:2];
319 called = true;
320 last_event = *event;
321 }));
322 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
323 nibName:@""
324 bundle:nil];
325 // Ctrl+tab
326 NSEvent* event = [NSEvent keyEventWithType:NSEventTypeKeyDown
327 location:NSZeroPoint
328 modifierFlags:0x40101
329 timestamp:0
330 windowNumber:0
331 context:nil
332 characters:@""
333 charactersIgnoringModifiers:@""
334 isARepeat:NO
335 keyCode:48];
336 const uint64_t kPhysicalKeyTab = 0x7002b;
337
338 [viewController viewWillAppear]; // Initializes the event channel.
339 // Creates a NSWindow so that FlutterView view can be first responder.
340 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
341 styleMask:NSBorderlessWindowMask
342 backing:NSBackingStoreBuffered
343 defer:NO];
344 window.contentView = viewController.view;
345 [window makeFirstResponder:viewController.flutterView];
346 [viewController.view performKeyEquivalent:event];
347
348 EXPECT_TRUE(called);
349 EXPECT_EQ(last_event.type, kFlutterKeyEventTypeDown);
350 EXPECT_EQ(last_event.physical, kPhysicalKeyTab);
351 return true;
352 }

References flutter::testing::CreateMockFlutterEngine().

## ◆ testFlagsChangedEventsArePropagatedIfNotHandled

- (bool) testFlagsChangedEventsArePropagatedIfNotHandled |  |  |

Definition at line 481 of file FlutterViewControllerTest.mm.

481 {
482 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
483 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
484 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
485 [engineMock binaryMessenger])
486 .andReturn(binaryMessengerMock);
487 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
488 callback:nil
489 userData:nil])
490 .andCall([FlutterViewControllerTestObjC class],
491 @selector(respondFalseForSendEvent:callback:userData:));
492 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
493 nibName:@""
494 bundle:nil];
495 id responderMock = flutter::testing::mockResponder();
496 viewController.nextResponder = responderMock;
497 NSDictionary* expectedEvent = @{
498 @"keymap" : @"macos",
499 @"type" : @"keydown",
500 @"keyCode" : @(56), // SHIFT key
501 @"modifiers" : @(537001986),
502 };
503 NSData* encodedKeyEvent = [[FlutterJSONMessageCodec sharedInstance] encode:expectedEvent];
504 CGEventRef cgEvent = CGEventCreateKeyboardEvent(NULL, 56, TRUE); // SHIFT key
505 CGEventSetType(cgEvent, kCGEventFlagsChanged);
506 NSEvent* event = [NSEvent eventWithCGEvent:cgEvent];
507 OCMExpect( // NOLINT(google-objc-avoid-throwing-exception)
508 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
509 message:encodedKeyEvent
510 binaryReply:[OCMArg any]])
511 .andDo((^(NSInvocation* invocation) {
512 FlutterBinaryReply handler;
513 [invocation getArgument:&handler atIndex:4];
514 NSDictionary* reply = @{
515 @"handled" : @(false),
516 };
517 NSData* encodedReply = [[FlutterJSONMessageCodec sharedInstance] encode:reply];
518 handler(encodedReply);
519 }));
520 [viewController viewWillAppear]; // Initializes the event channel.
521 [viewController flagsChanged:event];
522 @try {
523 OCMVerify( // NOLINT(google-objc-avoid-throwing-exception)
524 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
525 message:encodedKeyEvent
526 binaryReply:[OCMArg any]]);
527 } @catch (NSException* e) {
528 NSLog(@"%@", e.reason);
529 return false;
530 }
531 return true;
532 }

References flutter::testing::CreateMockFlutterEngine(), FlutterBinaryReply, and <FlutterMessageCodec>::sharedInstance.

## ◆ testFlutterViewIsConfigured

- (bool) testFlutterViewIsConfigured |  |  |

Definition at line 460 of file FlutterViewControllerTest.mm.

460 {
461 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
462
463 FlutterRenderer* renderer_ = [[FlutterRenderer alloc] initWithFlutterEngine:engineMock];
464 OCMStub([engineMock renderer]).andReturn(renderer_);
465
466 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
467 nibName:@""
468 bundle:nil];
469 [viewController loadView];
470
471 @try {
472 // Make sure "renderer" was called during "loadView", which means "flutterView" is created
473 OCMVerify([engineMock renderer]);
474 } @catch (...) {
475 return false;
476 }
477
478 return true;
479 }

References flutter::testing::CreateMockFlutterEngine().

## ◆ testKeyboardIsRestartedOnEngineRestart

- (bool) testKeyboardIsRestartedOnEngineRestart |  |  |

Definition at line 589 of file FlutterViewControllerTest.mm.

589 {
590 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
591 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
592 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
593 [engineMock binaryMessenger])
594 .andReturn(binaryMessengerMock);
595 __block bool called = false;
596 __block FlutterKeyEvent last_event;
597 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
598 callback:nil
599 userData:nil])
600 .andDo((^(NSInvocation* invocation) {
601 FlutterKeyEvent* event;
602 [invocation getArgument:&event atIndex:2];
603 called = true;
604 last_event = *event;
605 }));
606
607 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
608 nibName:@""
609 bundle:nil];
610 [viewController viewWillAppear];
611 NSEvent* keyADown = [NSEvent keyEventWithType:NSEventTypeKeyDown
612 location:NSZeroPoint
613 modifierFlags:0x100
614 timestamp:0
615 windowNumber:0
616 context:nil
617 characters:@"a"
618 charactersIgnoringModifiers:@"a"
619 isARepeat:FALSE
620 keyCode:0];
621 const uint64_t kPhysicalKeyA = 0x70004;
622
623 // Send KeyA key down event twice. Without restarting the keyboard during
624 // onPreEngineRestart, the second event received will be an empty event with
625 // physical key 0x0 because duplicate key down events are ignored.
626
627 called = false;
628 [viewController keyDown:keyADown];
629 EXPECT_TRUE(called);
630 EXPECT_EQ(last_event.type, kFlutterKeyEventTypeDown);
631 EXPECT_EQ(last_event.physical, kPhysicalKeyA);
632
633 [viewController onPreEngineRestart];
634
635 called = false;
636 [viewController keyDown:keyADown];
637 EXPECT_TRUE(called);
638 EXPECT_EQ(last_event.type, kFlutterKeyEventTypeDown);
639 EXPECT_EQ(last_event.physical, kPhysicalKeyA);
640 return true;
641 }

References flutter::testing::CreateMockFlutterEngine(), and FlutterViewController::onPreEngineRestart.

## ◆ testKeyEquivalentIsPassedToTextInputPlugin

- (bool) testKeyEquivalentIsPassedToTextInputPlugin |  |  |

Definition at line 354 of file FlutterViewControllerTest.mm.

354 {
355 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
356 __block bool called = false;
357 __block FlutterKeyEvent last_event;
358 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
359 callback:nil
360 userData:nil])
361 .andDo((^(NSInvocation* invocation) {
362 FlutterKeyEvent* event;
363 [invocation getArgument:&event atIndex:2];
364 called = true;
365 last_event = *event;
366 }));
367 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
368 nibName:@""
369 bundle:nil];
370 // Ctrl+tab
371 NSEvent* event = [NSEvent keyEventWithType:NSEventTypeKeyDown
372 location:NSZeroPoint
373 modifierFlags:0x40101
374 timestamp:0
375 windowNumber:0
376 context:nil
377 characters:@""
378 charactersIgnoringModifiers:@""
379 isARepeat:NO
380 keyCode:48];
381 const uint64_t kPhysicalKeyTab = 0x7002b;
382
383 [viewController viewWillAppear]; // Initializes the event channel.
384
385 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
386 styleMask:NSBorderlessWindowMask
387 backing:NSBackingStoreBuffered
388 defer:NO];
389 window.contentView = viewController.view;
390
391 [viewController.view addSubview:viewController.textInputPlugin];
392
393 // Make the textInputPlugin first responder. This should still result in
394 // view controller reporting the key event.
395 [window makeFirstResponder:viewController.textInputPlugin];
396
397 [viewController.view performKeyEquivalent:event];
398
399 EXPECT_TRUE(called);
400 EXPECT_EQ(last_event.type, kFlutterKeyEventTypeDown);
401 EXPECT_EQ(last_event.physical, kPhysicalKeyTab);
402 return true;
403 }

References flutter::testing::CreateMockFlutterEngine().

## ◆ testKeyEventsAreNotPropagatedIfHandled

- (bool) testKeyEventsAreNotPropagatedIfHandled |  |  |

Definition at line 534 of file FlutterViewControllerTest.mm.

534 {
535 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
536 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
537 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
538 [engineMock binaryMessenger])
539 .andReturn(binaryMessengerMock);
540 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
541 callback:nil
542 userData:nil])
543 .andCall([FlutterViewControllerTestObjC class],
544 @selector(respondFalseForSendEvent:callback:userData:));
545 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
546 nibName:@""
547 bundle:nil];
548 id responderMock = flutter::testing::mockResponder();
549 viewController.nextResponder = responderMock;
550 NSDictionary* expectedEvent = @{
551 @"keymap" : @"macos",
552 @"type" : @"keydown",
553 @"keyCode" : @(65),
554 @"modifiers" : @(538968064),
555 @"characters" : @".",
556 @"charactersIgnoringModifiers" : @".",
557 };
558 NSData* encodedKeyEvent = [[FlutterJSONMessageCodec sharedInstance] encode:expectedEvent];
559 CGEventRef cgEvent = CGEventCreateKeyboardEvent(NULL, 65, TRUE);
560 NSEvent* event = [NSEvent eventWithCGEvent:cgEvent];
561 OCMExpect( // NOLINT(google-objc-avoid-throwing-exception)
562 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
563 message:encodedKeyEvent
564 binaryReply:[OCMArg any]])
565 .andDo((^(NSInvocation* invocation) {
566 FlutterBinaryReply handler;
567 [invocation getArgument:&handler atIndex:4];
568 NSDictionary* reply = @{
569 @"handled" : @(true),
570 };
571 NSData* encodedReply = [[FlutterJSONMessageCodec sharedInstance] encode:reply];
572 handler(encodedReply);
573 }));
574 [viewController viewWillAppear]; // Initializes the event channel.
575 [viewController keyDown:event];
576 @try {
577 OCMVerify( // NOLINT(google-objc-avoid-throwing-exception)
578 never(), [responderMock keyDown:[OCMArg any]]);
579 OCMVerify( // NOLINT(google-objc-avoid-throwing-exception)
580 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
581 message:encodedKeyEvent
582 binaryReply:[OCMArg any]]);
583 } @catch (...) {
584 return false;
585 }
586 return true;
587 }

References flutter::testing::CreateMockFlutterEngine(), FlutterBinaryReply, and <FlutterMessageCodec>::sharedInstance.

## ◆ testKeyEventsArePropagatedIfNotHandled

- (bool) testKeyEventsArePropagatedIfNotHandled |  |  |

Definition at line 405 of file FlutterViewControllerTest.mm.

405 {
406 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
407 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
408 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
409 [engineMock binaryMessenger])
410 .andReturn(binaryMessengerMock);
411 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
412 callback:nil
413 userData:nil])
414 .andCall([FlutterViewControllerTestObjC class],
415 @selector(respondFalseForSendEvent:callback:userData:));
416 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
417 nibName:@""
418 bundle:nil];
419 id responderMock = flutter::testing::mockResponder();
420 viewController.nextResponder = responderMock;
421 NSDictionary* expectedEvent = @{
422 @"keymap" : @"macos",
423 @"type" : @"keydown",
424 @"keyCode" : @(65),
425 @"modifiers" : @(538968064),
426 @"characters" : @".",
427 @"charactersIgnoringModifiers" : @".",
428 };
429 NSData* encodedKeyEvent = [[FlutterJSONMessageCodec sharedInstance] encode:expectedEvent];
430 CGEventRef cgEvent = CGEventCreateKeyboardEvent(NULL, 65, TRUE);
431 NSEvent* event = [NSEvent eventWithCGEvent:cgEvent];
432 OCMExpect( // NOLINT(google-objc-avoid-throwing-exception)
433 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
434 message:encodedKeyEvent
435 binaryReply:[OCMArg any]])
436 .andDo((^(NSInvocation* invocation) {
437 FlutterBinaryReply handler;
438 [invocation getArgument:&handler atIndex:4];
439 NSDictionary* reply = @{
440 @"handled" : @(false),
441 };
442 NSData* encodedReply = [[FlutterJSONMessageCodec sharedInstance] encode:reply];
443 handler(encodedReply);
444 }));
445 [viewController viewWillAppear]; // Initializes the event channel.
446 [viewController keyDown:event];
447 @try {
448 OCMVerify( // NOLINT(google-objc-avoid-throwing-exception)
449 [responderMock keyDown:[OCMArg any]]);
450 OCMVerify( // NOLINT(google-objc-avoid-throwing-exception)
451 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
452 message:encodedKeyEvent
453 binaryReply:[OCMArg any]]);
454 } @catch (...) {
455 return false;
456 }
457 return true;
458 }

References flutter::testing::CreateMockFlutterEngine(), FlutterBinaryReply, and <FlutterMessageCodec>::sharedInstance.

## ◆ testKeyEventsAreSentToFramework

- (bool) testKeyEventsAreSentToFramework |  |  |

Definition at line 270 of file FlutterViewControllerTest.mm.

270 {
271 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
272 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
273 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
274 [engineMock binaryMessenger])
275 .andReturn(binaryMessengerMock);
276 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
277 callback:nil
278 userData:nil])
279 .andCall([FlutterViewControllerTestObjC class],
280 @selector(respondFalseForSendEvent:callback:userData:));
281 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
282 nibName:@""
283 bundle:nil];
284 NSDictionary* expectedEvent = @{
285 @"keymap" : @"macos",
286 @"type" : @"keydown",
287 @"keyCode" : @(65),
288 @"modifiers" : @(538968064),
289 @"characters" : @".",
290 @"charactersIgnoringModifiers" : @".",
291 };
292 NSData* encodedKeyEvent = [[FlutterJSONMessageCodec sharedInstance] encode:expectedEvent];
293 CGEventRef cgEvent = CGEventCreateKeyboardEvent(NULL, 65, TRUE);
294 NSEvent* event = [NSEvent eventWithCGEvent:cgEvent];
295 [viewController viewWillAppear]; // Initializes the event channel.
296 [viewController keyDown:event];
297 @try {
298 OCMVerify( // NOLINT(google-objc-avoid-throwing-exception)
299 [binaryMessengerMock sendOnChannel:@"flutter/keyevent"
300 message:encodedKeyEvent
301 binaryReply:[OCMArg any]]);
302 } @catch (...) {
303 return false;
304 }
305 return true;
306 }

References flutter::testing::CreateMockFlutterEngine(), and <FlutterMessageCodec>::sharedInstance.

## ◆ testLookupKeyAssets

- (bool) testLookupKeyAssets |  |  |

Definition at line 957 of file FlutterViewControllerTest.mm.

957 {
958 FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:nil];
959 NSString* key = [viewController lookupKeyForAsset:@"test.png"];
960 EXPECT_TRUE(
961 [key isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/test.png"]);
962 return true;
963 }

References FlutterViewController::lookupKeyForAsset:.

## ◆ testLookupKeyAssetsWithPackage

- (bool) testLookupKeyAssetsWithPackage |  |  |

Definition at line 965 of file FlutterViewControllerTest.mm.

965 {
966 FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:nil];
967
968 NSString* packageKey = [viewController lookupKeyForAsset:@"test.png" fromPackage:@"test"];
969 EXPECT_TRUE([packageKey
970 isEqualToString:
971 @"Contents/Frameworks/App.framework/Resources/flutter_assets/packages/test/test.png"]);
972 return true;
973 }

References FlutterViewController::lookupKeyForAsset:fromPackage:.

## ◆ testModifierKeysAreSynthesizedOnMouseMove

- (bool) testModifierKeysAreSynthesizedOnMouseMove |  |  |

Definition at line 1021 of file FlutterViewControllerTest.mm.

1021 {
1022 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
1023 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
1024 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
1025 [engineMock binaryMessenger])
1026 .andReturn(binaryMessengerMock);
1027
1028 // Need to return a real renderer to allow view controller to load.
1029 FlutterRenderer* renderer_ = [[FlutterRenderer alloc] initWithFlutterEngine:engineMock];
1030 OCMStub([engineMock renderer]).andReturn(renderer_);
1031
1032 // Capture calls to sendKeyEvent
1033 __block NSMutableArray<KeyEventWrapper*>* events = [NSMutableArray array];
1034 OCMStub([[engineMock ignoringNonObjectArgs] sendKeyEvent:FlutterKeyEvent {}
1035 callback:nil
1036 userData:nil])
1037 .andDo((^(NSInvocation* invocation) {
1038 FlutterKeyEvent* event;
1039 [invocation getArgument:&event atIndex:2];
1040 [events addObject:[[KeyEventWrapper alloc] initWithEvent:event]];
1041 }));
1042
1043 __block NSMutableArray<NSDictionary*>* channelEvents = [NSMutableArray array];
1044 OCMStub([binaryMessengerMock sendOnChannel:@"flutter/keyevent"
1045 message:[OCMArg any]
1046 binaryReply:[OCMArg any]])
1047 .andDo((^(NSInvocation* invocation) {
1048 NSData* data;
1049 [invocation getArgument:&data atIndex:3];
1050 id event = [[FlutterJSONMessageCodec sharedInstance] decode:data];
1051 [channelEvents addObject:event];
1052 }));
1053
1054 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
1055 nibName:@""
1056 bundle:nil];
1057 [viewController loadView];
1058 [viewController viewWillAppear];
1059
1060 // Zeroed modifier flag should not synthesize events.
1061 NSEvent* mouseEvent = flutter::testing::CreateMouseEvent(0x00);
1062 [viewController mouseMoved:mouseEvent];
1063 EXPECT_EQ([events count], 0u);
1064
1065 // For each modifier key, check that key events are synthesized.
1066 for (NSNumber* keyCode in flutter::keyCodeToModifierFlag) {
1067 FlutterKeyEvent* event;
1068 NSDictionary* channelEvent;
1069 NSNumber* logicalKey;
1070 NSNumber* physicalKey;
1071 NSEventModifierFlags flag = [flutter::keyCodeToModifierFlag[keyCode] unsignedLongValue];
1072
1073 // Cocoa event always contain combined flags.
1074 if (flag & (flutter::kModifierFlagShiftLeft | flutter::kModifierFlagShiftRight)) {
1075 flag |= NSEventModifierFlagShift;
1076 }
1077 if (flag & (flutter::kModifierFlagControlLeft | flutter::kModifierFlagControlRight)) {
1078 flag |= NSEventModifierFlagControl;
1079 }
1080 if (flag & (flutter::kModifierFlagAltLeft | flutter::kModifierFlagAltRight)) {
1081 flag |= NSEventModifierFlagOption;
1082 }
1083 if (flag & (flutter::kModifierFlagMetaLeft | flutter::kModifierFlagMetaRight)) {
1084 flag |= NSEventModifierFlagCommand;
1085 }
1086
1087 // Should synthesize down event.
1088 NSEvent* mouseEvent = flutter::testing::CreateMouseEvent(flag);
1089 [viewController mouseMoved:mouseEvent];
1090 EXPECT_EQ([events count], 1u);
1091 event = events[0].data;
1092 logicalKey = [flutter::keyCodeToLogicalKey objectForKey:keyCode];
1093 physicalKey = [flutter::keyCodeToPhysicalKey objectForKey:keyCode];
1094 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1095 EXPECT_EQ(event->logical, logicalKey.unsignedLongLongValue);
1096 EXPECT_EQ(event->physical, physicalKey.unsignedLongLongValue);
1097 EXPECT_EQ(event->synthesized, true);
1098
1099 channelEvent = channelEvents[0];
1100 EXPECT_TRUE([channelEvent[@"type"] isEqual:@"keydown"]);
1101 EXPECT_TRUE([channelEvent[@"keyCode"] isEqual:keyCode]);
1102 EXPECT_TRUE([channelEvent[@"modifiers"] isEqual:@(flag)]);
1103
1104 // Should synthesize up event.
1105 mouseEvent = flutter::testing::CreateMouseEvent(0x00);
1106 [viewController mouseMoved:mouseEvent];
1107 EXPECT_EQ([events count], 2u);
1108 event = events[1].data;
1109 logicalKey = [flutter::keyCodeToLogicalKey objectForKey:keyCode];
1110 physicalKey = [flutter::keyCodeToPhysicalKey objectForKey:keyCode];
1111 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1112 EXPECT_EQ(event->logical, logicalKey.unsignedLongLongValue);
1113 EXPECT_EQ(event->physical, physicalKey.unsignedLongLongValue);
1114 EXPECT_EQ(event->synthesized, true);
1115
1116 channelEvent = channelEvents[1];
1117 EXPECT_TRUE([channelEvent[@"type"] isEqual:@"keyup"]);
1118 EXPECT_TRUE([channelEvent[@"keyCode"] isEqual:keyCode]);
1119 EXPECT_TRUE([channelEvent[@"modifiers"] isEqual:@(0)]);
1120
1121 [events removeAllObjects];
1122 [channelEvents removeAllObjects];
1123 };
1124
1125 return true;
1126 }

References flutter::testing::CreateMockFlutterEngine(), KeyEventWrapper::data, flutter::keyCodeToModifierFlag, flutter::kModifierFlagAltLeft, flutter::kModifierFlagAltRight, flutter::kModifierFlagControlLeft, flutter::kModifierFlagControlRight, flutter::kModifierFlagMetaLeft, flutter::kModifierFlagMetaRight, flutter::kModifierFlagShiftLeft, flutter::kModifierFlagShiftRight, and <FlutterMessageCodec>::sharedInstance.

## ◆ testMouseDownUpEventsSentToNextResponder

- (bool) testMouseDownUpEventsSentToNextResponder |  |  |

Definition at line 984 of file FlutterViewControllerTest.mm.

984 {
985 // The root cause of the above bug is NSResponder mouseDown/mouseUp methods that don't correctly
986 // walk the responder chain calling the appropriate method on the next responder under certain
987 // conditions. Simulate this by swizzling out the default implementations and replacing them with
988 // no-ops.
989 Method mouseDown = class_getInstanceMethod([NSResponder class], @selector(mouseDown:));
990 Method mouseUp = class_getInstanceMethod([NSResponder class], @selector(mouseUp:));
991 IMP noopImp = (IMP)SwizzledNoop;
992 IMP origMouseDown = method_setImplementation(mouseDown, noopImp);
993 IMP origMouseUp = method_setImplementation(mouseUp, noopImp);
994
995 // Verify that mouseDown/mouseUp trigger mouseDown/mouseUp calls on FlutterViewController.
996 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
997 MouseEventFlutterViewController* viewController =
998 [[MouseEventFlutterViewController alloc] initWithEngine:engineMock nibName:@"" bundle:nil];
999 FlutterView* view = (FlutterView*)[viewController view];
1000
1001 EXPECT_FALSE(viewController.mouseDownCalled);
1002 EXPECT_FALSE(viewController.mouseUpCalled);
1003
1004 NSEvent* mouseEvent = flutter::testing::CreateMouseEvent(0x00);
1005 [view mouseDown:mouseEvent];
1006 EXPECT_TRUE(viewController.mouseDownCalled);
1007 EXPECT_FALSE(viewController.mouseUpCalled);
1008
1009 viewController.mouseDownCalled = NO;
1010 [view mouseUp:mouseEvent];
1011 EXPECT_FALSE(viewController.mouseDownCalled);
1012 EXPECT_TRUE(viewController.mouseUpCalled);
1013
1014 // Restore the original NSResponder mouseDown/mouseUp implementations.
1015 method_setImplementation(mouseDown, origMouseDown);
1016 method_setImplementation(mouseUp, origMouseUp);
1017
1018 return true;
1019 }

References flutter::testing::CreateMockFlutterEngine(), MouseEventFlutterViewController::mouseDownCalled, and MouseEventFlutterViewController::mouseUpCalled.

## ◆ testTrackpadGesturesAreSentToFramework

- (bool) testTrackpadGesturesAreSentToFramework |  |  |

Definition at line 651 of file FlutterViewControllerTest.mm.

651 {
652 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
653 // Need to return a real renderer to allow view controller to load.
654 FlutterRenderer* renderer_ = [[FlutterRenderer alloc] initWithFlutterEngine:engineMock];
655 OCMStub([engineMock renderer]).andReturn(renderer_);
656 __block bool called = false;
657 __block FlutterPointerEvent last_event;
658 OCMStub([[engineMock ignoringNonObjectArgs] sendPointerEvent:FlutterPointerEvent{}])
659 .andDo((^(NSInvocation* invocation) {
660 FlutterPointerEvent* event;
661 [invocation getArgument:&event atIndex:2];
662 called = true;
663 last_event = *event;
664 }));
665
666 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
667 nibName:@""
668 bundle:nil];
669 [viewController loadView];
670
671 // Test for pan events.
672 // Start gesture.
673 CGEventRef cgEventStart = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
674 CGEventSetType(cgEventStart, kCGEventScrollWheel);
675 CGEventSetIntegerValueField(cgEventStart, kCGScrollWheelEventScrollPhase, kCGScrollPhaseBegan);
676 CGEventSetIntegerValueField(cgEventStart, kCGScrollWheelEventIsContinuous, 1);
677
678 called = false;
679 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventStart]];
680 EXPECT_TRUE(called);
681 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
682 EXPECT_EQ(last_event.phase, kPanZoomStart);
683 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
684 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
685
686 // Update gesture.
687 CGEventRef cgEventUpdate = CGEventCreateCopy(cgEventStart);
688 CGEventSetIntegerValueField(cgEventUpdate, kCGScrollWheelEventScrollPhase, kCGScrollPhaseChanged);
689 CGEventSetIntegerValueField(cgEventUpdate, kCGScrollWheelEventDeltaAxis2, 1); // pan_x
690 CGEventSetIntegerValueField(cgEventUpdate, kCGScrollWheelEventDeltaAxis1, 2); // pan_y
691
692 called = false;
693 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventUpdate]];
694 EXPECT_TRUE(called);
695 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
696 EXPECT_EQ(last_event.phase, kPanZoomUpdate);
697 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
698 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
699 EXPECT_EQ(last_event.pan_x, 8 * viewController.flutterView.layer.contentsScale);
700 EXPECT_EQ(last_event.pan_y, 16 * viewController.flutterView.layer.contentsScale);
701
702 // Make sure the pan values accumulate.
703 called = false;
704 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventUpdate]];
705 EXPECT_TRUE(called);
706 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
707 EXPECT_EQ(last_event.phase, kPanZoomUpdate);
708 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
709 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
710 EXPECT_EQ(last_event.pan_x, 16 * viewController.flutterView.layer.contentsScale);
711 EXPECT_EQ(last_event.pan_y, 32 * viewController.flutterView.layer.contentsScale);
712
713 // End gesture.
714 CGEventRef cgEventEnd = CGEventCreateCopy(cgEventStart);
715 CGEventSetIntegerValueField(cgEventEnd, kCGScrollWheelEventScrollPhase, kCGScrollPhaseEnded);
716
717 called = false;
718 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventEnd]];
719 EXPECT_TRUE(called);
720 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
721 EXPECT_EQ(last_event.phase, kPanZoomEnd);
722 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
723 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
724
725 // Start system momentum.
726 CGEventRef cgEventMomentumStart = CGEventCreateCopy(cgEventStart);
727 CGEventSetIntegerValueField(cgEventMomentumStart, kCGScrollWheelEventScrollPhase, 0);
728 CGEventSetIntegerValueField(cgEventMomentumStart, kCGScrollWheelEventMomentumPhase,
729 kCGMomentumScrollPhaseBegin);
730
731 called = false;
732 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventMomentumStart]];
733 EXPECT_FALSE(called);
734
735 // Advance system momentum.
736 CGEventRef cgEventMomentumUpdate = CGEventCreateCopy(cgEventStart);
737 CGEventSetIntegerValueField(cgEventMomentumUpdate, kCGScrollWheelEventScrollPhase, 0);
738 CGEventSetIntegerValueField(cgEventMomentumUpdate, kCGScrollWheelEventMomentumPhase,
739 kCGMomentumScrollPhaseContinue);
740
741 called = false;
742 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventMomentumUpdate]];
743 EXPECT_FALSE(called);
744
745 // Mock a touch on the trackpad.
746 id touchMock = OCMClassMock([NSTouch class]);
747 NSSet* touchSet = [NSSet setWithObject:touchMock];
748 id touchEventMock1 = OCMClassMock([NSEvent class]);
749 OCMStub([touchEventMock1 allTouches]).andReturn(touchSet);
750 CGPoint touchLocation = {0, 0};
751 OCMStub([touchEventMock1 locationInWindow]).andReturn(touchLocation);
752 OCMStub([(NSEvent*)touchEventMock1 timestamp]).andReturn(0.150); // 150 milliseconds.
753
754 // Scroll inertia cancel event should not be issued (timestamp too far in the future).
755 called = false;
756 [viewController touchesBeganWithEvent:touchEventMock1];
757 EXPECT_FALSE(called);
758
759 // Mock another touch on the trackpad.
760 id touchEventMock2 = OCMClassMock([NSEvent class]);
761 OCMStub([touchEventMock2 allTouches]).andReturn(touchSet);
762 OCMStub([touchEventMock2 locationInWindow]).andReturn(touchLocation);
763 OCMStub([(NSEvent*)touchEventMock2 timestamp]).andReturn(0.005); // 5 milliseconds.
764
765 // Scroll inertia cancel event should be issued.
766 called = false;
767 [viewController touchesBeganWithEvent:touchEventMock2];
768 EXPECT_TRUE(called);
769 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindScrollInertiaCancel);
770 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
771
772 // End system momentum.
773 CGEventRef cgEventMomentumEnd = CGEventCreateCopy(cgEventStart);
774 CGEventSetIntegerValueField(cgEventMomentumEnd, kCGScrollWheelEventScrollPhase, 0);
775 CGEventSetIntegerValueField(cgEventMomentumEnd, kCGScrollWheelEventMomentumPhase,
776 kCGMomentumScrollPhaseEnd);
777
778 called = false;
779 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventMomentumEnd]];
780 EXPECT_FALSE(called);
781
782 // May-begin and cancel are used while macOS determines which type of gesture to choose.
783 CGEventRef cgEventMayBegin = CGEventCreateCopy(cgEventStart);
784 CGEventSetIntegerValueField(cgEventMayBegin, kCGScrollWheelEventScrollPhase,
785 kCGScrollPhaseMayBegin);
786
787 called = false;
788 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventMayBegin]];
789 EXPECT_TRUE(called);
790 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
791 EXPECT_EQ(last_event.phase, kPanZoomStart);
792 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
793 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
794
795 // Cancel gesture.
796 CGEventRef cgEventCancel = CGEventCreateCopy(cgEventStart);
797 CGEventSetIntegerValueField(cgEventCancel, kCGScrollWheelEventScrollPhase,
798 kCGScrollPhaseCancelled);
799
800 called = false;
801 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventCancel]];
802 EXPECT_TRUE(called);
803 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
804 EXPECT_EQ(last_event.phase, kPanZoomEnd);
805 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
806 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
807
808 // A discrete scroll event should use the PointerSignal system.
809 CGEventRef cgEventDiscrete = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
810 CGEventSetType(cgEventDiscrete, kCGEventScrollWheel);
811 CGEventSetIntegerValueField(cgEventDiscrete, kCGScrollWheelEventIsContinuous, 0);
812 CGEventSetIntegerValueField(cgEventDiscrete, kCGScrollWheelEventDeltaAxis2, 1); // scroll_delta_x
813 CGEventSetIntegerValueField(cgEventDiscrete, kCGScrollWheelEventDeltaAxis1, 2); // scroll_delta_y
814
815 called = false;
816 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventDiscrete]];
817 EXPECT_TRUE(called);
818 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindScroll);
819 // pixelsPerLine is 40.0 and direction is reversed.
820 EXPECT_EQ(last_event.scroll_delta_x, -40 * viewController.flutterView.layer.contentsScale);
821 EXPECT_EQ(last_event.scroll_delta_y, -80 * viewController.flutterView.layer.contentsScale);
822
823 // A discrete scroll event should use the PointerSignal system, and flip the
824 // direction when shift is pressed.
825 CGEventRef cgEventDiscreteShift =
826 CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
827 CGEventSetType(cgEventDiscreteShift, kCGEventScrollWheel);
828 CGEventSetFlags(cgEventDiscreteShift, kCGEventFlagMaskShift);
829 CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventIsContinuous, 0);
830 CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventDeltaAxis2,
831 0); // scroll_delta_x
832 CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventDeltaAxis1,
833 2); // scroll_delta_y
834
835 called = false;
836 [viewController scrollWheel:[NSEvent eventWithCGEvent:cgEventDiscreteShift]];
837 EXPECT_TRUE(called);
838 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindScroll);
839 // pixelsPerLine is 40.0, direction is reversed and axes have been flipped back.
840 EXPECT_FLOAT_EQ(last_event.scroll_delta_x, 0.0 * viewController.flutterView.layer.contentsScale);
841 EXPECT_FLOAT_EQ(last_event.scroll_delta_y,
842 -80.0 * viewController.flutterView.layer.contentsScale);
843
844 // Test for scale events.
845 // Start gesture.
846 called = false;
847 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
848 NSEventPhaseBegan, 1, 0)];
849 EXPECT_TRUE(called);
850 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
851 EXPECT_EQ(last_event.phase, kPanZoomStart);
852 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
853 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
854
855 // Update gesture.
856 called = false;
857 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
858 NSEventPhaseChanged, 1, 0)];
859 EXPECT_TRUE(called);
860 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
861 EXPECT_EQ(last_event.phase, kPanZoomUpdate);
862 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
863 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
864 EXPECT_EQ(last_event.pan_x, 0);
865 EXPECT_EQ(last_event.pan_y, 0);
866 EXPECT_EQ(last_event.scale, 2); // macOS uses logarithmic scaling values, the linear value for
867 // flutter here should be 2^1 = 2.
868 EXPECT_EQ(last_event.rotation, 0);
869
870 // Make sure the scale values accumulate.
871 called = false;
872 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
873 NSEventPhaseChanged, 1, 0)];
874 EXPECT_TRUE(called);
875 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
876 EXPECT_EQ(last_event.phase, kPanZoomUpdate);
877 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
878 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
879 EXPECT_EQ(last_event.pan_x, 0);
880 EXPECT_EQ(last_event.pan_y, 0);
881 EXPECT_EQ(last_event.scale, 4); // macOS uses logarithmic scaling values, the linear value for
882 // flutter here should be 2^(1+1) = 2.
883 EXPECT_EQ(last_event.rotation, 0);
884
885 // End gesture.
886 called = false;
887 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
888 NSEventPhaseEnded, 0, 0)];
889 EXPECT_TRUE(called);
890 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
891 EXPECT_EQ(last_event.phase, kPanZoomEnd);
892 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
893 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
894
895 // Test for rotation events.
896 // Start gesture.
897 called = false;
898 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(NSEventTypeRotate,
899 NSEventPhaseBegan, 1, 0)];
900 EXPECT_TRUE(called);
901 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
902 EXPECT_EQ(last_event.phase, kPanZoomStart);
903 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
904 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
905
906 // Update gesture.
907 called = false;
908 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(
909 NSEventTypeRotate, NSEventPhaseChanged, 0, -180)]; // degrees
910 EXPECT_TRUE(called);
911 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
912 EXPECT_EQ(last_event.phase, kPanZoomUpdate);
913 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
914 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
915 EXPECT_EQ(last_event.pan_x, 0);
916 EXPECT_EQ(last_event.pan_y, 0);
917 EXPECT_EQ(last_event.scale, 1);
918 EXPECT_EQ(last_event.rotation, M_PI); // radians
919
920 // Make sure the rotation values accumulate.
921 called = false;
922 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(
923 NSEventTypeRotate, NSEventPhaseChanged, 0, -360)]; // degrees
924 EXPECT_TRUE(called);
925 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
926 EXPECT_EQ(last_event.phase, kPanZoomUpdate);
927 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
928 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
929 EXPECT_EQ(last_event.pan_x, 0);
930 EXPECT_EQ(last_event.pan_y, 0);
931 EXPECT_EQ(last_event.scale, 1);
932 EXPECT_EQ(last_event.rotation, 3 * M_PI); // radians
933
934 // End gesture.
935 called = false;
936 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(NSEventTypeRotate,
937 NSEventPhaseEnded, 0, 0)];
938 EXPECT_TRUE(called);
939 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
940 EXPECT_EQ(last_event.phase, kPanZoomEnd);
941 EXPECT_EQ(last_event.device_kind, kFlutterPointerDeviceKindTrackpad);
942 EXPECT_EQ(last_event.signal_kind, kFlutterPointerSignalKindNone);
943
944 return true;
945 }

References flutter::testing::CreateMockFlutterEngine().

## ◆ testViewControllerIsReleased

- (bool) testViewControllerIsReleased |  |  |

Definition at line 1128 of file FlutterViewControllerTest.mm.

1128 {
1129 __weak FlutterViewController* weakController;
1130 @autoreleasepool {
1131 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
1132
1133 FlutterRenderer* renderer_ = [[FlutterRenderer alloc] initWithFlutterEngine:engineMock];
1134 OCMStub([engineMock renderer]).andReturn(renderer_);
1135
1136 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
1137 nibName:@""
1138 bundle:nil];
1139 [viewController loadView];
1140 weakController = viewController;
1141 }
1142
1143 EXPECT_EQ(weakController, nil);
1144
1145 return true;
1146 }

References flutter::testing::CreateMockFlutterEngine().

## ◆ testViewWillAppearCalledMultipleTimes

- (bool) testViewWillAppearCalledMultipleTimes |  |  |

Definition at line 947 of file FlutterViewControllerTest.mm.

947 {
948 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
949 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
950 nibName:@""
951 bundle:nil];
952 [viewController viewWillAppear];
953 [viewController viewWillAppear];
954 return true;
955 }

References flutter::testing::CreateMockFlutterEngine().

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

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

FlutterViewControllerTestObjC
Definition: FlutterViewControllerTest.mm:58
FlutterViewController
Definition: FlutterViewController.h:62
MouseEventFlutterViewController
Definition: FlutterViewControllerTest.mm:43
flutter::testing::CreateMockFlutterEngine
id CreateMockFlutterEngine(NSString *pasteboardString)
Definition: FlutterEngineTestUtils.mm:47
flutter::kModifierFlagMetaLeft
@ kModifierFlagMetaLeft
Definition: KeyCodeMap_Internal.h:80
flutter::kModifierFlagAltRight
@ kModifierFlagAltRight
Definition: KeyCodeMap_Internal.h:83
flutter::kModifierFlagMetaRight
@ kModifierFlagMetaRight
Definition: KeyCodeMap_Internal.h:81
-[FlutterViewController lookupKeyForAsset:]
nonnull NSString * lookupKeyForAsset:(nonnull NSString *asset)
MouseEventFlutterViewController::mouseDownCalled
BOOL mouseDownCalled
Definition: FlutterViewControllerTest.mm:44
KeyEventWrapper
Definition: FlutterViewControllerTest.mm:24
FlutterRenderer
Definition: FlutterRenderer.h:15
flutter::kModifierFlagControlLeft
@ kModifierFlagControlLeft
Definition: KeyCodeMap_Internal.h:77
-[FlutterViewController onPreEngineRestart]
void onPreEngineRestart()
Definition: FlutterViewController.mm:487
flutter::kModifierFlagAltLeft
@ kModifierFlagAltLeft
Definition: KeyCodeMap_Internal.h:82
-[FlutterViewController lookupKeyForAsset:fromPackage:]
nonnull NSString * lookupKeyForAsset:fromPackage:(nonnull NSString *asset,[fromPackage] nonnull NSString *package)
flutter::keyCodeToModifierFlag
const NSDictionary * keyCodeToModifierFlag
Definition: KeyCodeMap.g.mm:223
flutter::kModifierFlagShiftRight
@ kModifierFlagShiftRight
Definition: KeyCodeMap_Internal.h:79
MouseEventFlutterViewController::mouseUpCalled
BOOL mouseUpCalled
Definition: FlutterViewControllerTest.mm:45
FlutterView
Definition: FlutterView.h:39
flutter::kModifierFlagShiftLeft
@ kModifierFlagShiftLeft
Definition: KeyCodeMap_Internal.h:78
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:48
flutter::kModifierFlagControlRight
@ kModifierFlagControlRight
Definition: KeyCodeMap_Internal.h:84
FlutterBinaryReply
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
+[FlutterMessageCodec-p sharedInstance]
instancetype sharedInstance()
FlutterJSONMessageCodec
Definition: FlutterCodecs.h:81