Flutter macOS Embedder
flutter::testing Namespace Reference

Classes

class  FlutterEngineTest
 
class  FlutterMenuPluginTest
 
class  MockFlutterEngineTest
 

Typedefs

using FlutterChannelKeyResponderTest = AutoreleasePoolTest
 
using FlutterEmbedderExternalTextureTest = AutoreleasePoolTest
 
using FlutterViewControllerTest = AutoreleasePoolTest
 
using FlutterViewControllerMockEngineTest = MockFlutterEngineTest
 

Functions

 TEST_F (AccessibilityBridgeMacWindowTest, SendsAccessibilityCreateNotificationFlutterViewWindow)
 
 TEST_F (AccessibilityBridgeMacWindowTest, NonZeroRootNodeId)
 
 TEST_F (AccessibilityBridgeMacTest, DoesNotSendAccessibilityCreateNotificationWhenHeadless)
 
 TEST_F (AccessibilityBridgeMacTest, DoesNotSendAccessibilityCreateNotificationWhenNoWindow)
 
 TEST (FlutterAppDelegateTest, DoesNotCallDelegatesWithoutHandler)
 
 TEST (FlutterAppDelegateTest, ReceivesOpenURLs)
 
 TEST (FlutterAppDelegateTest, OperURLsStopsAfterHandled)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillFinishLaunching)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidFinishLaunching)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillBecomeActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidBecomeActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillResignActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidResignActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillTerminate)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillHide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillUnhide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidHide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidUnhide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidChangeScreenParameters)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidChangeOcclusionState)
 
 TEST (FlutterAppLifecycleDelegateTest, ReleasesDelegateOnDealloc)
 
 TEST_F (FlutterChannelKeyResponderTest, BasicKeyEvent)
 
 TEST_F (FlutterChannelKeyResponderTest, EmptyResponseIsTakenAsHandled)
 
 TEST_F (FlutterChannelKeyResponderTest, FollowsLayoutMap)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestTextureResolution)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTexture)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureYUVA)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureYUVA2)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateUnsupportedExternalTexture)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestTextureResolutionImpeller)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureImpeller)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureYUVAImpeller)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureYUVA2Impeller)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateUnsupportedExternalTextureImpeller)
 
 TEST (FlutterEmbedderKeyResponderUnittests, BasicKeyEvent)
 
 TEST (FlutterEmbedderKeyResponderUnittests, NonAsciiCharacters)
 
 TEST (FlutterEmbedderKeyResponderUnittests, MultipleCharacters)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynthesizeForDuplicateDownEvent)
 
 TEST (FlutterEmbedderKeyResponderUnittests, IgnoreDuplicateUpEvent)
 
 TEST (FlutterEmbedderKeyResponderUnittests, ConvertAbruptRepeatEventsToDown)
 
 TEST (FlutterEmbedderKeyResponderUnittests, ToggleModifiersDuringKeyTap)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SpecialModiferFlags)
 
 TEST (FlutterEmbedderKeyResponderUnittests, IdentifyLeftAndRightModifiers)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynthesizeMissedModifierEvents)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynthesizeMissedModifierEventsInNormalEvents)
 
 TEST (FlutterEmbedderKeyResponderUnittests, ConvertCapsLockEvents)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynchronizeCapsLockStateOnCapsLock)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynchronizeCapsLockStateOnNormalKey)
 
 TEST_F (FlutterEngineTest, CanLaunch)
 
 TEST_F (FlutterEngineTest, HasNonNullExecutableName)
 
 TEST_F (FlutterEngineTest, Switches)
 
 TEST_F (FlutterEngineTest, MessengerSend)
 
 TEST_F (FlutterEngineTest, CanLogToStdout)
 
 TEST_F (FlutterEngineTest, DISABLED_BackgroundIsBlack)
 
 TEST_F (FlutterEngineTest, DISABLED_CanOverrideBackgroundColor)
 
 TEST_F (FlutterEngineTest, CanToggleAccessibility)
 
 TEST_F (FlutterEngineTest, CanToggleAccessibilityWhenHeadless)
 
 TEST_F (FlutterEngineTest, ProducesAccessibilityTreeWhenAddingViews)
 
 TEST_F (FlutterEngineTest, NativeCallbacks)
 
 TEST_F (FlutterEngineTest, Compositor)
 
 TEST_F (FlutterEngineTest, CompositorIgnoresUnknownView)
 
 TEST_F (FlutterEngineTest, DartEntrypointArguments)
 
 TEST_F (FlutterEngineTest, FlutterBinaryMessengerDoesNotRetainEngine)
 
 TEST_F (FlutterEngineTest, FlutterTextureRegistryDoesNotReturnEngine)
 
 TEST_F (FlutterEngineTest, PublishedValueNilForUnknownPlugin)
 
 TEST_F (FlutterEngineTest, PublishedValueNSNullIfNoPublishedValue)
 
 TEST_F (FlutterEngineTest, PublishedValueReturnsLastPublished)
 
 TEST_F (FlutterEngineTest, MessengerCleanupConnectionWorks)
 
 TEST_F (FlutterEngineTest, HasStringsWhenPasteboardEmpty)
 
 TEST_F (FlutterEngineTest, HasStringsWhenPasteboardFull)
 
 TEST_F (FlutterEngineTest, ResponseAfterEngineDied)
 
 TEST_F (FlutterEngineTest, ResponseFromBackgroundThread)
 
 TEST_F (FlutterEngineTest, ThreadSynchronizerNotBlockingRasterThreadAfterShutdown)
 
 TEST_F (FlutterEngineTest, ManageControllersIfInitiatedByController)
 
 TEST_F (FlutterEngineTest, ManageControllersIfInitiatedByEngine)
 
 TEST_F (FlutterEngineTest, RemovingViewDisposesCompositorResources)
 
 TEST_F (FlutterEngineTest, HandlesTerminationRequest)
 
 TEST_F (FlutterEngineTest, IgnoresTerminationRequestIfNotFlutterAppDelegate)
 
 TEST_F (FlutterEngineTest, HandleAccessibilityEvent)
 
 TEST_F (FlutterEngineTest, HandleLifecycleStates) API_AVAILABLE(macos(10.9))
 
 TEST_F (FlutterEngineTest, ForwardsPluginDelegateRegistration)
 
 TEST_F (FlutterEngineTest, UnregistersPluginsOnEngineDestruction)
 
 TEST_F (FlutterEngineTest, RunWithEntrypointUpdatesDisplayConfig)
 
 TEST_F (FlutterEngineTest, NotificationsUpdateDisplays)
 
 TEST_F (FlutterEngineTest, DisplaySizeIsInPhysicalPixel)
 
 TEST_F (FlutterEngineTest, ReportsHourFormat)
 
id CreateMockFlutterEngine (NSString *pasteboardString)
 
 TEST (FlutterKeyboardManagerUnittests, SinglePrimaryResponder)
 
 TEST (FlutterKeyboardManagerUnittests, DoublePrimaryResponder)
 
 TEST (FlutterKeyboardManagerUnittests, SingleFinalResponder)
 
 TEST (FlutterKeyboardManagerUnittests, EmptyNextResponder)
 
 TEST (FlutterKeyboardManagerUnittests, GetPressedState)
 
 TEST (FlutterKeyboardManagerUnittests, KeyboardChannelGetPressedState)
 
 TEST (FlutterKeyboardManagerUnittests, RacingConditionBetweenKeyAndText)
 
 TEST (FlutterKeyboardManagerUnittests, CorrectLogicalKeyForLayouts)
 
 TEST (FlutterKeyboardManagerUnittests, ShouldNotHoldStrongReferenceToViewDelegate)
 
 TEST_F (FlutterMenuPluginTest, TestSetMenu)
 
 TEST (FlutterPlatformNodeDelegateMac, Basics)
 
 TEST (FlutterPlatformNodeDelegateMac, SelectableTextHasCorrectSemantics)
 
 TEST (FlutterPlatformNodeDelegateMac, SelectableTextWithoutSelectionReturnZeroRange)
 
 TEST (FlutterPlatformNodeDelegateMac, CanPerformAction)
 
 TEST (FlutterPlatformNodeDelegateMac, TextFieldUsesFlutterTextField)
 
 TEST (FlutterPlatformNodeDelegateMac, ChangingFlagsUpdatesNativeViewAccessible)
 
 TEST (FlutterPlatformViewController, TestCreatePlatformViewNoMatchingViewType)
 
 TEST (FlutterPlatformViewController, TestRegisterPlatformViewFactoryAndCreate)
 
 TEST (FlutterPlatformViewController, TestCreateAndDispose)
 
 TEST (FlutterPlatformViewController, TestDisposeOnMissingViewId)
 
 TEST (FlutterPlatformViewController, TestAcceptGesture)
 
 TEST (FlutterPlatformViewController, TestAcceptGestureOnMissingViewId)
 
 TEST (FlutterPlatformViewController, TestRejectGesture)
 
 TEST (FlutterPlatformViewController, TestRejectGestureOnMissingViewId)
 
static FlutterSurfaceManagerCreateSurfaceManager (TestView *testView)
 
static FlutterSurfacePresentInfoCreatePresentInfo (FlutterSurface *surface, CGPoint offset=CGPointZero, size_t index=0, const std::vector< FlutterRect > &paintRegion={})
 
 TEST (FlutterSurfaceManager, MetalTextureSizeMatchesSurfaceSize)
 
 TEST (FlutterSurfaceManager, TestSurfaceLookupFromTexture)
 
 TEST (FlutterSurfaceManager, BackBufferCacheDoesNotLeak)
 
 TEST (FlutterSurfaceManager, SurfacesAreRecycled)
 
 TEST (FlutterSurfaceManager, BackingStoreCacheSurfaceStuckInUse)
 
bool operator== (const CGRect &lhs, const CGRect &rhs)
 
 TEST (FlutterSurfaceManager, LayerManagement)
 
 TEST (FlutterTextInputPluginTest, TestEmptyCompositionRange)
 
 TEST (FlutterTextInputPluginTest, TestSetMarkedTextWithSelectionChange)
 
 TEST (FlutterTextInputPluginTest, TestSetMarkedTextWithReplacementRange)
 
 TEST (FlutterTextInputPluginTest, TestComposingRegionRemovedByFramework)
 
 TEST (FlutterTextInputPluginTest, TestClearClientDuringComposing)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenAutofillNotSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteEnabledWhenAutofillSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteEnabledWhenAutofillSetNoHint)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenObscureTextSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenPasswordAutofillSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenAutofillGroupIncludesPassword)
 
 TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRange)
 
 TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRangeAtInfinity)
 
 TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRangeWithEsotericAffineTransform)
 
 TEST (FlutterTextInputPluginTest, TestSetEditingStateWithTextEditingDelta)
 
 TEST (FlutterTextInputPluginTest, TestOperationsThatTriggerDelta)
 
 TEST (FlutterTextInputPluginTest, TestComposingWithDelta)
 
 TEST (FlutterTextInputPluginTest, TestComposingWithDeltasWhenSelectionIsActive)
 
 TEST (FlutterTextInputPluginTest, TestLocalTextAndSelectionUpdateAfterDelta)
 
 TEST (FlutterTextInputPluginTest, TestPerformKeyEquivalent)
 
 TEST (FlutterTextInputPluginTest, HandleArrowKeyWhenImePopoverIsActive)
 
 TEST (FlutterTextInputPluginTest, UnhandledKeyEquivalent)
 
 TEST (FlutterTextInputPluginTest, TestSelectorsAreForwardedToFramework)
 
 TEST (FlutterTextInputPluginTest, TestSelectorsNotForwardedToFrameworkIfNoClient)
 
 TEST (FlutterTextInputPluginTest, TestInsertNewLine)
 
 TEST (FlutterTextInputPluginTest, TestSendActionDoNotInsertNewLine)
 
 TEST (FlutterTextInputPluginTest, TestAttributedSubstringOutOfRange)
 
 TEST (FlutterTextInputPluginTest, CanWorkWithFlutterTextField)
 
 TEST (FlutterTextInputPluginTest, CanNotBecomeResponderIfNoViewController)
 
 TEST (FlutterTextInputPluginTest, IsAddedAndRemovedFromViewHierarchy)
 
 TEST (FlutterTextInputPluginTest, FirstResponderIsCorrect)
 
 TEST (FlutterTextInputPluginTest, HasZeroSizeAndClipsToBounds)
 
 TEST (FlutterTextInputSemanticsObjectTest, DoesInitialize)
 
 TEST_F (FlutterViewControllerTest, HasViewThatHidesOtherViewsInAccessibility)
 
 TEST_F (FlutterViewControllerTest, FlutterViewAcceptsFirstMouse)
 
 TEST_F (FlutterViewControllerTest, ReparentsPluginWhenAccessibilityDisabled)
 
 TEST_F (FlutterViewControllerTest, CanSetMouseTrackingModeBeforeViewLoaded)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEventsAreSentToFramework)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEventsArePropagatedIfNotHandled)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEventsAreNotPropagatedIfHandled)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestCtrlTabKeyEventIsPropagated)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEquivalentIsPassedToTextInputPlugin)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestFlagsChangedEventsArePropagatedIfNotHandled)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyboardIsRestartedOnEngineRestart)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestTrackpadGesturesAreSentToFramework)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestmouseAndGestureEventsAreHandledSeparately)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestMouseDownUpEventsSentToNextResponder)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestModifierKeysAreSynthesizedOnMouseMove)
 
 TEST_F (FlutterViewControllerMockEngineTest, testViewWillAppearCalledMultipleTimes)
 
 TEST_F (FlutterViewControllerMockEngineTest, testFlutterViewIsConfigured)
 
 TEST_F (FlutterViewControllerTest, testLookupKeyAssets)
 
 TEST_F (FlutterViewControllerTest, testLookupKeyAssetsWithPackage)
 
 TEST_F (FlutterViewControllerTest, testViewControllerIsReleased)
 
id CreateMockViewController ()
 
 TEST (FlutterViewEngineProviderUnittests, GetViewReturnsTheCorrectView)
 
 TEST (KeyMappingTest, HasExpectedValues)
 
FlutterSemanticsNode2 CreateSemanticsNode (int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)
 
 TEST (AccessibilityBridgeTest, BasicTest)
 
 TEST (AccessibilityBridgeTest, AccessibilityRootId)
 
 TEST (AccessibilityBridgeTest, AddOrder)
 
 TEST (AccessibilityBridgeTest, CanFireChildrenChangedCorrectly)
 
 TEST (AccessibilityBridgeTest, CanHandleSelectionChangeCorrectly)
 
 TEST (AccessibilityBridgeTest, DoesNotAssignEditableRootToSelectableText)
 
 TEST (AccessibilityBridgeTest, SwitchHasSwitchRole)
 
 TEST (AccessibilityBridgeTest, SliderHasSliderRole)
 
 TEST (AccessibilityBridgeTest, CanSetCheckboxChecked)
 
 TEST (AccessibilityBridgeTest, CanReparentNode)
 
 TEST (AccessibilityBridgeTest, CanReparentMultipleNodes)
 
 TEST (AccessibilityBridgeTest, CanReparentNodeWithChild)
 
 TEST (AccessibilityBridgeTest, AXTreeManagerTest)
 
 TEST (AccessibilityBridgeTest, LineBreakingObjectTest)
 
 TEST (FlutterPlatformNodeDelegateTest, NodeDelegateHasUniqueId)
 
 TEST (FlutterPlatformNodeDelegateTest, canPerfomActions)
 
 TEST (FlutterPlatformNodeDelegateTest, canGetAXNode)
 
 TEST (FlutterPlatformNodeDelegateTest, canCalculateBoundsCorrectly)
 
 TEST (FlutterPlatformNodeDelegateTest, canCalculateOffScreenBoundsCorrectly)
 
 TEST (FlutterPlatformNodeDelegateTest, canUseOwnerBridge)
 
 TEST (FlutterPlatformNodeDelegateTest, selfIsLowestPlatformAncestor)
 
 TEST (FlutterPlatformNodeDelegateTest, canGetFromNodeID)
 

Typedef Documentation

◆ FlutterChannelKeyResponderTest

using flutter::testing::FlutterChannelKeyResponderTest = typedef AutoreleasePoolTest

Definition at line 73 of file FlutterChannelKeyResponderTest.mm.

◆ FlutterEmbedderExternalTextureTest

using flutter::testing::FlutterEmbedderExternalTextureTest = typedef AutoreleasePoolTest

Definition at line 93 of file FlutterEmbedderExternalTextureTest.mm.

◆ FlutterViewControllerMockEngineTest

◆ FlutterViewControllerTest

using flutter::testing::FlutterViewControllerTest = typedef AutoreleasePoolTest

Definition at line 179 of file FlutterViewControllerTest.mm.

Function Documentation

◆ CreateMockFlutterEngine()

id flutter::testing::CreateMockFlutterEngine ( NSString *  pasteboardString)

Definition at line 76 of file FlutterEngineTestUtils.mm.

76  {
77  NSString* fixtures = @(testing::GetFixturesPath());
78  FlutterDartProject* project = [[FlutterDartProject alloc]
79  initWithAssetsPath:fixtures
80  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
81  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
82  project:project
83  allowHeadlessExecution:true];
84 
85  FakePasteboard* pasteboardMock = [[FakePasteboard alloc] init];
86  [pasteboardMock setString:pasteboardString forType:NSPasteboardTypeString];
87  engine.pasteboard = pasteboardMock;
88  id engineMock = OCMPartialMock(engine);
89  return engineMock;
90 }

References FlutterPasteboard::setString:forType:.

Referenced by flutter::testing::MockFlutterEngineTest::SetUp(), TEST(), TEST_F(), FlutterInputPluginTestObjc::testClearClientDuringComposing, FlutterInputPluginTestObjc::testEmptyCompositionRange, and FlutterViewControllerTestObjC::testViewControllerIsReleased.

◆ CreateMockViewController()

id flutter::testing::CreateMockViewController ( )

Definition at line 9 of file FlutterViewControllerTestUtils.mm.

9  {
10  {
11  NSString* fixtures = @(testing::GetFixturesPath());
12  FlutterDartProject* project = [[FlutterDartProject alloc]
13  initWithAssetsPath:fixtures
14  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
15  FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project];
16  id viewControllerMock = OCMPartialMock(viewController);
17  return viewControllerMock;
18  }
19 }

Referenced by TEST_F().

◆ CreatePresentInfo()

static FlutterSurfacePresentInfo* flutter::testing::CreatePresentInfo ( FlutterSurface surface,
CGPoint  offset = CGPointZero,
size_t  index = 0,
const std::vector< FlutterRect > &  paintRegion = {} 
)
static

Definition at line 51 of file FlutterSurfaceManagerTest.mm.

55  {}) {
57  res.surface = surface;
58  res.offset = offset;
59  res.zIndex = index;
60  res.paintRegion = paintRegion;
61  return res;
62 }

◆ CreateSemanticsNode()

FlutterSemanticsNode2 flutter::testing::CreateSemanticsNode ( int32_t  id,
const char *  label,
const std::vector< int32_t > *  children = nullptr 
)

Definition at line 18 of file accessibility_bridge_unittests.cc.

21  {
22  return {
23  .id = id,
24  .flags = static_cast<FlutterSemanticsFlag>(0),
25  .actions = static_cast<FlutterSemanticsAction>(0),
26  .text_selection_base = -1,
27  .text_selection_extent = -1,
28  .label = label,
29  .hint = "",
30  .value = "",
31  .increased_value = "",
32  .decreased_value = "",
33  .child_count = children ? children->size() : 0,
34  .children_in_traversal_order = children ? children->data() : nullptr,
35  .custom_accessibility_actions_count = 0,
36  .tooltip = "",
37  };
38 }

Referenced by TEST().

◆ CreateSurfaceManager()

static FlutterSurfaceManager* flutter::testing::CreateSurfaceManager ( TestView testView)
static

Definition at line 41 of file FlutterSurfaceManagerTest.mm.

41  {
42  id<MTLDevice> device = MTLCreateSystemDefaultDevice();
43  id<MTLCommandQueue> commandQueue = [device newCommandQueue];
44  CALayer* layer = reinterpret_cast<CALayer*>(testView.layer);
45  return [[FlutterSurfaceManager alloc] initWithDevice:device
46  commandQueue:commandQueue
47  layer:layer
48  delegate:testView];
49 }

Referenced by TEST().

◆ operator==()

bool flutter::testing::operator== ( const CGRect &  lhs,
const CGRect &  rhs 
)
inline

Definition at line 198 of file FlutterSurfaceManagerTest.mm.

198  {
199  return CGRectEqualToRect(lhs, rhs);
200 }

◆ TEST() [1/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
AccessibilityRootId   
)

Definition at line 72 of file accessibility_bridge_unittests.cc.

72  {
73  std::shared_ptr<TestAccessibilityBridge> bridge =
74  std::make_shared<TestAccessibilityBridge>();
75 
76  std::vector<int32_t> children{456, 789};
77  FlutterSemanticsNode2 root = CreateSemanticsNode(123, "root", &children);
78  FlutterSemanticsNode2 child1 = CreateSemanticsNode(456, "child 1");
79  FlutterSemanticsNode2 child2 = CreateSemanticsNode(789, "child 2");
80 
81  bridge->AddFlutterSemanticsNodeUpdate(root);
82  bridge->AddFlutterSemanticsNodeUpdate(child1);
83  bridge->AddFlutterSemanticsNodeUpdate(child2);
84  bridge->CommitUpdates();
85 
86  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(123).lock();
87  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(456).lock();
88  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(789).lock();
89  auto fake_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
90 
91  EXPECT_EQ(bridge->GetRootAsAXNode()->id(), 123);
92  EXPECT_EQ(bridge->RootDelegate()->GetName(), "root");
93 
94  EXPECT_EQ(root_node->GetChildCount(), 2);
95  EXPECT_EQ(root_node->GetData().child_ids[0], 456);
96  EXPECT_EQ(root_node->GetData().child_ids[1], 789);
97  EXPECT_EQ(root_node->GetName(), "root");
98 
99  EXPECT_EQ(child1_node->GetChildCount(), 0);
100  EXPECT_EQ(child1_node->GetName(), "child 1");
101 
102  EXPECT_EQ(child2_node->GetChildCount(), 0);
103  EXPECT_EQ(child2_node->GetName(), "child 2");
104 
105  ASSERT_FALSE(fake_delegate);
106 }

References CreateSemanticsNode().

◆ TEST() [2/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
AddOrder   
)

Definition at line 109 of file accessibility_bridge_unittests.cc.

109  {
110  std::shared_ptr<TestAccessibilityBridge> bridge =
111  std::make_shared<TestAccessibilityBridge>();
112 
113  std::vector<int32_t> root_children{34, 56};
114  std::vector<int32_t> child2_children{78};
115  std::vector<int32_t> child3_children{90};
116  FlutterSemanticsNode2 root = CreateSemanticsNode(12, "root", &root_children);
117  FlutterSemanticsNode2 child1 = CreateSemanticsNode(34, "child 1");
118  FlutterSemanticsNode2 child2 =
119  CreateSemanticsNode(56, "child 2", &child2_children);
120  FlutterSemanticsNode2 child3 =
121  CreateSemanticsNode(78, "child 3", &child3_children);
122  FlutterSemanticsNode2 child4 = CreateSemanticsNode(90, "child 4");
123 
124  bridge->AddFlutterSemanticsNodeUpdate(child3);
125  bridge->AddFlutterSemanticsNodeUpdate(child2);
126  bridge->AddFlutterSemanticsNodeUpdate(root);
127  bridge->AddFlutterSemanticsNodeUpdate(child1);
128  bridge->AddFlutterSemanticsNodeUpdate(child4);
129  bridge->CommitUpdates();
130 
131  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(12).lock();
132  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(34).lock();
133  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(56).lock();
134  auto child3_node = bridge->GetFlutterPlatformNodeDelegateFromID(78).lock();
135  auto child4_node = bridge->GetFlutterPlatformNodeDelegateFromID(90).lock();
136 
137  EXPECT_EQ(bridge->GetRootAsAXNode()->id(), 12);
138  EXPECT_EQ(bridge->RootDelegate()->GetName(), "root");
139 
140  EXPECT_EQ(root_node->GetChildCount(), 2);
141  EXPECT_EQ(root_node->GetData().child_ids[0], 34);
142  EXPECT_EQ(root_node->GetData().child_ids[1], 56);
143  EXPECT_EQ(root_node->GetName(), "root");
144 
145  EXPECT_EQ(child1_node->GetChildCount(), 0);
146  EXPECT_EQ(child1_node->GetName(), "child 1");
147 
148  EXPECT_EQ(child2_node->GetChildCount(), 1);
149  EXPECT_EQ(child2_node->GetData().child_ids[0], 78);
150  EXPECT_EQ(child2_node->GetName(), "child 2");
151 
152  EXPECT_EQ(child3_node->GetChildCount(), 1);
153  EXPECT_EQ(child3_node->GetData().child_ids[0], 90);
154  EXPECT_EQ(child3_node->GetName(), "child 3");
155 
156  EXPECT_EQ(child4_node->GetChildCount(), 0);
157  EXPECT_EQ(child4_node->GetName(), "child 4");
158 }

References CreateSemanticsNode().

◆ TEST() [3/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
AXTreeManagerTest   
)

Definition at line 546 of file accessibility_bridge_unittests.cc.

546  {
547  std::shared_ptr<TestAccessibilityBridge> bridge =
548  std::make_shared<TestAccessibilityBridge>();
549 
550  ui::AXTreeID tree_id = bridge->GetTreeID();
551  ui::AXTreeManager* manager =
552  ui::AXTreeManagerMap::GetInstance().GetManager(tree_id);
553  ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
554 }

◆ TEST() [4/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
BasicTest   
)

Definition at line 40 of file accessibility_bridge_unittests.cc.

40  {
41  std::shared_ptr<TestAccessibilityBridge> bridge =
42  std::make_shared<TestAccessibilityBridge>();
43 
44  std::vector<int32_t> children{1, 2};
45  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &children);
46  FlutterSemanticsNode2 child1 = CreateSemanticsNode(1, "child 1");
47  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
48 
49  bridge->AddFlutterSemanticsNodeUpdate(root);
50  bridge->AddFlutterSemanticsNodeUpdate(child1);
51  bridge->AddFlutterSemanticsNodeUpdate(child2);
52  bridge->CommitUpdates();
53 
54  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
55  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
56  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
57  EXPECT_EQ(root_node->GetChildCount(), 2);
58  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
59  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
60  EXPECT_EQ(root_node->GetName(), "root");
61 
62  EXPECT_EQ(child1_node->GetChildCount(), 0);
63  EXPECT_EQ(child1_node->GetName(), "child 1");
64 
65  EXPECT_EQ(child2_node->GetChildCount(), 0);
66  EXPECT_EQ(child2_node->GetName(), "child 2");
67 }

References CreateSemanticsNode().

◆ TEST() [5/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanFireChildrenChangedCorrectly   
)

Definition at line 160 of file accessibility_bridge_unittests.cc.

160  {
161  std::shared_ptr<TestAccessibilityBridge> bridge =
162  std::make_shared<TestAccessibilityBridge>();
163 
164  std::vector<int32_t> children{1};
165  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &children);
166  FlutterSemanticsNode2 child1 = CreateSemanticsNode(1, "child 1");
167 
168  bridge->AddFlutterSemanticsNodeUpdate(root);
169  bridge->AddFlutterSemanticsNodeUpdate(child1);
170 
171  bridge->CommitUpdates();
172 
173  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
174  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
175  EXPECT_EQ(root_node->GetChildCount(), 1);
176  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
177  EXPECT_EQ(root_node->GetName(), "root");
178 
179  EXPECT_EQ(child1_node->GetChildCount(), 0);
180  EXPECT_EQ(child1_node->GetName(), "child 1");
181  bridge->accessibility_events.clear();
182 
183  // Add a child to root.
184  root.child_count = 2;
185  int32_t new_children[] = {1, 2};
186  root.children_in_traversal_order = new_children;
187 
188  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
189 
190  bridge->AddFlutterSemanticsNodeUpdate(root);
191  bridge->AddFlutterSemanticsNodeUpdate(child2);
192  bridge->CommitUpdates();
193 
194  root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
195 
196  EXPECT_EQ(root_node->GetChildCount(), 2);
197  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
198  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
199  EXPECT_EQ(bridge->accessibility_events.size(), size_t{2});
200  std::set<ui::AXEventGenerator::Event> actual_event{
201  bridge->accessibility_events.begin(), bridge->accessibility_events.end()};
202  EXPECT_THAT(actual_event,
203  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED));
204  EXPECT_THAT(actual_event,
205  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED));
206 }

References CreateSemanticsNode().

◆ TEST() [6/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanHandleSelectionChangeCorrectly   
)

Definition at line 208 of file accessibility_bridge_unittests.cc.

208  {
209  std::shared_ptr<TestAccessibilityBridge> bridge =
210  std::make_shared<TestAccessibilityBridge>();
211  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
212  root.flags = static_cast<FlutterSemanticsFlag>(
213  FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField |
214  FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused);
215  bridge->AddFlutterSemanticsNodeUpdate(root);
216  bridge->CommitUpdates();
217 
218  const ui::AXTreeData& tree = bridge->GetAXTreeData();
219  EXPECT_EQ(tree.sel_anchor_object_id, ui::AXNode::kInvalidAXID);
220  bridge->accessibility_events.clear();
221 
222  // Update the selection.
223  root.text_selection_base = 0;
224  root.text_selection_extent = 5;
225  bridge->AddFlutterSemanticsNodeUpdate(root);
226 
227  bridge->CommitUpdates();
228 
229  EXPECT_EQ(tree.sel_anchor_object_id, 0);
230  EXPECT_EQ(tree.sel_anchor_offset, 0);
231  EXPECT_EQ(tree.sel_focus_object_id, 0);
232  EXPECT_EQ(tree.sel_focus_offset, 5);
233  ASSERT_EQ(bridge->accessibility_events.size(), size_t{2});
234  EXPECT_EQ(bridge->accessibility_events[0],
235  ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED);
236  EXPECT_EQ(bridge->accessibility_events[1],
237  ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED);
238 }

References CreateSemanticsNode().

◆ TEST() [7/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanReparentMultipleNodes   
)

Definition at line 372 of file accessibility_bridge_unittests.cc.

372  {
373  std::shared_ptr<TestAccessibilityBridge> bridge =
374  std::make_shared<TestAccessibilityBridge>();
375 
376  int32_t root_id = 0;
377  int32_t intermediary1_id = 1;
378  int32_t intermediary2_id = 2;
379  int32_t leaf1_id = 3;
380  int32_t leaf2_id = 4;
381  int32_t leaf3_id = 5;
382 
383  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
384  std::vector<int32_t> intermediary1_children{leaf1_id};
385  std::vector<int32_t> intermediary2_children{leaf2_id, leaf3_id};
386  FlutterSemanticsNode2 root =
387  CreateSemanticsNode(root_id, "root", &root_children);
388  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
389  intermediary1_id, "intermediary 1", &intermediary1_children);
390  FlutterSemanticsNode2 intermediary2 = CreateSemanticsNode(
391  intermediary2_id, "intermediary 2", &intermediary2_children);
392  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
393  FlutterSemanticsNode2 leaf2 = CreateSemanticsNode(leaf2_id, "leaf 2");
394  FlutterSemanticsNode2 leaf3 = CreateSemanticsNode(leaf3_id, "leaf 3");
395 
396  bridge->AddFlutterSemanticsNodeUpdate(root);
397  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
398  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
399  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
400  bridge->AddFlutterSemanticsNodeUpdate(leaf2);
401  bridge->AddFlutterSemanticsNodeUpdate(leaf3);
402  bridge->CommitUpdates();
403  bridge->accessibility_events.clear();
404 
405  // Swap intermediary 1's and intermediary2's children.
406  int32_t new_intermediary1_children[] = {leaf2_id, leaf3_id};
407  intermediary1.child_count = 2;
408  intermediary1.children_in_traversal_order = new_intermediary1_children;
409 
410  int32_t new_intermediary2_children[] = {leaf1_id};
411  intermediary2.child_count = 1;
412  intermediary2.children_in_traversal_order = new_intermediary2_children;
413 
414  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
415  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
416  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
417  bridge->AddFlutterSemanticsNodeUpdate(leaf2);
418  bridge->AddFlutterSemanticsNodeUpdate(leaf3);
419  bridge->CommitUpdates();
420 
421  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
422  auto intermediary1_node =
423  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
424  auto intermediary2_node =
425  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
426  auto leaf1_node =
427  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
428  auto leaf2_node =
429  bridge->GetFlutterPlatformNodeDelegateFromID(leaf2_id).lock();
430  auto leaf3_node =
431  bridge->GetFlutterPlatformNodeDelegateFromID(leaf3_id).lock();
432 
433  EXPECT_EQ(root_node->GetChildCount(), 2);
434  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary1_id);
435  EXPECT_EQ(root_node->GetData().child_ids[1], intermediary2_id);
436  EXPECT_EQ(root_node->GetName(), "root");
437 
438  EXPECT_EQ(intermediary1_node->GetChildCount(), 2);
439  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf2_id);
440  EXPECT_EQ(intermediary1_node->GetData().child_ids[1], leaf3_id);
441  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
442 
443  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
444  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], leaf1_id);
445  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
446 
447  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
448  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
449 
450  EXPECT_EQ(leaf2_node->GetChildCount(), 0);
451  EXPECT_EQ(leaf2_node->GetName(), "leaf 2");
452 
453  EXPECT_EQ(leaf3_node->GetChildCount(), 0);
454  EXPECT_EQ(leaf3_node->GetName(), "leaf 3");
455 
456  // Intermediary 1 and intermediary 2 have new children.
457  // Leaf 1, 2, and 3 are all moved.
458  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
459  EXPECT_THAT(bridge->accessibility_events,
460  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
461  EXPECT_THAT(bridge->accessibility_events,
462  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(3));
463 }

References CreateSemanticsNode().

◆ TEST() [8/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanReparentNode   
)

Definition at line 309 of file accessibility_bridge_unittests.cc.

