Flutter Impeller
compute_playground_test.cc
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 #include "flutter/fml/time/time_point.h"
6 
7 #include "flutter/testing/test_args.h"
9 
10 namespace impeller {
11 
13  : Playground(PlaygroundSwitches{flutter::testing::GetArgsForProcess()}) {}
14 
16 
18  if (!Playground::SupportsBackend(GetParam())) {
19  GTEST_SKIP_("Playground doesn't support this backend type.");
20  return;
21  }
22 
24  GTEST_SKIP_("Skipping due to user action.");
25  return;
26  }
27 
28  SetupContext(GetParam());
29  SetupWindow();
30 
31  start_time_ = fml::TimePoint::Now().ToEpochDelta();
32 }
33 
36 }
37 
38 // |Playground|
39 std::unique_ptr<fml::Mapping> ComputePlaygroundTest::OpenAssetAsMapping(
40  std::string asset_name) const {
41  return flutter::testing::OpenFixtureAsMapping(asset_name);
42 }
43 
44 std::shared_ptr<RuntimeStage> ComputePlaygroundTest::OpenAssetAsRuntimeStage(
45  const char* asset_name) const {
46  auto fixture = flutter::testing::OpenFixtureAsMapping(asset_name);
47  if (!fixture || fixture->GetSize() == 0) {
48  return nullptr;
49  }
50  auto stage = std::make_unique<RuntimeStage>(std::move(fixture));
51  if (!stage->IsValid()) {
52  return nullptr;
53  }
54  return stage;
55 }
56 
57 static std::string FormatWindowTitle(const std::string& test_name) {
58  std::stringstream stream;
59  stream << "Impeller Playground for '" << test_name << "' (Press ESC to quit)";
60  return stream.str();
61 }
62 
63 // |Playground|
65  return FormatWindowTitle(flutter::testing::GetCurrentTestName());
66 }
67 
68 } // namespace impeller
impeller::Playground::ShouldOpenNewPlaygrounds
static bool ShouldOpenNewPlaygrounds()
Definition: playground.cc:152
impeller::ComputePlaygroundTest::SetUp
void SetUp() override
Definition: compute_playground_test.cc:17
impeller::ComputePlaygroundTest::OpenAssetAsRuntimeStage
std::shared_ptr< RuntimeStage > OpenAssetAsRuntimeStage(const char *asset_name) const
Definition: compute_playground_test.cc:44
impeller::ComputePlaygroundTest::GetWindowTitle
std::string GetWindowTitle() const override
Definition: compute_playground_test.cc:64
impeller::Playground
Definition: playground.h:33
impeller::FormatWindowTitle
static std::string FormatWindowTitle(const std::string &test_name)
Definition: compute_playground_test.cc:57
impeller::Playground::SetupWindow
void SetupWindow()
Definition: playground.cc:126
impeller::ComputePlaygroundTest::TearDown
void TearDown() override
Definition: compute_playground_test.cc:34
impeller::ComputePlaygroundTest::OpenAssetAsMapping
std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const override
Definition: compute_playground_test.cc:39
impeller::ComputePlaygroundTest::~ComputePlaygroundTest
virtual ~ComputePlaygroundTest()
impeller::PlaygroundSwitches
Definition: switches.h:15
impeller::ComputePlaygroundTest::ComputePlaygroundTest
ComputePlaygroundTest()
Definition: compute_playground_test.cc:12
compute_playground_test.h
impeller::Playground::SetupContext
void SetupContext(PlaygroundBackend backend)
Definition: playground.cc:114
impeller::Playground::SupportsBackend
static bool SupportsBackend(PlaygroundBackend backend)
Definition: playground.cc:90
impeller::Playground::TeardownWindow
void TeardownWindow()
Definition: playground.cc:141
impeller
Definition: aiks_context.cc:10