Flutter Engine
 
Loading...
Searching...
No Matches
golden_playground_test.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_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
6#define FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
7
8#include <memory>
9
18#include "third_party/imgui/imgui.h"
19
20#if FML_OS_MACOSX
22#endif
23
24namespace impeller {
25
27 : public ::testing::TestWithParam<PlaygroundBackend> {
28 public:
30 std::function<std::optional<Picture>(AiksContext& renderer)>;
31
32 using AiksDlPlaygroundCallback = std::function<sk_sp<flutter::DisplayList>()>;
33
35
37
38 void SetUp();
39
40 void TearDown();
41
43
45 std::shared_ptr<TypographerContext> typographer_context);
46
47 bool OpenPlaygroundHere(Picture picture);
48
50
52
53 bool OpenPlaygroundHere(const sk_sp<flutter::DisplayList>& list);
54
55 std::unique_ptr<testing::Screenshot> MakeScreenshot(
56 const sk_sp<flutter::DisplayList>& list);
57
58 static bool SaveScreenshot(std::unique_ptr<testing::Screenshot> screenshot,
59 const std::string& postfix = "");
60
61 static bool ImGuiBegin(const char* name,
62 bool* p_open,
63 ImGuiWindowFlags flags);
64
65 std::shared_ptr<Texture> CreateTextureForFixture(
66 const char* fixture_name,
67 bool enable_mipmapping = false) const;
68
69 sk_sp<flutter::DlImage> CreateDlImageForFixture(
70 const char* fixture_name,
71 bool enable_mipmapping = false) const;
72
73 RuntimeStage::Map OpenAssetAsRuntimeStage(const char* asset_name) const;
74
75 std::shared_ptr<Context> GetContext() const;
76
77 std::shared_ptr<Context> MakeContext() const;
78
79 Point GetContentScale() const;
80
82
83 ISize GetWindowSize() const;
84
85 [[nodiscard]] fml::Status SetCapabilities(
86 const std::shared_ptr<Capabilities>& capabilities);
87
88 /// Returns true if `OpenPlaygroundHere` will actually render anything.
89 bool WillRenderSomething() const { return true; }
90
91 protected:
92 void SetWindowSize(ISize size);
93
94 private:
95#if FML_OS_MACOSX
96 // This must be placed first so that the autorelease pool is not destroyed
97 // until the GoldenPlaygroundTestImpl has been destructed.
98 fml::ScopedNSAutoreleasePool autorelease_pool_;
99#endif
100
101 std::shared_ptr<TypographerContext> typographer_context_;
102
103 struct GoldenPlaygroundTestImpl;
104 // This is only a shared_ptr so it can work with a forward declared type.
105 std::shared_ptr<GoldenPlaygroundTestImpl> pimpl_;
106
108
109 GoldenPlaygroundTest& operator=(const GoldenPlaygroundTest&) = delete;
110};
111
112} // namespace impeller
113
114#endif // FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
bool OpenPlaygroundHere(AiksPlaygroundCallback callback)
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
sk_sp< flutter::DlImage > CreateDlImageForFixture(const char *fixture_name, bool enable_mipmapping=false) const
fml::Status SetCapabilities(const std::shared_ptr< Capabilities > &capabilities)
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
std::shared_ptr< Context > MakeContext() const
static bool SaveScreenshot(std::unique_ptr< testing::Screenshot > screenshot, const std::string &postfix="")
std::unique_ptr< testing::Screenshot > MakeScreenshot(const sk_sp< flutter::DisplayList > &list)
RuntimeStage::Map OpenAssetAsRuntimeStage(const char *asset_name) const
bool OpenPlaygroundHere(Picture picture)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
std::function< sk_sp< flutter::DisplayList >()> AiksDlPlaygroundCallback
std::shared_ptr< Context > GetContext() const
bool WillRenderSomething() const
Returns true if OpenPlaygroundHere will actually render anything.
std::shared_ptr< Texture > CreateTextureForFixture(const char *fixture_name, bool enable_mipmapping=false) const
std::map< RuntimeStageBackend, std::shared_ptr< RuntimeStage > > Map
FlutterDesktopBinaryReply callback
const char * name
Definition fuchsia.cc:49
float Scalar
Definition scalar.h:19
PlaygroundBackend
Definition playground.h:27