Flutter Linux Embedder
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
5
#include "
flutter/shell/platform/linux/fl_platform_channel.h
"
6
#include "
flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h
"
7
#include "
flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h
"
8
#include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"
9
10
#include "gtest/gtest.h"
11
12
TEST
(FlPlatformChannelTest, ExitResponse) {
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
28
FlPlatformChannelVTable
vtable;
29
g_autoptr(FlPlatformChannel) channel =
30
fl_platform_channel_new
(FL_BINARY_MESSENGER(messenger), &vtable,
nullptr
);
31
fl_platform_channel_system_request_app_exit
(
32
channel,
FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED
,
nullptr
,
33
[](GObject*
object
, GAsyncResult* result, gpointer
user_data
) {
34
g_autoptr(GError)
error
=
nullptr
;
35
FlPlatformChannelExitResponse
response;
36
gboolean success =
fl_platform_channel_system_request_app_exit_finish
(
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
}
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
fl_method_channel.h
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition:
fl_value.h:42
TEST
TEST(FlPlatformChannelTest, ExitResponse)
Definition:
fl_platform_channel_test.cc:12
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
fl_standard_method_codec.h
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
fl_platform_channel.h
shell
platform
linux
fl_platform_channel_test.cc
Generated by
1.8.17