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"
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:
25 
26  virtual ~PlaygroundTest();
27 
28  void SetUp() override;
29 
30  void TearDown() override;
31 
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_
std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const override
std::string GetWindowTitle() const override
PlaygroundBackend GetBackend() const
RuntimeStage::Map OpenAssetAsRuntimeStage(const char *asset_name) const
std::map< RuntimeStageBackend, std::shared_ptr< RuntimeStage > > Map
Definition: runtime_stage.h:24
PlaygroundBackend
Definition: playground.h:27