| 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:515
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:504
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, FlutterViewId view_id, int32_t node_id)
Definition: fl_accessible_node.cc:495
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:50
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:584
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(), 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 fl_accessible_node_set_flags(
102 node, static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsButton));
103 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PUSH_BUTTON);
104
105 fl_accessible_node_set_flags(node, static_cast<FlutterSemanticsFlag>(
106 kFlutterSemanticsFlagHasCheckedState));
107 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_CHECK_BOX);
108
109 fl_accessible_node_set_flags(
110 node, static_cast<FlutterSemanticsFlag>(
111 kFlutterSemanticsFlagHasCheckedState |
112 kFlutterSemanticsFlagIsInMutuallyExclusiveGroup));
113 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_RADIO_BUTTON);
114
115 fl_accessible_node_set_flags(node, static_cast<FlutterSemanticsFlag>(
116 kFlutterSemanticsFlagHasToggledState));
117 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TOGGLE_BUTTON);
118
119 fl_accessible_node_set_flags(node, kFlutterSemanticsFlagIsTextField);
120 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_TEXT);
121
122 fl_accessible_node_set_flags(
123 node, static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsTextField |
124 kFlutterSemanticsFlagIsObscured));
125 EXPECT_EQ(atk_object_get_role(ATK_OBJECT(node)), ATK_ROLE_PASSWORD_TEXT);
126 }
fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)
Definition: fl_accessible_node.cc:559

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

## ◆ TEST() [3/6]

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

Definition at line 129 of file fl_accessible_node_test.cc.

129 {
130 g_autoptr(FlDartProject) project = fl_dart_project_new();
131 g_autoptr(FlEngine) engine = fl_engine_new(project);
132
133 g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 123, 0);
134 fl_accessible_node_set_actions(
135 node, static_cast<FlutterSemanticsAction>(
136 kFlutterSemanticsActionTap | kFlutterSemanticsActionLongPress));
137
138 EXPECT_EQ(atk_action_get_n_actions(ATK_ACTION(node)), 2);
139 EXPECT_STREQ(atk_action_get_name(ATK_ACTION(node), 0), "Tap");
140 EXPECT_STREQ(atk_action_get_name(ATK_ACTION(node), 1), "LongPress");
141 }
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:566

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

## ◆ 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:548
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38

References fl_accessible_node_new(), fl_accessible_node_set_extents(), fl_dart_project_new(), fl_engine_new(), 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 fl_accessible_node_set_flags(
81 node, static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsEnabled |
82 kFlutterSemanticsFlagIsFocusable |
83 kFlutterSemanticsFlagIsFocused));
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 }
state
AtkStateType state
Definition: fl_accessible_node.cc:10

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

## ◆ 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:542

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