309  {
310  std::shared_ptr<TestAccessibilityBridge> bridge =
311  std::make_shared<TestAccessibilityBridge>();
312 
313  std::vector<int32_t> root_children{1};
314  std::vector<int32_t> child1_children{2};
315  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &root_children);
316  FlutterSemanticsNode2 child1 =
317  CreateSemanticsNode(1, "child 1", &child1_children);
318  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
319 
320  bridge->AddFlutterSemanticsNodeUpdate(root);
321  bridge->AddFlutterSemanticsNodeUpdate(child1);
322  bridge->AddFlutterSemanticsNodeUpdate(child2);
323  bridge->CommitUpdates();
324  bridge->accessibility_events.clear();
325 
326  // Reparent child2 from child1 to the root.
327  child1.child_count = 0;
328  child1.children_in_traversal_order = nullptr;
329 
330  int32_t new_root_children[] = {1, 2};
331  root.child_count = 2;
332  root.children_in_traversal_order = new_root_children;
333 
334  bridge->AddFlutterSemanticsNodeUpdate(root);
335  bridge->AddFlutterSemanticsNodeUpdate(child1);
336  bridge->AddFlutterSemanticsNodeUpdate(child2);
337  bridge->CommitUpdates();
338 
339  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
340  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
341  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
342 
343  EXPECT_EQ(root_node->GetChildCount(), 2);
344  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
345  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
346  EXPECT_EQ(root_node->GetName(), "root");
347 
348  EXPECT_EQ(child1_node->GetChildCount(), 0);
349  EXPECT_EQ(child1_node->GetName(), "child 1");
350 
351  EXPECT_EQ(child2_node->GetChildCount(), 0);
352  EXPECT_EQ(child2_node->GetName(), "child 2");
353 
354  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
355 
356  // Child2 is moved from child1 to root.
357  EXPECT_THAT(bridge->accessibility_events,
358  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
359  EXPECT_THAT(bridge->accessibility_events,
360  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
361 
362  // Child1 is no longer a parent. It loses its group role and disables its
363  // 'clip children' attribute.
364  EXPECT_THAT(
365  bridge->accessibility_events,
366  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
367  EXPECT_THAT(bridge->accessibility_events,
368  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
369 }

References CreateSemanticsNode().

◆ TEST() [9/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanReparentNodeWithChild   
)

Definition at line 466 of file accessibility_bridge_unittests.cc.

466  {
467  std::shared_ptr<TestAccessibilityBridge> bridge =
468  std::make_shared<TestAccessibilityBridge>();
469 
470  int32_t root_id = 0;
471  int32_t intermediary1_id = 1;
472  int32_t intermediary2_id = 2;
473  int32_t leaf1_id = 3;
474 
475  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
476  std::vector<int32_t> intermediary1_children{leaf1_id};
477  FlutterSemanticsNode2 root =
478  CreateSemanticsNode(root_id, "root", &root_children);
479  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
480  intermediary1_id, "intermediary 1", &intermediary1_children);
481  FlutterSemanticsNode2 intermediary2 =
482  CreateSemanticsNode(intermediary2_id, "intermediary 2");
483  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
484 
485  bridge->AddFlutterSemanticsNodeUpdate(root);
486  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
487  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
488  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
489  bridge->CommitUpdates();
490  bridge->accessibility_events.clear();
491 
492  // Move intermediary1 from root to intermediary 2.
493  int32_t new_root_children[] = {intermediary2_id};
494  root.child_count = 1;
495  root.children_in_traversal_order = new_root_children;
496 
497  int32_t new_intermediary2_children[] = {intermediary1_id};
498  intermediary2.child_count = 1;
499  intermediary2.children_in_traversal_order = new_intermediary2_children;
500 
501  bridge->AddFlutterSemanticsNodeUpdate(root);
502  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
503  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
504  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
505  bridge->CommitUpdates();
506 
507  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
508  auto intermediary1_node =
509  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
510  auto intermediary2_node =
511  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
512  auto leaf1_node =
513  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
514 
515  EXPECT_EQ(root_node->GetChildCount(), 1);
516  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary2_id);
517  EXPECT_EQ(root_node->GetName(), "root");
518 
519  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
520  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], intermediary1_id);
521  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
522 
523  EXPECT_EQ(intermediary1_node->GetChildCount(), 1);
524  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf1_id);
525  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
526 
527  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
528  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
529 
530  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
531 
532  EXPECT_THAT(bridge->accessibility_events,
533  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
534  EXPECT_THAT(bridge->accessibility_events,
535  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
536 
537  // Intermediary 2 becomes a parent node. It updates to group role and enables
538  // its 'clip children' attribute.
539  EXPECT_THAT(
540  bridge->accessibility_events,
541  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
542  EXPECT_THAT(bridge->accessibility_events,
543  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
544 }

References CreateSemanticsNode().

◆ TEST() [10/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanSetCheckboxChecked   
)

Definition at line 292 of file accessibility_bridge_unittests.cc.

292  {
293  std::shared_ptr<TestAccessibilityBridge> bridge =
294  std::make_shared<TestAccessibilityBridge>();
295  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
296  root.flags = static_cast<FlutterSemanticsFlag>(
297  FlutterSemanticsFlag::kFlutterSemanticsFlagHasCheckedState |
298  FlutterSemanticsFlag::kFlutterSemanticsFlagIsChecked);
299  bridge->AddFlutterSemanticsNodeUpdate(root);
300  bridge->CommitUpdates();
301 
302  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
303  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
304  EXPECT_EQ(root_node->GetData().GetCheckedState(),
305  ax::mojom::CheckedState::kTrue);
306 }

References CreateSemanticsNode().

◆ TEST() [11/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
DoesNotAssignEditableRootToSelectableText   
)

Definition at line 240 of file accessibility_bridge_unittests.cc.

240  {
241  std::shared_ptr<TestAccessibilityBridge> bridge =
242  std::make_shared<TestAccessibilityBridge>();
243  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
244  root.flags = static_cast<FlutterSemanticsFlag>(
245  FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField |
246  FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly);
247  bridge->AddFlutterSemanticsNodeUpdate(root);
248  bridge->CommitUpdates();
249 
250  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
251 
252  EXPECT_FALSE(root_node->GetData().GetBoolAttribute(
253  ax::mojom::BoolAttribute::kEditableRoot));
254 }

References CreateSemanticsNode().

◆ TEST() [12/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
LineBreakingObjectTest   
)

Definition at line 556 of file accessibility_bridge_unittests.cc.

556  {
557  std::shared_ptr<TestAccessibilityBridge> bridge =
558  std::make_shared<TestAccessibilityBridge>();
559 
560  const int32_t root_id = 0;
561 
562  FlutterSemanticsNode2 root = CreateSemanticsNode(root_id, "root", {});
563 
564  bridge->AddFlutterSemanticsNodeUpdate(root);
565  bridge->CommitUpdates();
566 
567  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
568  auto root_data = root_node->GetData();
569  EXPECT_TRUE(root_data.HasBoolAttribute(
570  ax::mojom::BoolAttribute::kIsLineBreakingObject));
571  EXPECT_TRUE(root_data.GetBoolAttribute(
572  ax::mojom::BoolAttribute::kIsLineBreakingObject));
573 }

References CreateSemanticsNode().

◆ TEST() [13/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
SliderHasSliderRole   
)

Definition at line 271 of file accessibility_bridge_unittests.cc.

271  {
272  std::shared_ptr<TestAccessibilityBridge> bridge =
273  std::make_shared<TestAccessibilityBridge>();
274  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
275  root.flags = static_cast<FlutterSemanticsFlag>(
276  FlutterSemanticsFlag::kFlutterSemanticsFlagIsSlider |
277  FlutterSemanticsFlag::kFlutterSemanticsFlagHasEnabledState |
278  FlutterSemanticsFlag::kFlutterSemanticsFlagIsEnabled |
279  FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocusable);
280  bridge->AddFlutterSemanticsNodeUpdate(root);
281  bridge->CommitUpdates();
282 
283  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
284  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSlider);
285 }

References CreateSemanticsNode().

◆ TEST() [14/117]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
SwitchHasSwitchRole   
)

Definition at line 256 of file accessibility_bridge_unittests.cc.

256  {
257  std::shared_ptr<TestAccessibilityBridge> bridge =
258  std::make_shared<TestAccessibilityBridge>();
259  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
260  root.flags = static_cast<FlutterSemanticsFlag>(
261  FlutterSemanticsFlag::kFlutterSemanticsFlagHasToggledState |
262  FlutterSemanticsFlag::kFlutterSemanticsFlagHasEnabledState |
263  FlutterSemanticsFlag::kFlutterSemanticsFlagIsEnabled);
264  bridge->AddFlutterSemanticsNodeUpdate(root);
265  bridge->CommitUpdates();
266 
267  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
268  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
269 }

References CreateSemanticsNode().

◆ TEST() [15/117]

flutter::testing::TEST ( FlutterAppDelegateTest  ,
DoesNotCallDelegatesWithoutHandler   
)

Definition at line 32 of file FlutterAppDelegateTest.mm.

32  {
33  FlutterAppDelegate* appDelegate = [[FlutterAppDelegate alloc] init];
36  [appDelegate addApplicationLifecycleDelegate:noopDelegate];
37 
38  [appDelegate application:NSApplication.sharedApplication openURLs:@[]];
39  // No EXPECT, since the test is that the call doesn't throw due to calling without checking that
40  // the method is implemented.
41 }

References <FlutterAppLifecycleProvider>::addApplicationLifecycleDelegate:.

◆ TEST() [16/117]

flutter::testing::TEST ( FlutterAppDelegateTest  ,
OperURLsStopsAfterHandled   
)

Definition at line 57 of file FlutterAppDelegateTest.mm.

57  {
58  FlutterAppDelegate* appDelegate = [[FlutterAppDelegate alloc] init];
63  [appDelegate addApplicationLifecycleDelegate:firstDelegate];
64  [appDelegate addApplicationLifecycleDelegate:secondDelegate];
65 
66  NSURL* URL = [NSURL URLWithString:@"https://flutter.dev"];
67  EXPECT_NE(URL, nil);
68  NSArray<NSURL*>* URLs = @[ URL ];
69  [appDelegate application:NSApplication.sharedApplication openURLs:URLs];
70 
71  EXPECT_EQ([firstDelegate receivedURLs], URLs);
72  EXPECT_EQ([secondDelegate receivedURLs], nil);
73 }

References <FlutterAppLifecycleProvider>::addApplicationLifecycleDelegate:, and AppDelegateNoopFlutterAppLifecycleDelegate::receivedURLs.

◆ TEST() [17/117]

flutter::testing::TEST ( FlutterAppDelegateTest  ,
ReceivesOpenURLs   
)

Definition at line 43 of file FlutterAppDelegateTest.mm.

43  {
44  FlutterAppDelegate* appDelegate = [[FlutterAppDelegate alloc] init];
47  [appDelegate addApplicationLifecycleDelegate:delegate];
48 
49  NSURL* URL = [NSURL URLWithString:@"https://flutter.dev"];
50  EXPECT_NE(URL, nil);
51  NSArray<NSURL*>* URLs = @[ URL ];
52  [appDelegate application:NSApplication.sharedApplication openURLs:URLs];
53 
54  EXPECT_EQ([delegate receivedURLs], URLs);
55 }

References <FlutterAppLifecycleProvider>::addApplicationLifecycleDelegate:, and AppDelegateNoopFlutterAppLifecycleDelegate::receivedURLs.

◆ TEST() [18/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
ReleasesDelegateOnDealloc   
)

Definition at line 223 of file FlutterAppLifecycleDelegateTest.mm.

223  {
224  __weak FlutterAppLifecycleRegistrar* weakRegistrar;
225  __weak TestFlutterAppLifecycleDelegate* weakDelegate;
226  @autoreleasepool {
228  weakRegistrar = registrar;
230  weakDelegate = delegate;
231  [registrar addDelegate:delegate];
232  }
233  EXPECT_EQ(weakRegistrar, nil);
234  EXPECT_EQ(weakDelegate, nil);
235 }

References FlutterAppLifecycleRegistrar::addDelegate:.

◆ TEST() [19/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidBecomeActive   
)

Definition at line 109 of file FlutterAppLifecycleDelegateTest.mm.

109  {
112  [registrar addDelegate:delegate];
113 
114  NSNotification* didBecomeActive =
115  [NSNotification notificationWithName:NSApplicationDidBecomeActiveNotification object:nil];
116  [registrar handleDidBecomeActive:didBecomeActive];
117  EXPECT_EQ([delegate lastNotification], didBecomeActive);
118 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidBecomeActive:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [20/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidChangeOcclusionState   
)

Definition at line 209 of file FlutterAppLifecycleDelegateTest.mm.

209  {
212  [registrar addDelegate:delegate];
213 
214  NSNotification* didChangeOcclusionState =
215  [NSNotification notificationWithName:NSApplicationDidChangeOcclusionStateNotification
216  object:nil];
217  if ([registrar respondsToSelector:@selector(handleDidChangeOcclusionState:)]) {
218  [registrar handleDidChangeOcclusionState:didChangeOcclusionState];
219  EXPECT_EQ([delegate lastNotification], didChangeOcclusionState);
220  }
221 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidChangeOcclusionState:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [21/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidChangeScreenParameters   
)

Definition at line 197 of file FlutterAppLifecycleDelegateTest.mm.

197  {
200  [registrar addDelegate:delegate];
201 
202  NSNotification* didChangeScreenParameters =
203  [NSNotification notificationWithName:NSApplicationDidChangeScreenParametersNotification
204  object:nil];
205  [registrar handleDidChangeScreenParameters:didChangeScreenParameters];
206  EXPECT_EQ([delegate lastNotification], didChangeScreenParameters);
207 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidChangeScreenParameters:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [22/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidFinishLaunching   
)

Definition at line 87 of file FlutterAppLifecycleDelegateTest.mm.

87  {
90  [registrar addDelegate:delegate];
91 
92  NSNotification* didFinishLaunching =
93  [NSNotification notificationWithName:NSApplicationDidFinishLaunchingNotification object:nil];
94  [registrar handleDidFinishLaunching:didFinishLaunching];
95  EXPECT_EQ([delegate lastNotification], didFinishLaunching);
96 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidFinishLaunching:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [23/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidHide   
)

Definition at line 175 of file FlutterAppLifecycleDelegateTest.mm.

175  {
178  [registrar addDelegate:delegate];
179 
180  NSNotification* didHide = [NSNotification notificationWithName:NSApplicationDidHideNotification
181  object:nil];
182  [registrar handleDidHide:didHide];
183  EXPECT_EQ([delegate lastNotification], didHide);
184 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidHide:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [24/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidResignActive   
)

Definition at line 131 of file FlutterAppLifecycleDelegateTest.mm.

131  {
134  [registrar addDelegate:delegate];
135 
136  NSNotification* didResignActive =
137  [NSNotification notificationWithName:NSApplicationDidResignActiveNotification object:nil];
138  [registrar handleDidResignActive:didResignActive];
139  EXPECT_EQ([delegate lastNotification], didResignActive);
140 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidResignActive:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [25/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidUnhide   
)

Definition at line 186 of file FlutterAppLifecycleDelegateTest.mm.

186  {
189  [registrar addDelegate:delegate];
190 
191  NSNotification* didUnhide =
192  [NSNotification notificationWithName:NSApplicationDidUnhideNotification object:nil];
193  [registrar handleDidUnhide:didUnhide];
194  EXPECT_EQ([delegate lastNotification], didUnhide);
195 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleDidUnhide:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [26/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillBecomeActive   
)

Definition at line 98 of file FlutterAppLifecycleDelegateTest.mm.

98  {
101  [registrar addDelegate:delegate];
102 
103  NSNotification* willBecomeActive =
104  [NSNotification notificationWithName:NSApplicationWillBecomeActiveNotification object:nil];
105  [registrar handleWillBecomeActive:willBecomeActive];
106  EXPECT_EQ([delegate lastNotification], willBecomeActive);
107 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleWillBecomeActive:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [27/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillFinishLaunching   
)

Definition at line 76 of file FlutterAppLifecycleDelegateTest.mm.

76  {
79  [registrar addDelegate:delegate];
80 
81  NSNotification* willFinishLaunching =
82  [NSNotification notificationWithName:NSApplicationWillFinishLaunchingNotification object:nil];
83  [registrar handleWillFinishLaunching:willFinishLaunching];
84  EXPECT_EQ([delegate lastNotification], willFinishLaunching);
85 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleWillFinishLaunching:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [28/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillHide   
)

Definition at line 153 of file FlutterAppLifecycleDelegateTest.mm.

153  {
156  [registrar addDelegate:delegate];
157 
158  NSNotification* willHide = [NSNotification notificationWithName:NSApplicationWillHideNotification
159  object:nil];
160  [registrar handleWillHide:willHide];
161  EXPECT_EQ([delegate lastNotification], willHide);
162 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleWillHide:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [29/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillResignActive   
)

Definition at line 120 of file FlutterAppLifecycleDelegateTest.mm.

120  {
123  [registrar addDelegate:delegate];
124 
125  NSNotification* willResignActive =
126  [NSNotification notificationWithName:NSApplicationWillResignActiveNotification object:nil];
127  [registrar handleWillResignActive:willResignActive];
128  EXPECT_EQ([delegate lastNotification], willResignActive);
129 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleWillResignActive:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [30/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillTerminate   
)

Definition at line 142 of file FlutterAppLifecycleDelegateTest.mm.

142  {
145  [registrar addDelegate:delegate];
146 
147  NSNotification* applicationWillTerminate =
148  [NSNotification notificationWithName:NSApplicationWillTerminateNotification object:nil];
149  [registrar handleWillTerminate:applicationWillTerminate];
150  EXPECT_EQ([delegate lastNotification], applicationWillTerminate);
151 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleWillTerminate:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [31/117]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillUnhide   
)

Definition at line 164 of file FlutterAppLifecycleDelegateTest.mm.

164  {
167  [registrar addDelegate:delegate];
168 
169  NSNotification* willUnhide =
170  [NSNotification notificationWithName:NSApplicationWillUnhideNotification object:nil];
171  [registrar handleWillUnhide:willUnhide];
172  EXPECT_EQ([delegate lastNotification], willUnhide);
173 }

References FlutterAppLifecycleRegistrar::addDelegate:, <FlutterAppLifecycleDelegate>::handleWillUnhide:, and TestFlutterAppLifecycleDelegate::lastNotification.

◆ TEST() [32/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
BasicKeyEvent   
)

Definition at line 118 of file FlutterEmbedderKeyResponderTest.mm.

118  {
119  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
120  __block BOOL last_handled = TRUE;
121  FlutterKeyEvent* event;
122 
124  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
125  void* _Nullable user_data) {
126  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
127  callback:callback
128  userData:user_data]];
129  }];
130 
131  last_handled = FALSE;
132  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 123.0f, 0x100, @"a", @"a", FALSE, 0)
133  callback:^(BOOL handled) {
134  last_handled = handled;
135  }];
136 
137  EXPECT_EQ([events count], 1u);
138  event = [events lastObject].data;
139  ASSERT_NE(event, nullptr);
140  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
141  EXPECT_EQ(event->timestamp, 123000000.0f);
142  EXPECT_EQ(event->physical, kPhysicalKeyA);
143  EXPECT_EQ(event->logical, kLogicalKeyA);
144  EXPECT_STREQ(event->character, "a");
145  EXPECT_EQ(event->synthesized, false);
146 
147  EXPECT_EQ(last_handled, FALSE);
148  EXPECT_TRUE([[events lastObject] hasCallback]);
149  [[events lastObject] respond:TRUE];
150  EXPECT_EQ(last_handled, TRUE);
151 
152  [events removeAllObjects];
153 
154  last_handled = FALSE;
155  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", TRUE, kKeyCodeKeyA)
156  callback:^(BOOL handled) {
157  last_handled = handled;
158  }];
159 
160  EXPECT_EQ([events count], 1u);
161  event = [events lastObject].data;
162  ASSERT_NE(event, nullptr);
163  EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
164  EXPECT_EQ(event->physical, kPhysicalKeyA);
165  EXPECT_EQ(event->logical, kLogicalKeyA);
166  EXPECT_STREQ(event->character, "a");
167  EXPECT_EQ(event->synthesized, false);
168 
169  EXPECT_EQ(last_handled, FALSE);
170  EXPECT_TRUE([[events lastObject] hasCallback]);
171  [[events lastObject] respond:TRUE];
172  EXPECT_EQ(last_handled, TRUE);
173 
174  [events removeAllObjects];
175 
176  last_handled = TRUE;
177  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 124.0f, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
178  callback:^(BOOL handled) {
179  last_handled = handled;
180  }];
181 
182  EXPECT_EQ([events count], 1u);
183  event = [events lastObject].data;
184  ASSERT_NE(event, nullptr);
185  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
186  EXPECT_EQ(event->timestamp, 124000000.0f);
187  EXPECT_EQ(event->physical, kPhysicalKeyA);
188  EXPECT_EQ(event->logical, kLogicalKeyA);
189  EXPECT_EQ(event->character, nullptr);
190  EXPECT_EQ(event->synthesized, false);
191 
192  EXPECT_EQ(last_handled, TRUE);
193  EXPECT_TRUE([[events lastObject] hasCallback]);
194  [[events lastObject] respond:FALSE]; // Check if responding FALSE works
195  EXPECT_EQ(last_handled, FALSE);
196 
197  [events removeAllObjects];
198 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [33/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
ConvertAbruptRepeatEventsToDown   
)

Definition at line 410 of file FlutterEmbedderKeyResponderTest.mm.

410  {
411  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
412  __block BOOL last_handled = TRUE;
413  FlutterKeyEvent* event;
414 
416  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
417  void* _Nullable user_data) {
418  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
419  callback:callback
420  userData:user_data]];
421  }];
422 
423  last_handled = TRUE;
424  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", TRUE, kKeyCodeKeyA)
425  callback:^(BOOL handled) {
426  last_handled = handled;
427  }];
428 
429  EXPECT_EQ([events count], 1u);
430  event = [events lastObject].data;
431  ASSERT_NE(event, nullptr);
432  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
433  EXPECT_EQ(event->physical, kPhysicalKeyA);
434  EXPECT_EQ(event->logical, kLogicalKeyA);
435  EXPECT_STREQ(event->character, "a");
436  EXPECT_EQ(event->synthesized, false);
437  EXPECT_EQ(last_handled, TRUE);
438  [[events lastObject] respond:FALSE];
439  EXPECT_EQ(last_handled, FALSE);
440 
441  [events removeAllObjects];
442 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [34/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
ConvertCapsLockEvents   
)

Definition at line 1100 of file FlutterEmbedderKeyResponderTest.mm.

1100  {
1101  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1102  __block BOOL last_handled = TRUE;
1103  id keyEventCallback = ^(BOOL handled) {
1104  last_handled = handled;
1105  };
1106  FlutterKeyEvent* event;
1107 
1109  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1110  void* _Nullable user_data) {
1111  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1112  callback:callback
1113  userData:user_data]];
1114  }];
1115 
1116  // In: CapsLock down
1117  // Out: CapsLock down & *CapsLock Up
1118  last_handled = FALSE;
1119  [responder
1120  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x10100, @"", @"", FALSE, kKeyCodeCapsLock)
1121  callback:keyEventCallback];
1122 
1123  EXPECT_EQ([events count], 2u);
1124 
1125  event = [events firstObject].data;
1126  ASSERT_NE(event, nullptr);
1127  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1128  EXPECT_EQ(event->physical, kPhysicalCapsLock);
1129  EXPECT_EQ(event->logical, kLogicalCapsLock);
1130  EXPECT_STREQ(event->character, nullptr);
1131  EXPECT_EQ(event->synthesized, false);
1132  EXPECT_TRUE([[events firstObject] hasCallback]);
1133 
1134  event = [events lastObject].data;
1135  ASSERT_NE(event, nullptr);
1136  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1137  EXPECT_EQ(event->physical, kPhysicalCapsLock);
1138  EXPECT_EQ(event->logical, kLogicalCapsLock);
1139  EXPECT_STREQ(event->character, nullptr);
1140  EXPECT_EQ(event->synthesized, true);
1141  EXPECT_FALSE([[events lastObject] hasCallback]);
1142 
1143  EXPECT_EQ(last_handled, FALSE);
1144  [[events firstObject] respond:TRUE];
1145  EXPECT_EQ(last_handled, TRUE);
1146 
1147  [events removeAllObjects];
1148 
1149  // In: CapsLock up
1150  // Out: CapsLock down & *CapsLock Up
1151  last_handled = FALSE;
1152  [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeCapsLock)
1153  callback:keyEventCallback];
1154 
1155  EXPECT_EQ([events count], 2u);
1156 
1157  event = [events firstObject].data;
1158  ASSERT_NE(event, nullptr);
1159  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1160  EXPECT_EQ(event->physical, kPhysicalCapsLock);
1161  EXPECT_EQ(event->logical, kLogicalCapsLock);
1162  EXPECT_STREQ(event->character, nullptr);
1163  EXPECT_EQ(event->synthesized, false);
1164  EXPECT_TRUE([[events firstObject] hasCallback]);
1165 
1166  event = [events lastObject].data;
1167  ASSERT_NE(event, nullptr);
1168  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1169  EXPECT_EQ(event->physical, kPhysicalCapsLock);
1170  EXPECT_EQ(event->logical, kLogicalCapsLock);
1171  EXPECT_STREQ(event->character, nullptr);
1172  EXPECT_EQ(event->synthesized, true);
1173  EXPECT_FALSE([[events lastObject] hasCallback]);
1174 
1175  EXPECT_EQ(last_handled, FALSE);
1176  [[events firstObject] respond:TRUE];
1177  EXPECT_EQ(last_handled, TRUE);
1178 
1179  [events removeAllObjects];
1180 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [35/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
IdentifyLeftAndRightModifiers   
)

Definition at line 720 of file FlutterEmbedderKeyResponderTest.mm.

720  {
721  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
722  FlutterKeyEvent* event;
723 
725  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
726  void* _Nullable user_data) {
727  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
728  callback:callback
729  userData:user_data]];
730  }];
731 
732  [responder
733  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
734  callback:^(BOOL handled){
735  }];
736 
737  EXPECT_EQ([events count], 1u);
738  event = [events lastObject].data;
739  ASSERT_NE(event, nullptr);
740  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
741  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
742  EXPECT_EQ(event->logical, kLogicalShiftLeft);
743  EXPECT_STREQ(event->character, nullptr);
744  EXPECT_EQ(event->synthesized, false);
745  [[events lastObject] respond:TRUE];
746 
747  [events removeAllObjects];
748 
749  [responder
750  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20106, @"", @"", FALSE, kKeyCodeShiftRight)
751  callback:^(BOOL handled){
752  }];
753 
754  EXPECT_EQ([events count], 1u);
755  event = [events lastObject].data;
756  ASSERT_NE(event, nullptr);
757  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
758  EXPECT_EQ(event->physical, kPhysicalShiftRight);
759  EXPECT_EQ(event->logical, kLogicalShiftRight);
760  EXPECT_STREQ(event->character, nullptr);
761  EXPECT_EQ(event->synthesized, false);
762  [[events lastObject] respond:TRUE];
763 
764  [events removeAllObjects];
765 
766  [responder
767  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20104, @"", @"", FALSE, kKeyCodeShiftLeft)
768  callback:^(BOOL handled){
769  }];
770 
771  EXPECT_EQ([events count], 1u);
772  event = [events lastObject].data;
773  ASSERT_NE(event, nullptr);
774  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
775  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
776  EXPECT_EQ(event->logical, kLogicalShiftLeft);
777  EXPECT_STREQ(event->character, nullptr);
778  EXPECT_EQ(event->synthesized, false);
779  [[events lastObject] respond:TRUE];
780 
781  [events removeAllObjects];
782 
783  [responder
784  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
785  callback:^(BOOL handled){
786  }];
787 
788  EXPECT_EQ([events count], 1u);
789  event = [events lastObject].data;
790  ASSERT_NE(event, nullptr);
791  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
792  EXPECT_EQ(event->physical, kPhysicalShiftRight);
793  EXPECT_EQ(event->logical, kLogicalShiftRight);
794  EXPECT_STREQ(event->character, nullptr);
795  EXPECT_EQ(event->synthesized, false);
796  [[events lastObject] respond:TRUE];
797 
798  [events removeAllObjects];
799 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [36/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
IgnoreDuplicateUpEvent   
)

Definition at line 379 of file FlutterEmbedderKeyResponderTest.mm.

379  {
380  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
381  FlutterKeyEvent* event;
382  __block BOOL last_handled = TRUE;
383 
385  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
386  void* _Nullable user_data) {
387  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
388  callback:callback
389  userData:user_data]];
390  }];
391 
392  last_handled = FALSE;
393  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
394  callback:^(BOOL handled) {
395  last_handled = handled;
396  }];
397 
398  EXPECT_EQ([events count], 1u);
399  EXPECT_EQ(last_handled, TRUE);
400  event = [events lastObject].data;
401  ASSERT_NE(event, nullptr);
402  EXPECT_EQ(event->physical, 0ull);
403  EXPECT_EQ(event->logical, 0ull);
404  EXPECT_FALSE([[events lastObject] hasCallback]);
405  EXPECT_EQ(last_handled, TRUE);
406 
407  [events removeAllObjects];
408 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [37/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
MultipleCharacters   
)

Definition at line 274 of file FlutterEmbedderKeyResponderTest.mm.

274  {
275  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
276  FlutterKeyEvent* event;
277 
279  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
280  void* _Nullable user_data) {
281  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
282  callback:callback
283  userData:user_data]];
284  }];
285 
286  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0, @"àn", @"àn", FALSE, kKeyCodeKeyA)
287  callback:^(BOOL handled){
288  }];
289 
290  EXPECT_EQ([events count], 1u);
291  event = [events lastObject].data;
292  ASSERT_NE(event, nullptr);
293  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
294  EXPECT_EQ(event->physical, kPhysicalKeyA);
295  EXPECT_EQ(event->logical, 0x1400000000ull);
296  EXPECT_STREQ(event->character, "àn");
297  EXPECT_EQ(event->synthesized, false);
298 
299  [events removeAllObjects];
300 
301  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0, @"a", @"a", FALSE, kKeyCodeKeyA)
302  callback:^(BOOL handled){
303  }];
304 
305  EXPECT_EQ([events count], 1u);
306  event = [events lastObject].data;
307  ASSERT_NE(event, nullptr);
308  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
309  EXPECT_EQ(event->physical, kPhysicalKeyA);
310  EXPECT_EQ(event->logical, 0x1400000000ull);
311  EXPECT_STREQ(event->character, nullptr);
312  EXPECT_EQ(event->synthesized, false);
313 
314  [events removeAllObjects];
315 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [38/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
NonAsciiCharacters   
)

Definition at line 200 of file FlutterEmbedderKeyResponderTest.mm.

200  {
201  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
202  FlutterKeyEvent* event;
203 
205  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
206  void* _Nullable user_data) {
207  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
208  callback:callback
209  userData:user_data]];
210  }];
211 
212  [responder
213  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x80140, @"", @"", FALSE, kKeyCodeAltRight)
214  callback:^(BOOL handled){
215  }];
216 
217  EXPECT_EQ([events count], 1u);
218  event = [events lastObject].data;
219  ASSERT_NE(event, nullptr);
220  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
221  EXPECT_EQ(event->physical, kPhysicalAltRight);
222  EXPECT_EQ(event->logical, kLogicalAltRight);
223  EXPECT_STREQ(event->character, nullptr);
224  EXPECT_EQ(event->synthesized, false);
225 
226  [events removeAllObjects];
227 
228  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x80140, @"∑", @"w", FALSE, kKeyCodeKeyW)
229  callback:^(BOOL handled){
230  }];
231 
232  EXPECT_EQ([events count], 1u);
233  event = [events lastObject].data;
234  ASSERT_NE(event, nullptr);
235  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
236  EXPECT_EQ(event->physical, kPhysicalKeyW);
237  EXPECT_EQ(event->logical, kLogicalKeyW);
238  EXPECT_STREQ(event->character, "∑");
239  EXPECT_EQ(event->synthesized, false);
240 
241  [events removeAllObjects];
242 
243  [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeAltRight)
244  callback:^(BOOL handled){
245  }];
246 
247  EXPECT_EQ([events count], 1u);
248  event = [events lastObject].data;
249  ASSERT_NE(event, nullptr);
250  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
251  EXPECT_EQ(event->physical, kPhysicalAltRight);
252  EXPECT_EQ(event->logical, kLogicalAltRight);
253  EXPECT_STREQ(event->character, nullptr);
254  EXPECT_EQ(event->synthesized, false);
255 
256  [events removeAllObjects];
257 
258  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"w", @"w", FALSE, kKeyCodeKeyW)
259  callback:^(BOOL handled){
260  }];
261 
262  EXPECT_EQ([events count], 1u);
263  event = [events lastObject].data;
264  ASSERT_NE(event, nullptr);
265  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
266  EXPECT_EQ(event->physical, kPhysicalKeyW);
267  EXPECT_EQ(event->logical, kLogicalKeyW);
268  EXPECT_STREQ(event->character, nullptr);
269  EXPECT_EQ(event->synthesized, false);
270 
271  [events removeAllObjects];
272 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [39/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SpecialModiferFlags   
)

Definition at line 564 of file FlutterEmbedderKeyResponderTest.mm.

