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::kVulkan), \
67  [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
68  return PlaygroundBackendToString(info.param); \
69  });
70 
71 #define INSTANTIATE_METAL_PLAYGROUND_SUITE(playground) \
72  [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
73  ""; \
74  INSTANTIATE_TEST_SUITE_P( \
75  Play, playground, ::testing::Values(PlaygroundBackend::kMetal), \
76  [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
77  return PlaygroundBackendToString(info.param); \
78  });
79 
80 #define INSTANTIATE_VULKAN_PLAYGROUND_SUITE(playground) \
81  [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
82  ""; \
83  INSTANTIATE_TEST_SUITE_P( \
84  Play, playground, ::testing::Values(PlaygroundBackend::kVulkan), \
85  [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
86  return PlaygroundBackendToString(info.param); \
87  });
88 
89 #define INSTANTIATE_OPENGLES_PLAYGROUND_SUITE(playground) \
90  [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \
91  ""; \
92  INSTANTIATE_TEST_SUITE_P( \
93  Play, playground, ::testing::Values(PlaygroundBackend::kOpenGLES), \
94  [](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
95  return PlaygroundBackendToString(info.param); \
96  });
97 
98 } // namespace impeller
99 
100 #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:26