| Flutter Linux Embedder |

Functions
fl_accessible_node_test.cc File Reference
`#include "gtest/gtest.h"`
`#include "flutter/shell/platform/linux/fl_accessible_node.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 11 of file fl_accessible_node_test.cc.

11 {
12 g_autoptr(FlDartProject) project = fl_dart_project_new();
13 g_autoptr(FlEngine) engine = fl_engine_new(project);
14
15 int64_t view_id = 123;
16 g_autoptr(FlAccessibleNode) root = fl_accessible_node_new(engine, view_id, 0);
17 g_autoptr(FlAccessibleNode) child1 =
18 fl_accessible_node_new(engine, view_id, 1);
19 fl_accessible_node_set_parent(child1, ATK_OBJECT(root), 0);
20 g_autoptr(FlAccessibleNode) child2 =
21 fl_accessible_node_new(engine, view_id, 1);
22 fl_accessible_node_set_parent(child2, ATK_OBJECT(root), 1);
23 g_autoptr(GPtrArray) children =
24 g_ptr_array_new_with_free_func(g_object_unref);
25 g_ptr_array_add(children, g_object_ref(child1));
26 g_ptr_array_add(children, g_object_ref(child2));
27 fl_accessible_node_set_children(root, children);
28
29 EXPECT_EQ(atk_object_get_n_accessible_children(ATK_OBJECT(root)), 2);
30 EXPECT_EQ(atk_object_get_index_in_parent(ATK_OBJECT(root)), 0);
31 g_autoptr(AtkObject) c1 =
32 atk_object_ref_accessible_child(ATK_OBJECT(root), 0);
33 EXPECT_EQ(ATK_OBJECT(child1), c1);
34 g_autoptr(AtkObject) c2 =
35 atk_object_ref_accessible_child(ATK_OBJECT(root), 1);
36 EXPECT_EQ(ATK_OBJECT(child2), c2);
37 EXPECT_EQ(atk_object_get_parent(ATK_OBJECT(root)), nullptr);
38
39 EXPECT_EQ(atk_object_get_parent(ATK_OBJECT(child1)), ATK_OBJECT(root));
40 EXPECT_EQ(atk_object_get_index_in_parent(ATK_OBJECT(child1)), 0);
41 EXPECT_EQ(atk_object_get_n_accessible_children(ATK_OBJECT(child1)), 0);
42
43 EXPECT_EQ(atk_object_get_parent(ATK_OBJECT(child2)), ATK_OBJECT(root));
44 EXPECT_EQ(atk_object_get_index_in_parent(ATK_OBJECT(child2)), 1);
45 EXPECT_EQ(atk_object_get_n_accessible_children(ATK_OBJECT(child2)), 0);
46 }
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:549
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:538
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, FlutterViewId view_id, int32_t node_id)
Definition: fl_accessible_node.cc:529
g_autoptr
g_autoptr(GMutexLocker) locker
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:52
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:692
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References fl_accessible_node_new(), fl_accessible_node_set_children(), fl_accessible_node_set_parent(), fl_dart_project_new(), fl_engine_new(), g_autoptr(), and view_id.

## ◆ TEST() [2/6]

TEST | ( | FlAccessibleNodeTest | ,
|  | GetRole |
| ) |  |

Definition at line 95 of file fl_accessible_node_test.cc.

95 {
96 g_autoptr(FlDartProject) project = fl_dart_project_new();
97 g_autoptr(FlEngine) engine = fl_engine_new(project);
98
99 g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 123, 0);
100
101 FlutterSemanticsFlags flags1 = {};
102 flags1.is_button = true;
103 fl_accessible_node_set_flags(node, &flags1);
104 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PUSH_BUTTON);
105
106 FlutterSemanticsFlags flags2 = {};
107 flags2.is_checked = kFlutterCheckStateFalse;
108 fl_accessible_node_set_flags(node, &flags2);
109 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_CHECK_BOX);
110
111 FlutterSemanticsFlags flags3 = {};
112 flags3.is_checked = kFlutterCheckStateFalse;
113 flags3.is_in_mutually_exclusive_group = true;
114 fl_accessible_node_set_flags(node, &flags3);
115 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_RADIO_BUTTON);
116
117 FlutterSemanticsFlags flags4 = {};
118 flags4.is_toggled = kFlutterTristateFalse;
119 fl_accessible_node_set_flags(node, &flags4);
120 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TOGGLE_BUTTON);
121
122 FlutterSemanticsFlags flags5 = {};
123 flags5.is_text_field = true;
124 fl_accessible_node_set_flags(node, &flags5);
125 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TEXT);
126
127 FlutterSemanticsFlags flags6 = {};
128 flags6.is_text_field = true;
129 flags6.is_obscured = true;
130 fl_accessible_node_set_flags(node, &flags6);
131 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PASSWORD_TEXT);
132 }
fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlags *flags)
Definition: fl_accessible_node.cc:593

References fl_accessible_node_new(), fl_accessible_node_set_flags(), fl_dart_project_new(), fl_engine_new(), and g_autoptr().

## ◆ TEST() [3/6]

TEST | ( | FlAccessibleNodeTest | ,
|  | SetActions |
| ) |  |

Definition at line 135 of file fl_accessible_node_test.cc.

135 {
136 g_autoptr(FlDartProject) project = fl_dart_project_new();
137 g_autoptr(FlEngine) engine = fl_engine_new(project);
138
139 g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 123, 0);
140 fl_accessible_node_set_actions(
141 node, static_cast<FlutterSemanticsAction>(
142 kFlutterSemanticsActionTap | kFlutterSemanticsActionLongPress));
143
144 EXPECT_EQ(atk_action_get_n_actions(ATK_ACTION(node)), 2);
145 EXPECT_STREQ(atk_action_get_name(ATK_ACTION(node), 0), "Tap");
146 EXPECT_STREQ(atk_action_get_name(ATK_ACTION(node), 1), "LongPress");
147 }
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:600

References fl_accessible_node_new(), fl_accessible_node_set_actions(), fl_dart_project_new(), fl_engine_new(), and g_autoptr().

## ◆ TEST() [4/6]

TEST | ( | FlAccessibleNodeTest | ,
|  | SetExtents |
| ) |  |

Definition at line 59 of file fl_accessible_node_test.cc.

59 {
60 g_autoptr(FlDartProject) project = fl_dart_project_new();
61 g_autoptr(FlEngine) engine = fl_engine_new(project);
62
63 g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 123, 0);
64 fl_accessible_node_set_extents(node, 1, 2, 3, 4);
65 gint x, y, width, height;
66 atk_component_get_extents(ATK_COMPONENT(node), &x, &y, &width, &height,
67 ATK_XY_PARENT);
68 EXPECT_EQ(x, 1);
69 EXPECT_EQ(y, 2);
70 EXPECT_EQ(width, 3);
71 EXPECT_EQ(height, 4);
72 }
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:582
height
self height
Definition: fl_compositor_software.cc:43
width
self width
Definition: fl_compositor_software.cc:42

References fl_accessible_node_new(), fl_accessible_node_set_extents(), fl_dart_project_new(), fl_engine_new(), g_autoptr(), height, and width.

## ◆ TEST() [5/6]

TEST | ( | FlAccessibleNodeTest | ,
|  | SetFlags |
| ) |  |

Definition at line 75 of file fl_accessible_node_test.cc.

75 {
76 g_autoptr(FlDartProject) project = fl_dart_project_new();
77 g_autoptr(FlEngine) engine = fl_engine_new(project);
78
79 g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 123, 0);
80 FlutterSemanticsFlags flags = {};
81 flags.is_enabled = kFlutterTristateTrue;
82 flags.is_focused = kFlutterTristateTrue;
83 fl_accessible_node_set_flags(node, &flags);
84
85 AtkStateSet* state = atk_object_ref_state_set(ATK_OBJECT(node));
86 EXPECT_TRUE(atk_state_set_contains_state(state, ATK_STATE_ENABLED));
87 EXPECT_TRUE(atk_state_set_contains_state(state, ATK_STATE_SENSITIVE));
88 EXPECT_TRUE(atk_state_set_contains_state(state, ATK_STATE_FOCUSABLE));
89 EXPECT_TRUE(atk_state_set_contains_state(state, ATK_STATE_FOCUSED));
90 EXPECT_TRUE(!atk_state_set_contains_state(state, ATK_STATE_CHECKED));
91 g_object_unref(state);
92 }

References fl_accessible_node_new(), fl_accessible_node_set_flags(), fl_dart_project_new(), fl_engine_new(), and g_autoptr().

## ◆ TEST() [6/6]

TEST | ( | FlAccessibleNodeTest | ,
|  | SetName |
| ) |  |

Definition at line 49 of file fl_accessible_node_test.cc.

49 {
50 g_autoptr(FlDartProject) project = fl_dart_project_new();
51 g_autoptr(FlEngine) engine = fl_engine_new(project);
52
53 g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 123, 0);
54 fl_accessible_node_set_name(node, "test");
55 EXPECT_STREQ(atk_object_get_name(ATK_OBJECT(node)), "test");
56 }
fl_accessible_node_set_name
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:576

References fl_accessible_node_new(), fl_accessible_node_set_name(), fl_dart_project_new(), fl_engine_new(), and g_autoptr().