Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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
6
10
11namespace impeller {
12
14 : Playground(GetParam(),
15 PlaygroundSwitches{flutter::testing::GetArgsForProcess()}) {
17 [](const char* message, const char* file, int line) -> bool {
18 // GTEST_MESSAGE_AT_ can only be used in a function that returns void.
19 // Hence the goofy lambda. The failure message and location will still
20 // be correct however.
21 //
22 // https://google.github.io/googletest/advanced.html#assertion-placement
23 [message, file, line]() -> void {
24 GTEST_MESSAGE_AT_(file, line, "Impeller Validation Error",
25 ::testing::TestPartResult::kFatalFailure)
26 << message;
27 }();
28 return true;
29 });
30}
31
35
37 if (!Playground::SupportsBackend(GetParam())) {
38 GTEST_SKIP() << "Playground doesn't support this backend type.";
39 return;
40 }
41
43 GTEST_SKIP() << "Skipping due to user action.";
44 return;
45 }
46}
47
51
53 return GetParam();
54}
55
56// |Playground|
57std::unique_ptr<fml::Mapping> PlaygroundTest::OpenAssetAsMapping(
58 std::string asset_name) const {
60}
61
62absl::StatusOr<RuntimeStage::Map> PlaygroundTest::OpenAssetAsRuntimeStage(
63 const char* asset_name) const {
64 const std::shared_ptr<fml::Mapping> fixture =
66 if (!fixture || fixture->GetSize() == 0) {
67 return absl::NotFoundError("Asset not found or empty.");
68 }
70}
71
72// |Playground|
73std::string PlaygroundTest::GetWindowTitle() const {
74 std::stringstream stream;
75 stream << "Impeller Playground for '"
77 switch (GetBackend()) {
80 break;
83 if (GetSwitches().use_angle) {
84 stream << " (Angle) ";
85 }
86 break;
88 if (GetSwitches().use_swiftshader) {
89 stream << " (SwiftShader) ";
90 }
91 break;
92 }
93 stream << " (Press ESC to quit)";
94 return stream.str();
95}
96
97// |Playground|
98bool PlaygroundTest::ShouldKeepRendering() const {
99 if (!GetSwitches().timeout.has_value()) {
100 return true;
101 }
102
103 if (SecondsF{GetSecondsElapsed()} > GetSwitches().timeout.value()) {
104 return false;
105 }
106
107 return true;
108}
109
110} // namespace impeller
static bool ShouldOpenNewPlaygrounds()
static bool SupportsBackend(PlaygroundBackend backend)
const PlaygroundSwitches & GetSwitches() const
Return an unmodifiable reference to the current switches. The switches might change at the start of a...
Definition playground.h:167
Scalar GetSecondsElapsed() const
Get the amount of time elapsed from the start of the playground's execution.
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
static absl::StatusOr< Map > DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)
const char * message
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition testing.cc:14
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
Definition testing.cc:58
void ImpellerValidationErrorsSetCallback(ValidationFailureCallback callback)
Sets a callback that callers (usually tests) can set to intercept validation failures.
Definition validation.cc:21
PlaygroundBackend
Definition playground.h:27
std::chrono::duration< float > SecondsF
Definition timing.h:13
std::optional< std::chrono::milliseconds > timeout
Definition switches.h:21