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