Flutter Engine
The Flutter Engine
stub_flutter_api.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/common/client_wrapper/testing/stub_flutter_api.h"
6
7#include <cassert>
8
10
11namespace flutter {
12namespace testing {
13
14// static
17}
18
19// static
22}
23
24ScopedStubFlutterApi::ScopedStubFlutterApi(std::unique_ptr<StubFlutterApi> stub)
25 : stub_(std::move(stub)) {
26 previous_stub_ = StubFlutterApi::GetTestStub();
27 StubFlutterApi::SetTestStub(stub_.get());
28}
29
31 StubFlutterApi::SetTestStub(previous_stub_);
32}
33
34} // namespace testing
35} // namespace flutter
36
37// Forwarding dummy implementations of the C API.
38
41 // The stub ignores this, so just return an arbitrary non-zero value.
42 return reinterpret_cast<FlutterDesktopMessengerRef>(1);
43}
44
50 }
51}
52
54 const char* channel,
55 const uint8_t* message,
56 const size_t message_size) {
57 bool result = false;
59 result =
60 s_stub_implementation->MessengerSend(channel, message, message_size);
61 }
62 return result;
63}
64
66 const char* channel,
67 const uint8_t* message,
68 const size_t message_size,
69 const FlutterDesktopBinaryReply reply,
70 void* user_data) {
71 bool result = false;
74 channel, message, message_size, reply, user_data);
75 }
76 return result;
77}
78
82 const uint8_t* data,
83 size_t data_length) {
86 }
87}
88
90 const char* channel,
92 void* user_data) {
95 }
96}
97
100 assert(false); // not implemented
101 return nullptr;
102}
103
105 assert(false); // not implemented
106}
107
109 assert(false); // not implemented
110 return false;
111}
112
114 FlutterDesktopMessengerRef messenger) {
115 assert(false); // not implemented
116 return nullptr;
117}
118
120 assert(false); // not implemented
121}
122
125 return reinterpret_cast<FlutterDesktopTextureRegistrarRef>(1);
126}
127
131 uint64_t result = -1;
133 result =
135 }
136 return result;
137}
138
141 int64_t texture_id,
142 void (*callback)(void* user_data),
143 void* user_data) {
147 } else if (callback) {
149 }
150}
151
154 int64_t texture_id) {
155 bool result = false;
158 texture_id);
159 }
160 return result;
161}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
ScopedStubFlutterApi(std::unique_ptr< StubFlutterApi > stub)
virtual bool TextureRegistrarMarkTextureFrameAvailable(int64_t texture_id)
static void SetTestStub(StubFlutterApi *stub)
virtual void MessengerSetCallback(const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
static StubFlutterApi * GetTestStub()
virtual void PluginRegistrarSetDestructionHandler(FlutterDesktopOnPluginRegistrarDestroyed callback)
virtual void MessengerSendResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
virtual bool MessengerSendWithReply(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
virtual bool MessengerSend(const char *channel, const uint8_t *message, const size_t message_size)
virtual void TextureRegistrarUnregisterExternalTexture(int64_t texture_id, void(*callback)(void *user_data), void *user_data)
virtual int64_t TextureRegistrarRegisterExternalTexture(const FlutterDesktopTextureInfo *info)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)
void(* FlutterDesktopMessageCallback)(FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)
void(* FlutterDesktopOnPluginRegistrarDestroyed)(FlutterDesktopPluginRegistrarRef)
struct FlutterDesktopTextureRegistrar * FlutterDesktopTextureRegistrarRef
Win32Message message
G_BEGIN_DECLS FlTextureRegistrar * texture_registrar
Definition: ref_ptr.h:256
void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
static flutter::testing::StubFlutterApi * s_stub_implementation
int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, const FlutterDesktopTextureInfo *info)
void FlutterDesktopMessengerSendResponse(FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
void FlutterDesktopPluginRegistrarSetDestructionHandler(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopOnPluginRegistrarDestroyed callback)
bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id)
FlutterDesktopMessengerRef FlutterDesktopMessengerLock(FlutterDesktopMessengerRef messenger)
void FlutterDesktopTextureRegistrarUnregisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id, void(*callback)(void *user_data), void *user_data)
bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
bool FlutterDesktopMessengerSend(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
void FlutterDesktopMessengerUnlock(FlutterDesktopMessengerRef messenger)
FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar(FlutterDesktopPluginRegistrarRef registrar)
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar)
void FlutterDesktopMessengerRelease(FlutterDesktopMessengerRef messenger)
FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef(FlutterDesktopMessengerRef messenger)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
void * user_data
int64_t texture_id