564  {
565  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
566  FlutterKeyEvent* event;
567 
569  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
570  void* _Nullable user_data) {
571  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
572  callback:callback
573  userData:user_data]];
574  }];
575 
576  // Keydown: Numpad1, F1, KeyA, ShiftLeft
577  // Then KeyUp: Numpad1, F1, KeyA, ShiftLeft
578 
579  // Numpad 1
580  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x200100, @"1", @"1", FALSE, kKeyCodeNumpad1)
581  callback:^(BOOL handled){
582  }];
583 
584  EXPECT_EQ([events count], 1u);
585  event = [events lastObject].data;
586  ASSERT_NE(event, nullptr);
587  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
588  EXPECT_EQ(event->physical, kPhysicalNumpad1);
589  EXPECT_EQ(event->logical, kLogicalNumpad1);
590  EXPECT_STREQ(event->character, "1");
591  EXPECT_EQ(event->synthesized, false);
592  [[events lastObject] respond:TRUE];
593 
594  [events removeAllObjects];
595 
596  // F1
597  [responder
598  handleEvent:keyEvent(NSEventTypeKeyDown, 0x800100, @"\uf704", @"\uf704", FALSE, kKeyCodeF1)
599  callback:^(BOOL handled){
600  }];
601 
602  EXPECT_EQ([events count], 1u);
603  event = [events lastObject].data;
604  ASSERT_NE(event, nullptr);
605  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
606  EXPECT_EQ(event->physical, kPhysicalF1);
607  EXPECT_EQ(event->logical, kLogicalF1);
608  EXPECT_STREQ(event->character, nullptr);
609  EXPECT_EQ(event->synthesized, false);
610  [[events lastObject] respond:TRUE];
611 
612  [events removeAllObjects];
613 
614  // KeyA
615  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
616  callback:^(BOOL handled){
617  }];
618 
619  EXPECT_EQ([events count], 1u);
620  event = [events lastObject].data;
621  ASSERT_NE(event, nullptr);
622  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
623  EXPECT_EQ(event->physical, kPhysicalKeyA);
624  EXPECT_EQ(event->logical, kLogicalKeyA);
625  EXPECT_STREQ(event->character, "a");
626  EXPECT_EQ(event->synthesized, false);
627  [[events lastObject] respond:TRUE];
628 
629  [events removeAllObjects];
630 
631  // ShiftLeft
632  [responder
633  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
634  callback:^(BOOL handled){
635  }];
636 
637  EXPECT_EQ([events count], 1u);
638  event = [events lastObject].data;
639  ASSERT_NE(event, nullptr);
640  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
641  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
642  EXPECT_EQ(event->logical, kLogicalShiftLeft);
643  EXPECT_STREQ(event->character, nullptr);
644  EXPECT_EQ(event->synthesized, false);
645  [[events lastObject] respond:TRUE];
646 
647  [events removeAllObjects];
648 
649  // Numpad 1
650  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x220102, @"1", @"1", FALSE, kKeyCodeNumpad1)
651  callback:^(BOOL handled){
652  }];
653 
654  EXPECT_EQ([events count], 1u);
655  event = [events lastObject].data;
656  ASSERT_NE(event, nullptr);
657  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
658  EXPECT_EQ(event->physical, kPhysicalNumpad1);
659  EXPECT_EQ(event->logical, kLogicalNumpad1);
660  EXPECT_STREQ(event->character, nullptr);
661  EXPECT_EQ(event->synthesized, false);
662  [[events lastObject] respond:TRUE];
663 
664  [events removeAllObjects];
665 
666  // F1
667  [responder
668  handleEvent:keyEvent(NSEventTypeKeyUp, 0x820102, @"\uF704", @"\uF704", FALSE, kKeyCodeF1)
669  callback:^(BOOL handled){
670  }];
671 
672  EXPECT_EQ([events count], 1u);
673  event = [events lastObject].data;
674  ASSERT_NE(event, nullptr);
675  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
676  EXPECT_EQ(event->physical, kPhysicalF1);
677  EXPECT_EQ(event->logical, kLogicalF1);
678  EXPECT_STREQ(event->character, nullptr);
679  EXPECT_EQ(event->synthesized, false);
680  [[events lastObject] respond:TRUE];
681 
682  [events removeAllObjects];
683 
684  // KeyA
685  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x20102, @"a", @"a", FALSE, kKeyCodeKeyA)
686  callback:^(BOOL handled){
687  }];
688 
689  EXPECT_EQ([events count], 1u);
690  event = [events lastObject].data;
691  ASSERT_NE(event, nullptr);
692  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
693  EXPECT_EQ(event->physical, kPhysicalKeyA);
694  EXPECT_EQ(event->logical, kLogicalKeyA);
695  EXPECT_STREQ(event->character, nullptr);
696  EXPECT_EQ(event->synthesized, false);
697  [[events lastObject] respond:TRUE];
698 
699  [events removeAllObjects];
700 
701  // ShiftLeft
702  [responder
703  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftLeft)
704  callback:^(BOOL handled){
705  }];
706 
707  EXPECT_EQ([events count], 1u);
708  event = [events lastObject].data;
709  ASSERT_NE(event, nullptr);
710  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
711  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
712  EXPECT_EQ(event->logical, kLogicalShiftLeft);
713  EXPECT_STREQ(event->character, nullptr);
714  EXPECT_EQ(event->synthesized, false);
715  [[events lastObject] respond:TRUE];
716 
717  [events removeAllObjects];
718 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [40/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynchronizeCapsLockStateOnCapsLock   
)

Definition at line 1183 of file FlutterEmbedderKeyResponderTest.mm.

1183  {
1184  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1185  FlutterKeyEvent* event;
1186  __block BOOL last_handled = TRUE;
1187  id keyEventCallback = ^(BOOL handled) {
1188  last_handled = handled;
1189  };
1190 
1192  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1193  void* _Nullable user_data) {
1194  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1195  callback:callback
1196  userData:user_data]];
1197  }];
1198 
1199  // In: CapsLock down
1200  // Out: (empty)
1201  last_handled = FALSE;
1202  [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeCapsLock)
1203  callback:keyEventCallback];
1204 
1205  EXPECT_EQ([events count], 1u);
1206  EXPECT_EQ(last_handled, TRUE);
1207  event = [events lastObject].data;
1208  ASSERT_NE(event, nullptr);
1209  EXPECT_EQ(event->physical, 0ull);
1210  EXPECT_EQ(event->logical, 0ull);
1211  EXPECT_FALSE([[events lastObject] hasCallback]);
1212  EXPECT_EQ(last_handled, TRUE);
1213 
1214  [events removeAllObjects];
1215 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [41/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynchronizeCapsLockStateOnNormalKey   
)

Definition at line 1218 of file FlutterEmbedderKeyResponderTest.mm.

1218  {
1219  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1220  __block BOOL last_handled = TRUE;
1221  id keyEventCallback = ^(BOOL handled) {
1222  last_handled = handled;
1223  };
1224  FlutterKeyEvent* event;
1225 
1227  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1228  void* _Nullable user_data) {
1229  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1230  callback:callback
1231  userData:user_data]];
1232  }];
1233 
1234  last_handled = FALSE;
1235  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x10100, @"A", @"a", FALSE, kKeyCodeKeyA)
1236  callback:keyEventCallback];
1237 
1238  EXPECT_EQ([events count], 3u);
1239 
1240  event = events[0].data;
1241  ASSERT_NE(event, nullptr);
1242  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1243  EXPECT_EQ(event->physical, kPhysicalCapsLock);
1244  EXPECT_EQ(event->logical, kLogicalCapsLock);
1245  EXPECT_STREQ(event->character, nullptr);
1246  EXPECT_EQ(event->synthesized, true);
1247  EXPECT_FALSE([events[0] hasCallback]);
1248 
1249  event = events[1].data;
1250  ASSERT_NE(event, nullptr);
1251  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1252  EXPECT_EQ(event->physical, kPhysicalCapsLock);
1253  EXPECT_EQ(event->logical, kLogicalCapsLock);
1254  EXPECT_STREQ(event->character, nullptr);
1255  EXPECT_EQ(event->synthesized, true);
1256  EXPECT_FALSE([events[1] hasCallback]);
1257 
1258  event = events[2].data;
1259  ASSERT_NE(event, nullptr);
1260  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1261  EXPECT_EQ(event->physical, kPhysicalKeyA);
1262  EXPECT_EQ(event->logical, kLogicalKeyA);
1263  EXPECT_STREQ(event->character, "A");
1264  EXPECT_EQ(event->synthesized, false);
1265  EXPECT_TRUE([events[2] hasCallback]);
1266 
1267  EXPECT_EQ(last_handled, FALSE);
1268  [[events lastObject] respond:TRUE];
1269  EXPECT_EQ(last_handled, TRUE);
1270 
1271  [events removeAllObjects];
1272 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [42/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynthesizeForDuplicateDownEvent   
)

Definition at line 317 of file FlutterEmbedderKeyResponderTest.mm.

317  {
318  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
319  __block BOOL last_handled = TRUE;
320  FlutterKeyEvent* event;
321 
323  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
324  void* _Nullable user_data) {
325  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
326  callback:callback
327  userData:user_data]];
328  }];
329 
330  last_handled = TRUE;
331  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
332  callback:^(BOOL handled) {
333  last_handled = handled;
334  }];
335 
336  EXPECT_EQ([events count], 1u);
337  event = [events lastObject].data;
338  ASSERT_NE(event, nullptr);
339  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
340  EXPECT_EQ(event->physical, kPhysicalKeyA);
341  EXPECT_EQ(event->logical, kLogicalKeyA);
342  EXPECT_STREQ(event->character, "a");
343  EXPECT_EQ(event->synthesized, false);
344  EXPECT_EQ(last_handled, TRUE);
345  [[events lastObject] respond:FALSE];
346  EXPECT_EQ(last_handled, FALSE);
347 
348  [events removeAllObjects];
349 
350  last_handled = TRUE;
351  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"à", @"à", FALSE, kKeyCodeKeyA)
352  callback:^(BOOL handled) {
353  last_handled = handled;
354  }];
355 
356  EXPECT_EQ([events count], 2u);
357 
358  event = [events firstObject].data;
359  ASSERT_NE(event, nullptr);
360  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
361  EXPECT_EQ(event->physical, kPhysicalKeyA);
362  EXPECT_EQ(event->logical, kLogicalKeyA);
363  EXPECT_STREQ(event->character, NULL);
364  EXPECT_EQ(event->synthesized, true);
365 
366  event = [events lastObject].data;
367  ASSERT_NE(event, nullptr);
368  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
369  EXPECT_EQ(event->physical, kPhysicalKeyA);
370  EXPECT_EQ(event->logical, 0xE0ull /* à */);
371  EXPECT_STREQ(event->character, "à");
372  EXPECT_EQ(event->synthesized, false);
373  [[events lastObject] respond:FALSE];
374  EXPECT_EQ(last_handled, FALSE);
375 
376  [events removeAllObjects];
377 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [43/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynthesizeMissedModifierEvents   
)

Definition at line 806 of file FlutterEmbedderKeyResponderTest.mm.

806  {
807  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
808  __block BOOL last_handled = TRUE;
809  id keyEventCallback = ^(BOOL handled) {
810  last_handled = handled;
811  };
812  FlutterKeyEvent* event;
813 
815  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
816  void* _Nullable user_data) {
817  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
818  callback:callback
819  userData:user_data]];
820  }];
821 
822  // Case 1:
823  // In: L down, (L up), L down, L up
824  // Out: L down, L up
825  last_handled = FALSE;
826  [responder
827  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
828  callback:keyEventCallback];
829 
830  EXPECT_EQ([events count], 1u);
831  event = [events lastObject].data;
832  ASSERT_NE(event, nullptr);
833  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
834  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
835  EXPECT_EQ(event->logical, kLogicalShiftLeft);
836  EXPECT_STREQ(event->character, nullptr);
837  EXPECT_EQ(event->synthesized, false);
838 
839  EXPECT_EQ(last_handled, FALSE);
840  EXPECT_TRUE([[events lastObject] hasCallback]);
841  [[events lastObject] respond:TRUE];
842  EXPECT_EQ(last_handled, TRUE);
843 
844  [events removeAllObjects];
845 
846  last_handled = FALSE;
847  [responder
848  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
849  callback:keyEventCallback];
850 
851  EXPECT_EQ([events count], 1u);
852  event = [events lastObject].data;
853  ASSERT_NE(event, nullptr);
854  EXPECT_EQ(event->physical, 0u);
855  EXPECT_EQ(event->logical, 0u);
856  EXPECT_FALSE([[events lastObject] hasCallback]);
857  EXPECT_EQ(last_handled, TRUE);
858  [events removeAllObjects];
859 
860  last_handled = FALSE;
861  [responder
862  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftLeft)
863  callback:keyEventCallback];
864 
865  EXPECT_EQ([events count], 1u);
866  event = [events lastObject].data;
867  ASSERT_NE(event, nullptr);
868  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
869  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
870  EXPECT_EQ(event->logical, kLogicalShiftLeft);
871  EXPECT_STREQ(event->character, nullptr);
872  EXPECT_EQ(event->synthesized, false);
873 
874  EXPECT_EQ(last_handled, FALSE);
875  EXPECT_TRUE([[events lastObject] hasCallback]);
876  [[events lastObject] respond:TRUE];
877  EXPECT_EQ(last_handled, TRUE);
878 
879  [events removeAllObjects];
880 
881  // Case 2:
882  // In: (L down), L up
883  // Out:
884 
885  last_handled = FALSE;
886  [responder
887  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftLeft)
888  callback:keyEventCallback];
889 
890  EXPECT_EQ([events count], 1u);
891  event = [events lastObject].data;
892  ASSERT_NE(event, nullptr);
893  EXPECT_EQ(event->physical, 0u);
894  EXPECT_EQ(event->logical, 0u);
895  EXPECT_FALSE([[events lastObject] hasCallback]);
896  EXPECT_EQ(last_handled, TRUE);
897  [events removeAllObjects];
898 
899  // Case 3:
900  // In: L down, (L up), (R down), R up
901  // Out: L down, *L up
902 
903  last_handled = FALSE;
904  [responder
905  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
906  callback:keyEventCallback];
907 
908  EXPECT_EQ([events count], 1u);
909  event = [events lastObject].data;
910  ASSERT_NE(event, nullptr);
911  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
912  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
913  EXPECT_EQ(event->logical, kLogicalShiftLeft);
914  EXPECT_STREQ(event->character, nullptr);
915  EXPECT_EQ(event->synthesized, false);
916 
917  EXPECT_EQ(last_handled, FALSE);
918  EXPECT_TRUE([[events lastObject] hasCallback]);
919  [[events lastObject] respond:TRUE];
920  EXPECT_EQ(last_handled, TRUE);
921 
922  [events removeAllObjects];
923 
924  last_handled = FALSE;
925  [responder
926  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
927  callback:keyEventCallback];
928 
929  EXPECT_EQ([events count], 1u);
930  event = [events lastObject].data;
931  ASSERT_NE(event, nullptr);
932  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
933  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
934  EXPECT_EQ(event->logical, kLogicalShiftLeft);
935  EXPECT_STREQ(event->character, nullptr);
936  EXPECT_EQ(event->synthesized, true);
937 
938  // The primary event is automatically replied with TRUE, unrelated to the received event.
939  EXPECT_EQ(last_handled, TRUE);
940  EXPECT_FALSE([[events lastObject] hasCallback]);
941 
942  [events removeAllObjects];
943 
944  // Case 4:
945  // In: L down, R down, (L up), R up
946  // Out: L down, R down *L up & R up
947 
948  last_handled = FALSE;
949  [responder
950  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
951  callback:keyEventCallback];
952 
953  EXPECT_EQ([events count], 1u);
954  event = [events lastObject].data;
955  ASSERT_NE(event, nullptr);
956  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
957  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
958  EXPECT_EQ(event->logical, kLogicalShiftLeft);
959  EXPECT_STREQ(event->character, nullptr);
960  EXPECT_EQ(event->synthesized, false);
961 
962  EXPECT_EQ(last_handled, FALSE);
963  EXPECT_TRUE([[events lastObject] hasCallback]);
964  [[events lastObject] respond:TRUE];
965  EXPECT_EQ(last_handled, TRUE);
966 
967  [events removeAllObjects];
968 
969  last_handled = FALSE;
970  [responder
971  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20106, @"", @"", FALSE, kKeyCodeShiftRight)
972  callback:keyEventCallback];
973 
974  EXPECT_EQ([events count], 1u);
975  event = [events lastObject].data;
976  ASSERT_NE(event, nullptr);
977  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
978  EXPECT_EQ(event->physical, kPhysicalShiftRight);
979  EXPECT_EQ(event->logical, kLogicalShiftRight);
980  EXPECT_STREQ(event->character, nullptr);
981  EXPECT_EQ(event->synthesized, false);
982 
983  EXPECT_EQ(last_handled, FALSE);
984  EXPECT_TRUE([[events lastObject] hasCallback]);
985  [[events lastObject] respond:TRUE];
986  EXPECT_EQ(last_handled, TRUE);
987 
988  [events removeAllObjects];
989 
990  last_handled = FALSE;
991  [responder
992  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
993  callback:keyEventCallback];
994 
995  EXPECT_EQ([events count], 2u);
996  event = [events firstObject].data;
997  ASSERT_NE(event, nullptr);
998  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
999  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
1000  EXPECT_EQ(event->logical, kLogicalShiftLeft);
1001  EXPECT_STREQ(event->character, nullptr);
1002  EXPECT_EQ(event->synthesized, true);
1003 
1004  EXPECT_FALSE([[events firstObject] hasCallback]);
1005 
1006  event = [events lastObject].data;
1007  ASSERT_NE(event, nullptr);
1008  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1009  EXPECT_EQ(event->physical, kPhysicalShiftRight);
1010  EXPECT_EQ(event->logical, kLogicalShiftRight);
1011  EXPECT_STREQ(event->character, nullptr);
1012  EXPECT_EQ(event->synthesized, false);
1013 
1014  EXPECT_EQ(last_handled, FALSE);
1015  EXPECT_TRUE([[events lastObject] hasCallback]);
1016  [[events lastObject] respond:TRUE];
1017  EXPECT_EQ(last_handled, TRUE);
1018 
1019  [events removeAllObjects];
1020 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [44/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynthesizeMissedModifierEventsInNormalEvents   
)

Definition at line 1022 of file FlutterEmbedderKeyResponderTest.mm.

1022  {
1023  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1024  __block BOOL last_handled = TRUE;
1025  id keyEventCallback = ^(BOOL handled) {
1026  last_handled = handled;
1027  };
1028  FlutterKeyEvent* event;
1029 
1031  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1032  void* _Nullable user_data) {
1033  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1034  callback:callback
1035  userData:user_data]];
1036  }];
1037 
1038  // In: (LShift down), A down, (LShift up), A up
1039  // Out: *LS down & A down, *LS up & A up
1040 
1041  last_handled = FALSE;
1042  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x20102, @"A", @"A", FALSE, kKeyCodeKeyA)
1043  callback:keyEventCallback];
1044 
1045  EXPECT_EQ([events count], 2u);
1046  event = [events firstObject].data;
1047  ASSERT_NE(event, nullptr);
1048  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1049  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
1050  EXPECT_EQ(event->logical, kLogicalShiftLeft);
1051  EXPECT_STREQ(event->character, nullptr);
1052  EXPECT_EQ(event->synthesized, true);
1053  EXPECT_FALSE([[events firstObject] hasCallback]);
1054 
1055  event = [events lastObject].data;
1056  ASSERT_NE(event, nullptr);
1057  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1058  EXPECT_EQ(event->physical, kPhysicalKeyA);
1059  EXPECT_EQ(event->logical, kLogicalKeyA);
1060  EXPECT_STREQ(event->character, "A");
1061  EXPECT_EQ(event->synthesized, false);
1062  EXPECT_TRUE([[events lastObject] hasCallback]);
1063 
1064  EXPECT_EQ(last_handled, FALSE);
1065  [[events lastObject] respond:TRUE];
1066  EXPECT_EQ(last_handled, TRUE);
1067 
1068  [events removeAllObjects];
1069 
1070  last_handled = FALSE;
1071  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
1072  callback:keyEventCallback];
1073 
1074  EXPECT_EQ([events count], 2u);
1075  event = [events firstObject].data;
1076  ASSERT_NE(event, nullptr);
1077  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1078  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
1079  EXPECT_EQ(event->logical, kLogicalShiftLeft);
1080  EXPECT_STREQ(event->character, nullptr);
1081  EXPECT_EQ(event->synthesized, true);
1082  EXPECT_FALSE([[events firstObject] hasCallback]);
1083 
1084  event = [events lastObject].data;
1085  ASSERT_NE(event, nullptr);
1086  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1087  EXPECT_EQ(event->physical, kPhysicalKeyA);
1088  EXPECT_EQ(event->logical, kLogicalKeyA);
1089  EXPECT_STREQ(event->character, nullptr);
1090  EXPECT_EQ(event->synthesized, false);
1091  EXPECT_TRUE([[events lastObject] hasCallback]);
1092 
1093  EXPECT_EQ(last_handled, FALSE);
1094  [[events lastObject] respond:TRUE];
1095  EXPECT_EQ(last_handled, TRUE);
1096 
1097  [events removeAllObjects];
1098 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, and TestKeyEvent::hasCallback.

◆ TEST() [45/117]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
ToggleModifiersDuringKeyTap   
)

Definition at line 448 of file FlutterEmbedderKeyResponderTest.mm.

448  {
449  __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
450  FlutterKeyEvent* event;
451 
453  initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
454  void* _Nullable user_data) {
455  [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
456  callback:callback
457  userData:user_data]];
458  }];
459 
460  [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 123.0f, 0x20104, @"", @"", FALSE,
461  kKeyCodeShiftRight)
462  callback:^(BOOL handled){
463  }];
464 
465  EXPECT_EQ([events count], 1u);
466  event = [events lastObject].data;
467  ASSERT_NE(event, nullptr);
468  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
469  EXPECT_EQ(event->timestamp, 123000000.0f);
470  EXPECT_EQ(event->physical, kPhysicalShiftRight);
471  EXPECT_EQ(event->logical, kLogicalShiftRight);
472  EXPECT_STREQ(event->character, nullptr);
473  EXPECT_EQ(event->synthesized, false);
474  [[events lastObject] respond:TRUE];
475 
476  [events removeAllObjects];
477 
478  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x20104, @"A", @"A", FALSE, kKeyCodeKeyA)
479  callback:^(BOOL handled){
480  }];
481 
482  EXPECT_EQ([events count], 1u);
483  event = [events lastObject].data;
484  ASSERT_NE(event, nullptr);
485  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
486  EXPECT_EQ(event->physical, kPhysicalKeyA);
487  EXPECT_EQ(event->logical, kLogicalKeyA);
488  EXPECT_STREQ(event->character, "A");
489  EXPECT_EQ(event->synthesized, false);
490  [[events lastObject] respond:TRUE];
491 
492  [events removeAllObjects];
493 
494  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x20104, @"A", @"A", TRUE, kKeyCodeKeyA)
495  callback:^(BOOL handled){
496  }];
497 
498  EXPECT_EQ([events count], 1u);
499  event = [events lastObject].data;
500  ASSERT_NE(event, nullptr);
501  EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
502  EXPECT_EQ(event->physical, kPhysicalKeyA);
503  EXPECT_EQ(event->logical, kLogicalKeyA);
504  EXPECT_STREQ(event->character, "A");
505  EXPECT_EQ(event->synthesized, false);
506  [[events lastObject] respond:TRUE];
507 
508  [events removeAllObjects];
509 
510  [responder
511  handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
512  callback:^(BOOL handled){
513  }];
514 
515  EXPECT_EQ([events count], 1u);
516  event = [events lastObject].data;
517  ASSERT_NE(event, nullptr);
518  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
519  EXPECT_EQ(event->physical, kPhysicalShiftRight);
520  EXPECT_EQ(event->logical, kLogicalShiftRight);
521  EXPECT_STREQ(event->character, nullptr);
522  EXPECT_EQ(event->synthesized, false);
523  [[events lastObject] respond:TRUE];
524 
525  [events removeAllObjects];
526 
527  [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", TRUE, kKeyCodeKeyA)
528  callback:^(BOOL handled){
529  }];
530 
531  EXPECT_EQ([events count], 1u);
532  event = [events lastObject].data;
533  ASSERT_NE(event, nullptr);
534  EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
535  EXPECT_EQ(event->physical, kPhysicalKeyA);
536  EXPECT_EQ(event->logical, kLogicalKeyA);
537  EXPECT_STREQ(event->character, "a");
538  EXPECT_EQ(event->synthesized, false);
539 
540  [events removeAllObjects];
541 
542  [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
543  callback:^(BOOL handled){
544  }];
545 
546  EXPECT_EQ([events count], 1u);
547  event = [events lastObject].data;
548  ASSERT_NE(event, nullptr);
549  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
550  EXPECT_EQ(event->physical, kPhysicalKeyA);
551  EXPECT_EQ(event->logical, kLogicalKeyA);
552  EXPECT_STREQ(event->character, nullptr);
553  EXPECT_EQ(event->synthesized, false);
554  [[events lastObject] respond:TRUE];
555 
556  [events removeAllObjects];
557 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:.

◆ TEST() [46/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
CorrectLogicalKeyForLayouts   
)

Definition at line 462 of file FlutterKeyboardManagerTest.mm.

462  {
463  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] correctLogicalKeyForLayouts]);
464 }

◆ TEST() [47/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
DoublePrimaryResponder   
)

Definition at line 438 of file FlutterKeyboardManagerTest.mm.

438  {
439  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] doublePrimaryResponder]);
440 }

◆ TEST() [48/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
EmptyNextResponder   
)

Definition at line 446 of file FlutterKeyboardManagerTest.mm.

446  {
447  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] emptyNextResponder]);
448 }

◆ TEST() [49/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
GetPressedState   
)

Definition at line 450 of file FlutterKeyboardManagerTest.mm.

450  {
451  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] getPressedState]);
452 }

◆ TEST() [50/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
KeyboardChannelGetPressedState   
)

Definition at line 454 of file FlutterKeyboardManagerTest.mm.

454  {
455  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] keyboardChannelGetPressedState]);
456 }

◆ TEST() [51/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
RacingConditionBetweenKeyAndText   
)

Definition at line 458 of file FlutterKeyboardManagerTest.mm.

458  {
459  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] racingConditionBetweenKeyAndText]);
460 }

◆ TEST() [52/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
ShouldNotHoldStrongReferenceToViewDelegate   
)

Definition at line 466 of file FlutterKeyboardManagerTest.mm.

466  {
467  ASSERT_TRUE(
468  [[FlutterKeyboardManagerUnittestsObjC alloc] shouldNotHoldStrongReferenceToViewDelegate]);
469 }

◆ TEST() [53/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
SingleFinalResponder   
)

Definition at line 442 of file FlutterKeyboardManagerTest.mm.

442  {
443  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] textInputPlugin]);
444 }

◆ TEST() [54/117]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
SinglePrimaryResponder   
)

Definition at line 434 of file FlutterKeyboardManagerTest.mm.

434  {
435  ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] singlePrimaryResponder]);
436 }

◆ TEST() [55/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
Basics   
)

Definition at line 32 of file FlutterPlatformNodeDelegateMacTest.mm.

32  {
33  FlutterViewController* viewController = CreateTestViewController();
34  FlutterEngine* engine = viewController.engine;
35  engine.semanticsEnabled = YES;
36  auto bridge = viewController.accessibilityBridge.lock();
37  // Initialize ax node data.
38  FlutterSemanticsNode2 root;
39  root.id = 0;
40  root.flags = static_cast<FlutterSemanticsFlag>(0);
41  ;
42  root.actions = static_cast<FlutterSemanticsAction>(0);
43  root.text_selection_base = -1;
44  root.text_selection_extent = -1;
45  root.label = "accessibility";
46  root.hint = "";
47  root.value = "";
48  root.increased_value = "";
49  root.decreased_value = "";
50  root.tooltip = "";
51  root.child_count = 0;
52  root.custom_accessibility_actions_count = 0;
53  bridge->AddFlutterSemanticsNodeUpdate(root);
54 
55  bridge->CommitUpdates();
56 
57  auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
58  // Verify the accessibility attribute matches.
59  NSAccessibilityElement* native_accessibility =
60  root_platform_node_delegate->GetNativeViewAccessible();
61  std::string value = [native_accessibility.accessibilityValue UTF8String];
62  EXPECT_TRUE(value == "accessibility");
63  EXPECT_EQ(native_accessibility.accessibilityRole, NSAccessibilityStaticTextRole);
64  EXPECT_EQ([native_accessibility.accessibilityChildren count], 0u);
65  [engine shutDownEngine];
66 }

References FlutterViewController::engine.

◆ TEST() [56/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
CanPerformAction   
)

Definition at line 149 of file FlutterPlatformNodeDelegateMacTest.mm.

149  {
150  FlutterViewController* viewController = CreateTestViewController();
151  FlutterEngine* engine = viewController.engine;
152 
153  // Attach the view to a NSWindow.
154  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
155  styleMask:NSBorderlessWindowMask
156  backing:NSBackingStoreBuffered
157  defer:NO];
158  window.contentView = viewController.view;
159 
160  engine.semanticsEnabled = YES;
161  auto bridge = viewController.accessibilityBridge.lock();
162  // Initialize ax node data.
163  FlutterSemanticsNode2 root;
164  root.id = 0;
165  root.label = "root";
166  root.hint = "";
167  root.value = "";
168  root.increased_value = "";
169  root.decreased_value = "";
170  root.tooltip = "";
171  root.child_count = 1;
172  int32_t children[] = {1};
173  root.children_in_traversal_order = children;
174  root.custom_accessibility_actions_count = 0;
175  bridge->AddFlutterSemanticsNodeUpdate(root);
176 
177  FlutterSemanticsNode2 child1;
178  child1.id = 1;
179  child1.label = "child 1";
180  child1.hint = "";
181  child1.value = "";
182  child1.increased_value = "";
183  child1.decreased_value = "";
184  child1.tooltip = "";
185  child1.child_count = 0;
186  child1.custom_accessibility_actions_count = 0;
187  bridge->AddFlutterSemanticsNodeUpdate(child1);
188 
189  bridge->CommitUpdates();
190 
191  auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
192 
193  // Set up embedder API mock.
194  FlutterSemanticsAction called_action;
195  uint64_t called_id;
196 
197  engine.embedderAPI.DispatchSemanticsAction = MOCK_ENGINE_PROC(
198  DispatchSemanticsAction,
199  ([&called_id, &called_action](auto engine, uint64_t id, FlutterSemanticsAction action,
200  const uint8_t* data, size_t data_length) {
201  called_id = id;
202  called_action = action;
203  return kSuccess;
204  }));
205 
206  // Performs an AXAction.
207  ui::AXActionData action_data;
208  action_data.action = ax::mojom::Action::kDoDefault;
209  root_platform_node_delegate->AccessibilityPerformAction(action_data);
210 
211  EXPECT_EQ(called_action, FlutterSemanticsAction::kFlutterSemanticsActionTap);
212  EXPECT_EQ(called_id, 1u);
213 
214  [engine setViewController:nil];
215  [engine shutDownEngine];
216 }

References FlutterViewController::engine.

◆ TEST() [57/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
ChangingFlagsUpdatesNativeViewAccessible   
)

Definition at line 299 of file FlutterPlatformNodeDelegateMacTest.mm.

299  {
300  FlutterViewController* viewController = CreateTestViewController();
301  FlutterEngine* engine = viewController.engine;
302  [viewController loadView];
303 
304  // Creates a NSWindow so that the native text field can become first responder.
305  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
306  styleMask:NSBorderlessWindowMask
307  backing:NSBackingStoreBuffered
308  defer:NO];
309  window.contentView = viewController.view;
310  engine.semanticsEnabled = YES;
311 
312  auto bridge = viewController.accessibilityBridge.lock();
313  // Initialize ax node data.
314  FlutterSemanticsNode2 root;
315  root.id = 0;
316  root.flags = static_cast<FlutterSemanticsFlag>(0);
317  root.actions = static_cast<FlutterSemanticsAction>(0);
318  root.label = "root";
319  root.hint = "";
320  root.value = "";
321  root.increased_value = "";
322  root.decreased_value = "";
323  root.tooltip = "";
324  root.child_count = 1;
325  int32_t children[] = {1};
326  root.children_in_traversal_order = children;
327  root.custom_accessibility_actions_count = 0;
328  root.rect = {0, 0, 100, 100}; // LTRB
329  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
330  bridge->AddFlutterSemanticsNodeUpdate(root);
331 
332  double rectSize = 50;
333  double transformFactor = 0.5;
334 
335  FlutterSemanticsNode2 child1;
336  child1.id = 1;
337  child1.flags = static_cast<FlutterSemanticsFlag>(0);
338  child1.actions = static_cast<FlutterSemanticsAction>(0);
339  child1.label = "";
340  child1.hint = "";
341  child1.value = "textfield";
342  child1.increased_value = "";
343  child1.decreased_value = "";
344  child1.tooltip = "";
345  child1.text_selection_base = -1;
346  child1.text_selection_extent = -1;
347  child1.child_count = 0;
348  child1.custom_accessibility_actions_count = 0;
349  child1.rect = {0, 0, rectSize, rectSize}; // LTRB
350  child1.transform = {transformFactor, 0, 0, 0, transformFactor, 0, 0, 0, 1};
351  bridge->AddFlutterSemanticsNodeUpdate(child1);
352 
353  bridge->CommitUpdates();
354 
355  auto child_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
356  // Verify the accessibility attribute matches.
357  id native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
358  EXPECT_TRUE([[native_accessibility className] isEqualToString:@"AXPlatformNodeCocoa"]);
359 
360  // Converting child to text field should produce `FlutterTextField` native view accessible.
361  child1.flags = FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField;
362  bridge->AddFlutterSemanticsNodeUpdate(child1);
363  bridge->CommitUpdates();
364 
365  native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
366  EXPECT_TRUE([native_accessibility isKindOfClass:[FlutterTextField class]]);
367 
368  child1.flags = static_cast<FlutterSemanticsFlag>(0);
369  bridge->AddFlutterSemanticsNodeUpdate(child1);
370  bridge->CommitUpdates();
371 
372  native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
373  EXPECT_TRUE([[native_accessibility className] isEqualToString:@"AXPlatformNodeCocoa"]);
374 }

References FlutterViewController::engine.

◆ TEST() [58/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
SelectableTextHasCorrectSemantics   
)

Definition at line 68 of file FlutterPlatformNodeDelegateMacTest.mm.

68  {
69  FlutterViewController* viewController = CreateTestViewController();
70  FlutterEngine* engine = viewController.engine;
71  engine.semanticsEnabled = YES;
72  auto bridge = viewController.accessibilityBridge.lock();
73  // Initialize ax node data.
74  FlutterSemanticsNode2 root;
75  root.id = 0;
76  root.flags =
77  static_cast<FlutterSemanticsFlag>(FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField |
78  FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly);
79  root.actions = static_cast<FlutterSemanticsAction>(0);
80  root.text_selection_base = 1;
81  root.text_selection_extent = 3;
82  root.label = "";
83  root.hint = "";
84  // Selectable text store its text in value
85  root.value = "selectable text";
86  root.increased_value = "";
87  root.decreased_value = "";
88  root.tooltip = "";
89  root.child_count = 0;
90  root.custom_accessibility_actions_count = 0;
91  bridge->AddFlutterSemanticsNodeUpdate(root);
92 
93  bridge->CommitUpdates();
94 
95  auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
96  // Verify the accessibility attribute matches.
97  NSAccessibilityElement* native_accessibility =
98  root_platform_node_delegate->GetNativeViewAccessible();
99  std::string value = [native_accessibility.accessibilityValue UTF8String];
100  EXPECT_EQ(value, "selectable text");
101  EXPECT_EQ(native_accessibility.accessibilityRole, NSAccessibilityStaticTextRole);
102  EXPECT_EQ([native_accessibility.accessibilityChildren count], 0u);
103  NSRange selection = native_accessibility.accessibilitySelectedTextRange;
104  EXPECT_EQ(selection.location, 1u);
105  EXPECT_EQ(selection.length, 2u);
106  std::string selected_text = [native_accessibility.accessibilitySelectedText UTF8String];
107  EXPECT_EQ(selected_text, "el");
108 }

