Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
stub_flutter_windows_api.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_WINDOWS_CLIENT_WRAPPER_TESTING_STUB_FLUTTER_WINDOWS_API_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_TESTING_STUB_FLUTTER_WINDOWS_API_H_
7
8#include <memory>
9
12
13namespace flutter {
14namespace testing {
15
16// Base class for a object that provides test implementations of the APIs in
17// the headers in platform/windows/public/.
18
19// Linking this class into a test binary will provide dummy forwarding
20// implementations of that C API, so that the wrapper can be tested separately
21// from the actual library.
23 public:
24 // Sets |stub| as the instance to which calls to the Flutter library C APIs
25 // will be forwarded.
26 static void SetTestStub(StubFlutterWindowsApi* stub);
27
28 // Returns the current stub, as last set by SetTestFlutterStub.
30
32
33 // Called for FlutterDesktopViewControllerCreate.
36 return nullptr;
37 }
38
39 // Called for FlutterDesktopViewControllerDestroy.
40 virtual void ViewControllerDestroy() {}
41
42 // Called for FlutterDesktopViewControllerForceRedraw.
43 virtual void ViewControllerForceRedraw() {}
44
45 // Called for FlutterDesktopViewControllerHandleTopLevelWindowProc.
48 WPARAM wparam,
49 LPARAM lparam,
50 LRESULT* result) {
51 return false;
52 }
53
54 // Called for FlutterDesktopEngineCreate.
56 const FlutterDesktopEngineProperties& engine_properties) {
57 return nullptr;
58 }
59
60 // Called for FlutterDesktopEngineDestroy.
61 virtual bool EngineDestroy() { return true; }
62
63 // Called for FlutterDesktopEngineRun.
64 virtual bool EngineRun(const char* entry_point) { return true; }
65
66 // Called for FlutterDesktopEngineProcessMessages.
67 virtual uint64_t EngineProcessMessages() { return 0; }
68
69 // Called for FlutterDesktopEngineSetNextFrameCallback.
72
73 // Called for FlutterDesktopEngineIsPlatformThread.
74 virtual bool EngineIsPlatformThread() { return false; }
75
76 // Called for FlutterDesktopEnginePostPlatformThreadTask.
80
81 // Called for FlutterDesktopEngineReloadSystemFonts.
82 virtual void EngineReloadSystemFonts() {}
83
84 // Called for FlutterDesktopEngineRegisterPlatformViewType.
86 const char* view_type_name,
88
89 // Called for FlutterDesktopViewGetHWND.
90 virtual HWND ViewGetHWND() { return reinterpret_cast<HWND>(1); }
91
92 // Called for FlutterDesktopViewGetGraphicsAdapter.
93 virtual IDXGIAdapter* ViewGetGraphicsAdapter() {
94 return reinterpret_cast<IDXGIAdapter*>(2);
95 }
96
97 // Called for FlutterDesktopEngineGetGraphicsAdapter.
98 virtual bool EngineGetGraphicsAdapter(IDXGIAdapter** adapter_out) {
99 *adapter_out = reinterpret_cast<IDXGIAdapter*>(3);
100 return true;
101 }
102
103 // Called for FlutterDesktopPluginRegistrarGetView.
104 virtual FlutterDesktopViewRef PluginRegistrarGetView() { return nullptr; }
105
106 // Called for FlutterDesktopPluginRegistrarGetViewById.
111
112 // Called for FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate.
116
117 // Called for
118 // FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate.
121
122 // Called for FlutterDesktopPluginRegistrarGetGraphicsAdapter.
123 virtual bool PluginRegistrarGetGraphicsAdapter(IDXGIAdapter** adapter_out) {
124 return false;
125 }
126
127 // Called for FlutterDesktopEngineProcessExternalWindowMessage.
130 HWND hwnd,
132 WPARAM wparam,
133 LPARAM lparam,
134 LRESULT* result) {
135 return false;
136 }
137};
138
139// A test helper that owns a stub implementation, making it the test stub for
140// the lifetime of the object, then restoring the previous value.
142 public:
143 // Calls SetTestFlutterStub with |stub|.
144 ScopedStubFlutterWindowsApi(std::unique_ptr<StubFlutterWindowsApi> stub);
145
146 // Restores the previous test stub.
148
149 StubFlutterWindowsApi* stub() { return stub_.get(); }
150
151 private:
152 std::unique_ptr<StubFlutterWindowsApi> stub_;
153 // The previous stub.
154 StubFlutterWindowsApi* previous_stub_;
155};
156
157} // namespace testing
158} // namespace flutter
159
160#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_TESTING_STUB_FLUTTER_WINDOWS_API_H_
virtual bool ViewControllerHandleTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
virtual void EnginePostPlatformThreadTask(VoidCallback callback, VoidCallback on_cancel, void *user_data)
virtual void EngineSetNextFrameCallback(VoidCallback callback, void *user_data)
virtual FlutterDesktopEngineRef EngineCreate(const FlutterDesktopEngineProperties &engine_properties)
virtual FlutterDesktopViewRef PluginRegistrarGetViewById(FlutterDesktopViewId view_id)
virtual bool EngineGetGraphicsAdapter(IDXGIAdapter **adapter_out)
virtual FlutterDesktopViewControllerRef ViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)
virtual bool EngineRun(const char *entry_point)
virtual void EngineRegisterPlatformViewType(const char *view_type_name, FlutterPlatformViewTypeEntry view_type)
virtual bool PluginRegistrarGetGraphicsAdapter(IDXGIAdapter **adapter_out)
static void SetTestStub(StubFlutterWindowsApi *stub)
static StubFlutterWindowsApi * GetTestStub()
virtual void PluginRegistrarUnregisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback delegate)
virtual FlutterDesktopViewRef PluginRegistrarGetView()
virtual void PluginRegistrarRegisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback delegate, void *user_data)
virtual bool EngineProcessExternalWindowMessage(FlutterDesktopEngineRef engine, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
void(* VoidCallback)(void *)
Definition embedder.h:416
FlutterEngine engine
Definition main.cc:84
const char * message
G_BEGIN_DECLS FlutterViewId view_id
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
bool(* FlutterDesktopWindowProcCallback)(HWND, UINT, WPARAM, LPARAM, void *, LRESULT *result)
int64_t FlutterDesktopViewId
struct FlutterDesktopView * FlutterDesktopViewRef
FlutterDesktopBinaryReply callback
int32_t height
int32_t width
LONG_PTR LRESULT
unsigned int UINT
LONG_PTR LPARAM
UINT_PTR WPARAM