Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e2c881e

Browse files
Unit test
1 parent 5b69adf commit e2c881e

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

shell/platform/common/flutter_platform_node_delegate_unittests.cc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,5 +246,63 @@ TEST(FlutterPlatformNodeDelegateTest, canUseOwnerBridge) {
246246
EXPECT_EQ(result, false);
247247
}
248248

249+
TEST(FlutterPlatformNodeDelegateTest, selfIsLowestPlatformAncestor) {
250+
std::shared_ptr<TestAccessibilityBridge> bridge =
251+
std::make_shared<TestAccessibilityBridge>();
252+
FlutterSemanticsNode 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+
}
270+
271+
TEST(FlutterPlatformNodeDelegateTest, canGetFromNodeID) {
272+
std::shared_ptr<TestAccessibilityBridge> bridge =
273+
std::make_shared<TestAccessibilityBridge>();
274+
FlutterSemanticsNode 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+
FlutterSemanticsNode 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+
}
306+
249307
} // namespace testing
250308
} // namespace flutter

0 commit comments

Comments
 (0)