Flutter Engine
 
Loading...
Searching...
No Matches
embedder_test_context.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_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_H_
7
8#include <future>
9#include <map>
10#include <memory>
11#include <mutex>
12#include <string>
13#include <vector>
14
16#include "flutter/fml/closure.h"
17#include "flutter/fml/macros.h"
18#include "flutter/fml/mapping.h"
23#include "third_party/skia/include/core/SkImage.h"
24
25namespace flutter {
26namespace testing {
27
29 std::function<void(const FlutterSemanticsUpdate2*)>;
31 std::function<void(const FlutterSemanticsUpdate*)>;
32using SemanticsNodeCallback = std::function<void(const FlutterSemanticsNode*)>;
34 std::function<void(const FlutterSemanticsCustomAction*)>;
36 std::function<void(const char* tag, const char* message)>;
37using ChannelUpdateCallback = std::function<void(const FlutterChannelUpdate*)>;
39 std::function<void(const FlutterViewFocusChangeRequest*)>;
40
43 if (aot_data) {
45 }
46 }
47};
48
49using UniqueAOTData = std::unique_ptr<_FlutterEngineAOTData, AOTDataDeleter>;
50
57
59 public:
60 explicit EmbedderTestContext(std::string assets_path = "");
61
63
64 const std::string& GetAssetsPath() const;
65
66 const fml::Mapping* GetVMSnapshotData() const;
67
69
71
73
75
77
79
80 void AddIsolateCreateCallback(const fml::closure& closure);
81
83
85
86 void AddNativeCallback(const char* name, Dart_NativeFunction function);
87
88 void SetSemanticsNodeCallback(SemanticsNodeCallback update_semantics_node);
89
91 SemanticsActionCallback semantics_custom_action);
92
94 const std::function<void(const FlutterPlatformMessage*)>& callback);
95
96 void SetLogMessageCallback(const LogMessageCallback& log_message_callback);
97
99
102
103 std::future<sk_sp<SkImage>> GetNextSceneImage();
104
106
107 virtual size_t GetSurfacePresentCount() const = 0;
108
110
111 // Sets up the callback for vsync. This callback will be invoked
112 // for every vsync. This should be used in conjunction with SetupVsyncCallback
113 // on the EmbedderConfigBuilder. Any callback setup here must call
114 // `FlutterEngineOnVsync` from the platform task runner.
115 void SetVsyncCallback(std::function<void(intptr_t)> callback);
116
117 // Runs the vsync callback.
118 void RunVsyncCallback(intptr_t baton);
119
120 // TODO(gw280): encapsulate these properly for subclasses to use
121 protected:
122 // This allows the builder to access the hooks.
124
125 using NextSceneCallback = std::function<void(sk_sp<SkImage> image)>;
126
127 std::string assets_path_;
129 std::unique_ptr<fml::Mapping> vm_snapshot_data_;
130 std::unique_ptr<fml::Mapping> vm_snapshot_instructions_;
131 std::unique_ptr<fml::Mapping> isolate_snapshot_data_;
132 std::unique_ptr<fml::Mapping> isolate_snapshot_instructions_;
134 std::vector<fml::closure> isolate_create_callbacks_;
135 std::shared_ptr<TestDartNativeResolver> native_resolver_;
145 std::unique_ptr<EmbedderTestCompositor> compositor_;
148 std::function<void(intptr_t)> vsync_callback_ = nullptr;
149
151
153
155
157
160
162
165
167
169
171
173
174 virtual void SetSurface(DlISize surface_size) = 0;
175
176 virtual void SetupCompositor() = 0;
177
179
181
183
185
187 const std::function<sk_sp<SkImage>(void)>& image_callback);
188
189 void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);
190
192};
193
194} // namespace testing
195} // namespace flutter
196
197#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_H_
virtual void SetSurface(DlISize surface_size)=0
void SetSemanticsCustomActionCallback(SemanticsActionCallback semantics_custom_action)
const fml::Mapping * GetIsolateSnapshotData() const
std::vector< fml::closure > isolate_create_callbacks_
virtual EmbedderTestContextType GetContextType() const =0
const fml::Mapping * GetVMSnapshotInstructions() const
void AddNativeCallback(const char *name, Dart_NativeFunction function)
std::function< void(const FlutterPlatformMessage *)> platform_message_callback_
FlutterUpdateSemanticsNodeCallback GetUpdateSemanticsNodeCallbackHook()
std::unique_ptr< fml::Mapping > isolate_snapshot_instructions_
std::function< void(intptr_t)> vsync_callback_
void SetSemanticsUpdateCallback(SemanticsUpdateCallback update_semantics)
std::shared_ptr< TestDartNativeResolver > native_resolver_
std::unique_ptr< fml::Mapping > vm_snapshot_data_
void SetViewFocusChangeRequestCallback(const ViewFocusChangeRequestCallback &callback)
void SetVsyncCallback(std::function< void(intptr_t)> callback)
const fml::Mapping * GetIsolateSnapshotInstructions() const
virtual size_t GetSurfacePresentCount() const =0
static FlutterLogMessageCallback GetLogMessageCallbackHook()
void SetSemanticsNodeCallback(SemanticsNodeCallback update_semantics_node)
std::unique_ptr< fml::Mapping > vm_snapshot_instructions_
void SetPlatformMessageCallback(const std::function< void(const FlutterPlatformMessage *)> &callback)
static FlutterComputePlatformResolvedLocaleCallback GetComputePlatformResolvedLocaleCallbackHook()
void SetChannelUpdateCallback(const ChannelUpdateCallback &callback)
FlutterViewFocusChangeRequestCallback GetViewFocusChangeRequestCallbackHook()
void AddIsolateCreateCallback(const fml::closure &closure)
void SetNextSceneCallback(const NextSceneCallback &next_scene_callback)
void SetLogMessageCallback(const LogMessageCallback &log_message_callback)
std::unique_ptr< EmbedderTestCompositor > compositor_
void SetSemanticsUpdateCallback2(SemanticsUpdateCallback2 update_semantics)
std::unique_ptr< fml::Mapping > isolate_snapshot_data_
std::function< void(sk_sp< SkImage > image)> NextSceneCallback
FlutterUpdateSemanticsCustomActionCallback GetUpdateSemanticsCustomActionCallbackHook()
std::future< sk_sp< SkImage > > GetNextSceneImage()
SemanticsUpdateCallback2 update_semantics_callback2_
FlutterUpdateSemanticsCallback2 GetUpdateSemanticsCallback2Hook()
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContext)
ViewFocusChangeRequestCallback view_focus_change_request_callback_
FlutterUpdateSemanticsCallback GetUpdateSemanticsCallbackHook()
SemanticsActionCallback update_semantics_custom_action_callback_
void PlatformMessageCallback(const FlutterPlatformMessage *message)
FlutterChannelUpdateCallback GetChannelUpdateCallbackHook()
const fml::Mapping * GetVMSnapshotData() const
void FireRootSurfacePresentCallbackIfPresent(const std::function< sk_sp< SkImage >(void)> &image_callback)
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
Definition embedder.cc:1736
void(* FlutterUpdateSemanticsCustomActionCallback)(const FlutterSemanticsCustomAction *, void *)
Definition embedder.h:1816
void(* FlutterUpdateSemanticsCallback)(const FlutterSemanticsUpdate *, void *)
Definition embedder.h:1820
void(* FlutterLogMessageCallback)(const char *, const char *, void *)
Definition embedder.h:2448
void(* FlutterUpdateSemanticsNodeCallback)(const FlutterSemanticsNode *, void *)
Definition embedder.h:1812
void(* VoidCallback)(void *)
Definition embedder.h:409
const FlutterLocale *(* FlutterComputePlatformResolvedLocaleCallback)(const FlutterLocale **, size_t)
Definition embedder.h:2285
void(* FlutterUpdateSemanticsCallback2)(const FlutterSemanticsUpdate2 *, void *)
Definition embedder.h:1824
void(* FlutterChannelUpdateCallback)(const FlutterChannelUpdate *, void *)
Definition embedder.h:1838
void(* FlutterViewFocusChangeRequestCallback)(const FlutterViewFocusChangeRequest *, void *)
Definition embedder.h:1842
FlutterVulkanImage * image
G_BEGIN_DECLS GBytes * message
FlutterDesktopBinaryReply callback
std::function< void(const FlutterSemanticsCustomAction *)> SemanticsActionCallback
std::function< void(const FlutterSemanticsNode *)> SemanticsNodeCallback
std::function< void(const FlutterViewFocusChangeRequest *)> ViewFocusChangeRequestCallback
std::unique_ptr< _FlutterEngineAOTData, AOTDataDeleter > UniqueAOTData
std::function< void(const FlutterSemanticsUpdate2 *)> SemanticsUpdateCallback2
std::function< void(const char *tag, const char *message)> LogMessageCallback
std::function< void(const FlutterChannelUpdate *)> ChannelUpdateCallback
std::function< void(const FlutterSemanticsUpdate *)> SemanticsUpdateCallback
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
std::function< void()> closure
Definition closure.h:14
An update to whether a message channel has a listener set or not.
Definition embedder.h:1829
A batch of updates to semantics nodes and custom actions.
Definition embedder.h:1796
void operator()(FlutterEngineAOTData aot_data)
A 4x4 matrix using column-major storage.
Definition matrix.h:37