|
Flutter Linux Embedder
|
|
Go to the source code of this file.
|
| TEST (FlEngineTest, WindowMetrics) |
|
| TEST (FlEngineTest, MousePointer) |
|
| TEST (FlEngineTest, PointerPanZoom) |
|
| TEST (FlEngineTest, DispatchSemanticsAction) |
|
| TEST (FlEngineTest, PlatformMessage) |
|
| TEST (FlEngineTest, PlatformMessageResponse) |
|
| TEST (FlEngineTest, SettingsPlugin) |
|
void | on_pre_engine_restart_cb (FlEngine *engine, gpointer user_data) |
|
void | on_pre_engine_restart_destroy_notify (gpointer user_data) |
|
| TEST (FlEngineTest, OnPreEngineRestart) |
|
| TEST (FlEngineTest, DartEntrypointArgs) |
|
| TEST (FlEngineTest, Locales) |
|
| TEST (FlEngineTest, SwitchesEmpty) |
|
| TEST (FlEngineTest, SendWindowStateEvent) |
|
| TEST (FlEngineTest, Switches) |
|
◆ on_pre_engine_restart_cb()
void on_pre_engine_restart_cb |
( |
FlEngine * |
engine, |
|
|
gpointer |
user_data |
|
) |
| |
◆ on_pre_engine_restart_destroy_notify()
void on_pre_engine_restart_destroy_notify |
( |
gpointer |
user_data | ) |
|
◆ TEST() [1/13]
TEST |
( |
FlEngineTest |
, |
|
|
DartEntrypointArgs |
|
|
) |
| |
Definition at line 330 of file fl_engine_test.cc.
333 GPtrArray* args_array = g_ptr_array_new();
334 g_ptr_array_add(args_array,
const_cast<char*
>(
"arg_one"));
335 g_ptr_array_add(args_array,
const_cast<char*
>(
"arg_two"));
336 g_ptr_array_add(args_array,
const_cast<char*
>(
"arg_three"));
337 g_ptr_array_add(args_array,
nullptr);
338 gchar**
args =
reinterpret_cast<gchar**
>(g_ptr_array_free(args_array,
false));
342 g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
346 embedder_api->Initialize = MOCK_ENGINE_PROC(
347 Initialize, ([&called, &set_args =
args](
348 size_t version,
const FlutterRendererConfig* config,
350 FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
352 EXPECT_NE(set_args,
args->dart_entrypoint_argv);
353 EXPECT_EQ(
args->dart_entrypoint_argc, 3);
358 g_autoptr(GError)
error =
nullptr;
360 EXPECT_EQ(
error,
nullptr);
References args, error, fl_dart_project_new(), fl_dart_project_set_dart_entrypoint_arguments(), fl_engine_get_embedder_api(), fl_engine_start(), and user_data.
◆ TEST() [2/13]
TEST |
( |
FlEngineTest |
, |
|
|
DispatchSemanticsAction |
|
|
) |
| |
Definition at line 118 of file fl_engine_test.cc.
123 embedder_api->DispatchSemanticsAction = MOCK_ENGINE_PROC(
124 DispatchSemanticsAction,
125 ([&called](
auto engine, uint64_t
id, FlutterSemanticsAction action,
126 const uint8_t* data,
size_t data_length) {
127 EXPECT_EQ(
id,
static_cast<uint64_t
>(42));
128 EXPECT_EQ(action, kFlutterSemanticsActionTap);
129 EXPECT_EQ(data_length,
static_cast<size_t>(4));
130 EXPECT_EQ(data[0],
't');
131 EXPECT_EQ(data[1],
'e');
132 EXPECT_EQ(data[2],
's');
133 EXPECT_EQ(data[3],
't');
139 g_autoptr(GError)
error =
nullptr;
141 EXPECT_EQ(
error,
nullptr);
142 g_autoptr(GBytes) data = g_bytes_new_static(
"test", 4);
References error, fl_engine_dispatch_semantics_action(), fl_engine_get_embedder_api(), fl_engine_start(), and make_mock_engine().
◆ TEST() [3/13]
TEST |
( |
FlEngineTest |
, |
|
|
Locales |
|
|
) |
| |
Definition at line 365 of file fl_engine_test.cc.
366 gchar* initial_language = g_strdup(g_getenv(
"LANGUAGE"));
367 g_setenv(
"LANGUAGE",
"de:en_US",
TRUE);
370 g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
374 embedder_api->UpdateLocales = MOCK_ENGINE_PROC(
375 UpdateLocales, ([&called](
auto engine,
const FlutterLocale** locales,
376 size_t locales_count) {
379 EXPECT_EQ(locales_count,
static_cast<size_t>(4));
381 EXPECT_STREQ(locales[0]->language_code,
"de");
382 EXPECT_STREQ(locales[0]->country_code,
nullptr);
383 EXPECT_STREQ(locales[0]->script_code,
nullptr);
384 EXPECT_STREQ(locales[0]->variant_code,
nullptr);
386 EXPECT_STREQ(locales[1]->language_code,
"en");
387 EXPECT_STREQ(locales[1]->country_code,
"US");
388 EXPECT_STREQ(locales[1]->script_code,
nullptr);
389 EXPECT_STREQ(locales[1]->variant_code,
nullptr);
391 EXPECT_STREQ(locales[2]->language_code,
"en");
392 EXPECT_STREQ(locales[2]->country_code,
nullptr);
393 EXPECT_STREQ(locales[2]->script_code,
nullptr);
394 EXPECT_STREQ(locales[2]->variant_code,
nullptr);
396 EXPECT_STREQ(locales[3]->language_code,
"C");
397 EXPECT_STREQ(locales[3]->country_code,
nullptr);
398 EXPECT_STREQ(locales[3]->script_code,
nullptr);
399 EXPECT_STREQ(locales[3]->variant_code,
nullptr);
404 g_autoptr(GError)
error =
nullptr;
406 EXPECT_EQ(
error,
nullptr);
410 if (initial_language) {
411 g_setenv(
"LANGUAGE", initial_language,
TRUE);
413 g_unsetenv(
"LANGUAGE");
415 g_free(initial_language);
References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_start(), and TRUE.
◆ TEST() [4/13]
TEST |
( |
FlEngineTest |
, |
|
|
MousePointer |
|
|
) |
| |
Definition at line 45 of file fl_engine_test.cc.
50 embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
52 ([&called](
auto engine,
const FlutterPointerEvent* events,
53 size_t events_count) {
55 EXPECT_EQ(events_count,
static_cast<size_t>(1));
56 EXPECT_EQ(events[0].phase, kDown);
57 EXPECT_EQ(events[0].timestamp,
static_cast<size_t>(1234567890));
58 EXPECT_EQ(events[0].x, 800);
59 EXPECT_EQ(events[0].y, 600);
60 EXPECT_EQ(events[0].device,
static_cast<int32_t
>(0));
61 EXPECT_EQ(events[0].signal_kind, kFlutterPointerSignalKindScroll);
62 EXPECT_EQ(events[0].scroll_delta_x, 1.2);
63 EXPECT_EQ(events[0].scroll_delta_y, -3.4);
64 EXPECT_EQ(events[0].device_kind, kFlutterPointerDeviceKindMouse);
65 EXPECT_EQ(events[0].buttons, kFlutterPointerButtonMouseSecondary);
70 g_autoptr(GError)
error =
nullptr;
72 EXPECT_EQ(
error,
nullptr);
74 kFlutterPointerDeviceKindMouse, 1.2, -3.4,
75 kFlutterPointerButtonMouseSecondary);
References error, fl_engine_get_embedder_api(), fl_engine_send_mouse_pointer_event(), fl_engine_start(), and make_mock_engine().
◆ TEST() [5/13]
TEST |
( |
FlEngineTest |
, |
|
|
OnPreEngineRestart |
|
|
) |
| |
Definition at line 282 of file fl_engine_test.cc.
286 OnPreEngineRestartCallback
callback;
287 void* callback_user_data;
290 embedder_api->Initialize = MOCK_ENGINE_PROC(
291 Initialize, ([&
callback, &callback_user_data, &called](
292 size_t version,
const FlutterRendererConfig* config,
294 FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
302 g_autoptr(GError)
error =
nullptr;
304 EXPECT_EQ(
error,
nullptr);
326 g_object_unref(engine);
327 EXPECT_EQ(count, 11);
References args, callback, error, fl_engine_get_embedder_api(), fl_engine_set_on_pre_engine_restart_handler(), fl_engine_start(), make_mock_engine(), on_pre_engine_restart_cb(), on_pre_engine_restart_destroy_notify(), and user_data.
◆ TEST() [6/13]
TEST |
( |
FlEngineTest |
, |
|
|
PlatformMessage |
|
|
) |
| |
Definition at line 150 of file fl_engine_test.cc.
155 FlutterEngineSendPlatformMessageFnPtr old_handler =
156 embedder_api->SendPlatformMessage;
157 embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
159 ([&called, old_handler](
auto engine,
160 const FlutterPlatformMessage* message) {
161 if (strcmp(message->channel,
"test") != 0) {
162 return old_handler(engine, message);
167 EXPECT_EQ(message->message_size,
static_cast<size_t>(4));
168 EXPECT_EQ(message->message[0],
't');
169 EXPECT_EQ(message->message[1],
'e');
170 EXPECT_EQ(message->message[2],
's');
171 EXPECT_EQ(message->message[3],
't');
176 g_autoptr(GError)
error =
nullptr;
178 EXPECT_EQ(
error,
nullptr);
179 g_autoptr(GBytes) message = g_bytes_new_static(
"test", 4);
References error, fl_engine_get_embedder_api(), fl_engine_send_platform_message(), fl_engine_start(), and make_mock_engine().
◆ TEST() [7/13]
TEST |
( |
FlEngineTest |
, |
|
|
PlatformMessageResponse |
|
|
) |
| |
Definition at line 187 of file fl_engine_test.cc.
192 embedder_api->SendPlatformMessageResponse = MOCK_ENGINE_PROC(
193 SendPlatformMessageResponse,
194 ([&called](
auto engine,
195 const FlutterPlatformMessageResponseHandle* handle,
196 const uint8_t* data,
size_t data_length) {
201 reinterpret_cast<const FlutterPlatformMessageResponseHandle*
>(42));
202 EXPECT_EQ(data_length,
static_cast<size_t>(4));
203 EXPECT_EQ(data[0],
't');
204 EXPECT_EQ(data[1],
'e');
205 EXPECT_EQ(data[2],
's');
206 EXPECT_EQ(data[3],
't');
211 g_autoptr(GError)
error =
nullptr;
213 EXPECT_EQ(
error,
nullptr);
214 g_autoptr(GBytes) response = g_bytes_new_static(
"test", 4);
216 engine,
reinterpret_cast<const FlutterPlatformMessageResponseHandle*
>(42),
218 EXPECT_EQ(
error,
nullptr);
References error, fl_engine_get_embedder_api(), fl_engine_send_platform_message_response(), fl_engine_start(), and make_mock_engine().
◆ TEST() [8/13]
TEST |
( |
FlEngineTest |
, |
|
|
PointerPanZoom |
|
|
) |
| |
Definition at line 81 of file fl_engine_test.cc.
86 embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
88 ([&called](
auto engine,
const FlutterPointerEvent* events,
89 size_t events_count) {
91 EXPECT_EQ(events_count,
static_cast<size_t>(1));
92 EXPECT_EQ(events[0].phase, kPanZoomUpdate);
93 EXPECT_EQ(events[0].timestamp,
static_cast<size_t>(1234567890));
94 EXPECT_EQ(events[0].x, 800);
95 EXPECT_EQ(events[0].y, 600);
96 EXPECT_EQ(events[0].device,
static_cast<int32_t
>(1));
97 EXPECT_EQ(events[0].signal_kind, kFlutterPointerSignalKindNone);
98 EXPECT_EQ(events[0].pan_x, 1.5);
99 EXPECT_EQ(events[0].pan_y, 2.5);
100 EXPECT_EQ(events[0].scale, 3.5);
101 EXPECT_EQ(events[0].rotation, 4.5);
102 EXPECT_EQ(events[0].device_kind, kFlutterPointerDeviceKindTrackpad);
103 EXPECT_EQ(events[0].buttons, 0);
108 g_autoptr(GError)
error =
nullptr;
110 EXPECT_EQ(
error,
nullptr);
112 kPanZoomUpdate, 1.5, 2.5, 3.5, 4.5);
References error, fl_engine_get_embedder_api(), fl_engine_send_pointer_pan_zoom_event(), fl_engine_start(), and make_mock_engine().
◆ TEST() [9/13]
TEST |
( |
FlEngineTest |
, |
|
|
SendWindowStateEvent |
|
|
) |
| |
Definition at line 429 of file fl_engine_test.cc.
435 embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
437 ([&called, &
state](
auto engine,
const FlutterPlatformMessage* message) {
438 EXPECT_STREQ(message->channel,
"flutter/lifecycle");
441 g_autoptr(GBytes) data =
442 g_bytes_new(message->message, message->message_size);
443 g_autoptr(GError)
error =
nullptr;
445 FL_MESSAGE_CODEC(codec), data, &
error);
References flutter::AppLifecycleStateToString(), error, fl_engine_get_embedder_api(), fl_engine_send_window_state_event(), fl_message_codec_decode_message(), fl_string_codec_new(), fl_value_get_string(), flutter::kHidden, flutter::kInactive, flutter::kResumed, make_mock_engine(), and state.
◆ TEST() [10/13]
TEST |
( |
FlEngineTest |
, |
|
|
SettingsPlugin |
|
|
) |
| |
Definition at line 224 of file fl_engine_test.cc.
229 embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
231 ([&called](
auto engine,
const FlutterPlatformMessage* message) {
234 EXPECT_STREQ(message->channel,
"flutter/settings");
237 g_autoptr(GBytes) data =
238 g_bytes_new(message->message, message->message_size);
239 g_autoptr(GError)
error =
nullptr;
241 FL_MESSAGE_CODEC(codec), data, &
error);
242 EXPECT_NE(settings,
nullptr);
243 EXPECT_EQ(
error,
nullptr);
247 EXPECT_NE(text_scale_factor,
nullptr);
250 FlValue* always_use_24hr_format =
252 EXPECT_NE(always_use_24hr_format,
nullptr);
258 EXPECT_NE(platform_brightness,
nullptr);
264 g_autoptr(GError)
error =
nullptr;
266 EXPECT_EQ(
error,
nullptr);
References error, fl_engine_get_embedder_api(), fl_engine_start(), fl_json_message_codec_new(), fl_message_codec_decode_message(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_STRING, and make_mock_engine().
◆ TEST() [11/13]
TEST |
( |
FlEngineTest |
, |
|
|
Switches |
|
|
) |
| |
Definition at line 466 of file fl_engine_test.cc.
469 setenv(
"FLUTTER_ENGINE_SWITCHES",
"2", 1);
470 setenv(
"FLUTTER_ENGINE_SWITCH_1",
"abc", 1);
471 setenv(
"FLUTTER_ENGINE_SWITCH_2",
"foo=\"bar, baz\"", 1);
474 EXPECT_EQ(switches->len, 2U);
475 EXPECT_STREQ(
static_cast<const char*
>(g_ptr_array_index(switches, 0)),
477 EXPECT_STREQ(
static_cast<const char*
>(g_ptr_array_index(switches, 1)),
478 "--foo=\"bar, baz\"");
480 unsetenv(
"FLUTTER_ENGINE_SWITCHES");
481 unsetenv(
"FLUTTER_ENGINE_SWITCH_1");
482 unsetenv(
"FLUTTER_ENGINE_SWITCH_2");
References fl_engine_get_switches(), and make_mock_engine().
◆ TEST() [12/13]
TEST |
( |
FlEngineTest |
, |
|
|
SwitchesEmpty |
|
|
) |
| |
◆ TEST() [13/13]
TEST |
( |
FlEngineTest |
, |
|
|
WindowMetrics |
|
|
) |
| |
Definition at line 20 of file fl_engine_test.cc.
25 embedder_api->SendWindowMetricsEvent = MOCK_ENGINE_PROC(
26 SendWindowMetricsEvent,
27 ([&called](
auto engine,
const FlutterWindowMetricsEvent*
event) {
29 EXPECT_EQ(
event->width,
static_cast<size_t>(3840));
30 EXPECT_EQ(
event->height,
static_cast<size_t>(2160));
31 EXPECT_EQ(
event->pixel_ratio, 2.0);
36 g_autoptr(GError)
error =
nullptr;
38 EXPECT_EQ(
error,
nullptr);
References error, event, fl_engine_get_embedder_api(), fl_engine_send_window_metrics_event(), fl_engine_start(), and make_mock_engine().
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
void on_pre_engine_restart_destroy_notify(gpointer user_data)
typedefG_BEGIN_DECLS struct _FlValue FlValue
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
void fl_engine_dispatch_semantics_action(FlEngine *self, uint64_t id, FlutterSemanticsAction action, GBytes *data)
void fl_engine_send_window_metrics_event(FlEngine *self, size_t width, size_t height, double pixel_ratio)
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
const G_MODULE_EXPORT gchar * fl_value_get_string(FlValue *self)
static FlEngine * make_mock_engine()
G_MODULE_EXPORT FlValue * fl_message_codec_decode_message(FlMessageCodec *self, GBytes *message, GError **error)
void fl_engine_send_pointer_pan_zoom_event(FlEngine *self, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
G_MODULE_EXPORT void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject *self, char **argv)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, FlutterPointerDeviceKind device_kind, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
void fl_engine_send_platform_message(FlEngine *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
void on_pre_engine_restart_cb(FlEngine *engine, gpointer user_data)
G_MODULE_EXPORT FlStringCodec * fl_string_codec_new()
gboolean fl_engine_start(FlEngine *self, GError **error)
void fl_engine_send_window_state_event(FlEngine *self, gboolean visible, gboolean focused)
constexpr const char * AppLifecycleStateToString(AppLifecycleState state)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GPtrArray * fl_engine_get_switches(FlEngine *self)
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
void fl_engine_set_on_pre_engine_restart_handler(FlEngine *self, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)