Flutter Engine
 
Loading...
Searching...
No Matches
impeller::PlaygroundTest Class Reference

#include <playground_test.h>

Inheritance diagram for impeller::PlaygroundTest:
impeller::Playground impeller::AiksPlayground impeller::DlPlayground impeller::EntityPlayground impeller::RuntimeStagePlayground impeller::interop::testing::PlaygroundTest impeller::testing::RendererDartTest impeller::testing::BlendFilterContentsTest impeller::testing::GaussianBlurFilterContentsTest impeller::testing::MatrixFilterContentsTest

Public Member Functions

 PlaygroundTest ()
 
virtual ~PlaygroundTest ()
 
void SetUp () override
 
void TearDown () override
 
PlaygroundBackend GetBackend () const
 
std::unique_ptr< fml::MappingOpenAssetAsMapping (std::string asset_name) const override
 
RuntimeStage::Map OpenAssetAsRuntimeStage (const char *asset_name) const
 
std::string GetWindowTitle () const override
 
- Public Member Functions inherited from impeller::Playground
 Playground (PlaygroundSwitches switches)
 
virtual ~Playground ()
 
void SetupContext (PlaygroundBackend backend, const PlaygroundSwitches &switches)
 
void SetupWindow ()
 
void TeardownWindow ()
 
bool IsPlaygroundEnabled () const
 
Point GetCursorPosition () const
 
ISize GetWindowSize () const
 
Point GetContentScale () const
 
Scalar GetSecondsElapsed () const
 Get the amount of time elapsed from the start of the playground's execution.
 
std::shared_ptr< ContextGetContext () const
 
std::shared_ptr< ContextMakeContext () const
 
bool OpenPlaygroundHere (const RenderCallback &render_callback)
 
bool OpenPlaygroundHere (SinglePassCallback pass_callback)
 
std::shared_ptr< TextureCreateTextureForFixture (const char *fixture_name, bool enable_mipmapping=false) const
 
std::shared_ptr< TextureCreateTextureCubeForFixture (std::array< const char *, 6 > fixture_names) const
 
fml::Status SetCapabilities (const std::shared_ptr< Capabilities > &capabilities)
 
bool WillRenderSomething () const
 Returns true if OpenPlaygroundHere will actually render anything.
 
GLProcAddressResolver CreateGLProcAddressResolver () const
 
VKProcAddressResolver CreateVKProcAddressResolver () const
 
void SetGPUDisabled (bool disabled) const
 Mark the GPU as unavilable.
 

Additional Inherited Members

- Public Types inherited from impeller::Playground
using SinglePassCallback = std::function< bool(RenderPass &pass)>
 
using RenderCallback = std::function< bool(RenderTarget &render_target)>
 
using GLProcAddressResolver = std::function< void *(const char *proc_name)>
 
using VKProcAddressResolver = std::function< void *(void *instance, const char *proc_name)>
 
- Static Public Member Functions inherited from impeller::Playground
static bool ShouldOpenNewPlaygrounds ()
 
static std::shared_ptr< CompressedImageLoadFixtureImageCompressed (std::shared_ptr< fml::Mapping > mapping)
 
static std::optional< DecompressedImageDecodeImageRGBA (const std::shared_ptr< CompressedImage > &compressed)
 
static std::shared_ptr< TextureCreateTextureForMapping (const std::shared_ptr< Context > &context, std::shared_ptr< fml::Mapping > mapping, bool enable_mipmapping=false)
 
static bool SupportsBackend (PlaygroundBackend backend)
 
- Protected Member Functions inherited from impeller::Playground
void SetWindowSize (ISize size)
 
- Protected Attributes inherited from impeller::Playground
const PlaygroundSwitches switches_
 

Detailed Description

Definition at line 21 of file playground_test.h.

Constructor & Destructor Documentation

◆ PlaygroundTest()

impeller::PlaygroundTest::PlaygroundTest ( )

Definition at line 13 of file playground_test.cc.

14 : Playground(PlaygroundSwitches{flutter::testing::GetArgsForProcess()}) {
16 [](const char* message, const char* file, int line) -> bool {
17 // GTEST_MESSAGE_AT_ can only be used in a function that returns void.
18 // Hence the goofy lambda. The failure message and location will still
19 // be correct however.
20 //
21 // https://google.github.io/googletest/advanced.html#assertion-placement
22 [message, file, line]() -> void {
23 GTEST_MESSAGE_AT_(file, line, "Impeller Validation Error",
24 ::testing::TestPartResult::kFatalFailure)
25 << message;
26 }();
27 return true;
28 });
29}
Playground(PlaygroundSwitches switches)
Definition playground.cc:84
G_BEGIN_DECLS GBytes * message
const fml::CommandLine & GetArgsForProcess()
Definition test_args.cc:11
void ImpellerValidationErrorsSetCallback(ValidationFailureCallback callback)
Sets a callback that callers (usually tests) can set to intercept validation failures.
Definition validation.cc:21