References FlutterViewController::engine.

◆ TEST() [59/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
SelectableTextWithoutSelectionReturnZeroRange   
)

Definition at line 110 of file FlutterPlatformNodeDelegateMacTest.mm.

110  {
111  FlutterViewController* viewController = CreateTestViewController();
112  FlutterEngine* engine = viewController.engine;
113  engine.semanticsEnabled = YES;
114  auto bridge = viewController.accessibilityBridge.lock();
115  // Initialize ax node data.
116  FlutterSemanticsNode2 root;
117  root.id = 0;
118  root.flags =
119  static_cast<FlutterSemanticsFlag>(FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField |
120  FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly);
121  root.actions = static_cast<FlutterSemanticsAction>(0);
122  root.text_selection_base = -1;
123  root.text_selection_extent = -1;
124  root.label = "";
125  root.hint = "";
126  // Selectable text store its text in value
127  root.value = "selectable text";
128  root.increased_value = "";
129  root.decreased_value = "";
130  root.tooltip = "";
131  root.child_count = 0;
132  root.custom_accessibility_actions_count = 0;
133  bridge->AddFlutterSemanticsNodeUpdate(root);
134 
135  bridge->CommitUpdates();
136 
137  auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
138  // Verify the accessibility attribute matches.
139  NSAccessibilityElement* native_accessibility =
140  root_platform_node_delegate->GetNativeViewAccessible();
141  NSRange selection = native_accessibility.accessibilitySelectedTextRange;
142  EXPECT_TRUE(selection.location == NSNotFound);
143  EXPECT_EQ(selection.length, 0u);
144 }

References FlutterViewController::engine.

◆ TEST() [60/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
TextFieldUsesFlutterTextField   
)

Definition at line 220 of file FlutterPlatformNodeDelegateMacTest.mm.

220  {
221  FlutterViewController* viewController = CreateTestViewController();
222  FlutterEngine* engine = viewController.engine;
223  [viewController loadView];
224 
225  // Unit test localization is unnecessary.
226  // NOLINTNEXTLINE(clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker)
227  viewController.textInputPlugin.string = @"textfield";
228  // Creates a NSWindow so that the native text field can become first responder.
229  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
230  styleMask:NSBorderlessWindowMask
231  backing:NSBackingStoreBuffered
232  defer:NO];
233  window.contentView = viewController.view;
234  engine.semanticsEnabled = YES;
235 
236  auto bridge = viewController.accessibilityBridge.lock();
237  // Initialize ax node data.
238  FlutterSemanticsNode2 root;
239  root.id = 0;
240  root.flags = static_cast<FlutterSemanticsFlag>(0);
241  root.actions = static_cast<FlutterSemanticsAction>(0);
242  root.label = "root";
243  root.hint = "";
244  root.value = "";
245  root.increased_value = "";
246  root.decreased_value = "";
247  root.tooltip = "";
248  root.child_count = 1;
249  int32_t children[] = {1};
250  root.children_in_traversal_order = children;
251  root.custom_accessibility_actions_count = 0;
252  root.rect = {0, 0, 100, 100}; // LTRB
253  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
254  bridge->AddFlutterSemanticsNodeUpdate(root);
255 
256  double rectSize = 50;
257  double transformFactor = 0.5;
258 
259  FlutterSemanticsNode2 child1;
260  child1.id = 1;
261  child1.flags = FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField;
262  child1.actions = static_cast<FlutterSemanticsAction>(0);
263  child1.label = "";
264  child1.hint = "";
265  child1.value = "textfield";
266  child1.increased_value = "";
267  child1.decreased_value = "";
268  child1.tooltip = "";
269  child1.text_selection_base = -1;
270  child1.text_selection_extent = -1;
271  child1.child_count = 0;
272  child1.custom_accessibility_actions_count = 0;
273  child1.rect = {0, 0, rectSize, rectSize}; // LTRB
274  child1.transform = {transformFactor, 0, 0, 0, transformFactor, 0, 0, 0, 1};
275  bridge->AddFlutterSemanticsNodeUpdate(child1);
276 
277  bridge->CommitUpdates();
278 
279  auto child_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
280  // Verify the accessibility attribute matches.
281  id native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
282  EXPECT_EQ([native_accessibility isKindOfClass:[FlutterTextField class]], YES);
283  FlutterTextField* native_text_field = (FlutterTextField*)native_accessibility;
284 
285  NSView* view = viewController.flutterView;
286  CGRect scaledBounds = [view convertRectToBacking:view.bounds];
287  CGSize scaledSize = scaledBounds.size;
288  double pixelRatio = view.bounds.size.width == 0 ? 1 : scaledSize.width / view.bounds.size.width;
289 
290  double expectedFrameSize = rectSize * transformFactor / pixelRatio;
291  EXPECT_EQ(NSEqualRects(native_text_field.frame, NSMakeRect(0, 600 - expectedFrameSize,
292  expectedFrameSize, expectedFrameSize)),
293  YES);
294 
295  [native_text_field startEditing];
296  EXPECT_EQ([native_text_field.stringValue isEqualToString:@"textfield"], YES);
297 }

References FlutterViewController::engine.

◆ TEST() [61/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canCalculateBoundsCorrectly   
)

Definition at line 110 of file flutter_platform_node_delegate_unittests.cc.

110  {
111  std::shared_ptr<TestAccessibilityBridge> bridge =
112  std::make_shared<TestAccessibilityBridge>();
113  FlutterSemanticsNode2 root;
114  root.id = 0;
115  root.label = "root";
116  root.hint = "";
117  root.value = "";
118  root.increased_value = "";
119  root.decreased_value = "";
120  root.tooltip = "";
121  root.child_count = 1;
122  int32_t children[] = {1};
123  root.children_in_traversal_order = children;
124  root.custom_accessibility_actions_count = 0;
125  root.rect = {0, 0, 100, 100}; // LTRB
126  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
127  bridge->AddFlutterSemanticsNodeUpdate(root);
128 
129  FlutterSemanticsNode2 child1;
130  child1.id = 1;
131  child1.label = "child 1";
132  child1.hint = "";
133  child1.value = "";
134  child1.increased_value = "";
135  child1.decreased_value = "";
136  child1.tooltip = "";
137  child1.child_count = 0;
138  child1.custom_accessibility_actions_count = 0;
139  child1.rect = {0, 0, 50, 50}; // LTRB
140  child1.transform = {0.5, 0, 0, 0, 0.5, 0, 0, 0, 1};
141  bridge->AddFlutterSemanticsNodeUpdate(child1);
142 
143  bridge->CommitUpdates();
144  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
145  ui::AXOffscreenResult result;
146  gfx::Rect bounds =
147  child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
148  ui::AXClippingBehavior::kClipped, &result);
149  EXPECT_EQ(bounds.x(), 0);
150  EXPECT_EQ(bounds.y(), 0);
151  EXPECT_EQ(bounds.width(), 25);
152  EXPECT_EQ(bounds.height(), 25);
153  EXPECT_EQ(result, ui::AXOffscreenResult::kOnscreen);
154 }

◆ TEST() [62/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canCalculateOffScreenBoundsCorrectly   
)

Definition at line 156 of file flutter_platform_node_delegate_unittests.cc.

156  {
157  std::shared_ptr<TestAccessibilityBridge> bridge =
158  std::make_shared<TestAccessibilityBridge>();
159  FlutterSemanticsNode2 root;
160  root.id = 0;
161  root.label = "root";
162  root.hint = "";
163  root.value = "";
164  root.increased_value = "";
165  root.decreased_value = "";
166  root.tooltip = "";
167  root.child_count = 1;
168  int32_t children[] = {1};
169  root.children_in_traversal_order = children;
170  root.custom_accessibility_actions_count = 0;
171  root.rect = {0, 0, 100, 100}; // LTRB
172  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
173  bridge->AddFlutterSemanticsNodeUpdate(root);
174 
175  FlutterSemanticsNode2 child1;
176  child1.id = 1;
177  child1.label = "child 1";
178  child1.hint = "";
179  child1.value = "";
180  child1.increased_value = "";
181  child1.decreased_value = "";
182  child1.tooltip = "";
183  child1.child_count = 0;
184  child1.custom_accessibility_actions_count = 0;
185  child1.rect = {90, 90, 100, 100}; // LTRB
186  child1.transform = {2, 0, 0, 0, 2, 0, 0, 0, 1};
187  bridge->AddFlutterSemanticsNodeUpdate(child1);
188 
189  bridge->CommitUpdates();
190  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
191  ui::AXOffscreenResult result;
192  gfx::Rect bounds =
193  child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
194  ui::AXClippingBehavior::kUnclipped, &result);
195  EXPECT_EQ(bounds.x(), 180);
196  EXPECT_EQ(bounds.y(), 180);
197  EXPECT_EQ(bounds.width(), 20);
198  EXPECT_EQ(bounds.height(), 20);
199  EXPECT_EQ(result, ui::AXOffscreenResult::kOffscreen);
200 }

◆ TEST() [63/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canGetAXNode   
)

Definition at line 84 of file flutter_platform_node_delegate_unittests.cc.

84  {
85  // Set up a flutter accessibility node.
86  std::shared_ptr<TestAccessibilityBridge> bridge =
87  std::make_shared<TestAccessibilityBridge>();
88  FlutterSemanticsNode2 root;
89  root.id = 0;
90  root.flags = FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField;
91  root.actions = static_cast<FlutterSemanticsAction>(0);
92  root.text_selection_base = -1;
93  root.text_selection_extent = -1;
94  root.label = "root";
95  root.hint = "";
96  root.value = "";
97  root.increased_value = "";
98  root.decreased_value = "";
99  root.tooltip = "";
100  root.child_count = 0;
101  root.custom_accessibility_actions_count = 0;
102  bridge->AddFlutterSemanticsNodeUpdate(root);
103 
104  bridge->CommitUpdates();
105 
106  auto accessibility = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
107  EXPECT_EQ(accessibility->GetData().id, 0);
108 }

◆ TEST() [64/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canGetFromNodeID   
)

Definition at line 271 of file flutter_platform_node_delegate_unittests.cc.

271  {
272  std::shared_ptr<TestAccessibilityBridge> bridge =
273  std::make_shared<TestAccessibilityBridge>();
274  FlutterSemanticsNode2 root;
275  root.id = 0;
276  root.label = "root";
277  root.hint = "";
278  root.value = "";
279  root.increased_value = "";
280  root.decreased_value = "";
281  root.tooltip = "";
282  root.child_count = 1;
283  int32_t children[] = {1};
284  root.children_in_traversal_order = children;
285  root.custom_accessibility_actions_count = 0;
286  bridge->AddFlutterSemanticsNodeUpdate(root);
287 
288  FlutterSemanticsNode2 child1;
289  child1.id = 1;
290  child1.label = "child 1";
291  child1.hint = "";
292  child1.value = "";
293  child1.increased_value = "";
294  child1.decreased_value = "";
295  child1.tooltip = "";
296  child1.child_count = 0;
297  child1.custom_accessibility_actions_count = 0;
298  bridge->AddFlutterSemanticsNodeUpdate(child1);
299 
300  bridge->CommitUpdates();
301  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
302  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
303  auto node_by_id = root_node->GetFromNodeID(1);
304  EXPECT_EQ(child1_node->GetPlatformNode(), node_by_id);
305 }

◆ TEST() [65/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canPerfomActions   
)

Definition at line 40 of file flutter_platform_node_delegate_unittests.cc.

40  {
41  std::shared_ptr<TestAccessibilityBridge> bridge =
42  std::make_shared<TestAccessibilityBridge>();
43  FlutterSemanticsNode2 root;
44  root.id = 0;
45  root.flags = FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField;
46  root.actions = static_cast<FlutterSemanticsAction>(0);
47  root.text_selection_base = -1;
48  root.text_selection_extent = -1;
49  root.label = "root";
50  root.hint = "";
51  root.value = "";
52  root.increased_value = "";
53  root.decreased_value = "";
54  root.tooltip = "";
55  root.child_count = 0;
56  root.custom_accessibility_actions_count = 0;
57  bridge->AddFlutterSemanticsNodeUpdate(root);
58 
59  bridge->CommitUpdates();
60 
61  auto accessibility = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
62  // Performs an AXAction.
63  ui::AXActionData action_data;
64  action_data.action = ax::mojom::Action::kDoDefault;
65  accessibility->AccessibilityPerformAction(action_data);
66  EXPECT_EQ(bridge->performed_actions.size(), size_t{1});
67  EXPECT_EQ(bridge->performed_actions[0],
68  FlutterSemanticsAction::kFlutterSemanticsActionTap);
69 
70  action_data.action = ax::mojom::Action::kFocus;
71  accessibility->AccessibilityPerformAction(action_data);
72  EXPECT_EQ(bridge->performed_actions.size(), size_t{2});
73  EXPECT_EQ(
74  bridge->performed_actions[1],
75  FlutterSemanticsAction::kFlutterSemanticsActionDidGainAccessibilityFocus);
76 
77  action_data.action = ax::mojom::Action::kScrollToMakeVisible;
78  accessibility->AccessibilityPerformAction(action_data);
79  EXPECT_EQ(bridge->performed_actions.size(), size_t{3});
80  EXPECT_EQ(bridge->performed_actions[2],
81  FlutterSemanticsAction::kFlutterSemanticsActionShowOnScreen);
82 }

◆ TEST() [66/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canUseOwnerBridge   
)

Definition at line 202 of file flutter_platform_node_delegate_unittests.cc.

202  {
203  std::shared_ptr<TestAccessibilityBridge> bridge =
204  std::make_shared<TestAccessibilityBridge>();
205  FlutterSemanticsNode2 root;
206  root.id = 0;
207  root.label = "root";
208  root.hint = "";
209  root.value = "";
210  root.increased_value = "";
211  root.decreased_value = "";
212  root.tooltip = "";
213  root.child_count = 1;
214  int32_t children[] = {1};
215  root.children_in_traversal_order = children;
216  root.custom_accessibility_actions_count = 0;
217  root.rect = {0, 0, 100, 100}; // LTRB
218  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
219  bridge->AddFlutterSemanticsNodeUpdate(root);
220 
221  FlutterSemanticsNode2 child1;
222  child1.id = 1;
223  child1.label = "child 1";
224  child1.hint = "";
225  child1.value = "";
226  child1.increased_value = "";
227  child1.decreased_value = "";
228  child1.tooltip = "";
229  child1.child_count = 0;
230  child1.custom_accessibility_actions_count = 0;
231  child1.rect = {0, 0, 50, 50}; // LTRB
232  child1.transform = {0.5, 0, 0, 0, 0.5, 0, 0, 0, 1};
233  bridge->AddFlutterSemanticsNodeUpdate(child1);
234 
235  bridge->CommitUpdates();
236  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
237  auto owner_bridge = child1_node->GetOwnerBridge().lock();
238 
239  bool result;
240  gfx::RectF bounds = owner_bridge->RelativeToGlobalBounds(
241  child1_node->GetAXNode(), result, true);
242  EXPECT_EQ(bounds.x(), 0);
243  EXPECT_EQ(bounds.y(), 0);
244  EXPECT_EQ(bounds.width(), 25);
245  EXPECT_EQ(bounds.height(), 25);
246  EXPECT_EQ(result, false);
247 }

◆ TEST() [67/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
NodeDelegateHasUniqueId   
)

Definition at line 15 of file flutter_platform_node_delegate_unittests.cc.

15  {
16  std::shared_ptr<TestAccessibilityBridge> bridge =
17  std::make_shared<TestAccessibilityBridge>();
18 
19  // Add node 0: root.
20  FlutterSemanticsNode2 node0{sizeof(FlutterSemanticsNode2), 0};
21  std::vector<int32_t> node0_children{1};
22  node0.child_count = node0_children.size();
23  node0.children_in_traversal_order = node0_children.data();
24  node0.children_in_hit_test_order = node0_children.data();
25 
26  // Add node 1: text child of node 0.
27  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
28  node1.label = "prefecture";
29  node1.value = "Kyoto";
30 
31  bridge->AddFlutterSemanticsNodeUpdate(node0);
32  bridge->AddFlutterSemanticsNodeUpdate(node1);
33  bridge->CommitUpdates();
34 
35  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
36  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
37  EXPECT_TRUE(node0_delegate->GetUniqueId() != node1_delegate->GetUniqueId());
38 }

◆ TEST() [68/117]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
selfIsLowestPlatformAncestor   
)

Definition at line 249 of file flutter_platform_node_delegate_unittests.cc.

249  {
250  std::shared_ptr<TestAccessibilityBridge> bridge =
251  std::make_shared<TestAccessibilityBridge>();
252  FlutterSemanticsNode2 root;
253  root.id = 0;
254  root.label = "root";
255  root.hint = "";
256  root.value = "";
257  root.increased_value = "";
258  root.decreased_value = "";
259  root.tooltip = "";
260  root.child_count = 0;
261  root.children_in_traversal_order = nullptr;
262  root.custom_accessibility_actions_count = 0;
263  bridge->AddFlutterSemanticsNodeUpdate(root);
264 
265  bridge->CommitUpdates();
266  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
267  auto lowest_platform_ancestor = root_node->GetLowestPlatformAncestor();
268  EXPECT_EQ(root_node->GetNativeViewAccessible(), lowest_platform_ancestor);
269 }

◆ TEST() [69/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestAcceptGesture   
)

Definition at line 164 of file FlutterPlatformViewControllerTest.mm.

164  {
165  FlutterPlatformViewController* platformViewController =
166  [[FlutterPlatformViewController alloc] init];
167  [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
168  withId:@"MockPlatformView"];
169 
170  // Create the PlatformView.
171  const NSNumber* viewId = [NSNumber numberWithLongLong:2];
172  FlutterMethodCall* methodCallOnCreate = [FlutterMethodCall
173  methodCallWithMethodName:@"create"
174  arguments:@{@"id" : viewId, @"viewType" : @"MockPlatformView"}];
175  __block bool created = false;
176  FlutterResult resultOnCreate = ^(id result) {
177  // If a platform view is successfully created, the result is nil.
178  if (result == nil) {
179  created = true;
180  }
181  };
182  [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
183 
184  // Call acceptGesture.
185  FlutterMethodCall* methodCallAcceptGesture =
186  [FlutterMethodCall methodCallWithMethodName:@"acceptGesture" arguments:@{@"id" : viewId}];
187  __block bool acceptGestureCalled = false;
188  FlutterResult resultAcceptGesture = ^(id result) {
189  // If a acceptGesture is successful, the result is nil.
190  if (result == nil) {
191  acceptGestureCalled = true;
192  }
193  };
194  [platformViewController handleMethodCall:methodCallAcceptGesture result:resultAcceptGesture];
195 
196  EXPECT_TRUE(created);
197  EXPECT_TRUE(acceptGestureCalled);
198 }

◆ TEST() [70/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestAcceptGestureOnMissingViewId   
)

Definition at line 200 of file FlutterPlatformViewControllerTest.mm.

200  {
201  FlutterPlatformViewController* platformViewController =
202  [[FlutterPlatformViewController alloc] init];
203  [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
204  withId:@"MockPlatformView"];
205 
206  // Call rejectGesture.
207  FlutterMethodCall* methodCallAcceptGesture =
208  [FlutterMethodCall methodCallWithMethodName:@"acceptGesture" arguments:@{
209  @"id" : @20
210  }];
211  __block bool errored = false;
212  FlutterResult result = ^(id result) {
213  if ([result isKindOfClass:[FlutterError class]]) {
214  errored = true;
215  }
216  };
217  [platformViewController handleMethodCall:methodCallAcceptGesture result:result];
218 
219  EXPECT_TRUE(errored);
220 }

◆ TEST() [71/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestCreateAndDispose   
)

Definition at line 101 of file FlutterPlatformViewControllerTest.mm.

101  {
102  // Use id so we can access handleMethodCall method.
103  id platformViewController = [[FlutterPlatformViewController alloc] init];
104 
106 
107  [platformViewController registerViewFactory:factory withId:@"MockPlatformView"];
108 
109  FlutterMethodCall* methodCallOnCreate =
110  [FlutterMethodCall methodCallWithMethodName:@"create"
111  arguments:@{
112  @"id" : @2,
113  @"viewType" : @"MockPlatformView"
114  }];
115 
116  __block bool created = false;
117  FlutterResult resultOnCreate = ^(id result) {
118  // If a platform view is successfully created, the result is nil.
119  if (result == nil) {
120  created = true;
121  }
122  };
123 
124  [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
125 
126  FlutterMethodCall* methodCallOnDispose =
127  [FlutterMethodCall methodCallWithMethodName:@"dispose"
128  arguments:[NSNumber numberWithLongLong:2]];
129 
130  __block bool disposed = false;
131  FlutterResult resultOnDispose = ^(id result) {
132  // If a platform view is successfully created, the result is nil.
133  if (result == nil) {
134  disposed = true;
135  }
136  };
137 
138  [platformViewController handleMethodCall:methodCallOnDispose result:resultOnDispose];
139 
140  EXPECT_TRUE(created);
141  EXPECT_TRUE(disposed);
142 }

◆ TEST() [72/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestCreatePlatformViewNoMatchingViewType   
)

Definition at line 14 of file FlutterPlatformViewControllerTest.mm.

14  {
15  // Use id so we can access handleMethodCall method.
16  id platformViewController = [[FlutterPlatformViewController alloc] init];
17 
18  FlutterMethodCall* methodCall =
19  [FlutterMethodCall methodCallWithMethodName:@"create"
20  arguments:@{
21  @"id" : @2,
22  @"viewType" : @"FlutterPlatformViewMock"
23  }];
24 
25  __block bool errored = false;
26  FlutterResult result = ^(id result) {
27  if ([result isKindOfClass:[FlutterError class]]) {
28  errored = true;
29  }
30  };
31 
32  [platformViewController handleMethodCall:methodCall result:result];
33 
34  // We expect the call to error since no factories are registered.
35  EXPECT_TRUE(errored);
36 }

◆ TEST() [73/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestDisposeOnMissingViewId   
)

Definition at line 144 of file FlutterPlatformViewControllerTest.mm.

144  {
145  // Use id so we can access handleMethodCall method.
146  id platformViewController = [[FlutterPlatformViewController alloc] init];
147 
148  FlutterMethodCall* methodCall =
149  [FlutterMethodCall methodCallWithMethodName:@"dispose"
150  arguments:[NSNumber numberWithLongLong:20]];
151 
152  __block bool errored = false;
153  FlutterResult result = ^(id result) {
154  if ([result isKindOfClass:[FlutterError class]]) {
155  errored = true;
156  }
157  };
158 
159  [platformViewController handleMethodCall:methodCall result:result];
160 
161  EXPECT_TRUE(errored);
162 }

◆ TEST() [74/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRegisterPlatformViewFactoryAndCreate   
)

Definition at line 38 of file FlutterPlatformViewControllerTest.mm.

38  {
39  // Use id so we can access handleMethodCall method.
40  id platformViewController = [[FlutterPlatformViewController alloc] init];
41 
43 
44  [platformViewController registerViewFactory:factory withId:@"MockPlatformView"];
45 
46  NSDictionary* creationArgs = @{
47  @"album" : @"スコットã¨ãƒªãƒãƒ¼ã‚¹",
48  @"releaseYear" : @2013,
49  @"artists" : @[ @"Scott Murphy", @"Rivers Cuomo" ],
50  @"playlist" : @[ @"ãŠã‹ã—ã„ã‚„ã¤", @"ã»ã©ã‘ã¦ã„ãŸã‚“ã " ],
51  };
52  NSObject<FlutterMessageCodec>* codec = [factory createArgsCodec];
53  FlutterStandardTypedData* creationArgsData =
54  [FlutterStandardTypedData typedDataWithBytes:[codec encode:creationArgs]];
55 
56  FlutterMethodCall* methodCall =
57  [FlutterMethodCall methodCallWithMethodName:@"create"
58  arguments:@{
59  @"id" : @2,
60  @"viewType" : @"MockPlatformView",
61  @"params" : creationArgsData,
62  }];
63 
64  __block bool success = false;
65  FlutterResult result = ^(id result) {
66  // If a platform view is successfully created, the result is nil.
67  if (result == nil) {
68  success = true;
69  }
70  };
71  [platformViewController handleMethodCall:methodCall result:result];
72  EXPECT_TRUE(success);
73 
74  // Verify PlatformView parameters are decoded correctly.
76  (TestFlutterPlatformView*)[platformViewController platformViewWithID:2];
77  ASSERT_TRUE(view != nil);
78  ASSERT_TRUE(view.args != nil);
79 
80  // Verify string type.
81  NSString* album = [view.args objectForKey:@"album"];
82  EXPECT_TRUE([album isEqualToString:@"スコットã¨ãƒªãƒãƒ¼ã‚¹"]);
83 
84  // Verify int type.
85  NSNumber* releaseYear = [view.args objectForKey:@"releaseYear"];
86  EXPECT_EQ(releaseYear.intValue, 2013);
87 
88  // Verify list/array types.
89  NSArray* artists = [view.args objectForKey:@"artists"];
90  ASSERT_TRUE(artists != nil);
91  ASSERT_EQ(artists.count, 2ul);
92  EXPECT_TRUE([artists[0] isEqualToString:@"Scott Murphy"]);
93  EXPECT_TRUE([artists[1] isEqualToString:@"Rivers Cuomo"]);
94 
95  NSArray* playlist = [view.args objectForKey:@"playlist"];
96  ASSERT_EQ(playlist.count, 2ul);
97  EXPECT_TRUE([playlist[0] isEqualToString:@"ãŠã‹ã—ã„ã‚„ã¤"]);
98  EXPECT_TRUE([playlist[1] isEqualToString:@"ã»ã©ã‘ã¦ã„ãŸã‚“ã "]);
99 }

References TestFlutterPlatformView::args.

◆ TEST() [75/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRejectGesture   
)

Definition at line 222 of file FlutterPlatformViewControllerTest.mm.

222  {
223  FlutterPlatformViewController* platformViewController =
224  [[FlutterPlatformViewController alloc] init];
225  [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
226  withId:@"MockPlatformView"];
227 
228  // Create the PlatformView.
229  const NSNumber* viewId = [NSNumber numberWithLongLong:2];
230  FlutterMethodCall* methodCallOnCreate = [FlutterMethodCall
231  methodCallWithMethodName:@"create"
232  arguments:@{@"id" : viewId, @"viewType" : @"MockPlatformView"}];
233  __block bool created = false;
234  FlutterResult resultOnCreate = ^(id result) {
235  // If a platform view is successfully created, the result is nil.
236  if (result == nil) {
237  created = true;
238  }
239  };
240  [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
241 
242  // Call rejectGesture.
243  FlutterMethodCall* methodCallRejectGesture =
244  [FlutterMethodCall methodCallWithMethodName:@"rejectGesture" arguments:@{@"id" : viewId}];
245  __block bool rejectGestureCalled = false;
246  FlutterResult resultRejectGesture = ^(id result) {
247  // If a rejectGesture is successful, the result is nil.
248  if (result == nil) {
249  rejectGestureCalled = true;
250  }
251  };
252  [platformViewController handleMethodCall:methodCallRejectGesture result:resultRejectGesture];
253 
254  EXPECT_TRUE(created);
255  EXPECT_TRUE(rejectGestureCalled);
256 }

◆ TEST() [76/117]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRejectGestureOnMissingViewId   
)

Definition at line 258 of file FlutterPlatformViewControllerTest.mm.

258  {
259  FlutterPlatformViewController* platformViewController =
260  [[FlutterPlatformViewController alloc] init];
261  [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
262  withId:@"MockPlatformView"];
263 
264  // Call rejectGesture.
265  FlutterMethodCall* methodCallRejectGesture =
266  [FlutterMethodCall methodCallWithMethodName:@"rejectGesture" arguments:@{
267  @"id" : @20
268  }];
269  __block bool errored = false;
270  FlutterResult result = ^(id result) {
271  if ([result isKindOfClass:[FlutterError class]]) {
272  errored = true;
273  }
274  };
275  [platformViewController handleMethodCall:methodCallRejectGesture result:result];
276 
277  EXPECT_TRUE(errored);
278 }

◆ TEST() [77/117]

flutter::testing::TEST ( FlutterSurfaceManager  ,
BackBufferCacheDoesNotLeak   
)

Definition at line 96 of file FlutterSurfaceManagerTest.mm.

96  {
97  TestView* testView = [[TestView alloc] init];
98  FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
99  EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
100 
101  auto surface1 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
102  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1) ] atTime:0 notify:nil];
103 
104  EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
105 
106  auto surface2 = [surfaceManager surfaceForSize:CGSizeMake(110, 110)];
107  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface2) ] atTime:0 notify:nil];
108 
109  EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
110 
111  auto surface3 = [surfaceManager surfaceForSize:CGSizeMake(120, 120)];
112  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface3) ] atTime:0 notify:nil];
113 
114  // Cache should be cleaned during present and only contain the last visible
115  // surface(s).
116  EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
117  auto surfaceFromCache = [surfaceManager surfaceForSize:CGSizeMake(110, 110)];
118  EXPECT_EQ(surfaceFromCache, surface2);
119 
120  // Submit empty surfaces until the one in cache gets to age >= kSurfaceEvictionAge, in which case
121  // it should be removed.
122 
123  for (int i = 0; i < 30 /* kSurfaceEvictionAge */; ++i) {
124  [surfaceManager presentSurfaces:@[] atTime:0 notify:nil];
125  EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
126  }
127 
128  [surfaceManager presentSurfaces:@[] atTime:0 notify:nil];
129  EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
130 }

References FlutterSurfaceManager::backBufferCache, FlutterBackBufferCache::count, CreateSurfaceManager(), FlutterSurfaceManager::presentSurfaces:atTime:notify:, and FlutterSurfaceManager::surfaceForSize:.

◆ TEST() [78/117]

flutter::testing::TEST ( FlutterSurfaceManager  ,
BackingStoreCacheSurfaceStuckInUse   
)

Definition at line 171 of file FlutterSurfaceManagerTest.mm.

171  {
172  TestView* testView = [[TestView alloc] init];
173  FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
174 
175  auto surface1 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
176 
177  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1) ] atTime:0 notify:nil];
178  // Pretend that compositor is holding on to the surface. The surface will be kept
179  // in cache until the age of kSurfaceEvictionAge is reached, and then evicted.
180  surface1.isInUseOverride = YES;
181 
182  auto surface2 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
183  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface2) ] atTime:0 notify:nil];
184  EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
185 
186  for (int i = 0; i < 30 /* kSurfaceEvictionAge */ - 1; ++i) {
187  auto surface3 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
188  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface3) ] atTime:0 notify:nil];
189  EXPECT_EQ(surfaceManager.backBufferCache.count, 2ul);
190  }
191 
192  auto surface4 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
193  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface4) ] atTime:0 notify:nil];
194  // Surface in use should bet old enough at this point to be evicted.
195  EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
196 }

References FlutterSurfaceManager::backBufferCache, FlutterBackBufferCache::count, CreateSurfaceManager(), FlutterSurfaceManager::presentSurfaces:atTime:notify:, and FlutterSurfaceManager::surfaceForSize:.

◆ TEST() [79/117]

flutter::testing::TEST ( FlutterSurfaceManager  ,
LayerManagement   
)

Definition at line 202 of file FlutterSurfaceManagerTest.mm.

202  {
203  TestView* testView = [[TestView alloc] init];
204  FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
205 
206  EXPECT_EQ(testView.layer.sublayers.count, 0ul);
207 
208  auto surface1_1 = [surfaceManager surfaceForSize:CGSizeMake(50, 30)];
209  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1_1, CGPointMake(20, 10)) ]
210  atTime:0
211  notify:nil];
212 
213  EXPECT_EQ(testView.layer.sublayers.count, 1ul);
214  EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(70, 40)));
215 
216  auto surface2_1 = [surfaceManager surfaceForSize:CGSizeMake(50, 30)];
217  auto surface2_2 = [surfaceManager surfaceForSize:CGSizeMake(20, 20)];
218  [surfaceManager presentSurfaces:@[
219  CreatePresentInfo(surface2_1, CGPointMake(20, 10), 1),
220  CreatePresentInfo(surface2_2, CGPointMake(40, 50), 2,
221  {
222  FlutterRect{0, 0, 20, 20},
223  FlutterRect{40, 0, 60, 20},
224  })
225  ]
226  atTime:0
227  notify:nil];
228 
229  EXPECT_EQ(testView.layer.sublayers.count, 2ul);
230  EXPECT_EQ(testView.layer.sublayers[0].zPosition, 1.0);
231  EXPECT_EQ(testView.layer.sublayers[1].zPosition, 2.0);
232  CALayer* firstOverlaySublayer;
233  {
234  NSArray<CALayer*>* sublayers = testView.layer.sublayers[1].sublayers;
235  EXPECT_EQ(sublayers.count, 2ul);
236  EXPECT_TRUE(CGRectEqualToRect(sublayers[0].frame, CGRectMake(0, 0, 10, 10)));
237  EXPECT_TRUE(CGRectEqualToRect(sublayers[1].frame, CGRectMake(20, 0, 10, 10)));
238  EXPECT_TRUE(CGRectEqualToRect(sublayers[0].contentsRect, CGRectMake(0, 0, 1, 1)));
239  EXPECT_TRUE(CGRectEqualToRect(sublayers[1].contentsRect, CGRectMake(2, 0, 1, 1)));
240  EXPECT_EQ(sublayers[0].contents, sublayers[1].contents);
241  firstOverlaySublayer = sublayers[0];
242  }
243  EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(70, 70)));
244 
245  // Check second overlay sublayer is removed while first is reused and updated
246  [surfaceManager presentSurfaces:@[
247  CreatePresentInfo(surface2_1, CGPointMake(20, 10), 1),
248  CreatePresentInfo(surface2_2, CGPointMake(40, 50), 2,
249  {
250  FlutterRect{0, 10, 20, 20},
251  })
252  ]
253  atTime:0
254  notify:nil];
255  EXPECT_EQ(testView.layer.sublayers.count, 2ul);
256  {
257  NSArray<CALayer*>* sublayers = testView.layer.sublayers[1].sublayers;
258  EXPECT_EQ(sublayers.count, 1ul);
259  EXPECT_EQ(sublayers[0], firstOverlaySublayer);
260  EXPECT_TRUE(CGRectEqualToRect(sublayers[0].frame, CGRectMake(0, 5, 10, 5)));
261  }
262 
263  // Check that second overlay sublayer is added back while first is reused and updated
264  [surfaceManager presentSurfaces:@[
265  CreatePresentInfo(surface2_1, CGPointMake(20, 10), 1),
266  CreatePresentInfo(surface2_2, CGPointMake(40, 50), 2,
267  {
268  FlutterRect{0, 0, 20, 20},
269  FlutterRect{40, 0, 60, 20},
270  })
271  ]
272  atTime:0
273  notify:nil];
274 
275  EXPECT_EQ(testView.layer.sublayers.count, 2ul);
276  {
277  NSArray<CALayer*>* sublayers = testView.layer.sublayers[1].sublayers;
278  EXPECT_EQ(sublayers.count, 2ul);
279  EXPECT_EQ(sublayers[0], firstOverlaySublayer);
280  EXPECT_TRUE(CGRectEqualToRect(sublayers[0].frame, CGRectMake(0, 0, 10, 10)));
281  EXPECT_TRUE(CGRectEqualToRect(sublayers[1].frame, CGRectMake(20, 0, 10, 10)));
282  EXPECT_EQ(sublayers[0].contents, sublayers[1].contents);
283  }
284 
285  auto surface3_1 = [surfaceManager surfaceForSize:CGSizeMake(50, 30)];
286  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface3_1, CGPointMake(20, 10)) ]
287  atTime:0
288  notify:nil];
289 
290  EXPECT_EQ(testView.layer.sublayers.count, 1ul);
291  EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(70, 40)));
292 
293  // Check removal of all surfaces.
294  [surfaceManager presentSurfaces:@[] atTime:0 notify:nil];
295  EXPECT_EQ(testView.layer.sublayers.count, 0ul);
296  EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(0, 0)));
297 }

