diff --git a/shell/platform/linux/fl_engine.cc b/shell/platform/linux/fl_engine.cc index 2592c63b730d8..87020dbcceb58 100644 --- a/shell/platform/linux/fl_engine.cc +++ b/shell/platform/linux/fl_engine.cc @@ -537,11 +537,12 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { custom_task_runners.platform_task_runner = &platform_task_runner; custom_task_runners.render_task_runner = &platform_task_runner; - g_autoptr(GPtrArray) command_line_args = fl_engine_get_switches(self); - // FlutterProjectArgs expects a full argv, so when processing it for flags - // the first item is treated as the executable and ignored. Add a dummy value - // so that all switches are used. + g_autoptr(GPtrArray) command_line_args = + g_ptr_array_new_with_free_func(g_free); g_ptr_array_insert(command_line_args, 0, g_strdup("flutter")); + for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) { + g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str())); + } gchar** dart_entrypoint_args = fl_dart_project_get_dart_entrypoint_arguments(self->project); @@ -1026,16 +1027,6 @@ void fl_engine_update_accessibility_features(FlEngine* self, int32_t flags) { self->engine, static_cast(flags)); } -GPtrArray* fl_engine_get_switches(FlEngine* self) { - g_return_val_if_fail(FL_IS_ENGINE(self), nullptr); - - GPtrArray* switches = g_ptr_array_new_with_free_func(g_free); - for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) { - g_ptr_array_add(switches, g_strdup(env_switch.c_str())); - } - return switches; -} - void fl_engine_request_app_exit(FlEngine* self) { g_return_if_fail(FL_IS_ENGINE(self)); fl_platform_handler_request_app_exit(self->platform_handler); diff --git a/shell/platform/linux/fl_engine_private.h b/shell/platform/linux/fl_engine_private.h index ed5d3197f04ec..f32557902567f 100644 --- a/shell/platform/linux/fl_engine_private.h +++ b/shell/platform/linux/fl_engine_private.h @@ -416,16 +416,6 @@ gboolean fl_engine_unregister_external_texture(FlEngine* engine, */ void fl_engine_update_accessibility_features(FlEngine* engine, int32_t flags); -/** - * fl_engine_get_switches: - * @engine: an #FlEngine. - * - * Determines the switches that should be passed to the Flutter engine. - * - * Returns: an array of switches to pass to the Flutter engine. - */ -GPtrArray* fl_engine_get_switches(FlEngine* engine); - /** * fl_engine_request_app_exit: * @engine: an #FlEngine. diff --git a/shell/platform/linux/fl_engine_test.cc b/shell/platform/linux/fl_engine_test.cc index 6a84f8d4c7320..62fcb48974f15 100644 --- a/shell/platform/linux/fl_engine_test.cc +++ b/shell/platform/linux/fl_engine_test.cc @@ -537,17 +537,6 @@ TEST(FlEngineTest, EmptyLocales) { } } -TEST(FlEngineTest, SwitchesEmpty) { - g_autoptr(FlEngine) engine = make_mock_engine(); - - // Clear the main environment variable, since test order is not guaranteed. - unsetenv("FLUTTER_ENGINE_SWITCHES"); - - g_autoptr(GPtrArray) switches = fl_engine_get_switches(engine); - - EXPECT_EQ(switches->len, 0U); -} - static void add_view_cb(GObject* object, GAsyncResult* result, gpointer user_data) { @@ -759,25 +748,4 @@ TEST(FlEngineTest, RemoveViewEngineError) { g_main_loop_run(loop); } -#ifndef FLUTTER_RELEASE -TEST(FlEngineTest, Switches) { - g_autoptr(FlEngine) engine = make_mock_engine(); - - setenv("FLUTTER_ENGINE_SWITCHES", "2", 1); - setenv("FLUTTER_ENGINE_SWITCH_1", "abc", 1); - setenv("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"", 1); - - g_autoptr(GPtrArray) switches = fl_engine_get_switches(engine); - EXPECT_EQ(switches->len, 2U); - EXPECT_STREQ(static_cast(g_ptr_array_index(switches, 0)), - "--abc"); - EXPECT_STREQ(static_cast(g_ptr_array_index(switches, 1)), - "--foo=\"bar, baz\""); - - unsetenv("FLUTTER_ENGINE_SWITCHES"); - unsetenv("FLUTTER_ENGINE_SWITCH_1"); - unsetenv("FLUTTER_ENGINE_SWITCH_2"); -} -#endif // !FLUTTER_RELEASE - // NOLINTEND(clang-analyzer-core.StackAddressEscape)