Flutter Engine
The Flutter Engine
Functions
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));
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}
FlutterEngine engine
Definition: main.cc:68
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, int32_t id)
static FlEngine * make_mock_engine()
string root
Definition: scale_cpu.py:20

◆ 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
96 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PUSH_BUTTON);
97
100 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_CHECK_BOX);
101
103 node, static_cast<FlutterSemanticsFlag>(
106 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_RADIO_BUTTON);
107
110 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TOGGLE_BUTTON);
111
113 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TEXT);
114
118 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PASSWORD_TEXT);
119}
FlutterSemanticsFlag
Definition: embedder.h:172
@ kFlutterSemanticsFlagHasToggledState
The semantics node has the quality of either being "on" or "off".
Definition: embedder.h:209
@ kFlutterSemanticsFlagIsInMutuallyExclusiveGroup
Whether a semantic node is in a mutually exclusive group.
Definition: embedder.h:192
@ kFlutterSemanticsFlagIsButton
Whether the semantic node represents a button.
Definition: embedder.h:181
@ kFlutterSemanticsFlagIsObscured
Whether the value of the semantics node is obscured.
Definition: embedder.h:196
@ kFlutterSemanticsFlagIsTextField
Whether the semantic node represents a text field.
Definition: embedder.h:183
@ kFlutterSemanticsFlagHasCheckedState
Definition: embedder.h:175
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)

◆ 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>(
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}
FlutterSemanticsAction
Definition: embedder.h:113
@ kFlutterSemanticsActionLongPress
Definition: embedder.h:119
@ kFlutterSemanticsActionTap
Definition: embedder.h:116
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)

◆ 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}
void fl_accessible_node_set_extents(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
double y
double x
int32_t height
int32_t 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);
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}
@ kFlutterSemanticsFlagIsFocused
Whether the semantic node currently holds the user's focus.
Definition: embedder.h:185
@ kFlutterSemanticsFlagIsEnabled
Whether a semantic node that hasEnabledState is currently enabled.
Definition: embedder.h:190
@ kFlutterSemanticsFlagIsFocusable
Whether the semantic node can hold the user's focus.
Definition: embedder.h:232
AtkStateType state
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678

◆ 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}
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)