Flutter Linux Embedder
fl_platform_channel_test.cc File Reference
#include "flutter/shell/platform/linux/fl_platform_channel.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
#include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (FlPlatformChannelTest, ExitResponse)
 

Function Documentation

◆ TEST()

TEST ( FlPlatformChannelTest  ,
ExitResponse   
)

Definition at line 12 of file fl_platform_channel_test.cc.

12  {
13  g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
14 
15  g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
16  fl_mock_binary_messenger_set_json_method_channel(
17  messenger, "flutter/platform",
18  [](FlMockBinaryMessenger* messenger, GTask* task, const gchar* name,
19  FlValue* args, gpointer user_data) {
20  EXPECT_STREQ(name, "System.requestAppExit");
21  g_autoptr(FlValue) return_value = fl_value_new_map();
22  fl_value_set_string_take(return_value, "response",
23  fl_value_new_string("exit"));
24  return FL_METHOD_RESPONSE(fl_method_success_response_new(return_value));
25  },
26  nullptr);
27 
29  g_autoptr(FlPlatformChannel) channel =
30  fl_platform_channel_new(FL_BINARY_MESSENGER(messenger), &vtable, nullptr);
33  [](GObject* object, GAsyncResult* result, gpointer user_data) {
34  g_autoptr(GError) error = nullptr;
37  object, result, &response, &error);
38 
39  EXPECT_TRUE(success);
40  EXPECT_EQ(response, FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT);
41 
42  g_main_loop_quit(static_cast<GMainLoop*>(user_data));
43  },
44  loop);
45 
46  g_main_loop_run(loop);
47 }

References args, error, fl_method_success_response_new(), FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT, FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED, fl_platform_channel_new(), fl_platform_channel_system_request_app_exit(), fl_platform_channel_system_request_app_exit_finish(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), and user_data.

fl_platform_channel_system_request_app_exit_finish
gboolean fl_platform_channel_system_request_app_exit_finish(GObject *object, GAsyncResult *result, FlPlatformChannelExitResponse *exit_response, GError **error)
Definition: fl_platform_channel.cc:268
fl_value_set_string_take
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:650
FlPlatformChannelExitResponse
FlPlatformChannelExitResponse
Definition: fl_platform_channel.h:18
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
fl_method_success_response_new
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
Definition: fl_method_response.cc:126
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
fl_platform_channel_system_request_app_exit
void fl_platform_channel_system_request_app_exit(FlPlatformChannel *self, FlPlatformChannelExitType type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_platform_channel.cc:243
FlPlatformChannelVTable
Definition: fl_platform_channel.h:36
FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED
@ FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED
Definition: fl_platform_channel.h:15
fl_platform_channel_new
FlPlatformChannel * fl_platform_channel_new(FlBinaryMessenger *messenger, FlPlatformChannelVTable *vtable, gpointer user_data)
Definition: fl_platform_channel.cc:222
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT
@ FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT
Definition: fl_platform_channel.h:20
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276