Flutter Engine
The Flutter Engine
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
15#include "flutter/fml/closure.h"
16#include "flutter/fml/macros.h"
17#include "flutter/fml/mapping.h"
18#include "flutter/shell/platform/embedder/embedder.h"
19#include "flutter/shell/platform/embedder/tests/embedder_test_compositor.h"
20#include "flutter/testing/elf_loader.h"
21#include "flutter/testing/test_dart_native_resolver.h"
23
24namespace flutter {
25namespace testing {
26
35 std::function<void(const char* tag, const char* message)>;
37
40 if (aot_data) {
42 }
43 }
44};
45
46using UniqueAOTData = std::unique_ptr<_FlutterEngineAOTData, AOTDataDeleter>;
47
53};
54
56 public:
57 explicit EmbedderTestContext(std::string assets_path = "");
58
60
61 const std::string& GetAssetsPath() const;
62
63 const fml::Mapping* GetVMSnapshotData() const;
64
66
68
70
72
74
76
78
80
82
83 void SetSemanticsNodeCallback(SemanticsNodeCallback update_semantics_node);
84
86 SemanticsActionCallback semantics_custom_action);
87
89 const std::function<void(const FlutterPlatformMessage*)>& callback);
90
91 void SetLogMessageCallback(const LogMessageCallback& log_message_callback);
92
94
95 std::future<sk_sp<SkImage>> GetNextSceneImage();
96
98
99 virtual size_t GetSurfacePresentCount() const = 0;
100
102
103 // Sets up the callback for vsync. This callback will be invoked
104 // for every vsync. This should be used in conjunction with SetupVsyncCallback
105 // on the EmbedderConfigBuilder. Any callback setup here must call
106 // `FlutterEngineOnVsync` from the platform task runner.
107 void SetVsyncCallback(std::function<void(intptr_t)> callback);
108
109 // Runs the vsync callback.
110 void RunVsyncCallback(intptr_t baton);
111
112 // TODO(gw280): encapsulate these properly for subclasses to use
113 protected:
114 // This allows the builder to access the hooks.
116
118
119#ifdef SHELL_ENABLE_VULKAN
120 // The TestVulkanContext destructor must be called _after_ the compositor is
121 // freed.
122 fml::RefPtr<TestVulkanContext> vulkan_context_ = nullptr;
123#endif
124
125 std::string assets_path_;
127 std::unique_ptr<fml::Mapping> vm_snapshot_data_;
128 std::unique_ptr<fml::Mapping> vm_snapshot_instructions_;
129 std::unique_ptr<fml::Mapping> isolate_snapshot_data_;
130 std::unique_ptr<fml::Mapping> isolate_snapshot_instructions_;
132 std::vector<fml::closure> isolate_create_callbacks_;
133 std::shared_ptr<TestDartNativeResolver> native_resolver_;
141 std::unique_ptr<EmbedderTestCompositor> compositor_;
144 std::function<void(intptr_t)> vsync_callback_ = nullptr;
145
147
149
151
153
156
158
161
163
165
167
168 virtual void SetupCompositor() = 0;
169
171
173
175
177
179 const std::function<sk_sp<SkImage>(void)>& image_callback);
180
181 void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);
182
183 virtual void SetupSurface(SkISize surface_size) = 0;
184
186};
187
188} // namespace testing
189} // namespace flutter
190
191#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_H_
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 SetVsyncCallback(std::function< void(intptr_t)> callback)
const fml::Mapping * GetIsolateSnapshotInstructions() const
virtual size_t GetSurfacePresentCount() const =0
static FlutterLogMessageCallback GetLogMessageCallbackHook()
const std::string & GetAssetsPath() const
void SetSemanticsNodeCallback(SemanticsNodeCallback update_semantics_node)
SemanticsUpdateCallback update_semantics_callback_
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)
void AddIsolateCreateCallback(const fml::closure &closure)
FlutterEngineAOTData GetAOTData() const
void SetNextSceneCallback(const NextSceneCallback &next_scene_callback)
SemanticsNodeCallback update_semantics_node_callback_
FlutterTransformation GetRootSurfaceTransformation()
void SetLogMessageCallback(const LogMessageCallback &log_message_callback)
std::unique_ptr< EmbedderTestCompositor > compositor_
EmbedderTestContext(std::string assets_path="")
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)
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)
virtual void SetupSurface(SkISize surface_size)=0
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3207
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
Definition: embedder.cc:1480
void(* FlutterUpdateSemanticsCustomActionCallback)(const FlutterSemanticsCustomAction *, void *)
Definition: embedder.h:1522
void(* FlutterUpdateSemanticsCallback)(const FlutterSemanticsUpdate *, void *)
Definition: embedder.h:1526
void(* FlutterLogMessageCallback)(const char *, const char *, void *)
Definition: embedder.h:2130
void(* FlutterUpdateSemanticsNodeCallback)(const FlutterSemanticsNode *, void *)
Definition: embedder.h:1518
const FlutterLocale *(* FlutterComputePlatformResolvedLocaleCallback)(const FlutterLocale **, size_t)
Definition: embedder.h:1967
void(* FlutterUpdateSemanticsCallback2)(const FlutterSemanticsUpdate2 *, void *)
Definition: embedder.h:1530
void(* FlutterChannelUpdateCallback)(const FlutterChannelUpdate *, void *)
Definition: embedder.h:1544
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Dart_NativeFunction function
Definition: fuchsia.cc:51
Win32Message message
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< const SkImage > image
Definition: SkRecords.h:269
std::function< void(const FlutterSemanticsCustomAction *)> SemanticsActionCallback
std::function< void(const FlutterSemanticsNode *)> SemanticsNodeCallback
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: switches.h:32
std::function< void()> closure
Definition: closure.h:14
An update to whether a message channel has a listener set or not.
Definition: embedder.h:1535
A batch of updates to semantics nodes and custom actions.
Definition: embedder.h:1504
Definition: SkSize.h:16
void operator()(FlutterEngineAOTData aot_data)