References CreateSurfaceManager(), TestView::presentedFrameSize, FlutterSurfaceManager::presentSurfaces:atTime:notify:, and FlutterSurfaceManager::surfaceForSize:.

◆ TEST() [80/117]

flutter::testing::TEST ( FlutterSurfaceManager  ,
MetalTextureSizeMatchesSurfaceSize   
)

Definition at line 64 of file FlutterSurfaceManagerTest.mm.

64  {
65  TestView* testView = [[TestView alloc] init];
66  FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
67 
68  // Get back buffer, lookup should work for borrowed surfaces util present.
69  auto surface = [surfaceManager surfaceForSize:CGSizeMake(100, 50)];
70  auto texture = surface.asFlutterMetalTexture;
71  id<MTLTexture> metalTexture = (__bridge id)texture.texture;
72  EXPECT_EQ(metalTexture.width, 100ul);
73  EXPECT_EQ(metalTexture.height, 50ul);
74  texture.destruction_callback(texture.user_data);
75 }

References FlutterSurface::asFlutterMetalTexture, CreateSurfaceManager(), and FlutterSurfaceManager::surfaceForSize:.

◆ TEST() [81/117]

flutter::testing::TEST ( FlutterSurfaceManager  ,
SurfacesAreRecycled   
)

Definition at line 132 of file FlutterSurfaceManagerTest.mm.

132  {
133  TestView* testView = [[TestView alloc] init];
134  FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
135 
136  EXPECT_EQ(surfaceManager.frontSurfaces.count, 0ul);
137 
138  // Get first surface and present it.
139 
140  auto surface1 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
141  EXPECT_TRUE(CGSizeEqualToSize(surface1.size, CGSizeMake(100, 100)));
142 
143  EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
144  EXPECT_EQ(surfaceManager.frontSurfaces.count, 0ul);
145 
146  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1) ] atTime:0 notify:nil];
147 
148  EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
149  EXPECT_EQ(surfaceManager.frontSurfaces.count, 1ul);
150  EXPECT_EQ(testView.layer.sublayers.count, 1ul);
151 
152  // Get second surface and present it.
153 
154  auto surface2 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
155  EXPECT_TRUE(CGSizeEqualToSize(surface2.size, CGSizeMake(100, 100)));
156 
157  EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
158 
159  [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface2) ] atTime:0 notify:nil];
160 
161  // Check that current front surface returns to cache.
162  EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
163  EXPECT_EQ(surfaceManager.frontSurfaces.count, 1ul);
164  EXPECT_EQ(testView.layer.sublayers.count, 1ull);
165 
166  // Check that surface is properly reused.
167  auto surface3 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
168  EXPECT_EQ(surface3, surface1);
169 }

References FlutterSurfaceManager::backBufferCache, FlutterBackBufferCache::count, CreateSurfaceManager(), FlutterSurfaceManager::frontSurfaces, FlutterSurfaceManager::presentSurfaces:atTime:notify:, and FlutterSurfaceManager::surfaceForSize:.

◆ TEST() [82/117]

flutter::testing::TEST ( FlutterSurfaceManager  ,
TestSurfaceLookupFromTexture   
)

Definition at line 77 of file FlutterSurfaceManagerTest.mm.

77  {
78  TestView* testView = [[TestView alloc] init];
79  FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
80 
81  // Get back buffer, lookup should work for borrowed surfaces util present.
82  auto surface = [surfaceManager surfaceForSize:CGSizeMake(100, 50)];
83 
84  // SurfaceManager should keep texture alive while borrowed.
85  auto texture = surface.asFlutterMetalTexture;
86  texture.destruction_callback(texture.user_data);
87 
88  FlutterMetalTexture dummyTexture{.texture_id = 1, .texture = nullptr, .user_data = nullptr};
89  auto surface1 = [FlutterSurface fromFlutterMetalTexture:&dummyTexture];
90  EXPECT_EQ(surface1, nil);
91 
92  auto surface2 = [FlutterSurface fromFlutterMetalTexture:&texture];
93  EXPECT_EQ(surface2, surface);
94 }

References FlutterSurface::asFlutterMetalTexture, CreateSurfaceManager(), FlutterSurface::fromFlutterMetalTexture:, and FlutterSurfaceManager::surfaceForSize:.

◆ TEST() [83/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
CanNotBecomeResponderIfNoViewController   
)

Definition at line 2074 of file FlutterTextInputPluginTest.mm.

2074  {
2075  FlutterEngine* engine = CreateTestEngine();
2076  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2077  nibName:nil
2078  bundle:nil];
2079  [viewController loadView];
2080  // Creates a NSWindow so that the native text field can become first responder.
2081  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2082  styleMask:NSBorderlessWindowMask
2083  backing:NSBackingStoreBuffered
2084  defer:NO];
2085  window.contentView = viewController.view;
2086 
2087  engine.semanticsEnabled = YES;
2088 
2089  auto bridge = viewController.accessibilityBridge.lock();
2090  FlutterPlatformNodeDelegateMac delegate(bridge, viewController);
2091  ui::AXTree tree;
2092  ui::AXNode ax_node(&tree, nullptr, 0, 0);
2093  ui::AXNodeData node_data;
2094  node_data.SetValue("initial text");
2095  ax_node.SetData(node_data);
2096  delegate.Init(viewController.accessibilityBridge, &ax_node);
2097  FlutterTextPlatformNode text_platform_node(&delegate, viewController);
2098 
2099  FlutterTextField* textField = text_platform_node.GetNativeViewAccessible();
2100  EXPECT_EQ([textField becomeFirstResponder], YES);
2101  // Removes view controller.
2102  [engine setViewController:nil];
2103  FlutterTextPlatformNode text_platform_node_no_controller(&delegate, nil);
2104  textField = text_platform_node_no_controller.GetNativeViewAccessible();
2105  EXPECT_EQ([textField becomeFirstResponder], NO);
2106 }

References flutter::FlutterTextPlatformNode::GetNativeViewAccessible(), and flutter::FlutterPlatformNodeDelegateMac::Init().

◆ TEST() [84/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
CanWorkWithFlutterTextField   
)

Definition at line 2009 of file FlutterTextInputPluginTest.mm.

2009  {
2010  FlutterEngine* engine = CreateTestEngine();
2011  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2012  nibName:nil
2013  bundle:nil];
2014  [viewController loadView];
2015  // Create a NSWindow so that the native text field can become first responder.
2016  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2017  styleMask:NSBorderlessWindowMask
2018  backing:NSBackingStoreBuffered
2019  defer:NO];
2020  window.contentView = viewController.view;
2021 
2022  engine.semanticsEnabled = YES;
2023 
2024  auto bridge = viewController.accessibilityBridge.lock();
2025  FlutterPlatformNodeDelegateMac delegate(bridge, viewController);
2026  ui::AXTree tree;
2027  ui::AXNode ax_node(&tree, nullptr, 0, 0);
2028  ui::AXNodeData node_data;
2029  node_data.SetValue("initial text");
2030  ax_node.SetData(node_data);
2031  delegate.Init(viewController.accessibilityBridge, &ax_node);
2032  {
2033  FlutterTextPlatformNode text_platform_node(&delegate, viewController);
2034 
2035  FlutterTextFieldMock* mockTextField =
2036  [[FlutterTextFieldMock alloc] initWithPlatformNode:&text_platform_node
2037  fieldEditor:viewController.textInputPlugin];
2038  [viewController.view addSubview:mockTextField];
2039  [mockTextField startEditing];
2040 
2041  NSDictionary* setClientConfig = @{
2042  @"inputAction" : @"action",
2043  @"inputType" : @{@"name" : @"inputName"},
2044  };
2045  FlutterMethodCall* methodCall =
2046  [FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
2047  arguments:@[ @(1), setClientConfig ]];
2048  FlutterResult result = ^(id result) {
2049  };
2050  [viewController.textInputPlugin handleMethodCall:methodCall result:result];
2051 
2052  NSDictionary* arguments = @{
2053  @"text" : @"new text",
2054  @"selectionBase" : @(1),
2055  @"selectionExtent" : @(2),
2056  @"composingBase" : @(-1),
2057  @"composingExtent" : @(-1),
2058  };
2059  methodCall = [FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
2060  arguments:arguments];
2061  [viewController.textInputPlugin handleMethodCall:methodCall result:result];
2062  EXPECT_EQ([mockTextField.lastUpdatedString isEqualToString:@"new text"], YES);
2063  EXPECT_EQ(NSEqualRanges(mockTextField.lastUpdatedSelection, NSMakeRange(1, 1)), YES);
2064 
2065  // This blocks the FlutterTextFieldMock, which is held onto by the main event
2066  // loop, from crashing.
2067  [mockTextField setPlatformNode:nil];
2068  }
2069 
2070  // This verifies that clearing the platform node works.
2071  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
2072 }

References flutter::FlutterPlatformNodeDelegateMac::Init(), FlutterTextFieldMock::lastUpdatedSelection, FlutterTextFieldMock::lastUpdatedString, FlutterMethodCall::methodCallWithMethodName:arguments:, and FlutterTextField::startEditing.

◆ TEST() [85/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
FirstResponderIsCorrect   
)

Definition at line 2141 of file FlutterTextInputPluginTest.mm.

2141  {
2142  FlutterEngine* engine = CreateTestEngine();
2143  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2144  nibName:nil
2145  bundle:nil];
2146  [viewController loadView];
2147 
2148  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2149  styleMask:NSBorderlessWindowMask
2150  backing:NSBackingStoreBuffered
2151  defer:NO];
2152  window.contentView = viewController.view;
2153 
2154  ASSERT_TRUE(viewController.flutterView.acceptsFirstResponder);
2155 
2156  [window makeFirstResponder:viewController.flutterView];
2157 
2158  [viewController.textInputPlugin
2159  handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.show" arguments:@[]]
2160  result:^(id){
2161  }];
2162 
2163  ASSERT_TRUE(window.firstResponder == viewController.textInputPlugin);
2164 
2165  ASSERT_FALSE(viewController.flutterView.acceptsFirstResponder);
2166 
2167  [viewController.textInputPlugin
2168  handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.hide" arguments:@[]]
2169  result:^(id){
2170  }];
2171 
2172  ASSERT_TRUE(viewController.flutterView.acceptsFirstResponder);
2173  ASSERT_TRUE(window.firstResponder == viewController.flutterView);
2174 }

References FlutterMethodCall::methodCallWithMethodName:arguments:.

◆ TEST() [86/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
HandleArrowKeyWhenImePopoverIsActive   
)

Definition at line 1937 of file FlutterTextInputPluginTest.mm.

1937  {
1938  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] handleArrowKeyWhenImePopoverIsActive]);
1939 }

◆ TEST() [87/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
HasZeroSizeAndClipsToBounds   
)

Definition at line 2176 of file FlutterTextInputPluginTest.mm.

2176  {
2177  id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
2178  id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
2179  OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
2180  [engineMock binaryMessenger])
2181  .andReturn(binaryMessengerMock);
2182 
2183  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
2184  nibName:@""
2185  bundle:nil];
2186 
2187  FlutterTextInputPlugin* plugin =
2188  [[FlutterTextInputPlugin alloc] initWithViewController:viewController];
2189 
2190  ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
2191  ASSERT_TRUE(plugin.clipsToBounds);
2192 }

References CreateMockFlutterEngine().

◆ TEST() [88/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
IsAddedAndRemovedFromViewHierarchy   
)

Definition at line 2108 of file FlutterTextInputPluginTest.mm.

2108  {
2109  FlutterEngine* engine = CreateTestEngine();
2110  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2111  nibName:nil
2112  bundle:nil];
2113  [viewController loadView];
2114 
2115  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2116  styleMask:NSBorderlessWindowMask
2117  backing:NSBackingStoreBuffered
2118  defer:NO];
2119  window.contentView = viewController.view;
2120 
2121  ASSERT_EQ(viewController.textInputPlugin.superview, nil);
2122  ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
2123 
2124  [viewController.textInputPlugin
2125  handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.show" arguments:@[]]
2126  result:^(id){
2127  }];
2128 
2129  ASSERT_EQ(viewController.textInputPlugin.superview, viewController.view);
2130  ASSERT_TRUE(window.firstResponder == viewController.textInputPlugin);
2131 
2132  [viewController.textInputPlugin
2133  handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.hide" arguments:@[]]
2134  result:^(id){
2135  }];
2136 
2137  ASSERT_EQ(viewController.textInputPlugin.superview, nil);
2138  ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
2139 }

References FlutterMethodCall::methodCallWithMethodName:arguments:.

◆ TEST() [89/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAttributedSubstringOutOfRange   
)

Definition at line 1961 of file FlutterTextInputPluginTest.mm.

1961  {
1962  id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
1963  id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
1964  OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
1965  [engineMock binaryMessenger])
1966  .andReturn(binaryMessengerMock);
1967 
1968  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
1969  nibName:@""
1970  bundle:nil];
1971 
1972  FlutterTextInputPlugin* plugin =
1973  [[FlutterTextInputPlugin alloc] initWithViewController:viewController];
1974 
1975  NSDictionary* setClientConfig = @{
1976  @"inputAction" : @"action",
1977  @"enableDeltaModel" : @"true",
1978  @"inputType" : @{@"name" : @"inputName"},
1979  };
1980  [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
1981  arguments:@[ @(1), setClientConfig ]]
1982  result:^(id){
1983  }];
1984 
1985  FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
1986  arguments:@{
1987  @"text" : @"Text",
1988  @"selectionBase" : @(0),
1989  @"selectionExtent" : @(0),
1990  @"composingBase" : @(-1),
1991  @"composingExtent" : @(-1),
1992  }];
1993 
1994  [plugin handleMethodCall:call
1995  result:^(id){
1996  }];
1997 
1998  NSRange out;
1999  NSAttributedString* text = [plugin attributedSubstringForProposedRange:NSMakeRange(1, 10)
2000  actualRange:&out];
2001  EXPECT_TRUE([text.string isEqualToString:@"ext"]);
2002  EXPECT_EQ(out.location, 1u);
2003  EXPECT_EQ(out.length, 3u);
2004 
2005  text = [plugin attributedSubstringForProposedRange:NSMakeRange(4, 10) actualRange:&out];
2006  EXPECT_EQ(text, nil);
2007 }

References CreateMockFlutterEngine(), FlutterTextInputPlugin::handleMethodCall:result:, and FlutterMethodCall::methodCallWithMethodName:arguments:.

◆ TEST() [90/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenAutofillGroupIncludesPassword   
)

Definition at line 1895 of file FlutterTextInputPluginTest.mm.

1895  {
1896  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc]
1897  testAutocompleteDisabledWhenAutofillGroupIncludesPassword]);
1898 }

◆ TEST() [91/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenAutofillNotSet   
)

Definition at line 1875 of file FlutterTextInputPluginTest.mm.

1875  {
1876  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenAutofillNotSet]);
1877 }

◆ TEST() [92/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenObscureTextSet   
)

Definition at line 1887 of file FlutterTextInputPluginTest.mm.

1887  {
1888  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenObscureTextSet]);
1889 }

◆ TEST() [93/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenPasswordAutofillSet   
)

Definition at line 1891 of file FlutterTextInputPluginTest.mm.

1891  {
1892  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenPasswordAutofillSet]);
1893 }

◆ TEST() [94/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteEnabledWhenAutofillSet   
)

Definition at line 1879 of file FlutterTextInputPluginTest.mm.

1879  {
1880  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteEnabledWhenAutofillSet]);
1881 }

◆ TEST() [95/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteEnabledWhenAutofillSetNoHint   
)

Definition at line 1883 of file FlutterTextInputPluginTest.mm.

1883  {
1884  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteEnabledWhenAutofillSetNoHint]);
1885 }

◆ TEST() [96/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestClearClientDuringComposing   
)

Definition at line 1871 of file FlutterTextInputPluginTest.mm.

1871  {
1872  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testClearClientDuringComposing]);
1873 }

◆ TEST() [97/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingRegionRemovedByFramework   
)

Definition at line 1867 of file FlutterTextInputPluginTest.mm.

1867  {
1868  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingRegionRemovedByFramework]);
1869 }

◆ TEST() [98/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingWithDelta   
)

Definition at line 1921 of file FlutterTextInputPluginTest.mm.

1921  {
1922  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingWithDelta]);
1923 }

◆ TEST() [99/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingWithDeltasWhenSelectionIsActive   
)

Definition at line 1925 of file FlutterTextInputPluginTest.mm.

1925  {
1926  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingWithDeltasWhenSelectionIsActive]);
1927 }

◆ TEST() [100/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestEmptyCompositionRange   
)

Definition at line 1855 of file FlutterTextInputPluginTest.mm.

1855  {
1856  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testEmptyCompositionRange]);
1857 }

◆ TEST() [101/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRange   
)

Definition at line 1900 of file FlutterTextInputPluginTest.mm.

1900  {
1901  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testFirstRectForCharacterRange]);
1902 }

◆ TEST() [102/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRangeAtInfinity   
)

Definition at line 1904 of file FlutterTextInputPluginTest.mm.

1904  {
1905  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testFirstRectForCharacterRangeAtInfinity]);
1906 }

◆ TEST() [103/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRangeWithEsotericAffineTransform   
)

Definition at line 1908 of file FlutterTextInputPluginTest.mm.

1908  {
1909  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc]
1910  testFirstRectForCharacterRangeWithEsotericAffineTransform]);
1911 }

◆ TEST() [104/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestInsertNewLine   
)

Definition at line 1953 of file FlutterTextInputPluginTest.mm.

1953  {
1954  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testInsertNewLine]);
1955 }

◆ TEST() [105/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestLocalTextAndSelectionUpdateAfterDelta   
)

Definition at line 1929 of file FlutterTextInputPluginTest.mm.

1929  {
1930  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testLocalTextAndSelectionUpdateAfterDelta]);
1931 }

◆ TEST() [106/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestOperationsThatTriggerDelta   
)

Definition at line 1917 of file FlutterTextInputPluginTest.mm.

1917  {
1918  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testOperationsThatTriggerDelta]);
1919 }

◆ TEST() [107/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestPerformKeyEquivalent   
)

Definition at line 1933 of file FlutterTextInputPluginTest.mm.

1933  {
1934  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testPerformKeyEquivalent]);
1935 }

◆ TEST() [108/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSelectorsAreForwardedToFramework   
)

Definition at line 1945 of file FlutterTextInputPluginTest.mm.

1945  {
1946  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSelectorsAreForwardedToFramework]);
1947 }

◆ TEST() [109/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSelectorsNotForwardedToFrameworkIfNoClient   
)

Definition at line 1949 of file FlutterTextInputPluginTest.mm.

1949  {
1950  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSelectorsNotForwardedToFrameworkIfNoClient]);
1951 }

◆ TEST() [110/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSendActionDoNotInsertNewLine   
)

Definition at line 1957 of file FlutterTextInputPluginTest.mm.

1957  {
1958  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSendActionDoNotInsertNewLine]);
1959 }

◆ TEST() [111/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetEditingStateWithTextEditingDelta   
)

Definition at line 1913 of file FlutterTextInputPluginTest.mm.

1913  {
1914  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetEditingStateWithTextEditingDelta]);
1915 }

◆ TEST() [112/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetMarkedTextWithReplacementRange   
)

Definition at line 1863 of file FlutterTextInputPluginTest.mm.

1863  {
1864  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetMarkedTextWithReplacementRange]);
1865 }

◆ TEST() [113/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetMarkedTextWithSelectionChange   
)

Definition at line 1859 of file FlutterTextInputPluginTest.mm.

1859  {
1860  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetMarkedTextWithSelectionChange]);
1861 }

◆ TEST() [114/117]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
UnhandledKeyEquivalent   
)

Definition at line 1941 of file FlutterTextInputPluginTest.mm.

1941  {
1942  ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] unhandledKeyEquivalent]);
1943 }

◆ TEST() [115/117]

flutter::testing::TEST ( FlutterTextInputSemanticsObjectTest  ,
DoesInitialize   
)

Definition at line 27 of file FlutterTextInputSemanticsObjectTest.mm.

27  {
28  FlutterEngine* engine = CreateTestEngine();
29  {
30  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
31  nibName:nil
32  bundle:nil];
33  [viewController loadView];
34  // Create a NSWindow so that the native text field can become first responder.
35  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
36  styleMask:NSBorderlessWindowMask
37  backing:NSBackingStoreBuffered
38  defer:NO];
39  window.contentView = viewController.view;
40 
41  engine.semanticsEnabled = YES;
42 
43  auto bridge = viewController.accessibilityBridge.lock();
44  FlutterPlatformNodeDelegateMac delegate(bridge, viewController);
45  ui::AXTree tree;
46  ui::AXNode ax_node(&tree, nullptr, 0, 0);
47  ui::AXNodeData node_data;
48  node_data.SetValue("initial text");
49  ax_node.SetData(node_data);
50  delegate.Init(viewController.accessibilityBridge, &ax_node);
51  // Verify that a FlutterTextField is attached to the view.
52  FlutterTextPlatformNode text_platform_node(&delegate, viewController);
53  id native_accessibility = text_platform_node.GetNativeViewAccessible();
54  EXPECT_TRUE([native_accessibility isKindOfClass:[FlutterTextField class]]);
55  auto subviews = [viewController.view subviews];
56  EXPECT_EQ([subviews count], 2u);
57  EXPECT_TRUE([subviews[0] isKindOfClass:[FlutterTextField class]]);
58  FlutterTextField* nativeTextField = subviews[0];
59  EXPECT_EQ(text_platform_node.GetNativeViewAccessible(), nativeTextField);
60  }
61 
62  [engine shutDownEngine];
63  engine = nil;
64  // Pump the event loop to make sure no stray nodes cause crashes after the
65  // engine has been destroyed.
66  // From issue: https://github.com/flutter/flutter/issues/115599
67  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
68 }

References flutter::FlutterTextPlatformNode::GetNativeViewAccessible(), and flutter::FlutterPlatformNodeDelegateMac::Init().

◆ TEST() [116/117]

flutter::testing::TEST ( FlutterViewEngineProviderUnittests  ,
GetViewReturnsTheCorrectView   
)

Definition at line 19 of file FlutterViewEngineProviderTest.mm.

19  {
20  FlutterViewEngineProvider* viewProvider;
21  id mockEngine = CreateMockFlutterEngine(@"");
22  __block id mockFlutterViewController;
23  OCMStub([mockEngine viewControllerForIdentifier:0])
24  .ignoringNonObjectArgs()
25  .andDo(^(NSInvocation* invocation) {
26  FlutterViewIdentifier viewIdentifier;
27  [invocation getArgument:&viewIdentifier atIndex:2];
28  if (viewIdentifier == kFlutterImplicitViewId) {
29  if (mockFlutterViewController != nil) {
30  [invocation setReturnValue:&mockFlutterViewController];
31  }
32  }
33  });
34  viewProvider = [[FlutterViewEngineProvider alloc] initWithEngine:mockEngine];
35 
36  // When the view controller is not set, the returned view is nil.
37  EXPECT_EQ([viewProvider viewForIdentifier:0], nil);
38 
39  // When the view controller is set, the returned view is the controller's view.
40  mockFlutterViewController = OCMStrictClassMock([FlutterViewController class]);
41  id mockView = OCMStrictClassMock([FlutterView class]);
42  OCMStub([mockFlutterViewController flutterView]).andReturn(mockView);
43  EXPECT_EQ([viewProvider viewForIdentifier:0], mockView);
44 }

References CreateMockFlutterEngine().

◆ TEST() [117/117]

flutter::testing::TEST ( KeyMappingTest  ,
HasExpectedValues   
)

Definition at line 20 of file KeyCodeMapTest.mm.

20  {
21  // Has Space
22  EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x31, 0x20, false}),
23  kLayoutGoals.end());
24  // Has Digit0
25  EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x1d, 0x30, true}),
26  kLayoutGoals.end());
27  // Has KeyA
28  EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x00, 0x61, true}),
29  kLayoutGoals.end());
30  // Has Equal
31  EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x18, 0x3d, false}),
32  kLayoutGoals.end());
33  // Has IntlBackslash
34  EXPECT_NE(
35  std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x0a, 0x200000020, false}),
36  kLayoutGoals.end());
37 }

References flutter::kLayoutGoals.

◆ TEST_F() [1/76]

flutter::testing::TEST_F ( AccessibilityBridgeMacTest  ,
DoesNotSendAccessibilityCreateNotificationWhenHeadless   
)

Definition at line 213 of file AccessibilityBridgeMacTest.mm.

213  {
214  FlutterViewController* viewController = CreateTestViewController();
215  FlutterEngine* engine = viewController.engine;
216 
217  // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
218  // can query semantics information from.
219  engine.semanticsEnabled = YES;
220  auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
221  viewController.accessibilityBridge.lock());
222  FlutterSemanticsNode2 root;
223  root.id = 0;
224  root.flags = static_cast<FlutterSemanticsFlag>(0);
225  root.actions = static_cast<FlutterSemanticsAction>(0);
226  root.text_selection_base = -1;
227  root.text_selection_extent = -1;
228  root.label = "root";
229  root.hint = "";
230  root.value = "";
231  root.increased_value = "";
232  root.decreased_value = "";
233  root.tooltip = "";
234  root.child_count = 0;
235  root.custom_accessibility_actions_count = 0;
236  bridge->AddFlutterSemanticsNodeUpdate(root);
237 
238  bridge->CommitUpdates();
239  auto platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
240 
241  // Creates a targeted event.
242  ui::AXTree tree;
243  ui::AXNode ax_node(&tree, nullptr, 0, 0);
244  ui::AXNodeData node_data;
245  node_data.id = 0;
246  ax_node.SetData(node_data);
247  std::vector<ui::AXEventIntent> intent;
248  ui::AXEventGenerator::EventParams event_params(ui::AXEventGenerator::Event::CHILDREN_CHANGED,
249  ax::mojom::EventFrom::kNone, intent);
250  ui::AXEventGenerator::TargetedEvent targeted_event(&ax_node, event_params);
251 
252  bridge->OnAccessibilityEvent(targeted_event);
253 
254  // Does not send any notification if the engine is headless.
255  EXPECT_EQ(bridge->actual_notifications.size(), 0u);
256  [engine shutDownEngine];
257 }

References FlutterViewController::engine, and FlutterEngine::shutDownEngine.

◆ TEST_F() [2/76]

flutter::testing::TEST_F ( AccessibilityBridgeMacTest  ,
DoesNotSendAccessibilityCreateNotificationWhenNoWindow   
)

Definition at line 259 of file AccessibilityBridgeMacTest.mm.

259  {
260  FlutterViewController* viewController = CreateTestViewController();
261  FlutterEngine* engine = viewController.engine;
262 
263  // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
264  // can query semantics information from.
265  engine.semanticsEnabled = YES;
266  auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
267  viewController.accessibilityBridge.lock());
268  FlutterSemanticsNode2 root;
269  root.id = 0;
270  root.flags = static_cast<FlutterSemanticsFlag>(0);
271  root.actions = static_cast<FlutterSemanticsAction>(0);
272  root.text_selection_base = -1;
273  root.text_selection_extent = -1;
274  root.label = "root";
275  root.hint = "";
276  root.value = "";
277  root.increased_value = "";
278  root.decreased_value = "";
279  root.tooltip = "";
280  root.child_count = 0;
281  root.custom_accessibility_actions_count = 0;
282  bridge->AddFlutterSemanticsNodeUpdate(root);
283 
284  bridge->CommitUpdates();
285  auto platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
286 
287  // Creates a targeted event.
288  ui::AXTree tree;
289  ui::AXNode ax_node(&tree, nullptr, 0, 0);
290  ui::AXNodeData node_data;
291  node_data.id = 0;
292  ax_node.SetData(node_data);
293  std::vector<ui::AXEventIntent> intent;
294  ui::AXEventGenerator::EventParams event_params(ui::AXEventGenerator::Event::CHILDREN_CHANGED,
295  ax::mojom::EventFrom::kNone, intent);
296  ui::AXEventGenerator::TargetedEvent targeted_event(&ax_node, event_params);
297 
298  bridge->OnAccessibilityEvent(targeted_event);
299 
300  // Does not send any notification if the flutter view is not attached to a NSWindow.
301  EXPECT_EQ(bridge->actual_notifications.size(), 0u);
302  [engine shutDownEngine];
303 }

References FlutterViewController::engine, and FlutterEngine::shutDownEngine.

◆ TEST_F() [3/76]

flutter::testing::TEST_F ( AccessibilityBridgeMacWindowTest  ,
NonZeroRootNodeId   
)

Definition at line 147 of file AccessibilityBridgeMacTest.mm.

147  {
148  FlutterViewController* viewController = CreateTestViewController();
149  FlutterEngine* engine = viewController.engine;
150  NSWindow* expectedTarget = GetWindow();
151  expectedTarget.contentView = viewController.view;
152 
153  // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
154  // can query semantics information from.
155  engine.semanticsEnabled = YES;
156  auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
157  viewController.accessibilityBridge.lock());
158 
159  FlutterSemanticsNode2 node1;
160  std::vector<int32_t> node1_children{2};
161  node1.id = 1;
162  node1.flags = static_cast<FlutterSemanticsFlag>(0);
163  node1.actions = static_cast<FlutterSemanticsAction>(0);
164  node1.text_selection_base = -1;
165  node1.text_selection_extent = -1;
166  node1.label = "node1";
167  node1.hint = "";
168  node1.value = "";
169  node1.increased_value = "";
170  node1.decreased_value = "";
171  node1.tooltip = "";
172  node1.child_count = node1_children.size();
173  node1.children_in_traversal_order = node1_children.data();
174  node1.children_in_hit_test_order = node1_children.data();
175  node1.custom_accessibility_actions_count = 0;
176 
177  FlutterSemanticsNode2 node2;
178  node2.id = 2;
179  node2.flags = static_cast<FlutterSemanticsFlag>(0);
180  node2.actions = static_cast<FlutterSemanticsAction>(0);
181  node2.text_selection_base = -1;
182  node2.text_selection_extent = -1;
183  node2.label = "node2";
184  node2.hint = "";
185  node2.value = "";
186  node2.increased_value = "";
187  node2.decreased_value = "";
188  node2.tooltip = "";
189  node2.child_count = 0;
190  node2.custom_accessibility_actions_count = 0;
191 
192  bridge->AddFlutterSemanticsNodeUpdate(node1);
193  bridge->AddFlutterSemanticsNodeUpdate(node2);
194  bridge->CommitUpdates();
195 
196  // Look up the root node delegate.
197  auto root_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
198  ASSERT_TRUE(root_delegate);
199  ASSERT_EQ(root_delegate->GetChildCount(), 1);
200 
201  // Look up the child node delegate.
202  auto child_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
203  ASSERT_TRUE(child_delegate);
204  ASSERT_EQ(child_delegate->GetChildCount(), 0);
205 
206  // Ensure a node with ID 0 does not exist.
207  auto invalid_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
208  ASSERT_FALSE(invalid_delegate);
209 
210  [engine shutDownEngine];
211 }

References FlutterViewController::engine, and FlutterEngine::shutDownEngine.

◆ TEST_F() [4/76]

flutter::testing::TEST_F ( AccessibilityBridgeMacWindowTest  ,
SendsAccessibilityCreateNotificationFlutterViewWindow   
)

Definition at line 90 of file AccessibilityBridgeMacTest.mm.

90  {
91  FlutterViewController* viewController = CreateTestViewController();
92  FlutterEngine* engine = viewController.engine;
93  NSWindow* expectedTarget = GetWindow();
94  expectedTarget.contentView = viewController.view;
95 
96  // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
97  // can query semantics information from.
98  engine.semanticsEnabled = YES;
99  auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
100  viewController.accessibilityBridge.lock());
101  FlutterSemanticsNode2 root;
102  root.id = 0;
103  root.flags = static_cast<FlutterSemanticsFlag>(0);
104  root.actions = static_cast<FlutterSemanticsAction>(0);
105  root.text_selection_base = -1;
106  root.text_selection_extent = -1;
107  root.label = "root";
108  root.hint = "";
109  root.value = "";
110  root.increased_value = "";
111  root.decreased_value = "";
112  root.tooltip = "";
113  root.child_count = 0;
114  root.custom_accessibility_actions_count = 0;
115  bridge->AddFlutterSemanticsNodeUpdate(root);
116 
117  bridge->CommitUpdates();
118  auto platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
119 
120  // Creates a targeted event.
121  ui::AXTree tree;
122  ui::AXNode ax_node(&tree, nullptr, 0, 0);
123  ui::AXNodeData node_data;
124  node_data.id = 0;
125  ax_node.SetData(node_data);
126  std::vector<ui::AXEventIntent> intent;
127  ui::AXEventGenerator::EventParams event_params(ui::AXEventGenerator::Event::CHILDREN_CHANGED,
128  ax::mojom::EventFrom::kNone, intent);
129  ui::AXEventGenerator::TargetedEvent targeted_event(&ax_node, event_params);
130 
131  bridge->OnAccessibilityEvent(targeted_event);
132 
133  ASSERT_EQ(bridge->actual_notifications.size(), 1u);
134  auto target = bridge->actual_notifications.find([NSAccessibilityCreatedNotification UTF8String]);
135  ASSERT_NE(target, bridge->actual_notifications.end());
136  EXPECT_EQ(target->second, expectedTarget);
137  [engine shutDownEngine];
138 }

