Flutter Engine
 
Loading...
Searching...
No Matches
fl_platform_channel_test.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
9
10#include "gtest/gtest.h"
11
12TEST(FlPlatformChannelTest, ExitResponse) {
13 g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
14
15 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
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}
g_autoptr(GMutexLocker) locker
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
const gchar * channel
FlMockBinaryMessenger * fl_mock_binary_messenger_new()
void fl_mock_binary_messenger_set_json_method_channel(FlMockBinaryMessenger *self, const gchar *channel, FlMockBinaryMessengerMethodChannelHandler handler, gpointer user_data)
const uint8_t uint32_t uint32_t GError ** error
gboolean fl_platform_channel_system_request_app_exit_finish(GObject *object, GAsyncResult *result, FlPlatformChannelExitResponse *exit_response, GError **error)
void fl_platform_channel_system_request_app_exit(FlPlatformChannel *self, FlPlatformChannelExitType type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
FlPlatformChannel * fl_platform_channel_new(FlBinaryMessenger *messenger, FlPlatformChannelVTable *vtable, gpointer user_data)
FlPlatformChannelExitResponse
@ FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT
@ FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED
TEST(FlPlatformChannelTest, ExitResponse)
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition fl_value.cc:366
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:650
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition fl_value.cc:276
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
const char * name
Definition fuchsia.cc:49