Flutter Linux Embedder
fl_accessible_node_test.cc File Reference
#include "gtest/gtest.h"
#include "flutter/shell/platform/linux/fl_accessible_node.h"
#include "flutter/shell/platform/linux/testing/fl_test.h"

Go to the source code of this file.

Functions

 TEST (FlAccessibleNodeTest, BuildTree)
 
 TEST (FlAccessibleNodeTest, SetName)
 
 TEST (FlAccessibleNodeTest, SetExtents)
 
 TEST (FlAccessibleNodeTest, SetFlags)
 
 TEST (FlAccessibleNodeTest, GetRole)
 
 TEST (FlAccessibleNodeTest, SetActions)
 

Function Documentation

◆ TEST() [1/6]

TEST ( FlAccessibleNodeTest  ,
BuildTree   
)

Definition at line 12 of file fl_accessible_node_test.cc.

12  {
13  g_autoptr(FlEngine) engine = make_mock_engine();
14 
15  g_autoptr(FlAccessibleNode) root = fl_accessible_node_new(engine, 0);
16  g_autoptr(FlAccessibleNode) child1 = fl_accessible_node_new(engine, 1);
17  fl_accessible_node_set_parent(child1, ATK_OBJECT(root), 0);
18  g_autoptr(FlAccessibleNode) child2 = fl_accessible_node_new(engine, 1);
19  fl_accessible_node_set_parent(child2, ATK_OBJECT(root), 1);
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));
24  fl_accessible_node_set_children(root, children);
25 
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);
35 
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);
39 
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);
43 }

References fl_accessible_node_new(), fl_accessible_node_set_children(), fl_accessible_node_set_parent(), and make_mock_engine().

◆ TEST() [2/6]

TEST ( FlAccessibleNodeTest  ,
GetRole   
)

Definition at line 89 of file fl_accessible_node_test.cc.

89  {
90  g_autoptr(FlEngine) engine = make_mock_engine();
91 
92  g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
93 
95  node, static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsButton));
96  EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PUSH_BUTTON);
97 
98  fl_accessible_node_set_flags(node, static_cast<FlutterSemanticsFlag>(
99  kFlutterSemanticsFlagHasCheckedState));
100  EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_CHECK_BOX);
101 
103  node, static_cast<FlutterSemanticsFlag>(
104  kFlutterSemanticsFlagHasCheckedState |
105  kFlutterSemanticsFlagIsInMutuallyExclusiveGroup));
106  EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_RADIO_BUTTON);
107 
108  fl_accessible_node_set_flags(node, static_cast<FlutterSemanticsFlag>(
109  kFlutterSemanticsFlagHasToggledState));
110  EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TOGGLE_BUTTON);
111 
112  fl_accessible_node_set_flags(node, kFlutterSemanticsFlagIsTextField);
113  EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TEXT);
114 
116  node, static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsTextField |
117  kFlutterSemanticsFlagIsObscured));
118  EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PASSWORD_TEXT);
119 }

References fl_accessible_node_new(), fl_accessible_node_set_flags(), and make_mock_engine().

◆ TEST() [3/6]

TEST ( FlAccessibleNodeTest  ,
SetActions   
)

Definition at line 122 of file fl_accessible_node_test.cc.

122  {
123  g_autoptr(FlEngine) engine = make_mock_engine();
124 
125  g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
127  node, static_cast<FlutterSemanticsAction>(
128  kFlutterSemanticsActionTap | kFlutterSemanticsActionLongPress));
129 
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");
133 }

References fl_accessible_node_new(), fl_accessible_node_set_actions(), and make_mock_engine().

◆ TEST() [4/6]

TEST ( FlAccessibleNodeTest  ,
SetExtents   
)

Definition at line 55 of file fl_accessible_node_test.cc.

55  {
56  g_autoptr(FlEngine) engine = make_mock_engine();
57 
58  g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
59  fl_accessible_node_set_extents(node, 1, 2, 3, 4);
60  gint x, y, width, height;
61  atk_component_get_extents(ATK_COMPONENT(node), &x, &y, &width, &height,
62  ATK_XY_PARENT);
63  EXPECT_EQ(x, 1);
64  EXPECT_EQ(y, 2);
65  EXPECT_EQ(width, 3);
66  EXPECT_EQ(height, 4);
67 }

References fl_accessible_node_new(), fl_accessible_node_set_extents(), height, make_mock_engine(), and width.

◆ TEST() [5/6]

TEST ( FlAccessibleNodeTest  ,
SetFlags   
)

Definition at line 70 of file fl_accessible_node_test.cc.

70  {
71  g_autoptr(FlEngine) engine = make_mock_engine();
72 
73  g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
75  node, static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsEnabled |
76  kFlutterSemanticsFlagIsFocusable |
77  kFlutterSemanticsFlagIsFocused));
78 
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);
86 }

References fl_accessible_node_new(), fl_accessible_node_set_flags(), make_mock_engine(), and state.

◆ TEST() [6/6]

TEST ( FlAccessibleNodeTest  ,
SetName   
)

Definition at line 46 of file fl_accessible_node_test.cc.

46  {
47  g_autoptr(FlEngine) engine = make_mock_engine();
48 
49  g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
50  fl_accessible_node_set_name(node, "test");
51  EXPECT_STREQ(atk_object_get_name(ATK_OBJECT(node)), "test");
52 }

References fl_accessible_node_new(), fl_accessible_node_set_name(), and make_mock_engine().

fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)
Definition: fl_accessible_node.cc:543
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:488
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:499
state
AtkStateType state
Definition: fl_accessible_node.cc:10
make_mock_engine
static FlEngine * make_mock_engine()
Definition: fl_event_channel_test.cc:24
fl_accessible_node_set_extents
void fl_accessible_node_set_extents(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
Definition: fl_accessible_node.cc:532
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, int32_t id)
Definition: fl_accessible_node.cc:482
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
fl_accessible_node_set_name
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:526
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:550
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38