Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 35b4924

Browse files
committed
FlEngine: allow passing mock messenger at construction time
1 parent be61bfa commit 35b4924

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

shell/platform/linux/fl_engine.cc

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ G_DEFINE_TYPE_WITH_CODE(
7373
G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(),
7474
fl_engine_plugin_registry_iface_init))
7575

76+
enum { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };
77+
7678
// Parse a locale into its components.
7779
static void parse_locale(const gchar* locale,
7880
gchar** language,
@@ -351,6 +353,22 @@ static void fl_engine_plugin_registry_iface_init(
351353
iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
352354
}
353355

356+
static void fl_engine_set_property(GObject* object,
357+
guint prop_id,
358+
const GValue* value,
359+
GParamSpec* pspec) {
360+
FlEngine* self = FL_ENGINE(object);
361+
switch (prop_id) {
362+
case PROP_BINARY_MESSENGER:
363+
g_set_object(&self->binary_messenger,
364+
FL_BINARY_MESSENGER(g_value_get_object(value)));
365+
break;
366+
default:
367+
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
368+
break;
369+
}
370+
}
371+
354372
static void fl_engine_dispose(GObject* object) {
355373
FlEngine* self = FL_ENGINE(object);
356374

@@ -397,6 +415,15 @@ static void fl_engine_dispose(GObject* object) {
397415

398416
static void fl_engine_class_init(FlEngineClass* klass) {
399417
G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
418+
G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
419+
420+
g_object_class_install_property(
421+
G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
422+
g_param_spec_object(
423+
"binary-messenger", "messenger", "Binary messenger",
424+
fl_binary_messenger_get_type(),
425+
static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
426+
G_PARAM_STATIC_STRINGS)));
400427
}
401428

402429
static void fl_engine_init(FlEngine* self) {
@@ -406,7 +433,6 @@ static void fl_engine_init(FlEngine* self) {
406433
FlutterEngineGetProcAddresses(&self->embedder_api);
407434

408435
self->texture_registrar = fl_texture_registrar_new(self);
409-
self->binary_messenger = fl_binary_messenger_new(self);
410436
}
411437

412438
FlEngine* fl_engine_new(FlDartProject* project, FlRenderer* renderer) {
@@ -416,6 +442,7 @@ FlEngine* fl_engine_new(FlDartProject* project, FlRenderer* renderer) {
416442
FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
417443
self->project = FL_DART_PROJECT(g_object_ref(project));
418444
self->renderer = FL_RENDERER(g_object_ref(renderer));
445+
self->binary_messenger = fl_binary_messenger_new(self);
419446
return self;
420447
}
421448

0 commit comments

Comments
 (0)