| Flutter Impeller |

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
10 #include "flutter/testing/test_args.h"
11 #include "flutter/testing/testing.h"
12 #include "impeller/playground/playground.h"
13 #include "impeller/playground/switches.h"
14 #include "third_party/abseil-cpp/absl/status/statusor.h"
15
16 #if FML_OS_MACOSX
17 #include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h"
18 #endif
19
20 namespace impeller {
21
22 class PlaygroundTest : public Playground,
23 public ::testing::TestWithParam<PlaygroundBackend> {
24 public:
25 PlaygroundTest();
26
27 virtual ~PlaygroundTest();
28
29 void SetUp() override;
30
31 void TearDown() override;
32
33 PlaygroundBackend GetBackend() const;
34
35 // |Playground|
36 std::unique_ptr<fml::Mapping> OpenAssetAsMapping(
37 std::string asset_name) const override;
38
39 absl::StatusOr<RuntimeStage::Map> OpenAssetAsRuntimeStage(
40 const char* asset_name) const;
41
42 // |Playground|
43 std::string GetWindowTitle() const override;
44
45 private:
46 // |Playground|
47 bool ShouldKeepRendering() const override;
48
49 #if FML_OS_MACOSX
50 fml::ScopedNSAutoreleasePool autorelease_pool_;
51 #endif
52
53 PlaygroundTest(const PlaygroundTest&) = delete;
54
55 PlaygroundTest& operator=(const PlaygroundTest&) = delete;
56 };
57
58 #define INSTANTIATE_PLAYGROUND_SUITE(playground) \
59 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
60 ""; \
61 INSTANTIATE_TEST_SUITE_P( \
62 Play, playground, \
63 ::testing::Values(PlaygroundBackend::kMetal, \
64 PlaygroundBackend::kOpenGLES, \
65 PlaygroundBackend::kVulkan), \
66 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
67 return PlaygroundBackendToString(info.param); \
68 });
69
70 #define INSTANTIATE_METAL_PLAYGROUND_SUITE(playground) \
71 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
72 ""; \
73 INSTANTIATE_TEST_SUITE_P( \
74 Play, playground, ::testing::Values(PlaygroundBackend::kMetal), \
75 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
76 return PlaygroundBackendToString(info.param); \
77 });
78
79 #define INSTANTIATE_VULKAN_PLAYGROUND_SUITE(playground) \
80 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
81 ""; \
82 INSTANTIATE_TEST_SUITE_P( \
83 Play, playground, ::testing::Values(PlaygroundBackend::kVulkan), \
84 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
85 return PlaygroundBackendToString(info.param); \
86 });
87
88 #define INSTANTIATE_OPENGLES_PLAYGROUND_SUITE(playground) \
89 [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
90 ""; \
91 INSTANTIATE_TEST_SUITE_P( \
92 Play, playground, ::testing::Values(PlaygroundBackend::kOpenGLES), \
93 [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
94 return PlaygroundBackendToString(info.param); \
95 });
96
97 } // namespace impeller
98
99 #endif // FLUTTER_IMPELLER_PLAYGROUND_PLAYGROUND_TEST_H_
impeller::Playground
Definition: playground.h:48
impeller::PlaygroundTest
Definition: playground_test.h:23
impeller::PlaygroundTest::OpenAssetAsMapping
std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const override
Definition: playground_test.cc:84
impeller::PlaygroundTest::GetWindowTitle
std::string GetWindowTitle() const override
Definition: playground_test.cc:100
impeller::PlaygroundTest::OpenAssetAsRuntimeStage
absl::StatusOr< RuntimeStage::Map > OpenAssetAsRuntimeStage(const char *asset_name) const
Definition: playground_test.cc:89
impeller::PlaygroundTest::PlaygroundTest
PlaygroundTest()
Definition: playground_test.cc:13
impeller::PlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: playground_test.cc:75
impeller::PlaygroundTest::~PlaygroundTest
virtual ~PlaygroundTest()
Definition: playground_test.cc:31
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:79
impeller::PlaygroundTest::SetUp
void SetUp() override
Definition: playground_test.cc:45
impeller
Definition: allocation.cc:12
impeller::PlaygroundBackend
PlaygroundBackend
Definition: playground.h:27
switches.h
playground.h