6 #include "gtest/gtest.h"
9 #include "flutter/shell/platform/linux/testing/fl_test.h"
12 TEST(FlAccessibleNodeTest, BuildTree) {
20 g_autoptr(GPtrArray) children =
21 g_ptr_array_new_with_free_func(g_object_unref);
22 g_ptr_array_add(children, g_object_ref(child1));
23 g_ptr_array_add(children, g_object_ref(child2));
26 EXPECT_EQ(atk_object_get_n_accessible_children(ATK_OBJECT(root)), 2);
27 EXPECT_EQ(atk_object_get_index_in_parent(ATK_OBJECT(root)), 0);
28 g_autoptr(AtkObject) c1 =
29 atk_object_ref_accessible_child(ATK_OBJECT(root), 0);
30 EXPECT_EQ(ATK_OBJECT(child1), c1);
31 g_autoptr(AtkObject) c2 =
32 atk_object_ref_accessible_child(ATK_OBJECT(root), 1);
33 EXPECT_EQ(ATK_OBJECT(child2), c2);
34 EXPECT_EQ(atk_object_get_parent(ATK_OBJECT(root)),
nullptr);
36 EXPECT_EQ(atk_object_get_parent(ATK_OBJECT(child1)), ATK_OBJECT(root));
37 EXPECT_EQ(atk_object_get_index_in_parent(ATK_OBJECT(child1)), 0);
38 EXPECT_EQ(atk_object_get_n_accessible_children(ATK_OBJECT(child1)), 0);
40 EXPECT_EQ(atk_object_get_parent(ATK_OBJECT(child2)), ATK_OBJECT(root));
41 EXPECT_EQ(atk_object_get_index_in_parent(ATK_OBJECT(child2)), 1);
42 EXPECT_EQ(atk_object_get_n_accessible_children(ATK_OBJECT(child2)), 0);
46 TEST(FlAccessibleNodeTest, SetName) {
51 EXPECT_STREQ(atk_object_get_name(ATK_OBJECT(node)),
"test");
55 TEST(FlAccessibleNodeTest, SetExtents) {
61 atk_component_get_extents(ATK_COMPONENT(node), &x, &y, &
width, &
height,
70 TEST(FlAccessibleNodeTest, SetFlags) {
75 node,
static_cast<FlutterSemanticsFlag
>(kFlutterSemanticsFlagIsEnabled |
76 kFlutterSemanticsFlagIsFocusable |
77 kFlutterSemanticsFlagIsFocused));
79 AtkStateSet*
state = atk_object_ref_state_set(ATK_OBJECT(node));
80 EXPECT_TRUE(atk_state_set_contains_state(
state, ATK_STATE_ENABLED));
81 EXPECT_TRUE(atk_state_set_contains_state(
state, ATK_STATE_SENSITIVE));
82 EXPECT_TRUE(atk_state_set_contains_state(
state, ATK_STATE_FOCUSABLE));
83 EXPECT_TRUE(atk_state_set_contains_state(
state, ATK_STATE_FOCUSED));
84 EXPECT_TRUE(!atk_state_set_contains_state(
state, ATK_STATE_CHECKED));
85 g_object_unref(
state);
89 TEST(FlAccessibleNodeTest, GetRole) {
95 node,
static_cast<FlutterSemanticsFlag
>(kFlutterSemanticsFlagIsButton));
96 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PUSH_BUTTON);
99 kFlutterSemanticsFlagHasCheckedState));
100 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_CHECK_BOX);
103 node,
static_cast<FlutterSemanticsFlag
>(
104 kFlutterSemanticsFlagHasCheckedState |
105 kFlutterSemanticsFlagIsInMutuallyExclusiveGroup));
106 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_RADIO_BUTTON);
109 kFlutterSemanticsFlagHasToggledState));
110 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TOGGLE_BUTTON);
113 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TEXT);
116 node,
static_cast<FlutterSemanticsFlag
>(kFlutterSemanticsFlagIsTextField |
117 kFlutterSemanticsFlagIsObscured));
118 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PASSWORD_TEXT);
122 TEST(FlAccessibleNodeTest, SetActions) {
127 node,
static_cast<FlutterSemanticsAction
>(
128 kFlutterSemanticsActionTap | kFlutterSemanticsActionLongPress));
130 EXPECT_EQ(atk_action_get_n_actions(ATK_ACTION(node)), 2);
131 EXPECT_STREQ(atk_action_get_name(ATK_ACTION(node), 0),
"Tap");
132 EXPECT_STREQ(atk_action_get_name(ATK_ACTION(node), 1),
"LongPress");