Remove unnecessary method for getting engine switches (command line). (flutter/engine#56265)
This method simply wrapped a common method, which is simpler to use directly. The test only tested this common method, which already has tests in common/.
This commit is contained in:
@@ -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<FlutterAccessibilityFeature>(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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<const char*>(g_ptr_array_index(switches, 0)),
|
||||
"--abc");
|
||||
EXPECT_STREQ(static_cast<const char*>(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)
|
||||
|
||||
Reference in New Issue
Block a user