5#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_UNITTESTS_UTIL_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_UNITTESTS_UTIL_H_
8#define FML_USED_ON_EMBEDDER
19#include "third_party/skia/include/core/SkSurface.h"
25 GrDirectContext* context);
37 const std::string&
name);
49 bool opengl_framebuffer);
61 bool opengl_framebuffer);
64 const std::string&
name,
65 const sk_sp<SkImage>&
image);
68 const sk_sp<SkImage>& scene_image,
69 int allowable_different_pixels = 0);
72 std::future<sk_sp<SkImage>>& scene_image,
73 int allowable_different_pixels = 0);
76 const std::vector<uint8_t>& bytes);
79 const std::vector<uint8_t>& bytes);
112 std::move(on_task_expired),
117 std::function<
void()> destruction_callback)
118 : identifier_(++sEmbedderTaskRunnerIdentifiers),
119 real_task_runner_(
std::move(real_task_runner)),
120 on_task_expired_(
std::move(on_task_expired)),
121 destruction_callback_(
std::move(destruction_callback)) {
126 task_runner_description_.
user_data =
this;
133 uint64_t target_time_nanos,
139 auto on_task_expired = thiz->on_task_expired_;
140 auto invoke_task = [task, on_task_expired]() { on_task_expired(task); };
141 auto real_task_runner = thiz->real_task_runner_;
143 real_task_runner->PostTaskForTime(invoke_task, target_time);
145 if (destruction_callback_) {
148 thiz->destruction_callback_();
153 task_runner_description_.
identifier = identifier_;
157 return task_runner_description_;
161 static std::atomic_size_t sEmbedderTaskRunnerIdentifiers;
162 const size_t identifier_;
175 real_task_runner_ = std::move(task_runner);
181 on_task_expired_ = std::move(
callback);
187 destruction_callback_ = std::move(
callback);
193 destruction_callback_);
EmbedderTestTaskRunnerBuilder & SetRealTaskRunner(fml::RefPtr< fml::TaskRunner > task_runner)
EmbedderTestTaskRunnerBuilder & SetTaskExpiryCallback(EmbedderTestTaskRunner::TaskExpiryCallback callback)
EmbedderTestTaskRunner Build()
EmbedderTestTaskRunnerBuilder & SetDestructionCallback(EmbedderTestTaskRunner::DestructionCallback callback)
A task runner that we expect the embedder to provide but whose implementation is a real FML task runn...
const FlutterTaskRunnerDescription & GetFlutterTaskRunnerDescription()
EmbedderTestTaskRunner(fml::RefPtr< fml::TaskRunner > real_task_runner, TaskExpiryCallback on_task_expired)
EmbedderTestTaskRunner(fml::RefPtr< fml::TaskRunner > real_task_runner, TaskExpiryCallback on_task_expired, std::function< void()> destruction_callback)
std::function< void(FlutterTask)> TaskExpiryCallback
std::function< void()> DestructionCallback
virtual bool RunsTasksOnCurrentThread()
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
FlutterPlatformViewMutationType
FlutterVulkanImage * image
const gchar FlBinaryMessengerMessageHandler handler
FlutterDesktopBinaryReply callback
#define FML_CHECK(condition)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
bool WriteImageToDisk(const fml::UniqueFD &directory, const std::string &name, const sk_sp< SkImage > &image)
sk_sp< SkSurface > CreateRenderSurface(const FlutterLayer &layer, GrDirectContext *context)
void FilterMutationsByType(const FlutterPlatformViewMutation **mutations, size_t count, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
bool SurfacePixelDataMatchesBytes(SkSurface *surface, const std::vector< uint8_t > &bytes)
bool ImageMatchesFixture(const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image, int allowable_different_pixels)
void ConfigureBackingStore(FlutterBackingStore &backing_store, EmbedderTestContextType backend, bool opengl_framebuffer)
Configures per-backend properties for a given backing store.
std::string FixtureNameForBackend(EmbedderTestContextType backend, const std::string &name)
Prepends a prefix to the name which is unique to the test context type. This is useful for tests that...
EmbedderTestBackingStoreProducer::RenderTargetType GetRenderTargetFromBackend(EmbedderTestContextType backend, bool opengl_framebuffer)
Resolves a render target type for a given backend description. This is useful for tests that use Embe...
bool RasterImagesAreSame(const sk_sp< SkImage > &a, const sk_sp< SkImage > &b, int allowable_different_pixels)
DlMatrix GetTotalMutationTransformationMatrix(const FlutterPlatformViewMutation **mutations, size_t count)
DEF_SWITCHES_START aot vmservice shared library name
impeller::ShaderType type
size_t struct_size
The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
BoolCallback runs_task_on_current_thread_callback
FlutterTaskRunnerPostTaskCallback post_task_callback
VoidCallback destruction_callback
The callback invoked when the task runner is destroyed.
A 4x4 matrix using column-major storage.