References FlutterViewController::engine, and FlutterEngine::shutDownEngine.

◆ TEST_F() [5/76]

flutter::testing::TEST_F ( FlutterChannelKeyResponderTest  ,
BasicKeyEvent   
)

Definition at line 75 of file FlutterChannelKeyResponderTest.mm.

75  {
76  __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
77  FakeMessageChannel* channel = [[FakeMessageChannel alloc] init];
78  FlutterChannelKeyResponder* responder =
79  [[FlutterChannelKeyResponder alloc] initWithChannel:channel];
80 
81  // Initial empty modifiers.
82  //
83  // This can happen when user opens window while modifier key is pressed and then releases the
84  // modifier. No events should be sent, but the callback should still be called.
85  // Regression test for https://github.com/flutter/flutter/issues/87339.
86  channel.nextResponse = @{@"handled" : @YES};
87  [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", NO, 60)
88  callback:^(BOOL handled) {
89  [responses addObject:@(handled)];
90  }];
91 
92  EXPECT_EQ([channel.messages count], 0u);
93  ASSERT_EQ([responses count], 1u);
94  EXPECT_EQ([responses[0] boolValue], YES);
95  [responses removeAllObjects];
96 
97  // Key down
98  channel.nextResponse = @{@"handled" : @YES};
99  [responder handleEvent:CreateKeyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", NO, 0)
100  callback:^(BOOL handled) {
101  [responses addObject:@(handled)];
102  }];
103 
104  ASSERT_EQ([channel.messages count], 1u);
105  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
106  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
107  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
108  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x0);
109  EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "a");
110  EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");
111 
112  ASSERT_EQ([responses count], 1u);
113  EXPECT_EQ([[responses lastObject] boolValue], YES);
114 
115  [channel.messages removeAllObjects];
116  [responses removeAllObjects];
117 
118  // Key up
119  channel.nextResponse = @{@"handled" : @NO};
120  [responder handleEvent:CreateKeyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", NO, 0)
121  callback:^(BOOL handled) {
122  [responses addObject:@(handled)];
123  }];
124 
125  ASSERT_EQ([channel.messages count], 1u);
126  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
127  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keyup");
128  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
129  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0);
130  EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "a");
131  EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");
132 
133  ASSERT_EQ([responses count], 1u);
134  EXPECT_EQ([[responses lastObject] boolValue], NO);
135 
136  [channel.messages removeAllObjects];
137  [responses removeAllObjects];
138 
139  // LShift down
140  channel.nextResponse = @{@"handled" : @YES};
141  [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", NO, 56)
142  callback:^(BOOL handled) {
143  [responses addObject:@(handled)];
144  }];
145 
146  ASSERT_EQ([channel.messages count], 1u);
147  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
148  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
149  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 56);
150  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x20002);
151 
152  ASSERT_EQ([responses count], 1u);
153  EXPECT_EQ([[responses lastObject] boolValue], YES);
154 
155  [channel.messages removeAllObjects];
156  [responses removeAllObjects];
157 
158  // RShift down
159  channel.nextResponse = @{@"handled" : @NO};
160  [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x20006, @"", @"", NO, 60)
161  callback:^(BOOL handled) {
162  [responses addObject:@(handled)];
163  }];
164 
165  ASSERT_EQ([channel.messages count], 1u);
166  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
167  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
168  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 60);
169  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x20006);
170 
171  ASSERT_EQ([responses count], 1u);
172  EXPECT_EQ([[responses lastObject] boolValue], NO);
173 
174  [channel.messages removeAllObjects];
175  [responses removeAllObjects];
176 
177  // LShift up
178  channel.nextResponse = @{@"handled" : @NO};
179  [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x20104, @"", @"", NO, 56)
180  callback:^(BOOL handled) {
181  [responses addObject:@(handled)];
182  }];
183 
184  ASSERT_EQ([channel.messages count], 1u);
185  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
186  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keyup");
187  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 56);
188  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x20004);
189 
190  ASSERT_EQ([responses count], 1u);
191  EXPECT_EQ([[responses lastObject] boolValue], NO);
192 
193  [channel.messages removeAllObjects];
194  [responses removeAllObjects];
195 
196  // RShift up
197  channel.nextResponse = @{@"handled" : @NO};
198  [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0, @"", @"", NO, 60)
199  callback:^(BOOL handled) {
200  [responses addObject:@(handled)];
201  }];
202 
203  ASSERT_EQ([channel.messages count], 1u);
204  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
205  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keyup");
206  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 60);
207  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0);
208 
209  ASSERT_EQ([responses count], 1u);
210  EXPECT_EQ([[responses lastObject] boolValue], NO);
211 
212  [channel.messages removeAllObjects];
213  [responses removeAllObjects];
214 
215  // RShift up again, should be ignored and not produce a keydown event, but the
216  // callback should be called.
217  channel.nextResponse = @{@"handled" : @NO};
218  [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", NO, 60)
219  callback:^(BOOL handled) {
220  [responses addObject:@(handled)];
221  }];
222 
223  EXPECT_EQ([channel.messages count], 0u);
224  ASSERT_EQ([responses count], 1u);
225  EXPECT_EQ([responses[0] boolValue], YES);
226 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, FakeMessageChannel::messages, and FakeMessageChannel::nextResponse.

◆ TEST_F() [6/76]

flutter::testing::TEST_F ( FlutterChannelKeyResponderTest  ,
EmptyResponseIsTakenAsHandled   
)

Definition at line 228 of file FlutterChannelKeyResponderTest.mm.

228  {
229  __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
230  FakeMessageChannel* channel = [[FakeMessageChannel alloc] init];
231  FlutterChannelKeyResponder* responder =
232  [[FlutterChannelKeyResponder alloc] initWithChannel:channel];
233 
234  channel.nextResponse = nil;
235  [responder handleEvent:CreateKeyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", NO, 0)
236  callback:^(BOOL handled) {
237  [responses addObject:@(handled)];
238  }];
239 
240  ASSERT_EQ([channel.messages count], 1u);
241  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
242  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
243  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
244  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0);
245  EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "a");
246  EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");
247 
248  ASSERT_EQ([responses count], 1u);
249  EXPECT_EQ([[responses lastObject] boolValue], YES);
250 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, FakeMessageChannel::messages, and FakeMessageChannel::nextResponse.

◆ TEST_F() [7/76]

flutter::testing::TEST_F ( FlutterChannelKeyResponderTest  ,
FollowsLayoutMap   
)

Definition at line 252 of file FlutterChannelKeyResponderTest.mm.

252  {
253  __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
254  FakeMessageChannel* channel = [[FakeMessageChannel alloc] init];
255  FlutterChannelKeyResponder* responder =
256  [[FlutterChannelKeyResponder alloc] initWithChannel:channel];
257 
258  NSMutableDictionary<NSNumber*, NSNumber*>* layoutMap =
259  [NSMutableDictionary<NSNumber*, NSNumber*> dictionary];
260  responder.layoutMap = layoutMap;
261  // French layout
262  layoutMap[@(kVK_ANSI_A)] = @(kLogicalKeyQ);
263 
264  channel.nextResponse = @{@"handled" : @YES};
265  [responder handleEvent:CreateKeyEvent(NSEventTypeKeyDown, kVK_ANSI_A, @"q", @"q", NO, 0)
266  callback:^(BOOL handled) {
267  [responses addObject:@(handled)];
268  }];
269 
270  ASSERT_EQ([channel.messages count], 1u);
271  EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
272  EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
273  EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
274  EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x0);
275  EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "q");
276  EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "q");
277  EXPECT_EQ([channel.messages lastObject][@"specifiedLogicalKey"], @(kLogicalKeyQ));
278 
279  ASSERT_EQ([responses count], 1u);
280  EXPECT_EQ([[responses lastObject] boolValue], YES);
281 
282  [channel.messages removeAllObjects];
283  [responses removeAllObjects];
284 }

References <FlutterKeyPrimaryResponder>::handleEvent:callback:, <FlutterKeyPrimaryResponder>::layoutMap, FakeMessageChannel::messages, and FakeMessageChannel::nextResponse.

◆ TEST_F() [8/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTexture   
)

Definition at line 153 of file FlutterEmbedderExternalTextureTest.mm.

153  {
154  // Constants.
155  const size_t width = 100;
156  const size_t height = 100;
157  const int64_t texture_id = 1;
158 
159  // Set up the surface.
160  FlutterDarwinContextMetalSkia* darwinContextMetal =
161  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
162  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
163  GrDirectContext* grContext = darwinContextMetal.mainContext.get();
164  sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
165 
166  // Create a texture.
167  TestExternalTexture* testExternalTexture =
168  [[TestExternalTexture alloc] initWidth:width
169  height:height
170  pixelFormatType:kCVPixelFormatType_32BGRA];
171  FlutterExternalTexture* textureHolder =
172  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
173  darwinMetalContext:darwinContextMetal];
174 
175  // Callback to resolve the texture.
176  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
177  size_t h) {
178  EXPECT_TRUE(w == width);
179  EXPECT_TRUE(h == height);
180 
181  auto texture = std::make_unique<FlutterMetalExternalTexture>();
182  [textureHolder populateTexture:texture.get()];
183 
184  EXPECT_TRUE(texture->num_textures == 1);
185  EXPECT_TRUE(texture->textures != nullptr);
186  EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kRGBA);
187  return texture;
188  };
189 
190  // Render the texture.
191  std::unique_ptr<flutter::Texture> texture =
192  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
193  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
194  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
195  DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
196  flutter::Texture::PaintContext context{
197  .canvas = &canvas,
198  .gr_context = grContext,
199  };
200  texture->Paint(context, bounds, /*freeze=*/false, sampling);
201 
202  gpuSurface->makeImageSnapshot();
203 }

References FlutterExternalTexture::populateTexture:, and texture_id.

◆ TEST_F() [9/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureImpeller   
)

Definition at line 412 of file FlutterEmbedderExternalTextureTest.mm.

412  {
413  // Constants.
414  const size_t width = 100;
415  const size_t height = 100;
416  const int64_t texture_id = 1;
417 
418  // Set up the surface.
419  FlutterDarwinContextMetalSkia* darwinContextMetal =
420  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
421  impeller::AiksContext aiks_context(CreateImpellerContext(), nullptr);
422  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
423 
424  // Create a texture.
425  TestExternalTexture* testExternalTexture =
426  [[TestExternalTexture alloc] initWidth:width
427  height:height
428  pixelFormatType:kCVPixelFormatType_32BGRA];
429  FlutterExternalTexture* textureHolder =
430  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
431  darwinMetalContext:darwinContextMetal];
432 
433  // Callback to resolve the texture.
434  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
435  size_t h) {
436  EXPECT_TRUE(w == width);
437  EXPECT_TRUE(h == height);
438 
439  auto texture = std::make_unique<FlutterMetalExternalTexture>();
440  [textureHolder populateTexture:texture.get()];
441 
442  EXPECT_TRUE(texture->num_textures == 1);
443  EXPECT_TRUE(texture->textures != nullptr);
444  EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kRGBA);
445  return texture;
446  };
447 
448  // Render the texture.
449  std::unique_ptr<flutter::Texture> texture =
450  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
451  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
452  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
453 
454  DisplayListBuilder builder;
455  flutter::Texture::PaintContext context{
456  .canvas = &builder,
457  .gr_context = nullptr,
458  .aiks_context = &aiks_context,
459  };
460  texture->Paint(context, bounds, /*freeze=*/false, sampling);
461 }

References CreateImpellerContext(), FlutterExternalTexture::populateTexture:, and texture_id.

◆ TEST_F() [10/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureYUVA   
)

Definition at line 205 of file FlutterEmbedderExternalTextureTest.mm.

205  {
206  // Constants.
207  const size_t width = 100;
208  const size_t height = 100;
209  const int64_t texture_id = 1;
210 
211  // Set up the surface.
212  FlutterDarwinContextMetalSkia* darwinContextMetal =
213  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
214  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
215  GrDirectContext* grContext = darwinContextMetal.mainContext.get();
216  sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
217 
218  // Create a texture.
219  TestExternalTexture* testExternalTexture =
220  [[TestExternalTexture alloc] initWidth:width
221  height:height
222  pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange];
223  FlutterExternalTexture* textureHolder =
224  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
225  darwinMetalContext:darwinContextMetal];
226 
227  // Callback to resolve the texture.
228  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
229  size_t h) {
230  EXPECT_TRUE(w == width);
231  EXPECT_TRUE(h == height);
232 
233  auto texture = std::make_unique<FlutterMetalExternalTexture>();
234  [textureHolder populateTexture:texture.get()];
235 
236  EXPECT_TRUE(texture->num_textures == 2);
237  EXPECT_TRUE(texture->textures != nullptr);
238  EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kYUVA);
239  EXPECT_TRUE(texture->yuv_color_space ==
240  FlutterMetalExternalTextureYUVColorSpace::kBT601LimitedRange);
241  return texture;
242  };
243 
244  // Render the texture.
245  std::unique_ptr<flutter::Texture> texture =
246  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
247  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
248  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
249  DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
250  flutter::Texture::PaintContext context{
251  .canvas = &canvas,
252  .gr_context = grContext,
253  };
254  texture->Paint(context, bounds, /*freeze=*/false, sampling);
255 
256  gpuSurface->makeImageSnapshot();
257 }

References FlutterExternalTexture::populateTexture:, and texture_id.

◆ TEST_F() [11/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureYUVA2   
)

Definition at line 259 of file FlutterEmbedderExternalTextureTest.mm.

259  {
260  // Constants.
261  const size_t width = 100;
262  const size_t height = 100;
263  const int64_t texture_id = 1;
264 
265  // Set up the surface.
266  FlutterDarwinContextMetalSkia* darwinContextMetal =
267  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
268  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
269  GrDirectContext* grContext = darwinContextMetal.mainContext.get();
270  sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
271 
272  // Create a texture.
273  TestExternalTexture* testExternalTexture =
274  [[TestExternalTexture alloc] initWidth:width
275  height:height
276  pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
277  FlutterExternalTexture* textureHolder =
278  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
279  darwinMetalContext:darwinContextMetal];
280 
281  // Callback to resolve the texture.
282  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
283  size_t h) {
284  EXPECT_TRUE(w == width);
285  EXPECT_TRUE(h == height);
286 
287  auto texture = std::make_unique<FlutterMetalExternalTexture>();
288  [textureHolder populateTexture:texture.get()];
289 
290  EXPECT_TRUE(texture->num_textures == 2);
291  EXPECT_TRUE(texture->textures != nullptr);
292  EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kYUVA);
293  EXPECT_TRUE(texture->yuv_color_space ==
294  FlutterMetalExternalTextureYUVColorSpace::kBT601FullRange);
295  return texture;
296  };
297 
298  // Render the texture.
299  std::unique_ptr<flutter::Texture> texture =
300  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
301  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
302  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
303  DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
304  flutter::Texture::PaintContext context{
305  .canvas = &canvas,
306  .gr_context = grContext,
307  };
308  texture->Paint(context, bounds, /*freeze=*/false, sampling);
309 
310  gpuSurface->makeImageSnapshot();
311 }

References FlutterExternalTexture::populateTexture:, and texture_id.

◆ TEST_F() [12/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureYUVA2Impeller   
)

Definition at line 513 of file FlutterEmbedderExternalTextureTest.mm.

513  {
514  // Constants.
515  const size_t width = 100;
516  const size_t height = 100;
517  const int64_t texture_id = 1;
518 
519  // Set up the surface.
520  FlutterDarwinContextMetalSkia* darwinContextMetal =
521  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
522  impeller::AiksContext aiks_context(CreateImpellerContext(), nullptr);
523  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
524 
525  // Create a texture.
526  TestExternalTexture* testExternalTexture =
527  [[TestExternalTexture alloc] initWidth:width
528  height:height
529  pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
530  FlutterExternalTexture* textureHolder =
531  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
532  darwinMetalContext:darwinContextMetal];
533 
534  // Callback to resolve the texture.
535  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
536  size_t h) {
537  EXPECT_TRUE(w == width);
538  EXPECT_TRUE(h == height);
539 
540  auto texture = std::make_unique<FlutterMetalExternalTexture>();
541  [textureHolder populateTexture:texture.get()];
542 
543  EXPECT_TRUE(texture->num_textures == 2);
544  EXPECT_TRUE(texture->textures != nullptr);
545  EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kYUVA);
546  EXPECT_TRUE(texture->yuv_color_space ==
547  FlutterMetalExternalTextureYUVColorSpace::kBT601FullRange);
548  return texture;
549  };
550 
551  // Render the texture.
552  std::unique_ptr<flutter::Texture> texture =
553  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
554  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
555  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
556 
557  DisplayListBuilder builder;
558  flutter::Texture::PaintContext context{
559  .canvas = &builder, .gr_context = nullptr, .aiks_context = &aiks_context};
560  texture->Paint(context, bounds, /*freeze=*/false, sampling);
561 }

References CreateImpellerContext(), FlutterExternalTexture::populateTexture:, and texture_id.

◆ TEST_F() [13/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureYUVAImpeller   
)

Definition at line 463 of file FlutterEmbedderExternalTextureTest.mm.

463  {
464  // Constants.
465  const size_t width = 100;
466  const size_t height = 100;
467  const int64_t texture_id = 1;
468 
469  // Set up the surface.
470  FlutterDarwinContextMetalSkia* darwinContextMetal =
471  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
472  impeller::AiksContext aiks_context(CreateImpellerContext(), nullptr);
473  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
474 
475  // Create a texture.
476  TestExternalTexture* testExternalTexture =
477  [[TestExternalTexture alloc] initWidth:width
478  height:height
479  pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange];
480  FlutterExternalTexture* textureHolder =
481  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
482  darwinMetalContext:darwinContextMetal];
483 
484  // Callback to resolve the texture.
485  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
486  size_t h) {
487  EXPECT_TRUE(w == width);
488  EXPECT_TRUE(h == height);
489 
490  auto texture = std::make_unique<FlutterMetalExternalTexture>();
491  [textureHolder populateTexture:texture.get()];
492 
493  EXPECT_TRUE(texture->num_textures == 2);
494  EXPECT_TRUE(texture->textures != nullptr);
495  EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kYUVA);
496  EXPECT_TRUE(texture->yuv_color_space ==
497  FlutterMetalExternalTextureYUVColorSpace::kBT601LimitedRange);
498  return texture;
499  };
500 
501  // Render the texture.
502  std::unique_ptr<flutter::Texture> texture =
503  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
504  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
505  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
506 
507  DisplayListBuilder builder;
508  flutter::Texture::PaintContext context{
509  .canvas = &builder, .gr_context = nullptr, .aiks_context = &aiks_context};
510  texture->Paint(context, bounds, /*freeze=*/false, sampling);
511 }

References CreateImpellerContext(), FlutterExternalTexture::populateTexture:, and texture_id.

◆ TEST_F() [14/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateUnsupportedExternalTexture   
)

Definition at line 313 of file FlutterEmbedderExternalTextureTest.mm.

313  {
314  // Constants.
315  const size_t width = 100;
316  const size_t height = 100;
317  const int64_t texture_id = 1;
318 
319  // Set up the surface.
320  FlutterDarwinContextMetalSkia* darwinContextMetal =
321  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
322  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
323  GrDirectContext* grContext = darwinContextMetal.mainContext.get();
324  sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
325 
326  // Create a texture.
327  TestExternalTexture* testExternalTexture =
328  [[TestExternalTexture alloc] initWidth:width
329  height:height
330  pixelFormatType:kCVPixelFormatType_420YpCbCr8PlanarFullRange];
331  FlutterExternalTexture* textureHolder =
332  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
333  darwinMetalContext:darwinContextMetal];
334 
335  // Callback to resolve the texture.
336  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
337  size_t h) {
338  EXPECT_TRUE(w == width);
339  EXPECT_TRUE(h == height);
340 
341  auto texture = std::make_unique<FlutterMetalExternalTexture>();
342  EXPECT_FALSE([textureHolder populateTexture:texture.get()]);
343  return nullptr;
344  };
345 
346  // Render the texture.
347  std::unique_ptr<flutter::Texture> texture =
348  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
349  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
350  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
351  DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
352  flutter::Texture::PaintContext context{
353  .canvas = &canvas,
354  .gr_context = grContext,
355  };
356  texture->Paint(context, bounds, /*freeze=*/false, sampling);
357 }

References texture_id.

◆ TEST_F() [15/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateUnsupportedExternalTextureImpeller   
)

Definition at line 563 of file FlutterEmbedderExternalTextureTest.mm.

563  {
564  // Constants.
565  const size_t width = 100;
566  const size_t height = 100;
567  const int64_t texture_id = 1;
568 
569  // Set up the surface.
570  FlutterDarwinContextMetalSkia* darwinContextMetal =
571  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
572  impeller::AiksContext aiks_context(CreateImpellerContext(), nullptr);
573  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
574 
575  // Create a texture.
576  TestExternalTexture* testExternalTexture =
577  [[TestExternalTexture alloc] initWidth:width
578  height:height
579  pixelFormatType:kCVPixelFormatType_420YpCbCr8PlanarFullRange];
580  FlutterExternalTexture* textureHolder =
581  [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
582  darwinMetalContext:darwinContextMetal];
583 
584  // Callback to resolve the texture.
585  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
586  size_t h) {
587  EXPECT_TRUE(w == width);
588  EXPECT_TRUE(h == height);
589 
590  auto texture = std::make_unique<FlutterMetalExternalTexture>();
591  EXPECT_FALSE([textureHolder populateTexture:texture.get()]);
592  return nullptr;
593  };
594 
595  // Render the texture.
596  std::unique_ptr<flutter::Texture> texture =
597  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
598  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
599  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
600 
601  DisplayListBuilder builder;
602  flutter::Texture::PaintContext context{
603  .canvas = &builder, .gr_context = nullptr, .aiks_context = &aiks_context};
604  texture->Paint(context, bounds, /*freeze=*/false, sampling);
605 }

References CreateImpellerContext(), and texture_id.

◆ TEST_F() [16/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestTextureResolution   
)

Definition at line 95 of file FlutterEmbedderExternalTextureTest.mm.

95  {
96  // Constants.
97  const size_t width = 100;
98  const size_t height = 100;
99  const int64_t texture_id = 1;
100 
101  // Set up the surface.
102  FlutterDarwinContextMetalSkia* darwinContextMetal =
103  [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
104  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
105  GrDirectContext* grContext = darwinContextMetal.mainContext.get();
106  sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
107 
108  // Create a texture.
109  MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init];
110  textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
111  textureDescriptor.width = width;
112  textureDescriptor.height = height;
113  textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
114  id<MTLTexture> mtlTexture =
115  [darwinContextMetal.device newTextureWithDescriptor:textureDescriptor];
116  std::vector<FlutterMetalTextureHandle> textures = {
117  (__bridge FlutterMetalTextureHandle)mtlTexture,
118  };
119 
120  // Callback to resolve the texture.
121  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
122  size_t h) {
123  EXPECT_TRUE(w == width);
124  EXPECT_TRUE(h == height);
125 
126  auto texture = std::make_unique<FlutterMetalExternalTexture>();
127  texture->struct_size = sizeof(FlutterMetalExternalTexture);
128  texture->num_textures = 1;
129  texture->height = h;
130  texture->width = w;
131  texture->pixel_format = FlutterMetalExternalTexturePixelFormat::kRGBA;
132  texture->textures = textures.data();
133  return texture;
134  };
135 
136  // Render the texture.
137  std::unique_ptr<flutter::Texture> texture =
138  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
139  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
140  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
141  DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
142  flutter::Texture::PaintContext context{
143  .canvas = &canvas,
144  .gr_context = grContext,
145  };
146  texture->Paint(context, bounds, /*freeze=*/false, sampling);
147 
148  ASSERT_TRUE(mtlTexture != nil);
149 
150  gpuSurface->makeImageSnapshot();
151 }

References texture_id.

◆ TEST_F() [17/76]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestTextureResolutionImpeller   
)

Definition at line 359 of file FlutterEmbedderExternalTextureTest.mm.

359  {
360  // Constants.
361  const size_t width = 100;
362  const size_t height = 100;
363  const int64_t texture_id = 1;
364 
365  // Set up the surface.
366  auto device = ::MTLCreateSystemDefaultDevice();
367  impeller::AiksContext aiks_context(CreateImpellerContext(), nullptr);
368 
369  SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
370 
371  // Create a texture.
372  MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init];
373  textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
374  textureDescriptor.width = width;
375  textureDescriptor.height = height;
376  textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
377  id<MTLTexture> mtlTexture = [device newTextureWithDescriptor:textureDescriptor];
378  std::vector<FlutterMetalTextureHandle> textures = {
379  (__bridge FlutterMetalTextureHandle)mtlTexture,
380  };
381 
382  // Callback to resolve the texture.
383  EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w,
384  size_t h) {
385  EXPECT_TRUE(w == width);
386  EXPECT_TRUE(h == height);
387 
388  auto texture = std::make_unique<FlutterMetalExternalTexture>();
389  texture->struct_size = sizeof(FlutterMetalExternalTexture);
390  texture->num_textures = 1;
391  texture->height = h;
392  texture->width = w;
393  texture->pixel_format = FlutterMetalExternalTexturePixelFormat::kRGBA;
394  texture->textures = textures.data();
395  return texture;
396  };
397 
398  // Render the texture.
399  std::unique_ptr<flutter::Texture> texture =
400  std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
401  SkRect bounds = SkRect::MakeWH(info.width(), info.height());
402  DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
403 
404  DisplayListBuilder builder;
405  flutter::Texture::PaintContext context{
406  .canvas = &builder, .gr_context = nullptr, .aiks_context = &aiks_context};
407  texture->Paint(context, bounds, /*freeze=*/false, sampling);
408 
409  ASSERT_TRUE(mtlTexture != nil);
410 }

References CreateImpellerContext(), and texture_id.

◆ TEST_F() [18/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanLaunch   
)

Definition at line 142 of file FlutterEngineTest.mm.

142  {
143  FlutterEngine* engine = GetFlutterEngine();
144  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
145  ASSERT_TRUE(engine.running);
146 }

◆ TEST_F() [19/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanLogToStdout   
)

Definition at line 205 of file FlutterEngineTest.mm.

205  {
206  // Block until completion of print statement.
207  fml::AutoResetWaitableEvent latch;
208  AddNativeCallback("SignalNativeTest",
209  CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { latch.Signal(); }));
210 
211  // Replace stdout stream buffer with our own.
212  StreamCapture stdout_capture(&std::cout);
213 
214  // Launch the test entrypoint.
215  FlutterEngine* engine = GetFlutterEngine();
216  EXPECT_TRUE([engine runWithEntrypoint:@"canLogToStdout"]);
217  ASSERT_TRUE(engine.running);
218 
219  latch.Wait();
220 
221  stdout_capture.Stop();
222 
223  // Verify hello world was written to stdout.
224  EXPECT_TRUE(stdout_capture.GetOutput().find("Hello logging") != std::string::npos);
225 }

◆ TEST_F() [20/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanToggleAccessibility   
)

Definition at line 286 of file FlutterEngineTest.mm.

286  {
287  FlutterEngine* engine = GetFlutterEngine();
288  // Capture the update callbacks before the embedder API initializes.
289  auto original_init = engine.embedderAPI.Initialize;
290  std::function<void(const FlutterSemanticsUpdate2*, void*)> update_semantics_callback;
291  engine.embedderAPI.Initialize = MOCK_ENGINE_PROC(
292  Initialize, ([&update_semantics_callback, &original_init](
293  size_t version, const FlutterRendererConfig* config,
294  const FlutterProjectArgs* args, void* user_data, auto engine_out) {
295  update_semantics_callback = args->update_semantics_callback2;
296  return original_init(version, config, args, user_data, engine_out);
297  }));
298  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
299  // Set up view controller.
300  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
301  nibName:nil
302  bundle:nil];
303  [viewController loadView];
304  // Enable the semantics.
305  bool enabled_called = false;
306  engine.embedderAPI.UpdateSemanticsEnabled =
307  MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&enabled_called](auto engine, bool enabled) {
308  enabled_called = enabled;
309  return kSuccess;
310  }));
311  engine.semanticsEnabled = YES;
312  EXPECT_TRUE(enabled_called);
313  // Send flutter semantics updates.
314  FlutterSemanticsNode2 root;
315  root.id = 0;
316  root.flags = static_cast<FlutterSemanticsFlag>(0);
317  root.actions = static_cast<FlutterSemanticsAction>(0);
318  root.text_selection_base = -1;
319  root.text_selection_extent = -1;
320  root.label = "root";
321  root.hint = "";
322  root.value = "";
323  root.increased_value = "";
324  root.decreased_value = "";
325  root.tooltip = "";
326  root.child_count = 1;
327  int32_t children[] = {1};
328  root.children_in_traversal_order = children;
329  root.custom_accessibility_actions_count = 0;
330 
331  FlutterSemanticsNode2 child1;
332  child1.id = 1;
333  child1.flags = static_cast<FlutterSemanticsFlag>(0);
334  child1.actions = static_cast<FlutterSemanticsAction>(0);
335  child1.text_selection_base = -1;
336  child1.text_selection_extent = -1;
337  child1.label = "child 1";
338  child1.hint = "";
339  child1.value = "";
340  child1.increased_value = "";
341  child1.decreased_value = "";
342  child1.tooltip = "";
343  child1.child_count = 0;
344  child1.custom_accessibility_actions_count = 0;
345 
346  FlutterSemanticsUpdate2 update;
347  update.node_count = 2;
348  FlutterSemanticsNode2* nodes[] = {&root, &child1};
349  update.nodes = nodes;
350  update.custom_action_count = 0;
351  update_semantics_callback(&update, (__bridge void*)engine);
352 
353  // Verify the accessibility tree is attached to the flutter view.
354  EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 1u);
355  NSAccessibilityElement* native_root = engine.viewController.flutterView.accessibilityChildren[0];
356  std::string root_label = [native_root.accessibilityLabel UTF8String];
357  EXPECT_TRUE(root_label == "root");
358  EXPECT_EQ(native_root.accessibilityRole, NSAccessibilityGroupRole);
359  EXPECT_EQ([native_root.accessibilityChildren count], 1u);
360  NSAccessibilityElement* native_child1 = native_root.accessibilityChildren[0];
361  std::string child1_value = [native_child1.accessibilityValue UTF8String];
362  EXPECT_TRUE(child1_value == "child 1");
363  EXPECT_EQ(native_child1.accessibilityRole, NSAccessibilityStaticTextRole);
364  EXPECT_EQ([native_child1.accessibilityChildren count], 0u);
365  // Disable the semantics.
366  bool semanticsEnabled = true;
367  engine.embedderAPI.UpdateSemanticsEnabled =
368  MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&semanticsEnabled](auto engine, bool enabled) {
369  semanticsEnabled = enabled;
370  return kSuccess;
371  }));
372  engine.semanticsEnabled = NO;
373  EXPECT_FALSE(semanticsEnabled);
374  // Verify the accessibility tree is removed from the view.
375  EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 0u);
376 
377  [engine setViewController:nil];
378 }

References user_data.

◆ TEST_F() [21/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanToggleAccessibilityWhenHeadless   
)

Definition at line 380 of file FlutterEngineTest.mm.

380  {
381  FlutterEngine* engine = GetFlutterEngine();
382  // Capture the update callbacks before the embedder API initializes.
383  auto original_init = engine.embedderAPI.Initialize;
384  std::function<void(const FlutterSemanticsUpdate2*, void*)> update_semantics_callback;
385  engine.embedderAPI.Initialize = MOCK_ENGINE_PROC(
386  Initialize, ([&update_semantics_callback, &original_init](
387  size_t version, const FlutterRendererConfig* config,
388  const FlutterProjectArgs* args, void* user_data, auto engine_out) {
389  update_semantics_callback = args->update_semantics_callback2;
390  return original_init(version, config, args, user_data, engine_out);
391  }));
392  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
393 
394  // Enable the semantics without attaching a view controller.
395  bool enabled_called = false;
396  engine.embedderAPI.UpdateSemanticsEnabled =
397  MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&enabled_called](auto engine, bool enabled) {
398  enabled_called = enabled;
399  return kSuccess;
400  }));
401  engine.semanticsEnabled = YES;
402  EXPECT_TRUE(enabled_called);
403  // Send flutter semantics updates.
404  FlutterSemanticsNode2 root;
405  root.id = 0;
406  root.flags = static_cast<FlutterSemanticsFlag>(0);
407  root.actions = static_cast<FlutterSemanticsAction>(0);
408  root.text_selection_base = -1;
409  root.text_selection_extent = -1;
410  root.label = "root";
411  root.hint = "";
412  root.value = "";
413  root.increased_value = "";
414  root.decreased_value = "";
415  root.tooltip = "";
416  root.child_count = 1;
417  int32_t children[] = {1};
418  root.children_in_traversal_order = children;
419  root.custom_accessibility_actions_count = 0;
420 
421  FlutterSemanticsNode2 child1;
422  child1.id = 1;
423  child1.flags = static_cast<FlutterSemanticsFlag>(0);
424  child1.actions = static_cast<FlutterSemanticsAction>(0);
425  child1.text_selection_base = -1;
426  child1.text_selection_extent = -1;
427  child1.label = "child 1";
428  child1.hint = "";
429  child1.value = "";
430  child1.increased_value = "";
431  child1.decreased_value = "";
432  child1.tooltip = "";
433  child1.child_count = 0;
434  child1.custom_accessibility_actions_count = 0;
435 
436  FlutterSemanticsUpdate2 update;
437  update.node_count = 2;
438  FlutterSemanticsNode2* nodes[] = {&root, &child1};
439  update.nodes = nodes;
440  update.custom_action_count = 0;
441  // This call updates semantics for the implicit view, which does not exist,
442  // and therefore this call is invalid. But the engine should not crash.
443  update_semantics_callback(&update, (__bridge void*)engine);
444 
445  // No crashes.
446  EXPECT_EQ(engine.viewController, nil);
447 
448  // Disable the semantics.
449  bool semanticsEnabled = true;
450  engine.embedderAPI.UpdateSemanticsEnabled =
451  MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&semanticsEnabled](auto engine, bool enabled) {
452  semanticsEnabled = enabled;
453  return kSuccess;
454  }));
455  engine.semanticsEnabled = NO;
456  EXPECT_FALSE(semanticsEnabled);
457  // Still no crashes
458  EXPECT_EQ(engine.viewController, nil);
459 }

References user_data.

◆ TEST_F() [22/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
Compositor   
)

Definition at line 502 of file FlutterEngineTest.mm.

