Skip to content

Commit

Permalink
Fix typos and fix some env var state leakage in tests (flutter#22576)
Browse files Browse the repository at this point in the history
This just fixes some typos, and a small state leak in some of the tests that set env variables.
  • Loading branch information
gspencergoog authored Nov 18, 2020
1 parent 4e61986 commit 4b859ce
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
///
/// The `scale` parameter will scale the `width` and `height` by the specified amount,
/// and keep track of the scale. The scales of placeholders added can be accessed
/// through [placeholderScales]. This is primarily used for acessibility scaling.
/// through [placeholderScales]. This is primarily used for accessibility scaling.
void addPlaceholder(double width, double height, PlaceholderAlignment alignment, {
double scale = 1.0,
double? baselineOffset,
Expand Down
6 changes: 4 additions & 2 deletions shell/platform/common/cpp/engine_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ std::vector<std::string> GetSwitchesFromEnvironment() {
const char* switch_count_key = "FLUTTER_ENGINE_SWITCHES";
const int kMaxSwitchCount = 50;
const char* switch_count_string = std::getenv(switch_count_key);
int switch_count = std::min(
kMaxSwitchCount, switch_count_string ? atoi(switch_count_string) : 0);
if (!switch_count_string) {
return switches;
}
int switch_count = std::min(kMaxSwitchCount, atoi(switch_count_string));
for (int i = 1; i <= switch_count; ++i) {
std::ostringstream switch_key;
switch_key << "FLUTTER_ENGINE_SWITCH_" << i;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_basic_message_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct _FlBasicMessageChannelResponseHandle {
FlBinaryMessengerResponseHandle* response_handle;
};

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_basic_message_channel_get_type();

G_DEFINE_TYPE(FlBasicMessageChannel, fl_basic_message_channel, G_TYPE_OBJECT)
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_binary_messenger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TEST(FlBinaryMessengerTest, ReceiveMessage) {
fl_binary_messenger_set_message_handler_on_channel(
messenger, "test/responses", response_cb, loop, nullptr);

// Triggger the engine to send a message.
// Trigger the engine to send a message.
const char* text = "Marco!";
g_autoptr(GBytes) message = g_bytes_new(text, strlen(text));
fl_binary_messenger_send_on_channel(messenger, "test/send-message", message,
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/linux/fl_dart_project_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ TEST(FlDartProjectTest, Switches) {
"--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
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ gboolean fl_engine_send_platform_message_response(

if (result != kSuccess) {
g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
"Failed to send platorm message response");
"Failed to send platform message response");
return FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_engine_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ FlutterEngineProcTable* fl_engine_get_embedder_api(FlEngine* engine);
* @destroy_notify: (allow-none): a function which gets called to free
* @user_data, or %NULL.
*
* Registers the function called when a platform message is reveived. Call
* Registers the function called when a platform message is received. Call
* fl_engine_send_platform_message_response() with the response to this message.
* Ownership of #FlutterPlatformMessageResponseHandle is
* transferred to the caller, and the message must be responded to to avoid
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct _FlEventChannelResponseHandle {
FlBinaryMessengerResponseHandle* response_handle;
};

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_event_channel_get_type();

G_DEFINE_TYPE(FlEventChannel, fl_event_channel, G_TYPE_OBJECT)
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/linux/fl_json_method_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,

if (fl_value_get_type(value) != FL_VALUE_TYPE_MAP) {
g_set_error(error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED,
"Expected JSON map in method resonse, got %d instead",
"Expected JSON map in method response, got %d instead",
fl_value_get_type(value));
return FALSE;
}

FlValue* method_value = fl_value_lookup_string(value, kMethodKey);
if (method_value == nullptr) {
g_set_error(error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED,
"Missing JSON method field in method resonse");
"Missing JSON method field in method response");
return FALSE;
}
if (fl_value_get_type(method_value) != FL_VALUE_TYPE_STRING) {
Expand Down Expand Up @@ -138,7 +138,7 @@ static FlMethodResponse* fl_json_method_codec_decode_response(

if (fl_value_get_type(value) != FL_VALUE_TYPE_LIST) {
g_set_error(error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED,
"Expected JSON list in method resonse, got %d instead",
"Expected JSON list in method response, got %d instead",
fl_value_get_type(value));
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_message_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

G_DEFINE_QUARK(fl_message_codec_error_quark, fl_message_codec_error)

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_message_codec_get_type();

G_DEFINE_TYPE(FlMessageCodec, fl_message_codec, G_TYPE_OBJECT)
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_method_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct _FlMethodChannel {
GDestroyNotify method_call_handler_destroy_notify;
};

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_method_channel_get_type();

G_DEFINE_TYPE(FlMethodChannel, fl_method_channel, G_TYPE_OBJECT)
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_method_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <gmodule.h>

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_method_codec_get_type();

G_DEFINE_TYPE(FlMethodCodec, fl_method_codec, G_TYPE_OBJECT)
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_method_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct _FlMethodNotImplementedResponse {
FlMethodResponse parent_instance;
};

// Added here to stop the compiler from optimising these functions away.
// Added here to stop the compiler from optimizing these functions away.
G_MODULE_EXPORT GType fl_method_response_get_type();
G_MODULE_EXPORT GType fl_method_success_response_get_type();
G_MODULE_EXPORT GType fl_method_error_response_get_type();
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_plugin_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct _FlPluginRegistrar {
FlBinaryMessenger* messenger;
};

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_plugin_registrar_get_type();

G_DEFINE_TYPE(FlPluginRegistrar, fl_plugin_registrar, G_TYPE_OBJECT)
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_plugin_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <gmodule.h>

// Added here to stop the compiler from optimising this function away.
// Added here to stop the compiler from optimizing this function away.
G_MODULE_EXPORT GType fl_plugin_registry_get_type();

G_DEFINE_INTERFACE(FlPluginRegistry, fl_plugin_registry, G_TYPE_OBJECT)
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void fl_value_destroy(gpointer value) {
}

// Finds the index of a key in a FlValueMap.
// FIXME(robert-ancell) This is highly inefficient, and should be optimised if
// FIXME(robert-ancell) This is highly inefficient, and should be optimized if
// necessary.
static ssize_t fl_value_lookup_index(FlValue* self, FlValue* key) {
g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, -1);
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/linux/public/flutter_linux/fl_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ FlValue* fl_value_get_map_value(FlValue* value, size_t index);
* fl_value_equal(). Calling this with an #FlValue that is not of type
* #FL_VALUE_TYPE_MAP is a programming error.
*
* Map lookups are not optimised for performance - if you have a large map or
* Map lookups are not optimized for performance - if you have a large map or
* need frequent access you should copy the data into another structure, e.g.
* #GHashTable.
*
Expand All @@ -560,7 +560,7 @@ FlValue* fl_value_lookup(FlValue* value, FlValue* key);
* fl_value_equal(). Calling this with an #FlValue that is not of type
* #FL_VALUE_TYPE_MAP is a programming error.
*
* Map lookups are not optimised for performance - if you have a large map or
* Map lookups are not optimized for performance - if you have a large map or
* need frequent access you should copy the data into another structure, e.g.
* #GHashTable.
*
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/public/flutter_linux/fl_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ G_DECLARE_FINAL_TYPE(FlView, fl_view, FL, VIEW, GtkWidget)
* gtk_widget_show (GTK_WIDGET (view));
* gtk_container_add (GTK_CONTAINER (parent), view);
*
* FlBinaryMessenger *mesenger =
* FlBinaryMessenger *messenger =
* fl_engine_get_binary_messenger (fl_view_get_engine (view));
* setup_channels_or_plugins (messenger);
* ]|
Expand Down

0 comments on commit 4b859ce

Please sign in to comment.