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