502  {
503  NSString* fixtures = @(flutter::testing::GetFixturesPath());
504  FlutterDartProject* project = [[FlutterDartProject alloc]
505  initWithAssetsPath:fixtures
506  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
507  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:project];
508 
509  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
510  nibName:nil
511  bundle:nil];
512  [viewController loadView];
513  [viewController viewDidLoad];
514  viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
515 
516  EXPECT_TRUE([engine runWithEntrypoint:@"canCompositePlatformViews"]);
517 
518  [engine.platformViewController registerViewFactory:[[TestPlatformViewFactory alloc] init]
519  withId:@"factory_id"];
520  [engine.platformViewController
521  handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"create"
522  arguments:@{
523  @"id" : @(42),
524  @"viewType" : @"factory_id",
525  }]
526  result:^(id result){
527  }];
528 
529  [engine.testThreadSynchronizer blockUntilFrameAvailable];
530 
531  CALayer* rootLayer = viewController.flutterView.layer;
532 
533  // There are two layers with Flutter contents and one view
534  EXPECT_EQ(rootLayer.sublayers.count, 2u);
535  EXPECT_EQ(viewController.flutterView.subviews.count, 1u);
536 
537  // TODO(gw280): add support for screenshot tests in this test harness
538 
539  [engine shutDownEngine];
540 }

References FlutterMethodCall::methodCallWithMethodName:arguments:, and FlutterEngine::shutDownEngine.

◆ TEST_F() [23/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CompositorIgnoresUnknownView   
)

Definition at line 542 of file FlutterEngineTest.mm.

542  {
543  FlutterEngine* engine = GetFlutterEngine();
544  auto original_init = engine.embedderAPI.Initialize;
545  ::FlutterCompositor compositor;
546  engine.embedderAPI.Initialize = MOCK_ENGINE_PROC(
547  Initialize, ([&compositor, &original_init](
548  size_t version, const FlutterRendererConfig* config,
549  const FlutterProjectArgs* args, void* user_data, auto engine_out) {
550  compositor = *args->compositor;
551  return original_init(version, config, args, user_data, engine_out);
552  }));
553 
554  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
555  nibName:nil
556  bundle:nil];
557  [viewController loadView];
558 
559  EXPECT_TRUE([engine runWithEntrypoint:@"empty"]);
560 
561  FlutterBackingStoreConfig config = {
562  .struct_size = sizeof(FlutterBackingStoreConfig),
563  .size = FlutterSize{10, 10},
564  };
565  FlutterBackingStore backing_store = {};
566  EXPECT_NE(compositor.create_backing_store_callback, nullptr);
567  EXPECT_TRUE(
568  compositor.create_backing_store_callback(&config, &backing_store, compositor.user_data));
569 
570  FlutterLayer layer{
571  .type = kFlutterLayerContentTypeBackingStore,
572  .backing_store = &backing_store,
573  };
574  std::vector<FlutterLayer*> layers = {&layer};
575 
576  FlutterPresentViewInfo info = {
577  .struct_size = sizeof(FlutterPresentViewInfo),
578  .view_id = 123,
579  .layers = const_cast<const FlutterLayer**>(layers.data()),
580  .layers_count = 1,
581  .user_data = compositor.user_data,
582  };
583  EXPECT_NE(compositor.present_view_callback, nullptr);
584  EXPECT_FALSE(compositor.present_view_callback(&info));
585  EXPECT_TRUE(compositor.collect_backing_store_callback(&backing_store, compositor.user_data));
586 
587  (void)viewController;
588  [engine shutDownEngine];
589 }

References FlutterEngine::shutDownEngine, and user_data.

◆ TEST_F() [24/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DartEntrypointArguments   
)

Definition at line 591 of file FlutterEngineTest.mm.

591  {
592  NSString* fixtures = @(flutter::testing::GetFixturesPath());
593  FlutterDartProject* project = [[FlutterDartProject alloc]
594  initWithAssetsPath:fixtures
595  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
596 
597  project.dartEntrypointArguments = @[ @"arg1", @"arg2" ];
598  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:project];
599 
600  bool called = false;
601  auto original_init = engine.embedderAPI.Initialize;
602  engine.embedderAPI.Initialize = MOCK_ENGINE_PROC(
603  Initialize, ([&called, &original_init](size_t version, const FlutterRendererConfig* config,
604  const FlutterProjectArgs* args, void* user_data,
605  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
606  called = true;
607  EXPECT_EQ(args->dart_entrypoint_argc, 2);
608  NSString* arg1 = [[NSString alloc] initWithCString:args->dart_entrypoint_argv[0]
609  encoding:NSUTF8StringEncoding];
610  NSString* arg2 = [[NSString alloc] initWithCString:args->dart_entrypoint_argv[1]
611  encoding:NSUTF8StringEncoding];
612 
613  EXPECT_TRUE([arg1 isEqualToString:@"arg1"]);
614  EXPECT_TRUE([arg2 isEqualToString:@"arg2"]);
615 
616  return original_init(version, config, args, user_data, engine_out);
617  }));
618 
619  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
620  EXPECT_TRUE(called);
621 }

References user_data.

◆ TEST_F() [25/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DISABLED_BackgroundIsBlack   
)

Definition at line 227 of file FlutterEngineTest.mm.

227  {
228  FlutterEngine* engine = GetFlutterEngine();
229 
230  // Latch to ensure the entire layer tree has been generated and presented.
231  fml::AutoResetWaitableEvent latch;
232  AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
233  CALayer* rootLayer = engine.viewController.flutterView.layer;
234  EXPECT_TRUE(rootLayer.backgroundColor != nil);
235  if (rootLayer.backgroundColor != nil) {
236  NSColor* actualBackgroundColor =
237  [NSColor colorWithCGColor:rootLayer.backgroundColor];
238  EXPECT_EQ(actualBackgroundColor, [NSColor blackColor]);
239  }
240  latch.Signal();
241  }));
242 
243  // Launch the test entrypoint.
244  EXPECT_TRUE([engine runWithEntrypoint:@"backgroundTest"]);
245  ASSERT_TRUE(engine.running);
246 
247  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
248  nibName:nil
249  bundle:nil];
250  [viewController loadView];
251  viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
252 
253  latch.Wait();
254 }

References FlutterEngine::viewController.

◆ TEST_F() [26/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DISABLED_CanOverrideBackgroundColor   
)

Definition at line 256 of file FlutterEngineTest.mm.

256  {
257  FlutterEngine* engine = GetFlutterEngine();
258 
259  // Latch to ensure the entire layer tree has been generated and presented.
260  fml::AutoResetWaitableEvent latch;
261  AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
262  CALayer* rootLayer = engine.viewController.flutterView.layer;
263  EXPECT_TRUE(rootLayer.backgroundColor != nil);
264  if (rootLayer.backgroundColor != nil) {
265  NSColor* actualBackgroundColor =
266  [NSColor colorWithCGColor:rootLayer.backgroundColor];
267  EXPECT_EQ(actualBackgroundColor, [NSColor whiteColor]);
268  }
269  latch.Signal();
270  }));
271 
272  // Launch the test entrypoint.
273  EXPECT_TRUE([engine runWithEntrypoint:@"backgroundTest"]);
274  ASSERT_TRUE(engine.running);
275 
276  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
277  nibName:nil
278  bundle:nil];
279  [viewController loadView];
280  viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
281  viewController.flutterView.backgroundColor = [NSColor whiteColor];
282 
283  latch.Wait();
284 }

References FlutterViewController::backgroundColor, and FlutterEngine::viewController.

◆ TEST_F() [27/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DisplaySizeIsInPhysicalPixel   
)

Definition at line 1243 of file FlutterEngineTest.mm.

1243  {
1244  NSString* fixtures = @(testing::GetFixturesPath());
1245  FlutterDartProject* project = [[FlutterDartProject alloc]
1246  initWithAssetsPath:fixtures
1247  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
1248  project.rootIsolateCreateCallback = FlutterEngineTest::IsolateCreateCallback;
1249  MockableFlutterEngine* engine = [[MockableFlutterEngine alloc] initWithName:@"foobar"
1250  project:project
1251  allowHeadlessExecution:true];
1252  BOOL updated = NO;
1253  auto original_update_displays = engine.embedderAPI.NotifyDisplayUpdate;
1254  engine.embedderAPI.NotifyDisplayUpdate = MOCK_ENGINE_PROC(
1255  NotifyDisplayUpdate, ([&updated, &original_update_displays](
1256  auto engine, auto update_type, auto* displays, auto display_count) {
1257  EXPECT_EQ(display_count, 1UL);
1258  EXPECT_EQ(displays->display_id, 10UL);
1259  EXPECT_EQ(displays->width, 60UL);
1260  EXPECT_EQ(displays->height, 80UL);
1261  EXPECT_EQ(displays->device_pixel_ratio, 2UL);
1262  updated = YES;
1263  return original_update_displays(engine, update_type, displays, display_count);
1264  }));
1265  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1266  EXPECT_TRUE(updated);
1267  [engine shutDownEngine];
1268  engine = nil;
1269 }

References FlutterEngine::shutDownEngine.

◆ TEST_F() [28/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
FlutterBinaryMessengerDoesNotRetainEngine   
)

Definition at line 629 of file FlutterEngineTest.mm.

629  {
630  __weak FlutterEngine* weakEngine;
631  id<FlutterBinaryMessenger> binaryMessenger = nil;
632  @autoreleasepool {
633  // Create a test engine.
634  NSString* fixtures = @(flutter::testing::GetFixturesPath());
635  FlutterDartProject* project = [[FlutterDartProject alloc]
636  initWithAssetsPath:fixtures
637  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
638  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
639  project:project
640  allowHeadlessExecution:YES];
641  weakEngine = engine;
642  binaryMessenger = engine.binaryMessenger;
643  }
644 
645  // Once the engine has been deallocated, verify the weak engine pointer is nil, and thus not
646  // retained by the relay.
647  EXPECT_NE(binaryMessenger, nil);
648  EXPECT_EQ(weakEngine, nil);
649 }

References FlutterEngine::binaryMessenger.

◆ TEST_F() [29/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
FlutterTextureRegistryDoesNotReturnEngine   
)

Definition at line 653 of file FlutterEngineTest.mm.

653  {
654  __weak FlutterEngine* weakEngine;
655  id<FlutterTextureRegistry> textureRegistry;
656  @autoreleasepool {
657  // Create a test engine.
658  NSString* fixtures = @(flutter::testing::GetFixturesPath());
659  FlutterDartProject* project = [[FlutterDartProject alloc]
660  initWithAssetsPath:fixtures
661  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
662  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
663  project:project
664  allowHeadlessExecution:YES];
665  id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:@"MyPlugin"];
666  textureRegistry = registrar.textures;
667  }
668 
669  // Once the engine has been deallocated, verify the weak engine pointer is nil, and thus not
670  // retained via the texture registry.
671  EXPECT_NE(textureRegistry, nil);
672  EXPECT_EQ(weakEngine, nil);
673 }

◆ TEST_F() [30/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ForwardsPluginDelegateRegistration   
)

Definition at line 1156 of file FlutterEngineTest.mm.

1156  {
1157  id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1158  FakeLifecycleProvider* fakeAppDelegate = [[FakeLifecycleProvider alloc] init];
1159  [NSApplication sharedApplication].delegate = fakeAppDelegate;
1160 
1161  FakeAppDelegatePlugin* plugin = [[FakeAppDelegatePlugin alloc] init];
1162  FlutterEngine* engine = CreateMockFlutterEngine(nil);
1163 
1164  [[engine registrarForPlugin:@"TestPlugin"] addApplicationDelegate:plugin];
1165 
1166  EXPECT_TRUE([fakeAppDelegate hasDelegate:plugin]);
1167 
1168  [NSApplication sharedApplication].delegate = previousDelegate;
1169 }

References CreateMockFlutterEngine().

◆ TEST_F() [31/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HandleAccessibilityEvent   
)

Definition at line 1062 of file FlutterEngineTest.mm.

1062  {
1063  __block BOOL announced = NO;
1064  id engineMock = CreateMockFlutterEngine(nil);
1065 
1066  OCMStub([engineMock announceAccessibilityMessage:[OCMArg any]
1067  withPriority:NSAccessibilityPriorityMedium])
1068  .andDo((^(NSInvocation* invocation) {
1069  announced = TRUE;
1070  [invocation retainArguments];
1071  NSString* message;
1072  [invocation getArgument:&message atIndex:2];
1073  EXPECT_EQ(message, @"error message");
1074  }));
1075 
1076  NSDictionary<NSString*, id>* annotatedEvent =
1077  @{@"type" : @"announce",
1078  @"data" : @{@"message" : @"error message"}};
1079 
1080  [engineMock handleAccessibilityEvent:annotatedEvent];
1081 
1082  EXPECT_TRUE(announced);
1083 }

References CreateMockFlutterEngine().

◆ TEST_F() [32/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HandleLifecycleStates   
)

Definition at line 1085 of file FlutterEngineTest.mm.

1085  {
1086  __block flutter::AppLifecycleState sentState;
1087  id engineMock = CreateMockFlutterEngine(nil);
1088 
1089  // Have to enumerate all the values because OCMStub can't capture
1090  // non-Objective-C object arguments.
1091  OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kDetached])
1092  .andDo((^(NSInvocation* invocation) {
1094  }));
1095  OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kResumed])
1096  .andDo((^(NSInvocation* invocation) {
1098  }));
1099  OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kInactive])
1100  .andDo((^(NSInvocation* invocation) {
1102  }));
1103  OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kHidden])
1104  .andDo((^(NSInvocation* invocation) {
1106  }));
1107  OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kPaused])
1108  .andDo((^(NSInvocation* invocation) {
1110  }));
1111 
1112  __block NSApplicationOcclusionState visibility = NSApplicationOcclusionStateVisible;
1113  id mockApplication = OCMPartialMock([NSApplication sharedApplication]);
1114  OCMStub((NSApplicationOcclusionState)[mockApplication occlusionState])
1115  .andDo(^(NSInvocation* invocation) {
1116  [invocation setReturnValue:&visibility];
1117  });
1118 
1119  NSNotification* willBecomeActive =
1120  [[NSNotification alloc] initWithName:NSApplicationWillBecomeActiveNotification
1121  object:nil
1122  userInfo:nil];
1123  NSNotification* willResignActive =
1124  [[NSNotification alloc] initWithName:NSApplicationWillResignActiveNotification
1125  object:nil
1126  userInfo:nil];
1127 
1128  NSNotification* didChangeOcclusionState;
1129  didChangeOcclusionState =
1130  [[NSNotification alloc] initWithName:NSApplicationDidChangeOcclusionStateNotification
1131  object:nil
1132  userInfo:nil];
1133 
1134  [engineMock handleDidChangeOcclusionState:didChangeOcclusionState];
1135  EXPECT_EQ(sentState, flutter::AppLifecycleState::kInactive);
1136 
1137  [engineMock handleWillBecomeActive:willBecomeActive];
1138  EXPECT_EQ(sentState, flutter::AppLifecycleState::kResumed);
1139 
1140  [engineMock handleWillResignActive:willResignActive];
1141  EXPECT_EQ(sentState, flutter::AppLifecycleState::kInactive);
1142 
1143  visibility = 0;
1144  [engineMock handleDidChangeOcclusionState:didChangeOcclusionState];
1145  EXPECT_EQ(sentState, flutter::AppLifecycleState::kHidden);
1146 
1147  [engineMock handleWillBecomeActive:willBecomeActive];
1148  EXPECT_EQ(sentState, flutter::AppLifecycleState::kHidden);
1149 
1150  [engineMock handleWillResignActive:willResignActive];
1151  EXPECT_EQ(sentState, flutter::AppLifecycleState::kHidden);
1152 
1153  [mockApplication stopMocking];
1154 }

References CreateMockFlutterEngine(), flutter::kDetached, flutter::kHidden, flutter::kInactive, flutter::kPaused, and flutter::kResumed.

◆ TEST_F() [33/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HandlesTerminationRequest   
)

Definition at line 968 of file FlutterEngineTest.mm.

968  {
969  id engineMock = CreateMockFlutterEngine(nil);
970  __block NSString* nextResponse = @"exit";
971  __block BOOL triedToTerminate = NO;
972  FlutterEngineTerminationHandler* terminationHandler =
973  [[FlutterEngineTerminationHandler alloc] initWithEngine:engineMock
974  terminator:^(id sender) {
975  triedToTerminate = TRUE;
976  // Don't actually terminate, of course.
977  }];
978  OCMStub([engineMock terminationHandler]).andReturn(terminationHandler);
979  id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
980  OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
981  [engineMock binaryMessenger])
982  .andReturn(binaryMessengerMock);
983  OCMStub([engineMock sendOnChannel:@"flutter/platform"
984  message:[OCMArg any]
985  binaryReply:[OCMArg any]])
986  .andDo((^(NSInvocation* invocation) {
987  [invocation retainArguments];
988  FlutterBinaryReply callback;
989  NSData* returnedMessage;
990  [invocation getArgument:&callback atIndex:4];
991  if ([nextResponse isEqualToString:@"error"]) {
992  FlutterError* errorResponse = [FlutterError errorWithCode:@"Error"
993  message:@"Failed"
994  details:@"Details"];
995  returnedMessage =
996  [[FlutterJSONMethodCodec sharedInstance] encodeErrorEnvelope:errorResponse];
997  } else {
998  NSDictionary* responseDict = @{@"response" : nextResponse};
999  returnedMessage =
1000  [[FlutterJSONMethodCodec sharedInstance] encodeSuccessEnvelope:responseDict];
1001  }
1002  callback(returnedMessage);
1003  }));
1004  __block NSString* calledAfterTerminate = @"";
1005  FlutterResult appExitResult = ^(id result) {
1006  NSDictionary* resultDict = result;
1007  calledAfterTerminate = resultDict[@"response"];
1008  };
1009  FlutterMethodCall* methodExitApplication =
1010  [FlutterMethodCall methodCallWithMethodName:@"System.exitApplication"
1011  arguments:@{@"type" : @"cancelable"}];
1012 
1013  // Always terminate when the binding isn't ready (which is the default).
1014  triedToTerminate = NO;
1015  calledAfterTerminate = @"";
1016  nextResponse = @"cancel";
1017  [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1018  EXPECT_STREQ([calledAfterTerminate UTF8String], "");
1019  EXPECT_TRUE(triedToTerminate);
1020 
1021  // Once the binding is ready, handle the request.
1022  terminationHandler.acceptingRequests = YES;
1023  triedToTerminate = NO;
1024  calledAfterTerminate = @"";
1025  nextResponse = @"exit";
1026  [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1027  EXPECT_STREQ([calledAfterTerminate UTF8String], "exit");
1028  EXPECT_TRUE(triedToTerminate);
1029 
1030  triedToTerminate = NO;
1031  calledAfterTerminate = @"";
1032  nextResponse = @"cancel";
1033  [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1034  EXPECT_STREQ([calledAfterTerminate UTF8String], "cancel");
1035  EXPECT_FALSE(triedToTerminate);
1036 
1037  // Check that it doesn't crash on error.
1038  triedToTerminate = NO;
1039  calledAfterTerminate = @"";
1040  nextResponse = @"error";
1041  [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1042  EXPECT_STREQ([calledAfterTerminate UTF8String], "");
1043  EXPECT_TRUE(triedToTerminate);
1044 }

References CreateMockFlutterEngine(), FlutterError::errorWithCode:message:details:, FlutterBinaryReply, and FlutterMethodCall::methodCallWithMethodName:arguments:.

◆ TEST_F() [34/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HasNonNullExecutableName   
)

Definition at line 148 of file FlutterEngineTest.mm.

148  {
149  FlutterEngine* engine = GetFlutterEngine();
150  std::string executable_name = [[engine executableName] UTF8String];
151  ASSERT_FALSE(executable_name.empty());
152 
153  // Block until notified by the Dart test of the value of Platform.executable.
154  fml::AutoResetWaitableEvent latch;
155  AddNativeCallback("NotifyStringValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
156  const auto dart_string = tonic::DartConverter<std::string>::FromDart(
157  Dart_GetNativeArgument(args, 0));
158  EXPECT_EQ(executable_name, dart_string);
159  latch.Signal();
160  }));
161 
162  // Launch the test entrypoint.
163  EXPECT_TRUE([engine runWithEntrypoint:@"executableNameNotNull"]);
164 
165  latch.Wait();
166 }

◆ TEST_F() [35/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HasStringsWhenPasteboardEmpty   
)

Definition at line 788 of file FlutterEngineTest.mm.

788  {
789  id engineMock = CreateMockFlutterEngine(nil);
790 
791  // Call hasStrings and expect it to be false.
792  __block bool calledAfterClear = false;
793  __block bool valueAfterClear;
794  FlutterResult resultAfterClear = ^(id result) {
795  calledAfterClear = true;
796  NSNumber* valueNumber = [result valueForKey:@"value"];
797  valueAfterClear = [valueNumber boolValue];
798  };
799  FlutterMethodCall* methodCallAfterClear =
800  [FlutterMethodCall methodCallWithMethodName:@"Clipboard.hasStrings" arguments:nil];
801  [engineMock handleMethodCall:methodCallAfterClear result:resultAfterClear];
802  EXPECT_TRUE(calledAfterClear);
803  EXPECT_FALSE(valueAfterClear);
804 }

References CreateMockFlutterEngine(), and FlutterMethodCall::methodCallWithMethodName:arguments:.

◆ TEST_F() [36/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HasStringsWhenPasteboardFull   
)

Definition at line 806 of file FlutterEngineTest.mm.

806  {
807  id engineMock = CreateMockFlutterEngine(@"some string");
808 
809  // Call hasStrings and expect it to be true.
810  __block bool called = false;
811  __block bool value;
812  FlutterResult result = ^(id result) {
813  called = true;
814  NSNumber* valueNumber = [result valueForKey:@"value"];
815  value = [valueNumber boolValue];
816  };
817  FlutterMethodCall* methodCall =
818  [FlutterMethodCall methodCallWithMethodName:@"Clipboard.hasStrings" arguments:nil];
819  [engineMock handleMethodCall:methodCall result:result];
820  EXPECT_TRUE(called);
821  EXPECT_TRUE(value);
822 }

References CreateMockFlutterEngine(), and FlutterMethodCall::methodCallWithMethodName:arguments:.

◆ TEST_F() [37/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
IgnoresTerminationRequestIfNotFlutterAppDelegate   
)

Definition at line 1046 of file FlutterEngineTest.mm.

1046  {
1047  id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1048  id<NSApplicationDelegate> plainDelegate = [[PlainAppDelegate alloc] init];
1049  [NSApplication sharedApplication].delegate = plainDelegate;
1050 
1051  // Creating the engine shouldn't fail here, even though the delegate isn't a
1052  // FlutterAppDelegate.
1054 
1055  // Asking to terminate the app should cancel.
1056  EXPECT_EQ([[[NSApplication sharedApplication] delegate] applicationShouldTerminate:NSApp],
1057  NSTerminateCancel);
1058 
1059  [NSApplication sharedApplication].delegate = previousDelegate;
1060 }

References CreateMockFlutterEngine().

◆ TEST_F() [38/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ManageControllersIfInitiatedByController   
)

Definition at line 880 of file FlutterEngineTest.mm.

880  {
881  NSString* fixtures = @(flutter::testing::GetFixturesPath());
882  FlutterDartProject* project = [[FlutterDartProject alloc]
883  initWithAssetsPath:fixtures
884  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
885 
886  FlutterEngine* engine;
887  FlutterViewController* viewController1;
888 
889  @autoreleasepool {
890  // Create FVC1.
891  viewController1 = [[FlutterViewController alloc] initWithProject:project];
892  EXPECT_EQ(viewController1.viewIdentifier, 0ll);
893 
894  engine = viewController1.engine;
895  engine.viewController = nil;
896 
897  // Create FVC2 based on the same engine.
898  FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine
899  nibName:nil
900  bundle:nil];
901  EXPECT_EQ(engine.viewController, viewController2);
902  }
903  // FVC2 is deallocated but FVC1 is retained.
904 
905  EXPECT_EQ(engine.viewController, nil);
906 
907  engine.viewController = viewController1;
908  EXPECT_EQ(engine.viewController, viewController1);
909  EXPECT_EQ(viewController1.viewIdentifier, 0ll);
910 }

References FlutterViewController::engine, FlutterEngine::viewController, and FlutterViewController::viewIdentifier.

◆ TEST_F() [39/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ManageControllersIfInitiatedByEngine   
)

Definition at line 912 of file FlutterEngineTest.mm.

912  {
913  // Don't create the engine with `CreateMockFlutterEngine`, because it adds
914  // additional references to FlutterViewControllers, which is crucial to this
915  // test case.
916  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"io.flutter"
917  project:nil
918  allowHeadlessExecution:NO];
919  FlutterViewController* viewController1;
920 
921  @autoreleasepool {
922  viewController1 = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil];
923  EXPECT_EQ(viewController1.viewIdentifier, 0ll);
924  EXPECT_EQ(engine.viewController, viewController1);
925 
926  engine.viewController = nil;
927 
928  FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine
929  nibName:nil
930  bundle:nil];
931  EXPECT_EQ(viewController2.viewIdentifier, 0ll);
932  EXPECT_EQ(engine.viewController, viewController2);
933  }
934  // FVC2 is deallocated but FVC1 is retained.
935 
936  EXPECT_EQ(engine.viewController, nil);
937 
938  engine.viewController = viewController1;
939  EXPECT_EQ(engine.viewController, viewController1);
940  EXPECT_EQ(viewController1.viewIdentifier, 0ll);
941 }

References FlutterEngine::viewController, and FlutterViewController::viewIdentifier.

◆ TEST_F() [40/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
MessengerCleanupConnectionWorks   
)

Definition at line 731 of file FlutterEngineTest.mm.

731  {
732  FlutterEngine* engine = GetFlutterEngine();
733  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
734 
735  NSString* channel = @"_test_";
736  NSData* channel_data = [channel dataUsingEncoding:NSUTF8StringEncoding];
737 
738  // Mock SendPlatformMessage so that if a message is sent to
739  // "test/send_message", act as if the framework has sent an empty message to
740  // the channel marked by the `sendOnChannel:message:` call's message.
741  engine.embedderAPI.SendPlatformMessage = MOCK_ENGINE_PROC(
742  SendPlatformMessage, ([](auto engine_, auto message_) {
743  if (strcmp(message_->channel, "test/send_message") == 0) {
744  // The simplest message that is acceptable to a method channel.
745  std::string message = R"|({"method": "a"})|";
746  std::string channel(reinterpret_cast<const char*>(message_->message),
747  message_->message_size);
748  reinterpret_cast<EmbedderEngine*>(engine_)
749  ->GetShell()
750  .GetPlatformView()
751  ->HandlePlatformMessage(std::make_unique<PlatformMessage>(
752  channel.c_str(), fml::MallocMapping::Copy(message.c_str(), message.length()),
753  fml::RefPtr<PlatformMessageResponse>()));
754  }
755  return kSuccess;
756  }));
757 
758  __block int record = 0;
759 
760  FlutterMethodChannel* channel1 =
762  binaryMessenger:engine.binaryMessenger
763  codec:[FlutterJSONMethodCodec sharedInstance]];
764  [channel1 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
765  record += 1;
766  }];
767 
768  [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
769  EXPECT_EQ(record, 1);
770 
771  FlutterMethodChannel* channel2 =
773  binaryMessenger:engine.binaryMessenger
774  codec:[FlutterJSONMethodCodec sharedInstance]];
775  [channel2 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
776  record += 10;
777  }];
778 
779  [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
780  EXPECT_EQ(record, 11);
781 
782  [channel1 setMethodCallHandler:nil];
783 
784  [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
785  EXPECT_EQ(record, 21);
786 }

References FlutterMethodChannel::methodChannelWithName:binaryMessenger:codec:, and FlutterMethodChannel::setMethodCallHandler:.

◆ TEST_F() [41/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
MessengerSend   
)

Definition at line 186 of file FlutterEngineTest.mm.

186  {
187  FlutterEngine* engine = GetFlutterEngine();
188  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
189 
190  NSData* test_message = [@"a message" dataUsingEncoding:NSUTF8StringEncoding];
191  bool called = false;
192 
193  engine.embedderAPI.SendPlatformMessage = MOCK_ENGINE_PROC(
194  SendPlatformMessage, ([&called, test_message](auto engine, auto message) {
195  called = true;
196  EXPECT_STREQ(message->channel, "test");
197  EXPECT_EQ(memcmp(message->message, test_message.bytes, message->message_size), 0);
198  return kSuccess;
199  }));
200 
201  [engine.binaryMessenger sendOnChannel:@"test" message:test_message];
202  EXPECT_TRUE(called);
203 }

◆ TEST_F() [42/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
NativeCallbacks   
)

Definition at line 486 of file FlutterEngineTest.mm.

486  {
487  fml::AutoResetWaitableEvent latch;
488  bool latch_called = false;
489  AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
490  latch_called = true;
491  latch.Signal();
492  }));
493 
494  FlutterEngine* engine = GetFlutterEngine();
495  EXPECT_TRUE([engine runWithEntrypoint:@"nativeCallback"]);
496  ASSERT_TRUE(engine.running);
497 
498  latch.Wait();
499  ASSERT_TRUE(latch_called);
500 }

◆ TEST_F() [43/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
NotificationsUpdateDisplays   
)

Definition at line 1213 of file FlutterEngineTest.mm.

1213  {
1214  BOOL updated = NO;
1215  FlutterEngine* engine = GetFlutterEngine();
1216  auto original_set_viewport_metrics = engine.embedderAPI.SendWindowMetricsEvent;
1217  engine.embedderAPI.SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1218  SendWindowMetricsEvent,
1219  ([&updated, &original_set_viewport_metrics](auto engine, auto* window_metrics) {
1220  updated = YES;
1221  return original_set_viewport_metrics(engine, window_metrics);
1222  }));
1223 
1224  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1225 
1226  updated = NO;
1227  [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1228  object:nil];
1229  // No VC.
1230  EXPECT_FALSE(updated);
1231 
1232  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
1233  nibName:nil
1234  bundle:nil];
1235  [viewController loadView];
1236  viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
1237 
1238  [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1239  object:nil];
1240  EXPECT_TRUE(updated);
1241 }

◆ TEST_F() [44/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ProducesAccessibilityTreeWhenAddingViews   
)

Definition at line 461 of file FlutterEngineTest.mm.

461  {
462  FlutterEngine* engine = GetFlutterEngine();
463  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
464 
465  // Enable the semantics without attaching a view controller.
466  bool enabled_called = false;
467  engine.embedderAPI.UpdateSemanticsEnabled =
468  MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&enabled_called](auto engine, bool enabled) {
469  enabled_called = enabled;
470  return kSuccess;
471  }));
472  engine.semanticsEnabled = YES;
473  EXPECT_TRUE(enabled_called);
474 
475  EXPECT_EQ(engine.viewController, nil);
476 
477  // Assign the view controller after enabling semantics
478  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
479  nibName:nil
480  bundle:nil];
481  engine.viewController = viewController;
482 
483  EXPECT_NE(viewController.accessibilityBridge.lock(), nullptr);
484 }

References FlutterEngine::viewController.

◆ TEST_F() [45/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
PublishedValueNilForUnknownPlugin   
)

Definition at line 675 of file FlutterEngineTest.mm.

675  {
676  NSString* fixtures = @(flutter::testing::GetFixturesPath());
677  FlutterDartProject* project = [[FlutterDartProject alloc]
678  initWithAssetsPath:fixtures
679  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
680  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
681  project:project
682  allowHeadlessExecution:YES];
683 
684  EXPECT_EQ([engine valuePublishedByPlugin:@"NoSuchPlugin"], nil);
685 }

◆ TEST_F() [46/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
PublishedValueNSNullIfNoPublishedValue   
)

Definition at line 687 of file FlutterEngineTest.mm.

687  {
688  NSString* fixtures = @(flutter::testing::GetFixturesPath());
689  FlutterDartProject* project = [[FlutterDartProject alloc]
690  initWithAssetsPath:fixtures
691  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
692  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
693  project:project
694  allowHeadlessExecution:YES];
695  NSString* pluginName = @"MyPlugin";
696  // Request the registarar to register the plugin as existing.
697  [engine registrarForPlugin:pluginName];
698 
699  // The documented behavior is that a plugin that exists but hasn't published
700  // anything returns NSNull, rather than nil, as on iOS.
701  EXPECT_EQ([engine valuePublishedByPlugin:pluginName], [NSNull null]);
702 }

◆ TEST_F() [47/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
PublishedValueReturnsLastPublished   
)

Definition at line 704 of file FlutterEngineTest.mm.

704  {
705  NSString* fixtures = @(flutter::testing::GetFixturesPath());
706  FlutterDartProject* project = [[FlutterDartProject alloc]
707  initWithAssetsPath:fixtures
708  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
709  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
710  project:project
711  allowHeadlessExecution:YES];
712  NSString* pluginName = @"MyPlugin";
713  id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:pluginName];
714 
715  NSString* firstValue = @"A published value";
716  NSArray* secondValue = @[ @"A different published value" ];
717 
718  [registrar publish:firstValue];
719  EXPECT_EQ([engine valuePublishedByPlugin:pluginName], firstValue);
720 
721  [registrar publish:secondValue];
722  EXPECT_EQ([engine valuePublishedByPlugin:pluginName], secondValue);
723 }

◆ TEST_F() [48/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
RemovingViewDisposesCompositorResources   
)

Definition at line 943 of file FlutterEngineTest.mm.

943  {
944  NSString* fixtures = @(flutter::testing::GetFixturesPath());
945  FlutterDartProject* project = [[FlutterDartProject alloc]
946  initWithAssetsPath:fixtures
947  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
948  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:project];
949 
950  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
951  nibName:nil
952  bundle:nil];
953  [viewController loadView];
954  [viewController viewDidLoad];
955  viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
956 
957  EXPECT_TRUE([engine runWithEntrypoint:@"drawIntoAllViews"]);
958  [engine.testThreadSynchronizer blockUntilFrameAvailable];
959  EXPECT_EQ(engine.macOSCompositor->DebugNumViews(), 1u);
960 
961  engine.viewController = nil;
962  EXPECT_EQ(engine.macOSCompositor->DebugNumViews(), 0u);
963 
964  [engine shutDownEngine];
965  engine = nil;
966 }

References FlutterEngine::shutDownEngine, and FlutterEngine::viewController.

◆ TEST_F() [49/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ReportsHourFormat   
)

Definition at line 1271 of file FlutterEngineTest.mm.