References impeller::ImpellerValidationErrorsSetCallback(), and message.

◆ ~PlaygroundTest()

impeller::PlaygroundTest::~PlaygroundTest ( )
virtual

Member Function Documentation

◆ GetBackend()

◆ GetWindowTitle()

std::string impeller::PlaygroundTest::GetWindowTitle ( ) const
overridevirtual

Implements impeller::Playground.

Definition at line 100 of file playground_test.cc.

100 {
101 std::stringstream stream;
102 stream << "Impeller Playground for '"
104 switch (GetBackend()) {
106 break;
108 if (switches_.use_angle) {
109 stream << " (Angle) ";
110 }
111 break;
114 stream << " (SwiftShader) ";
115 }
116 break;
117 }
118 stream << " (Press ESC to quit)";
119 return stream.str();
120}
const PlaygroundSwitches switches_
Definition playground.h:131
PlaygroundBackend GetBackend() const
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition testing.cc:14

References GetBackend(), flutter::testing::GetCurrentTestName(), impeller::kMetal, impeller::kOpenGLES, impeller::kVulkan, impeller::Playground::switches_, impeller::PlaygroundSwitches::use_angle, and impeller::PlaygroundSwitches::use_swiftshader.

◆ OpenAssetAsMapping()

std::unique_ptr< fml::Mapping > impeller::PlaygroundTest::OpenAssetAsMapping ( std::string  asset_name) const
overridevirtual

Implements impeller::Playground.

Definition at line 84 of file playground_test.cc.

85 {
87}
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
Definition testing.cc:58

References flutter::testing::OpenFixtureAsMapping().

Referenced by impeller::interop::testing::PlaygroundTest::OpenAssetAsHPPMapping(), and impeller::interop::testing::PlaygroundTest::OpenAssetAsHPPTexture().

◆ OpenAssetAsRuntimeStage()

RuntimeStage::Map impeller::PlaygroundTest::OpenAssetAsRuntimeStage ( const char *  asset_name) const

Definition at line 89 of file playground_test.cc.

90 {
91 const std::shared_ptr<fml::Mapping> fixture =
93 if (!fixture || fixture->GetSize() == 0) {
94 return {};
95 }
97}
static Map DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)

References impeller::RuntimeStage::DecodeRuntimeStages(), and flutter::testing::OpenFixtureAsMapping().

◆ SetUp()

void impeller::PlaygroundTest::SetUp ( )
override

Definition at line 45 of file playground_test.cc.

45 {
46 if (!Playground::SupportsBackend(GetParam())) {
47 GTEST_SKIP() << "Playground doesn't support this backend type.";
48 return;
49 }
50
52 GTEST_SKIP() << "Skipping due to user action.";
53 return;
54 }
55
56 // Test names that end with "WideGamut" will render with wide gamut support.
57 std::string test_name = flutter::testing::GetCurrentTestName();
58 PlaygroundSwitches switches = switches_;
59 switches.enable_wide_gamut =
60 test_name.find("WideGamut/") != std::string::npos;
61
62 if (switches.enable_wide_gamut && (GetParam() != PlaygroundBackend::kMetal ||
63 !DoesSupportWideGamutTests())) {
64 GTEST_SKIP() << "This backend doesn't yet support wide gamut.";
65 return;
66 }
67
68 switches.flags.antialiased_lines =
69 test_name.find("ExperimentAntialiasLines/") != std::string::npos;
70
71 SetupContext(GetParam(), switches);
73}
static bool ShouldOpenNewPlaygrounds()
void SetupContext(PlaygroundBackend backend, const PlaygroundSwitches &switches)
static bool SupportsBackend(PlaygroundBackend backend)

References impeller::Flags::antialiased_lines, impeller::PlaygroundSwitches::enable_wide_gamut, impeller::PlaygroundSwitches::flags, flutter::testing::GetCurrentTestName(), impeller::kMetal, impeller::Playground::SetupContext(), impeller::Playground::SetupWindow(), impeller::Playground::ShouldOpenNewPlaygrounds(), impeller::Playground::SupportsBackend(), and impeller::Playground::switches_.

Referenced by impeller::interop::testing::PlaygroundTest::SetUp().

◆ TearDown()

void impeller::PlaygroundTest::TearDown ( )
override

The documentation for this class was generated from the following files: