5#include "flutter/shell/platform/linux/testing/mock_binary_messenger.h"
6#include "flutter/shell/platform/linux/testing/mock_binary_messenger_response_handle.h"
11 fl_mock_binary_messenger,
13 MOCK_BINARY_MESSENGER,
16struct _FlMockBinaryMessenger {
17 GObject parent_instance;
23 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(
24 g_object_new(fl_mock_binary_messenger_get_type(),
nullptr));
26 return FL_BINARY_MESSENGER(
self);
29MockBinaryMessenger::MockBinaryMessenger()
33 if (FL_IS_BINARY_MESSENGER(instance_)) {
34 g_clear_object(&instance_);
38MockBinaryMessenger::operator FlBinaryMessenger*() {
43 return message_handlers_.at(channel) !=
nullptr;
50 message_handlers_[channel] = handler;
57 if (response_handles_[channel] ==
nullptr) {
58 response_handles_[channel] = FL_BINARY_MESSENGER_RESPONSE_HANDLE(
61 handler(instance_, channel,
message, response_handles_[channel],
62 user_datas_[channel]);
66 FlBinaryMessengerInterface* iface);
69 FlMockBinaryMessenger,
70 fl_mock_binary_messenger,
72 G_IMPLEMENT_INTERFACE(fl_binary_messenger_get_type(),
75static void fl_mock_binary_messenger_class_init(
76 FlMockBinaryMessengerClass* klass) {}
79 FlBinaryMessenger* messenger,
83 GDestroyNotify destroy_notify) {
84 g_return_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger));
85 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(messenger);
87 self->mock->fl_binary_messenger_set_message_handler_on_channel(
88 messenger, channel, handler,
user_data, destroy_notify);
92 FlBinaryMessenger* messenger,
93 FlBinaryMessengerResponseHandle* response_handle,
96 g_return_val_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger),
false);
97 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(messenger);
98 return self->mock->fl_binary_messenger_send_response(
99 messenger, response_handle, response,
error);
103 FlBinaryMessenger* messenger,
104 const gchar* channel,
106 GCancellable* cancellable,
109 g_return_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger));
110 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(messenger);
111 self->mock->fl_binary_messenger_send_on_channel(
116 FlBinaryMessenger* messenger,
119 g_return_val_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger),
nullptr);
120 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(messenger);
121 return self->mock->fl_binary_messenger_send_on_channel_finish(messenger,
126 FlBinaryMessenger* messenger,
127 const gchar* channel,
129 g_return_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger));
130 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(messenger);
131 self->mock->fl_binary_messenger_resize_channel(messenger, channel, new_size);
135 FlBinaryMessenger* messenger,
136 const gchar* channel,
138 g_return_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger));
139 FlMockBinaryMessenger*
self = FL_MOCK_BINARY_MESSENGER(messenger);
140 self->mock->fl_binary_messenger_set_warns_on_channel_overflow(messenger,
145 FlBinaryMessengerInterface* iface) {
146 iface->set_message_handler_on_channel =
150 iface->send_on_channel_finish =
153 iface->set_warns_on_channel_overflow =
bool HasMessageHandler(const gchar *channel) const
void ReceiveMessage(const gchar *channel, GBytes *message)
void SetMessageHandler(const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data)
G_MODULE_EXPORT GObject typedef void(* FlBinaryMessengerMessageHandler)(FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, FlBinaryMessengerResponseHandle *response_handle, gpointer user_data)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
static void fl_mock_binary_messenger_set_message_handler_on_channel(FlBinaryMessenger *messenger, const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
static void fl_mock_binary_messenger_iface_init(FlBinaryMessengerInterface *iface)
static FlBinaryMessenger * fl_mock_binary_messenger_new(MockBinaryMessenger *mock)
G_DECLARE_FINAL_TYPE(FlMockBinaryMessenger, fl_mock_binary_messenger, FL, MOCK_BINARY_MESSENGER, GObject) struct _FlMockBinaryMessenger
static void fl_mock_binary_messenger_resize_channel(FlBinaryMessenger *messenger, const gchar *channel, int64_t new_size)
static gboolean fl_mock_binary_messenger_send_response(FlBinaryMessenger *messenger, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error)
static void fl_mock_binary_messenger_set_warns_on_channel_overflow(FlBinaryMessenger *messenger, const gchar *channel, bool warns)
static void fl_mock_binary_messenger_send_on_channel(FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
static void fl_mock_binary_messenger_init(FlMockBinaryMessenger *self)
G_DEFINE_TYPE_WITH_CODE(FlMockBinaryMessenger, fl_mock_binary_messenger, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_binary_messenger_get_type(), fl_mock_binary_messenger_iface_init)) static void fl_mock_binary_messenger_class_init(FlMockBinaryMessengerClass *klass)
static GBytes * fl_mock_binary_messenger_send_on_channel_finish(FlBinaryMessenger *messenger, GAsyncResult *result, GError **error)
FlMockBinaryMessengerResponseHandle * fl_mock_binary_messenger_response_handle_new()