Flutter Engine
The Flutter Engine
mock_binary_messenger.h
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#ifndef FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_BINARY_MESSENGER_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_BINARY_MESSENGER_H_
7
8#include <unordered_map>
9
10#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
11
12#include "gmock/gmock.h"
13
14namespace flutter {
15namespace testing {
16
17// Mock for FlBinaryMessenger.
19 public:
22
23 // This was an existing use of operator overloading. It's against our style
24 // guide but enabling clang tidy on header files is a higher priority than
25 // fixing this.
26 // NOLINTNEXTLINE(google-explicit-constructor)
27 operator FlBinaryMessenger*();
28
31 (FlBinaryMessenger * messenger,
32 const gchar* channel,
34 gpointer user_data,
35 GDestroyNotify destroy_notify));
36
37 MOCK_METHOD(gboolean,
39 (FlBinaryMessenger * messenger,
40 FlBinaryMessengerResponseHandle* response_handle,
41 GBytes* response,
42 GError** error));
43
46 (FlBinaryMessenger * messenger,
47 const gchar* channel,
48 GBytes* message,
49 GCancellable* cancellable,
50 GAsyncReadyCallback callback,
51 gpointer user_data));
52
53 MOCK_METHOD(GBytes*,
55 (FlBinaryMessenger * messenger,
56 GAsyncResult* result,
57 GError** error));
58
61 (FlBinaryMessenger * messenger,
62 const gchar* channel,
63 int64_t new_size));
64
67 (FlBinaryMessenger * messenger,
68 const gchar* channel,
69 bool warns));
70
71 bool HasMessageHandler(const gchar* channel) const;
72
73 void SetMessageHandler(const gchar* channel,
75 gpointer user_data);
76
77 void ReceiveMessage(const gchar* channel, GBytes* message);
78
79 private:
80 FlBinaryMessenger* instance_ = nullptr;
81 std::unordered_map<std::string, FlBinaryMessengerMessageHandler>
82 message_handlers_;
83 std::unordered_map<std::string, FlBinaryMessengerResponseHandle*>
84 response_handles_;
85 std::unordered_map<std::string, gpointer> user_datas_;
86};
87
88} // namespace testing
89} // namespace flutter
90
91#endif // FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_BINARY_MESSENGER_H_
bool HasMessageHandler(const gchar *channel) const
MOCK_METHOD(void, fl_binary_messenger_send_on_channel,(FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data))
MOCK_METHOD(gboolean, fl_binary_messenger_send_response,(FlBinaryMessenger *messenger, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error))
MOCK_METHOD(void, fl_binary_messenger_resize_channel,(FlBinaryMessenger *messenger, const gchar *channel, int64_t new_size))
MOCK_METHOD(void, fl_binary_messenger_set_message_handler_on_channel,(FlBinaryMessenger *messenger, const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify))
void ReceiveMessage(const gchar *channel, GBytes *message)
MOCK_METHOD(void, fl_binary_messenger_set_warns_on_channel_overflow,(FlBinaryMessenger *messenger, const gchar *channel, bool warns))
void SetMessageHandler(const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data)
MOCK_METHOD(GBytes *, fl_binary_messenger_send_on_channel_finish,(FlBinaryMessenger *messenger, GAsyncResult *result, GError **error))
G_MODULE_EXPORT GBytes * fl_binary_messenger_send_on_channel_finish(FlBinaryMessenger *self, GAsyncResult *result, GError **error)
G_MODULE_EXPORT void fl_binary_messenger_resize_channel(FlBinaryMessenger *self, const gchar *channel, int64_t new_size)
G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel(FlBinaryMessenger *self, const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
G_MODULE_EXPORT void fl_binary_messenger_send_on_channel(FlBinaryMessenger *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
G_MODULE_EXPORT gboolean fl_binary_messenger_send_response(FlBinaryMessenger *self, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error)
G_MODULE_EXPORT void fl_binary_messenger_set_warns_on_channel_overflow(FlBinaryMessenger *self, const gchar *channel, bool warns)
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
GAsyncResult * result
Win32Message message
void * user_data