1271  {
1272  __block BOOL expectedValue;
1273 
1274  // Set up mocks.
1275  id channelMock = OCMClassMock([FlutterBasicMessageChannel class]);
1276  OCMStub([channelMock messageChannelWithName:@"flutter/settings"
1277  binaryMessenger:[OCMArg any]
1278  codec:[OCMArg any]])
1279  .andReturn(channelMock);
1280  OCMStub([channelMock sendMessage:[OCMArg any]]).andDo((^(NSInvocation* invocation) {
1281  __weak id message;
1282  [invocation getArgument:&message atIndex:2];
1283  EXPECT_EQ(message[@"alwaysUse24HourFormat"], @(expectedValue));
1284  }));
1285 
1286  id mockHourFormat = OCMClassMock([FlutterHourFormat class]);
1287  OCMStub([mockHourFormat isAlwaysUse24HourFormat]).andDo((^(NSInvocation* invocation) {
1288  [invocation setReturnValue:&expectedValue];
1289  }));
1290 
1291  id engineMock = CreateMockFlutterEngine(nil);
1292 
1293  // Verify the YES case.
1294  expectedValue = YES;
1295  EXPECT_TRUE([engineMock runWithEntrypoint:@"main"]);
1296  [engineMock shutDownEngine];
1297 
1298  // Verify the NO case.
1299  expectedValue = NO;
1300  EXPECT_TRUE([engineMock runWithEntrypoint:@"main"]);
1301  [engineMock shutDownEngine];
1302 
1303  // Clean up mocks.
1304  [mockHourFormat stopMocking];
1305  [engineMock stopMocking];
1306  [channelMock stopMocking];
1307 }

References CreateMockFlutterEngine().

◆ TEST_F() [50/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ResponseAfterEngineDied   
)

Definition at line 824 of file FlutterEngineTest.mm.

824  {
825  FlutterEngine* engine = GetFlutterEngine();
827  initWithName:@"foo"
828  binaryMessenger:engine.binaryMessenger
830  __block BOOL didCallCallback = NO;
831  [channel setMessageHandler:^(id message, FlutterReply callback) {
832  ShutDownEngine();
833  callback(nil);
834  didCallCallback = YES;
835  }];
836  EXPECT_TRUE([engine runWithEntrypoint:@"sendFooMessage"]);
837  engine = nil;
838 
839  while (!didCallCallback) {
840  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
841  }
842 }

References FlutterBasicMessageChannel::setMessageHandler:, and <FlutterMessageCodec>::sharedInstance.

◆ TEST_F() [51/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ResponseFromBackgroundThread   
)

Definition at line 844 of file FlutterEngineTest.mm.

844  {
845  FlutterEngine* engine = GetFlutterEngine();
847  initWithName:@"foo"
848  binaryMessenger:engine.binaryMessenger
850  __block BOOL didCallCallback = NO;
851  [channel setMessageHandler:^(id message, FlutterReply callback) {
852  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
853  callback(nil);
854  dispatch_async(dispatch_get_main_queue(), ^{
855  didCallCallback = YES;
856  });
857  });
858  }];
859  EXPECT_TRUE([engine runWithEntrypoint:@"sendFooMessage"]);
860 
861  while (!didCallCallback) {
862  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
863  }
864 }

References FlutterBasicMessageChannel::setMessageHandler:, and <FlutterMessageCodec>::sharedInstance.

◆ TEST_F() [52/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
RunWithEntrypointUpdatesDisplayConfig   
)

Definition at line 1192 of file FlutterEngineTest.mm.

1192  {
1193  BOOL updated = NO;
1194  FlutterEngine* engine = GetFlutterEngine();
1195  auto original_update_displays = engine.embedderAPI.NotifyDisplayUpdate;
1196  engine.embedderAPI.NotifyDisplayUpdate = MOCK_ENGINE_PROC(
1197  NotifyDisplayUpdate, ([&updated, &original_update_displays](
1198  auto engine, auto update_type, auto* displays, auto display_count) {
1199  updated = YES;
1200  return original_update_displays(engine, update_type, displays, display_count);
1201  }));
1202 
1203  EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1204  EXPECT_TRUE(updated);
1205 
1206  updated = NO;
1207  [[NSNotificationCenter defaultCenter]
1208  postNotificationName:NSApplicationDidChangeScreenParametersNotification
1209  object:nil];
1210  EXPECT_TRUE(updated);
1211 }

◆ TEST_F() [53/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
Switches   
)

Definition at line 169 of file FlutterEngineTest.mm.

169  {
170  setenv("FLUTTER_ENGINE_SWITCHES", "2", 1);
171  setenv("FLUTTER_ENGINE_SWITCH_1", "abc", 1);
172  setenv("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"", 1);
173 
174  FlutterEngine* engine = GetFlutterEngine();
175  std::vector<std::string> switches = engine.switches;
176  ASSERT_EQ(switches.size(), 2UL);
177  EXPECT_EQ(switches[0], "--abc");
178  EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
179 
180  unsetenv("FLUTTER_ENGINE_SWITCHES");
181  unsetenv("FLUTTER_ENGINE_SWITCH_1");
182  unsetenv("FLUTTER_ENGINE_SWITCH_2");
183 }

◆ TEST_F() [54/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ThreadSynchronizerNotBlockingRasterThreadAfterShutdown   
)

Definition at line 866 of file FlutterEngineTest.mm.

866  {
867  FlutterThreadSynchronizer* threadSynchronizer = [[FlutterThreadSynchronizer alloc] init];
868  [threadSynchronizer shutdown];
869 
870  std::thread rasterThread([&threadSynchronizer] {
871  [threadSynchronizer performCommitForView:kImplicitViewId
872  size:CGSizeMake(100, 100)
873  notify:^{
874  }];
875  });
876 
877  rasterThread.join();
878 }

References FlutterThreadSynchronizer::performCommitForView:size:notify:, and FlutterThreadSynchronizer::shutdown.

◆ TEST_F() [55/76]

flutter::testing::TEST_F ( FlutterEngineTest  ,
UnregistersPluginsOnEngineDestruction   
)

Definition at line 1171 of file FlutterEngineTest.mm.

1171  {
1172  id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1173  FakeLifecycleProvider* fakeAppDelegate = [[FakeLifecycleProvider alloc] init];
1174  [NSApplication sharedApplication].delegate = fakeAppDelegate;
1175 
1176  FakeAppDelegatePlugin* plugin = [[FakeAppDelegatePlugin alloc] init];
1177 
1178  @autoreleasepool {
1179  FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
1180 
1181  [[engine registrarForPlugin:@"TestPlugin"] addApplicationDelegate:plugin];
1182  EXPECT_TRUE([fakeAppDelegate hasDelegate:plugin]);
1183  }
1184 
1185  // When the engine is released, it should unregister any plugins it had
1186  // registered on its behalf.
1187  EXPECT_FALSE([fakeAppDelegate hasDelegate:plugin]);
1188 
1189  [NSApplication sharedApplication].delegate = previousDelegate;
1190 }

◆ TEST_F() [56/76]

flutter::testing::TEST_F ( FlutterMenuPluginTest  ,
TestSetMenu   
)

Definition at line 84 of file FlutterMenuPluginTest.mm.

84  {
85  // Build a simulation of the default main menu.
86  NSMenu* mainMenu = [[NSMenu alloc] init];
87  NSMenuItem* appNameMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"APP_NAME", nil)
88  action:nil
89  keyEquivalent:@""];
90  NSMenu* submenu =
91  [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Prexisting APP_NAME menu", nil)];
92  [submenu addItem:[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About APP_NAME", nil)
93  action:nil
94  keyEquivalent:@""]];
95  appNameMenu.submenu = submenu;
96  [mainMenu addItem:appNameMenu];
97  [NSApp setMainMenu:mainMenu];
98 
99  FakePluginRegistrar* registrar = [[FakePluginRegistrar alloc] init];
101  FlutterMenuPlugin* plugin = [registrar plugin];
102 
103  NSDictionary* testMenus = @{
104  @"0" : @[
105  @{
106  @"id" : [NSNumber numberWithInt:1],
107  @"label" : @"APP_NAME",
108  @"enabled" : @(YES),
109  @"children" : @[
110  @{
111  @"id" : [NSNumber numberWithInt:3],
112  @"platformProvidedMenu" : @(static_cast<int>(flutter::PlatformProvidedMenu::kQuit)),
113  @"enabled" : @(YES),
114  },
115  @{
116  @"id" : [NSNumber numberWithInt:2],
117  @"label" : @"APP_NAME Info",
118  @"enabled" : @(YES),
119  @"shortcutTrigger" : [NSNumber numberWithUnsignedLongLong:0x61],
120  @"shortcutModifiers" : [NSNumber numberWithUnsignedInt:0],
121  },
122  ],
123  },
124  @{
125  @"id" : [NSNumber numberWithInt:4],
126  @"label" : @"Help for APP_NAME",
127  @"enabled" : @(YES),
128  @"children" : @[
129  @{
130  @"id" : [NSNumber numberWithInt:5],
131  @"label" : @"Help me!",
132  @"enabled" : @(YES),
133  },
134  @{
135  @"id" : [NSNumber numberWithInt:6],
136  @"label" : @"",
137  @"enabled" : @(NO),
138  @"isDivider" : @(YES),
139  },
140  @{
141  @"id" : [NSNumber numberWithInt:7],
142  @"label" : @"Search help",
143  @"enabled" : @(NO),
144  },
145  ],
146  },
147  ],
148  };
149 
150  __block id available = @NO;
151  [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"Menu.isPluginAvailable"
152  arguments:nil]
153  result:^(id _Nullable result) {
154  available = result;
155  }];
156 
157  EXPECT_TRUE(available);
158 
160  arguments:testMenus]
161  result:^(id _Nullable result){
162  }];
163 
164  EXPECT_EQ([NSApp.mainMenu numberOfItems], 2);
165  NSMenuItem* firstMenu = [NSApp.mainMenu itemAtIndex:0];
166  EXPECT_TRUE([[firstMenu title] isEqualToString:@"flutter_desktop_darwin_unittests"]);
167  EXPECT_EQ([firstMenu tag], 1);
168  EXPECT_TRUE([firstMenu isEnabled]);
169  EXPECT_FALSE([firstMenu isHidden]);
170  EXPECT_TRUE([[firstMenu keyEquivalent] isEqualToString:@"\0"]);
171 
172  EXPECT_EQ([[firstMenu submenu] numberOfItems], 1);
173  NSMenuItem* firstItem = [[firstMenu submenu] itemAtIndex:0];
174  EXPECT_TRUE([[firstItem title] isEqualToString:@"flutter_desktop_darwin_unittests Info"]);
175  EXPECT_TRUE([[firstItem keyEquivalent] isEqualToString:@"a"]);
176  EXPECT_TRUE([firstItem isEnabled]);
177  EXPECT_FALSE([firstItem isHidden]);
178  EXPECT_TRUE(
179  [NSStringFromSelector([firstItem action]) isEqualToString:@"flutterMenuItemSelected:"]);
180  EXPECT_EQ([firstItem tag], 2);
181 
182  NSMenuItem* secondMenu = [NSApp.mainMenu itemAtIndex:1];
183  EXPECT_TRUE([[secondMenu title] isEqualToString:@"Help for flutter_desktop_darwin_unittests"]);
184  EXPECT_EQ([secondMenu tag], 4);
185  EXPECT_TRUE([secondMenu isEnabled]);
186  EXPECT_FALSE([secondMenu isHidden]);
187 
188  EXPECT_EQ([[secondMenu submenu] numberOfItems], 3);
189  NSMenuItem* secondMenuFirst = [[secondMenu submenu] itemAtIndex:0];
190  EXPECT_TRUE([[secondMenuFirst title] isEqualToString:@"Help me!"]);
191  EXPECT_TRUE([secondMenuFirst isEnabled]);
192  EXPECT_FALSE([secondMenuFirst isHidden]);
193  EXPECT_TRUE(
194  [NSStringFromSelector([secondMenuFirst action]) isEqualToString:@"flutterMenuItemSelected:"]);
195  EXPECT_EQ([secondMenuFirst tag], 5);
196 
197  NSMenuItem* secondMenuDivider = [[secondMenu submenu] itemAtIndex:1];
198  EXPECT_TRUE([[secondMenuDivider title] isEqualToString:@""]);
199  EXPECT_TRUE([[secondMenuDivider keyEquivalent] isEqualToString:@""]);
200  EXPECT_FALSE([secondMenuDivider isEnabled]);
201  EXPECT_FALSE([secondMenuDivider isHidden]);
202  EXPECT_EQ([secondMenuDivider action], nil);
203  EXPECT_EQ([secondMenuDivider tag], 0);
204 
205  NSMenuItem* secondMenuLast = [[secondMenu submenu] itemAtIndex:2];
206  EXPECT_TRUE([[secondMenuLast title] isEqualToString:@"Search help"]);
207  EXPECT_FALSE([secondMenuLast isEnabled]);
208  EXPECT_FALSE([secondMenuLast isHidden]);
209  EXPECT_TRUE(
210  [NSStringFromSelector([secondMenuLast action]) isEqualToString:@"flutterMenuItemSelected:"]);
211  EXPECT_EQ([secondMenuLast tag], 7);
212 }

References <FlutterPlugin>::handleMethodCall:result:, FlutterMethodCall::methodCallWithMethodName:arguments:, FakePluginRegistrar::plugin, and FlutterMenuPlugin::registerWithRegistrar:.

◆ TEST_F() [57/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestCtrlTabKeyEventIsPropagated   
)

Definition at line 261 of file FlutterViewControllerTest.mm.

261  {
262  id mockEngine = GetMockEngine();
263  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testCtrlTabKeyEventIsPropagated:mockEngine]);
264 }

◆ TEST_F() [58/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestFlagsChangedEventsArePropagatedIfNotHandled   
)

Definition at line 272 of file FlutterViewControllerTest.mm.

272  {
273  id mockEngine = GetMockEngine();
274  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc]
275  testFlagsChangedEventsArePropagatedIfNotHandled:mockEngine]);
276 }

◆ TEST_F() [59/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
testFlutterViewIsConfigured   
)

Definition at line 314 of file FlutterViewControllerTest.mm.

314  {
315  id mockEngine = GetMockEngine();
316  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testFlutterViewIsConfigured:mockEngine]);
317 }

◆ TEST_F() [60/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyboardIsRestartedOnEngineRestart   
)

Definition at line 278 of file FlutterViewControllerTest.mm.

278  {
279  id mockEngine = GetMockEngine();
280  ASSERT_TRUE(
281  [[FlutterViewControllerTestObjC alloc] testKeyboardIsRestartedOnEngineRestart:mockEngine]);
282 }

◆ TEST_F() [61/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEquivalentIsPassedToTextInputPlugin   
)

Definition at line 266 of file FlutterViewControllerTest.mm.

266  {
267  id mockEngine = GetMockEngine();
268  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc]
269  testKeyEquivalentIsPassedToTextInputPlugin:mockEngine]);
270 }

◆ TEST_F() [62/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEventsAreNotPropagatedIfHandled   
)

Definition at line 255 of file FlutterViewControllerTest.mm.

255  {
256  id mockEngine = GetMockEngine();
257  ASSERT_TRUE(
258  [[FlutterViewControllerTestObjC alloc] testKeyEventsAreNotPropagatedIfHandled:mockEngine]);
259 }

◆ TEST_F() [63/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEventsArePropagatedIfNotHandled   
)

Definition at line 249 of file FlutterViewControllerTest.mm.

249  {
250  id mockEngine = GetMockEngine();
251  ASSERT_TRUE(
252  [[FlutterViewControllerTestObjC alloc] testKeyEventsArePropagatedIfNotHandled:mockEngine]);
253 }

◆ TEST_F() [64/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEventsAreSentToFramework   
)

Definition at line 244 of file FlutterViewControllerTest.mm.

244  {
245  id mockEngine = GetMockEngine();
246  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testKeyEventsAreSentToFramework:mockEngine]);
247 }

◆ TEST_F() [65/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestModifierKeysAreSynthesizedOnMouseMove   
)

Definition at line 302 of file FlutterViewControllerTest.mm.

302  {
303  id mockEngine = GetMockEngine();
304  ASSERT_TRUE(
305  [[FlutterViewControllerTestObjC alloc] testModifierKeysAreSynthesizedOnMouseMove:mockEngine]);
306 }

◆ TEST_F() [66/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestmouseAndGestureEventsAreHandledSeparately   
)

Definition at line 290 of file FlutterViewControllerTest.mm.

290  {
291  id mockEngine = GetMockEngine();
292  ASSERT_TRUE(
293  [[FlutterViewControllerTestObjC alloc] mouseAndGestureEventsAreHandledSeparately:mockEngine]);
294 }

◆ TEST_F() [67/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestMouseDownUpEventsSentToNextResponder   
)

Definition at line 296 of file FlutterViewControllerTest.mm.

296  {
297  id mockEngine = GetMockEngine();
298  ASSERT_TRUE(
299  [[FlutterViewControllerTestObjC alloc] testMouseDownUpEventsSentToNextResponder:mockEngine]);
300 }

◆ TEST_F() [68/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestTrackpadGesturesAreSentToFramework   
)

Definition at line 284 of file FlutterViewControllerTest.mm.

284  {
285  id mockEngine = GetMockEngine();
286  ASSERT_TRUE(
287  [[FlutterViewControllerTestObjC alloc] testTrackpadGesturesAreSentToFramework:mockEngine]);
288 }

◆ TEST_F() [69/76]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
testViewWillAppearCalledMultipleTimes   
)

Definition at line 308 of file FlutterViewControllerTest.mm.

308  {
309  id mockEngine = GetMockEngine();
310  ASSERT_TRUE(
311  [[FlutterViewControllerTestObjC alloc] testViewWillAppearCalledMultipleTimes:mockEngine]);
312 }

◆ TEST_F() [70/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
CanSetMouseTrackingModeBeforeViewLoaded   
)

Definition at line 234 of file FlutterViewControllerTest.mm.

234  {
235  NSString* fixtures = @(testing::GetFixturesPath());
236  FlutterDartProject* project = [[FlutterDartProject alloc]
237  initWithAssetsPath:fixtures
238  ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
239  FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project];
240  viewController.mouseTrackingMode = kFlutterMouseTrackingModeInActiveApp;
241  ASSERT_EQ(viewController.mouseTrackingMode, kFlutterMouseTrackingModeInActiveApp);
242 }

References FlutterViewController::mouseTrackingMode.

◆ TEST_F() [71/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
FlutterViewAcceptsFirstMouse   
)

Definition at line 203 of file FlutterViewControllerTest.mm.

203  {
204  FlutterViewController* viewControllerMock = CreateMockViewController();
205  [viewControllerMock loadView];
206  EXPECT_EQ([viewControllerMock.flutterView acceptsFirstMouse:nil], YES);
207 }

References CreateMockViewController().

◆ TEST_F() [72/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
HasViewThatHidesOtherViewsInAccessibility   
)

Definition at line 182 of file FlutterViewControllerTest.mm.

182  {
183  FlutterViewController* viewControllerMock = CreateMockViewController();
184 
185  [viewControllerMock loadView];
186  auto subViews = [viewControllerMock.view subviews];
187 
188  EXPECT_EQ([subViews count], 1u);
189  EXPECT_EQ(subViews[0], viewControllerMock.flutterView);
190 
191  NSTextField* textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 1, 1)];
192  [viewControllerMock.view addSubview:textField];
193 
194  subViews = [viewControllerMock.view subviews];
195  EXPECT_EQ([subViews count], 2u);
196 
197  auto accessibilityChildren = viewControllerMock.view.accessibilityChildren;
198  // The accessibilityChildren should only contains the FlutterView.
199  EXPECT_EQ([accessibilityChildren count], 1u);
200  EXPECT_EQ(accessibilityChildren[0], viewControllerMock.flutterView);
201 }

References CreateMockViewController().

◆ TEST_F() [73/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
ReparentsPluginWhenAccessibilityDisabled   
)

Definition at line 209 of file FlutterViewControllerTest.mm.

209  {
210  FlutterEngine* engine = CreateTestEngine();
211  FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
212  nibName:nil
213  bundle:nil];
214  [viewController loadView];
215  // Creates a NSWindow so that sub view can be first responder.
216  NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
217  styleMask:NSBorderlessWindowMask
218  backing:NSBackingStoreBuffered
219  defer:NO];
220  window.contentView = viewController.view;
221  NSView* dummyView = [[NSView alloc] initWithFrame:CGRectZero];
222  [viewController.view addSubview:dummyView];
223  // Attaches FlutterTextInputPlugin to the view;
224  [dummyView addSubview:viewController.textInputPlugin];
225  // Makes sure the textInputPlugin can be the first responder.
226  EXPECT_TRUE([window makeFirstResponder:viewController.textInputPlugin]);
227  EXPECT_EQ([window firstResponder], viewController.textInputPlugin);
228  EXPECT_FALSE(viewController.textInputPlugin.superview == viewController.view);
229  [viewController onAccessibilityStatusChanged:NO];
230  // FlutterView becomes child of view controller
231  EXPECT_TRUE(viewController.textInputPlugin.superview == viewController.view);
232 }

References FlutterViewController::onAccessibilityStatusChanged:.

◆ TEST_F() [74/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testLookupKeyAssets   
)

Definition at line 319 of file FlutterViewControllerTest.mm.

319  {
320  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]);
321 }

◆ TEST_F() [75/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testLookupKeyAssetsWithPackage   
)

Definition at line 323 of file FlutterViewControllerTest.mm.

323  {
324  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssetsWithPackage]);
325 }

◆ TEST_F() [76/76]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testViewControllerIsReleased   
)

Definition at line 327 of file FlutterViewControllerTest.mm.

327  {
328  ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testViewControllerIsReleased]);
329 }
flutter::testing::CreateSemanticsNode
FlutterSemanticsNode2 CreateSemanticsNode(int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)
Definition: accessibility_bridge_unittests.cc:18
TestView
Definition: FlutterSurfaceManagerTest.mm:14
+[FlutterSurface fromFlutterMetalTexture:]
nullable FlutterSurface * fromFlutterMetalTexture:(nonnull const FlutterMetalTexture *texture)
FlutterViewControllerTestObjC
Definition: FlutterViewControllerTest.mm:95
flutter::AppLifecycleState::kHidden
@ kHidden
FlutterEngine
Definition: FlutterEngine.h:31
-[FlutterAppLifecycleDelegate-p handleDidHide:]
void handleDidHide:(NSNotification *notification)
-[FlutterAppLifecycleDelegate-p handleWillResignActive:]
void handleWillResignActive:(NSNotification *notification)
FlutterTextFieldMock::lastUpdatedString
NSString * lastUpdatedString
Definition: FlutterTextInputPluginTest.mm:23
+[FlutterMethodCall methodCallWithMethodName:arguments:]
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
FlutterBasicMessageChannel
Definition: FlutterChannels.h:37
-[FlutterAppLifecycleDelegate-p handleDidChangeOcclusionState:]
void handleDidChangeOcclusionState:(NSNotification *notification)
-[FlutterTextInputPlugin handleMethodCall:result:]
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
FlutterAppLifecycleRegistrar
Definition: FlutterAppLifecycleDelegate.h:126
-[FlutterAppLifecycleRegistrar addDelegate:]
void addDelegate:(NSObject< FlutterAppLifecycleDelegate > *delegate)
Definition: FlutterAppLifecycleDelegate.mm:58
FlutterViewController
Definition: FlutterViewController.h:73
FlutterMethodChannel
Definition: FlutterChannels.h:220
-[FlutterAppLifecycleDelegate-p handleWillHide:]
void handleWillHide:(NSNotification *notification)
flutter::testing::CreateMockFlutterEngine
id CreateMockFlutterEngine(NSString *pasteboardString)
Definition: FlutterEngineTestUtils.mm:76
-[FlutterViewController onAccessibilityStatusChanged:]
void onAccessibilityStatusChanged:(BOOL enabled)
TestKeyEvent
Definition: FlutterEmbedderKeyResponderTest.mm:13
flutter::testing::CreateMockViewController
id CreateMockViewController()
Definition: FlutterViewControllerTestUtils.mm:9
FlutterPlatformViewController
Definition: FlutterPlatformViewController.h:17
user_data
void * user_data
Definition: texture_registrar_unittests.cc:27
-[FlutterKeyPrimaryResponder-p handleEvent:callback:]
void handleEvent:callback:(nonnull NSEvent *event,[callback] nonnull FlutterAsyncKeyCallback callback)
-[FlutterBackBufferCache count]
NSUInteger count()
Definition: FlutterSurfaceManager.mm:352
FlutterSurfaceManager
Definition: FlutterSurfaceManager.h:44
FlutterError
Definition: FlutterCodecs.h:246
flutter::kLayoutGoals
const std::vector< LayoutGoal > kLayoutGoals
Definition: KeyCodeMap.g.mm:248
FlutterTextFieldMock
Definition: FlutterTextInputPluginTest.mm:21
FlutterEngine::viewController
FlutterViewController * viewController
Definition: FlutterEngine.h:87
TestFlutterPlatformViewFactory
Definition: TestFlutterPlatformView.h:19
TestPlatformViewFactory
Definition: FlutterEngineTest.mm:48
FakeLifecycleProvider
Definition: FlutterEngineTest.mm:71
FakeMessageChannel
Definition: FlutterChannelKeyResponderTest.mm:19
FakePluginRegistrar::plugin
id< FlutterPlugin > plugin
Definition: FlutterMenuPluginTest.mm:23
-[FlutterAppLifecycleProvider-p addApplicationLifecycleDelegate:]
void addApplicationLifecycleDelegate:(nonnull NSObject< FlutterAppLifecycleDelegate > *delegate)
FakeAppDelegatePlugin
Definition: FlutterEngineTest.mm:113
FlutterViewController::engine
FlutterEngine * engine
Definition: FlutterViewController.h:78
TestFlutterPlatformView
Definition: TestFlutterPlatformView.h:12
CreateImpellerContext
static std::shared_ptr< impeller::ContextMTL > CreateImpellerContext()
Definition: FlutterEmbedderExternalTextureTest.mm:34
+[FlutterError errorWithCode:message:details:]
instancetype errorWithCode:message:details:(NSString *code,[message] NSString *_Nullable message,[details] id _Nullable details)
FakeMessageChannel::messages
NSMutableArray< id > * messages
Definition: FlutterChannelKeyResponderTest.mm:20
FlutterExternalTexture
Definition: FlutterExternalTexture.h:18
FlutterMenuPlugin
Definition: FlutterMenuPlugin.h:20
FlutterTextFieldMock::lastUpdatedSelection
NSRange lastUpdatedSelection
Definition: FlutterTextInputPluginTest.mm:24
FlutterEngine::binaryMessenger
id< FlutterBinaryMessenger > binaryMessenger
Definition: FlutterEngine.h:92
FlutterViewEngineProvider
Definition: FlutterViewEngineProvider.h:18
TestFlutterPlatformView::args
id args
Arguments passed via the params value in the create method call.
Definition: TestFlutterPlatformView.h:15
-[FlutterAppLifecycleDelegate-p handleDidUnhide:]
void handleDidUnhide:(NSNotification *notification)
-[FlutterAppLifecycleDelegate-p handleWillTerminate:]
void handleWillTerminate:(NSNotification *notification)
flutter::AppLifecycleState::kInactive
@ kInactive
FlutterSurface
Definition: FlutterSurface.h:16
-[FlutterMethodChannel setMethodCallHandler:]
void setMethodCallHandler:(FlutterMethodCallHandler _Nullable handler)
-[FlutterAppLifecycleDelegate-p handleDidChangeScreenParameters:]
void handleDidChangeScreenParameters:(NSNotification *notification)
FlutterStandardMessageCodec
Definition: FlutterCodecs.h:209
FlutterMethodCall
Definition: FlutterCodecs.h:220
FlutterViewController::backgroundColor
NSColor * backgroundColor
Definition: FlutterViewController.h:210
FlutterHourFormat
Definition: FlutterHourFormat.h:10
TestExternalTexture
Definition: FlutterEmbedderExternalTextureTest.mm:47
FlutterThreadSynchronizer
Definition: FlutterThreadSynchronizer.h:18
FakePasteboard
Definition: FlutterEngineTestUtils.mm:17
AppDelegateNoopFlutterAppLifecycleDelegate
Definition: FlutterAppDelegateTest.mm:10
FlutterSurfacePresentInfo::surface
FlutterSurface * surface
Definition: FlutterSurfaceManager.h:20
AppDelegateTestFlutterAppLifecycleDelegate
Definition: FlutterAppDelegateTest.mm:17
PlainAppDelegate
Definition: FlutterEngineTest.mm:59
FlutterAppDelegate
Definition: FlutterAppDelegate.h:54
FlutterSurfaceManager::frontSurfaces
NSArray< FlutterSurface * > * frontSurfaces
Definition: FlutterSurfaceManager.h:106
-[FlutterTextField startEditing]
void startEditing()
Definition: FlutterTextInputSemanticsObject.mm:112
FlutterTextInputPlugin
Definition: FlutterTextInputPlugin.h:27
-[FlutterAppLifecycleDelegate-p handleDidFinishLaunching:]
void handleDidFinishLaunching:(NSNotification *notification)
FlutterResult
void(^ FlutterResult)(id _Nullable result)
Definition: FlutterChannels.h:194
FlutterSurfacePresentInfo::offset
CGPoint offset
Definition: FlutterSurfaceManager.h:21
FlutterKeyPrimaryResponder-p::layoutMap
NSMutableDictionary< NSNumber *, NSNumber * > * layoutMap
Definition: FlutterKeyPrimaryResponder.h:46
FlutterSurfaceManager::backBufferCache
FlutterBackBufferCache * backBufferCache
Definition: FlutterSurfaceManager.h:105
-[FlutterPlugin-p handleMethodCall:result:]
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
FlutterChannelKeyResponder
Definition: FlutterChannelKeyResponder.h:20
+[FlutterMethodChannel methodChannelWithName:binaryMessenger:codec:]
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMethodCodec > *codec)
MockableFlutterEngine
Definition: FlutterEngineTest.mm:123
FlutterSurfacePresentInfo
Definition: FlutterSurfaceManager.h:18
-[FlutterThreadSynchronizer performCommitForView:size:notify:]
void performCommitForView:size:notify:(FlutterViewIdentifier viewIdentifier,[size] CGSize size,[notify] nonnull dispatch_block_t notify)
Definition: FlutterThreadSynchronizer.mm:137
-[FlutterSurfaceManager presentSurfaces:atTime:notify:]
void presentSurfaces:atTime:notify:(nonnull NSArray< FlutterSurfacePresentInfo * > *surfaces,[atTime] CFTimeInterval presentationTime,[notify] nullable dispatch_block_t notify)
FakeMessageChannel::nextResponse
NSDictionary * nextResponse
Definition: FlutterChannelKeyResponderTest.mm:21
FlutterSurfacePresentInfo::zIndex
size_t zIndex
Definition: FlutterSurfaceManager.h:22
+[FlutterMenuPlugin registerWithRegistrar:]
void registerWithRegistrar:(nonnull id< FlutterPluginRegistrar > registrar)
Definition: FlutterMenuPlugin.mm:412
-[FlutterSurfaceManager surfaceForSize:]
nonnull FlutterSurface * surfaceForSize:(CGSize size)
Definition: FlutterSurfaceManager.mm:133
-[FlutterAppLifecycleDelegate-p handleWillFinishLaunching:]
void handleWillFinishLaunching:(NSNotification *notification)
FlutterViewController::viewIdentifier
FlutterViewIdentifier viewIdentifier
Definition: FlutterViewController.h:130
FlutterStandardTypedData
Definition: FlutterCodecs.h:300
TestView::presentedFrameSize
CGSize presentedFrameSize
Definition: FlutterSurfaceManagerTest.mm:16
flutter::AppLifecycleState::kResumed
@ kResumed
FlutterView
Definition: FlutterView.h:35
flutter::AppLifecycleState::kDetached
@ kDetached
flutter::testing::CreateSurfaceManager
static FlutterSurfaceManager * CreateSurfaceManager(TestView *testView)
Definition: FlutterSurfaceManagerTest.mm:41
-[FlutterAppLifecycleDelegate-p handleWillBecomeActive:]
void handleWillBecomeActive:(NSNotification *notification)
FlutterJSONMethodCodec
Definition: FlutterCodecs.h:455
-[FlutterBasicMessageChannel setMessageHandler:]
void setMessageHandler:(FlutterMessageHandler _Nullable handler)
FlutterSurfacePresentInfo::paintRegion
std::vector< FlutterRect > paintRegion
Definition: FlutterSurfaceManager.h:23
-[FlutterAppLifecycleDelegate-p handleDidBecomeActive:]
void handleDidBecomeActive:(NSNotification *notification)
flutter::AppLifecycleState
AppLifecycleState
Definition: app_lifecycle_state.h:32
FakePluginRegistrar
Definition: FlutterMenuPluginTest.mm:22
-[FlutterEngine shutDownEngine]
void shutDownEngine()
Definition: FlutterEngine.mm:1134
FlutterDartProject
Definition: FlutterDartProject.mm:24
FlutterKeyboardManagerUnittestsObjC
Definition: FlutterKeyboardManagerTest.mm:420
FlutterEngineTerminationHandler::acceptingRequests
BOOL acceptingRequests
Definition: FlutterEngine_Internal.h:60
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:49
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
FlutterTextField
Definition: FlutterTextInputSemanticsObject.h:81
-[FlutterAppLifecycleDelegate-p handleWillUnhide:]
void handleWillUnhide:(NSNotification *notification)
FlutterEmbedderKeyResponder
Definition: FlutterEmbedderKeyResponder.h:23
FlutterEngineTerminationHandler
Definition: FlutterEngine.mm:188
FlutterViewIdentifier
int64_t FlutterViewIdentifier
Definition: FlutterViewController.h:21
-[FlutterThreadSynchronizer shutdown]
void shutdown()
Definition: FlutterThreadSynchronizer.mm:192
-[FlutterExternalTexture populateTexture:]
BOOL populateTexture:(nonnull FlutterMetalExternalTexture *metalTexture)
FlutterBinaryReply
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
FlutterViewController::mouseTrackingMode
FlutterMouseTrackingMode mouseTrackingMode
Definition: FlutterViewController.h:84
+[FlutterMessageCodec-p sharedInstance]
instancetype sharedInstance()
FlutterInputPluginTestObjc
Definition: FlutterTextInputPluginTest.mm:52
-[FlutterAppLifecycleDelegate-p handleDidResignActive:]
void handleDidResignActive:(NSNotification *notification)
flutter::AppLifecycleState::kPaused
@ kPaused
TestFlutterAppLifecycleDelegate
Definition: FlutterAppLifecycleDelegateTest.mm:10