Skip to content

Commit

Permalink
Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakovschectman committed Jan 4, 2023
1 parent d2bd6cf commit cc00078
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions shell/platform/common/flutter_platform_node_delegate_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,63 @@ TEST(FlutterPlatformNodeDelegateTest, canUseOwnerBridge) {
EXPECT_EQ(result, false);
}

TEST(FlutterPlatformNodeDelegateTest, selfIsLowestPlatformAncestor) {
std::shared_ptr<TestAccessibilityBridge> bridge =
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode root;
root.id = 0;
root.label = "root";
root.hint = "";
root.value = "";
root.increased_value = "";
root.decreased_value = "";
root.tooltip = "";
root.child_count = 0;
root.children_in_traversal_order = nullptr;
root.custom_accessibility_actions_count = 0;
bridge->AddFlutterSemanticsNodeUpdate(&root);

bridge->CommitUpdates();
auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
auto lowest_platform_ancestor = root_node->GetLowestPlatformAncestor();
EXPECT_EQ(root_node->GetNativeViewAccessible(), lowest_platform_ancestor);
}

TEST(FlutterPlatformNodeDelegateTest, canGetFromNodeID) {
std::shared_ptr<TestAccessibilityBridge> bridge =
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode root;
root.id = 0;
root.label = "root";
root.hint = "";
root.value = "";
root.increased_value = "";
root.decreased_value = "";
root.tooltip = "";
root.child_count = 1;
int32_t children[] = {1};
root.children_in_traversal_order = children;
root.custom_accessibility_actions_count = 0;
bridge->AddFlutterSemanticsNodeUpdate(&root);

FlutterSemanticsNode child1;
child1.id = 1;
child1.label = "child 1";
child1.hint = "";
child1.value = "";
child1.increased_value = "";
child1.decreased_value = "";
child1.tooltip = "";
child1.child_count = 0;
child1.custom_accessibility_actions_count = 0;
bridge->AddFlutterSemanticsNodeUpdate(&child1);

bridge->CommitUpdates();
auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
auto node_by_id = root_node->GetFromNodeID(1);
EXPECT_EQ(child1_node->GetPlatformNode(), node_by_id);
}

} // namespace testing
} // namespace flutter

0 comments on commit cc00078

Please sign in to comment.