Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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_PLAYGROUND_PLAYGROUND_TEST_H_
6#define FLUTTER_IMPELLER_PLAYGROUND_PLAYGROUND_TEST_H_
7
8#include <memory>
9
15#include "third_party/abseil-cpp/absl/status/statusor.h"
16
17#if FML_OS_MACOSX
19#endif
20
21namespace impeller {
22
24 public ::testing::TestWithParam<PlaygroundBackend> {
25 public:
27
28 virtual ~PlaygroundTest();
29
30 static void SetupTestEnvironment();
31
32 void SetUp() override;
33
34 void TearDown() override;
35
37
38 // |Playground|
39 std::unique_ptr<fml::Mapping> OpenAssetAsMapping(
40 std::string asset_name) const override;
41
42 absl::StatusOr<RuntimeStage::Map> OpenAssetAsRuntimeStage(
43 const char* asset_name) const;
44
45 // |Playground|
46 std::string GetWindowTitle() const override;
47
49
50 protected:
51 /// @brief This method is overridden on a test suite basis and establishes
52 /// whether a given set of tests is intended to generate goldens.
53 ///
54 /// The return value of this method is used to set the default value of
55 /// |Playground::ShouldWriteGoldenImage|, but an individual test is still
56 /// allowed to enable a golden image by calling |SetEnableWriteGolden|.
57 ///
58 /// @return false by default unless overridden in a subclass
59 virtual bool IsGoldenTestSuite() const;
60
61 private:
62 // |Playground|
63 bool ShouldKeepRendering() const override;
64
65#if FML_OS_MACOSX
66 fml::ScopedNSAutoreleasePool autorelease_pool_;
67#endif
68
69 PlaygroundTest(const PlaygroundTest&) = delete;
70
71 PlaygroundTest& operator=(const PlaygroundTest&) = delete;
72};
73
75 protected:
76 bool IsGoldenTestSuite() const override { return true; }
77};
78
79#define INSTANTIATE_PLAYGROUND_SUITE(playground) \
80 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
81 ""; \
82 INSTANTIATE_TEST_SUITE_P( \
83 Play, playground, \
84 ::testing::Values( \
85 PlaygroundBackend::kMetal, PlaygroundBackend::kMetalSDF, \
86 PlaygroundBackend::kOpenGLES, PlaygroundBackend::kOpenGLESSDF, \
87 PlaygroundBackend::kVulkan), \
88 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
89 return PlaygroundBackendToString(info.param); \
90 });
91
92#define INSTANTIATE_METAL_PLAYGROUND_SUITE(playground) \
93 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
94 ""; \
95 INSTANTIATE_TEST_SUITE_P( \
96 Play, playground, ::testing::Values(PlaygroundBackend::kMetal), \
97 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
98 return PlaygroundBackendToString(info.param); \
99 });
100
101#define INSTANTIATE_VULKAN_PLAYGROUND_SUITE(playground) \
102 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
103 ""; \
104 INSTANTIATE_TEST_SUITE_P( \
105 Play, playground, ::testing::Values(PlaygroundBackend::kVulkan), \
106 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
107 return PlaygroundBackendToString(info.param); \
108 });
109
110#define INSTANTIATE_OPENGLES_PLAYGROUND_SUITE(playground) \
111 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
112 ""; \
113 INSTANTIATE_TEST_SUITE_P( \
114 Play, playground, ::testing::Values(PlaygroundBackend::kOpenGLES), \
115 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
116 return PlaygroundBackendToString(info.param); \
117 });
118
119} // namespace impeller
120
121#endif // FLUTTER_IMPELLER_PLAYGROUND_PLAYGROUND_TEST_H_
std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const override
std::string GetWindowTitle() const override
absl::StatusOr< RuntimeStage::Map > OpenAssetAsRuntimeStage(const char *asset_name) const
PlaygroundBackend GetBackend() const
testing::GoldenDigestManager * GetGoldenDigestManager() const override
virtual bool IsGoldenTestSuite() const
This method is overridden on a test suite basis and establishes whether a given set of tests is inten...
bool IsGoldenTestSuite() const override
This method is overridden on a test suite basis and establishes whether a given set of tests is inten...
PlaygroundBackend
Definition playground.h:32