| Flutter Linux Embedder |

Enumerations | Functions | Variables
fl_accessibility_handler_test.cc File Reference
`#include <atk/atk.h>`
`#include "flutter/shell/platform/linux/fl_accessibility_handler.h"`
`#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "flutter/shell/platform/linux/fl_view_private.h"`
`#include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"`
`#include "flutter/shell/platform/linux/testing/fl_test_gtk_logs.h"`
`#include "flutter/testing/testing.h"`
`#include "gmock/gmock.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Enumerations
enum | FlAtkLive { FL_ATK_LIVE_NONE , FL_ATK_LIVE_POLITE , FL_ATK_LIVE_ASSERTIVE , FL_ATK_LIVE_NONE , FL_ATK_LIVE_POLITE , FL_ATK_LIVE_ASSERTIVE }

## Functions
static void | announcement_cb (FlViewAccessible *accessible, const gchar *message, gpointer user_data)
static void | notification_polite_cb (FlViewAccessible *accessible, const gchar *message, FlAtkLive politeness, gpointer user_data)
static void | notification_assertive_cb (FlViewAccessible *accessible, const gchar *message, FlAtkLive politeness, gpointer user_data)
static gboolean | atk_supports_announce ()
static void | subscribe_signal (FlViewAccessible *accessible, gboolean *signalled, gboolean assertive)
| TEST (FlAccessibilityHandlerTest, Announce)
| TEST (FlAccessibilityHandlerTest, AnnounceAssertive)
| TEST (FlAccessibilityHandlerTest, AnnounceUnknownView)
| TEST (FlAccessibilityHandlerTest, UnknownType)

## Variables
static constexpr int64_t | kTextDirectionLtr = 0
static constexpr int64_t | kAssertivenessAssertive = 1

## Enumeration Type Documentation

## ◆ FlAtkLive

enum FlAtkLive

Enumerator
FL_ATK_LIVE_NONE |
FL_ATK_LIVE_POLITE |
FL_ATK_LIVE_ASSERTIVE |
FL_ATK_LIVE_NONE |
FL_ATK_LIVE_POLITE |
FL_ATK_LIVE_ASSERTIVE |

Definition at line 27 of file fl_accessibility_handler_test.cc.

27 {
28 FL_ATK_LIVE_NONE,
29 FL_ATK_LIVE_POLITE,
30 FL_ATK_LIVE_ASSERTIVE
31 } FlAtkLive;
FlAtkLive
FlAtkLive
Definition: fl_accessibility_handler_test.cc:27
FL_ATK_LIVE_ASSERTIVE
@ FL_ATK_LIVE_ASSERTIVE
Definition: fl_accessibility_handler_test.cc:30
FL_ATK_LIVE_NONE
@ FL_ATK_LIVE_NONE
Definition: fl_accessibility_handler_test.cc:28
FL_ATK_LIVE_POLITE
@ FL_ATK_LIVE_POLITE
Definition: fl_accessibility_handler_test.cc:29

## Function Documentation

## ◆ announcement_cb()

static void announcement_cb | ( | FlViewAccessible * | accessible,
|  | const gchar * | message,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 33 of file fl_accessibility_handler_test.cc.

35 {
36 EXPECT_STREQ(message, "MESSAGE");
37 gboolean* signalled = static_cast<gboolean*>(user_data);
38 *signalled = TRUE;
39 }
message
const char * message
Definition: fl_accessibility_handler.cc:21
user_data
const char FlTextDirection FlAssertiveness gpointer user_data
Definition: fl_accessibility_handler.cc:24
TRUE
return TRUE
Definition: fl_compositor_software.cc:68

References message, TRUE, and user_data.

Referenced by subscribe_signal().

## ◆ atk_supports_announce()

static gboolean atk_supports_announce | ( |  | ) |
| static

Definition at line 61 of file fl_accessibility_handler_test.cc.

61 {
62 return atk_get_major_version() == 2 && atk_get_minor_version() >= 46;
63 }

Referenced by subscribe_signal(), and TEST().

## ◆ notification_assertive_cb()

static void notification_assertive_cb | ( | FlViewAccessible * | accessible,
|  | const gchar * | message,
|  | FlAtkLive | politeness,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 51 of file fl_accessibility_handler_test.cc.

54 {
55 EXPECT_STREQ(message, "MESSAGE");
56 EXPECT_EQ(politeness, FL_ATK_LIVE_ASSERTIVE);
57 gboolean* signalled = static_cast<gboolean*>(user_data);
58 *signalled = TRUE;
59 }

References FL_ATK_LIVE_ASSERTIVE, message, TRUE, and user_data.

Referenced by subscribe_signal().

## ◆ notification_polite_cb()

static void notification_polite_cb | ( | FlViewAccessible * | accessible,
|  | const gchar * | message,
|  | FlAtkLive | politeness,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 41 of file fl_accessibility_handler_test.cc.

44 {
45 EXPECT_STREQ(message, "MESSAGE");
46 EXPECT_EQ(politeness, FL_ATK_LIVE_POLITE);
47 gboolean* signalled = static_cast<gboolean*>(user_data);
48 *signalled = TRUE;
49 }

References FL_ATK_LIVE_POLITE, message, TRUE, and user_data.

Referenced by subscribe_signal().

## ◆ subscribe_signal()

static void subscribe_signal | ( | FlViewAccessible * | accessible,
|  | gboolean * | signalled,
|  | gboolean | assertive
| ) |  |
| static

Definition at line 65 of file fl_accessibility_handler_test.cc.

67 {
68 if (!atk_supports_announce()) {
69 return;
70 }
71
72 if (atk_get_major_version() == 2 && atk_get_minor_version() < 50) {
73 g_signal_connect(accessible, "announcement", G_CALLBACK(announcement_cb),
74 signalled);
75 } else {
76 g_signal_connect(accessible, "notification",
77 G_CALLBACK(assertive ? notification_assertive_cb
78 : notification_polite_cb),
79 signalled);
80 }
81 }
accessible
FlViewAccessible * accessible
Definition: fl_accessibility_handler.cc:41
announcement_cb
static void announcement_cb(FlViewAccessible *accessible, const gchar *message, gpointer user_data)
Definition: fl_accessibility_handler_test.cc:33
notification_polite_cb
static void notification_polite_cb(FlViewAccessible *accessible, const gchar *message, FlAtkLive politeness, gpointer user_data)
Definition: fl_accessibility_handler_test.cc:41
notification_assertive_cb
static void notification_assertive_cb(FlViewAccessible *accessible, const gchar *message, FlAtkLive politeness, gpointer user_data)
Definition: fl_accessibility_handler_test.cc:51
atk_supports_announce
static gboolean atk_supports_announce()
Definition: fl_accessibility_handler_test.cc:61

References accessible, announcement_cb(), atk_supports_announce(), notification_assertive_cb(), and notification_polite_cb().

Referenced by TEST().

## ◆ TEST() [1/4]

TEST | ( | FlAccessibilityHandlerTest | ,
|  | Announce |
| ) |  |

Definition at line 83 of file fl_accessibility_handler_test.cc.

83 {
84 flutter::testing::fl_ensure_gtk_init();
85
86 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
87 g_autoptr(FlEngine) engine =
88 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
89 FlView* view = fl_view_new_for_engine(engine);
90
91 gboolean signalled = FALSE;
92 subscribe_signal(fl_view_get_accessible(view), &signalled, FALSE);
93
94 g_autoptr(FlValue) message = fl_value_new_map();
95 fl_value_set_string_take(message, "type", fl_value_new_string("announce"));
96 g_autoptr(FlValue) data = fl_value_new_map();
97 fl_value_set_string(message, "data", data);
98 fl_value_set_string_take(data, "viewId",
99 fl_value_new_int(fl_view_get_id(view)));
100 fl_value_set_string_take(data, "message", fl_value_new_string("MESSAGE"));
101 fl_value_set_string_take(data, "textDirection",
102 fl_value_new_int(kTextDirectionLtr));
103
104 gboolean called = FALSE;
105 fl_mock_binary_messenger_send_standard_message(
106 messenger, "flutter/accessibility", message,
107 [](FlMockBinaryMessenger* messenger, FlValue* response,
108 gpointer user_data) {
109 EXPECT_EQ(fl_value_get_type(response), FL_VALUE_TYPE_NULL);
110 gboolean* called = static_cast<gboolean*>(user_data);
111 *called = TRUE;
112 },
113 &called);
114 EXPECT_TRUE(called);
115 if (atk_supports_announce()) {
116 EXPECT_TRUE(signalled);
117 }
118
119 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
120 }
view
FlView * view
Definition: fl_accessibility_handler.cc:40
g_autoptr
g_autoptr(FlEngine) engine
subscribe_signal
static void subscribe_signal(FlViewAccessible *accessible, gboolean *signalled, gboolean assertive)
Definition: fl_accessibility_handler_test.cc:65
kTextDirectionLtr
static constexpr int64_t kTextDirectionLtr
Definition: fl_accessibility_handler_test.cc:22
fl_binary_messenger_shutdown
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
Definition: fl_binary_messenger.cc:500
fl_engine_new_with_binary_messenger
FlEngine * fl_engine_new_with_binary_messenger(FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:701
fl_value_set_string
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:639
fl_value_set_string_take
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:650
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
FL_VALUE_TYPE_NULL
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:64
fl_view_get_accessible
FlViewAccessible * fl_view_get_accessible(FlView *self)
Definition: fl_view.cc:808
fl_view_new_for_engine
G_MODULE_EXPORT FlView * fl_view_new_for_engine(FlEngine *engine)
Definition: fl_view.cc:777
fl_view_get_id
G_MODULE_EXPORT int64_t fl_view_get_id(FlView *self)
Definition: fl_view.cc:796

References atk_supports_announce(), fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_get_type(), fl_value_new_int(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string(), fl_value_set_string_take(), FL_VALUE_TYPE_NULL, fl_view_get_accessible(), fl_view_get_id(), fl_view_new_for_engine(), g_autoptr(), kTextDirectionLtr, message, subscribe_signal(), TRUE, user_data, and view.

## ◆ TEST() [2/4]

TEST | ( | FlAccessibilityHandlerTest | ,
|  | AnnounceAssertive |
| ) |  |

Definition at line 122 of file fl_accessibility_handler_test.cc.

122 {
123 flutter::testing::fl_ensure_gtk_init();
124
125 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
126 g_autoptr(FlEngine) engine =
127 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
128 FlView* view = fl_view_new_for_engine(engine);
129
130 gboolean signalled = FALSE;
131 subscribe_signal(fl_view_get_accessible(view), &signalled, TRUE);
132
133 g_autoptr(FlValue) message = fl_value_new_map();
134 fl_value_set_string_take(message, "type", fl_value_new_string("announce"));
135 g_autoptr(FlValue) data = fl_value_new_map();
136 fl_value_set_string(message, "data", data);
137 fl_value_set_string_take(data, "viewId",
138 fl_value_new_int(fl_view_get_id(view)));
139 fl_value_set_string_take(data, "message", fl_value_new_string("MESSAGE"));
140 fl_value_set_string_take(data, "textDirection",
141 fl_value_new_int(kTextDirectionLtr));
142 // Add optional assertiveness (not used in ATK)
143 fl_value_set_string_take(data, "assertiveness",
144 fl_value_new_int(kAssertivenessAssertive));
145
146 gboolean called = FALSE;
147 fl_mock_binary_messenger_send_standard_message(
148 messenger, "flutter/accessibility", message,
149 [](FlMockBinaryMessenger* messenger, FlValue* response,
150 gpointer user_data) {
151 EXPECT_EQ(fl_value_get_type(response), FL_VALUE_TYPE_NULL);
152 gboolean* called = static_cast<gboolean*>(user_data);
153 *called = TRUE;
154 },
155 &called);
156 EXPECT_TRUE(called);
157 if (atk_supports_announce()) {
158 EXPECT_TRUE(signalled);
159 }
160
161 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
162 }
kAssertivenessAssertive
static constexpr int64_t kAssertivenessAssertive
Definition: fl_accessibility_handler_test.cc:23

References atk_supports_announce(), fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_get_type(), fl_value_new_int(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string(), fl_value_set_string_take(), FL_VALUE_TYPE_NULL, fl_view_get_accessible(), fl_view_get_id(), fl_view_new_for_engine(), g_autoptr(), kAssertivenessAssertive, kTextDirectionLtr, message, subscribe_signal(), TRUE, user_data, and view.

## ◆ TEST() [3/4]

TEST | ( | FlAccessibilityHandlerTest | ,
|  | AnnounceUnknownView |
| ) |  |

Definition at line 164 of file fl_accessibility_handler_test.cc.

164 {
165 flutter::testing::fl_ensure_gtk_init();
166
167 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
168 g_autoptr(FlEngine) engine =
169 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
170 FlView* view = fl_view_new_for_engine(engine);
171
172 gboolean signalled = FALSE;
173 subscribe_signal(fl_view_get_accessible(view), &signalled, FALSE);
174
175 g_autoptr(FlValue) message = fl_value_new_map();
176 fl_value_set_string_take(message, "type", fl_value_new_string("announce"));
177 g_autoptr(FlValue) data = fl_value_new_map();
178 fl_value_set_string(message, "data", data);
179 fl_value_set_string_take(data, "viewId", fl_value_new_int(999));
180 fl_value_set_string_take(data, "message", fl_value_new_string("MESSAGE"));
181 fl_value_set_string_take(data, "textDirection",
182 fl_value_new_int(kTextDirectionLtr));
183 // Add optional assertiveness (not used in ATK)
184 fl_value_set_string_take(data, "assertiveness",
185 fl_value_new_int(kAssertivenessAssertive));
186
187 gboolean called = FALSE;
188 fl_mock_binary_messenger_send_standard_message(
189 messenger, "flutter/accessibility", message,
190 [](FlMockBinaryMessenger* messenger, FlValue* response,
191 gpointer user_data) {
192 EXPECT_EQ(fl_value_get_type(response), FL_VALUE_TYPE_NULL);
193 gboolean* called = static_cast<gboolean*>(user_data);
194 *called = TRUE;
195 },
196 &called);
197 EXPECT_TRUE(called);
198 EXPECT_FALSE(signalled);
199
200 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
201 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_get_type(), fl_value_new_int(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string(), fl_value_set_string_take(), FL_VALUE_TYPE_NULL, fl_view_get_accessible(), fl_view_new_for_engine(), g_autoptr(), kAssertivenessAssertive, kTextDirectionLtr, message, subscribe_signal(), TRUE, user_data, and view.

## ◆ TEST() [4/4]

TEST | ( | FlAccessibilityHandlerTest | ,
|  | UnknownType |
| ) |  |

Definition at line 203 of file fl_accessibility_handler_test.cc.

203 {
204 flutter::testing::fl_ensure_gtk_init();
205
206 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
207 g_autoptr(FlEngine) engine =
208 fl_engine_new_with_binary_messenger(FL_BINARY_MESSENGER(messenger));
209 FlView* view = fl_view_new_for_engine(engine);
210
211 gboolean signalled = FALSE;
212 subscribe_signal(fl_view_get_accessible(view), &signalled, FALSE);
213
214 // Unknown type, ignored by embedder.
215 g_autoptr(FlValue) message = fl_value_new_map();
216 fl_value_set_string_take(message, "type", fl_value_new_string("UNKNOWN"));
217 fl_value_set_string_take(message, "data", fl_value_new_map());
218
219 gboolean called = FALSE;
220 fl_mock_binary_messenger_send_standard_message(
221 messenger, "flutter/accessibility", message,
222 [](FlMockBinaryMessenger* messenger, FlValue* response,
223 gpointer user_data) {
224 EXPECT_EQ(fl_value_get_type(response), FL_VALUE_TYPE_NULL);
225 gboolean* called = static_cast<gboolean*>(user_data);
226 *called = TRUE;
227 },
228 &called);
229 EXPECT_TRUE(called);
230 EXPECT_FALSE(signalled);
231
232 fl_binary_messenger_shutdown(FL_BINARY_MESSENGER(messenger));
233 }

References fl_binary_messenger_shutdown(), fl_engine_new_with_binary_messenger(), fl_value_get_type(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), FL_VALUE_TYPE_NULL, fl_view_get_accessible(), fl_view_new_for_engine(), g_autoptr(), message, subscribe_signal(), TRUE, user_data, and view.

## Variable Documentation

## ◆ kAssertivenessAssertive

constexpr int64_t kAssertivenessAssertive = 1
| static constexpr

Definition at line 23 of file fl_accessibility_handler_test.cc.

Referenced by TEST().

## ◆ kTextDirectionLtr

constexpr int64_t kTextDirectionLtr = 0
| static constexpr

Definition at line 22 of file fl_accessibility_handler_test.cc.

Referenced by TEST().