| Flutter iOS Embedder |

Classes | Functions
flutter::testing Namespace Reference

## Classes
class | MockAccessibilityBridge
class | MockAccessibilityBridgeNoWindow
class | SemanticsActionObservation

## Functions
FlutterUIPressProxy * | keyDownEvent (UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
FlutterUIPressProxy * | keyUpEvent (UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
FlutterUIPressProxy * | keyEventWithPhase (UIPressPhase phase, UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
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)

## Function Documentation

## ◆ 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().

## ◆ keyDownEvent()

FlutterUIPressProxy * flutter::testing::keyDownEvent | ( | UIKeyboardHIDUsage | keyCode,
|  | UIKeyModifierFlags | modifierFlags = `0x0`,
|  | NSTimeInterval | timestamp = `0.0f`,
|  | const char * | characters = `""`,
|  | const char * | charactersIgnoringModifiers = `""`
| ) |  |

Definition at line 90 of file FlutterFakeKeyEvents.mm.

95 {
96 return keyEventWithPhase(UIPressPhaseBegan, keyCode, modifierFlags, timestamp, characters,
97 charactersIgnoringModifiers);
98 }

References keyEventWithPhase().

## ◆ keyEventWithPhase()

FlutterUIPressProxy * flutter::testing::keyEventWithPhase | ( | UIPressPhase | phase,
|  | UIKeyboardHIDUsage | keyCode,
|  | UIKeyModifierFlags | modifierFlags = `0x0`,
|  | NSTimeInterval | timestamp = `0.0f`,
|  | const char * | characters = `""`,
|  | const char * | charactersIgnoringModifiers = `""`
| ) |  |

Definition at line 109 of file FlutterFakeKeyEvents.mm.

115 {
116 FML_DCHECK(!(modifierFlags & kModifierFlagSidedMask))
117 << "iOS doesn't supply modifier side flags, so don't create events with them.";
118 UIKey* key =
119 [[FakeUIKey alloc] initWithData:keyCode
120 modifierFlags:modifierFlags
121 characters:[NSString stringWithUTF8String:characters]
122 charactersIgnoringModifiers:[NSString stringWithUTF8String:charactersIgnoringModifiers]];
123
124 return [[FakeUIPressProxy alloc] initWithData:phase
125 key:key
126 type:UIEventTypePresses
127 timestamp:timestamp];
128 }

References kModifierFlagSidedMask.

Referenced by keyDownEvent(), and keyUpEvent().

## ◆ keyUpEvent()

FlutterUIPressProxy * flutter::testing::keyUpEvent | ( | UIKeyboardHIDUsage | keyCode,
|  | UIKeyModifierFlags | modifierFlags = `0x0`,
|  | NSTimeInterval | timestamp = `0.0f`,
|  | const char * | characters = `""`,
|  | const char * | charactersIgnoringModifiers = `""`
| ) |  |

Definition at line 100 of file FlutterFakeKeyEvents.mm.

104 {
105 return keyEventWithPhase(UIPressPhaseEnded, keyCode, modifierFlags, timestamp, characters,
106 charactersIgnoringModifiers);
107 }

References keyEventWithPhase().

## ◆ TEST() [1/22]

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(), and fake_delegate.

## ◆ TEST() [2/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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/22]

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() [16/22]

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() [17/22]

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() [18/22]

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() [19/22]

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() [20/22]

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() [21/22]

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() [22/22]

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 }
flutter::testing::CreateSemanticsNode
FlutterSemanticsNode2 CreateSemanticsNode(int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)
Definition: accessibility_bridge_unittests.cc:18
flutter::testing::keyEventWithPhase
FlutterUIPressProxy * keyEventWithPhase(UIPressPhase phase, UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
Definition: FlutterFakeKeyEvents.mm:109
kModifierFlagSidedMask
constexpr uint32_t kModifierFlagSidedMask
Definition: KeyCodeMap_Internal.h:93
fake_delegate
flutter::FakeDelegate fake_delegate
Definition: FlutterEnginePlatformViewTest.mm:67
FakeUIPressProxy
Definition: FlutterFakeKeyEvents.h:15
FakeUIKey
Definition: FlutterFakeKeyEvents.h:33