Fix runtime stage tests (flutter/engine#37025)

This commit is contained in:
Brandon DeRosier 2022-10-26 11:31:24 -07:00 committed by GitHub
parent 0a923d0c24
commit 9f5b68ded6
8 changed files with 18 additions and 37 deletions

View File

@ -2086,7 +2086,7 @@ TEST_P(EntityTest, RuntimeEffect) {
contents->SetGeometry(Geometry::MakeCover());
auto runtime_stage =
LoadFixtureRuntimeStage("runtime_stage_example.frag.iplr");
OpenAssetAsRuntimeStage("runtime_stage_example.frag.iplr");
contents->SetRuntimeStage(runtime_stage);
struct FragUniforms {

View File

@ -437,22 +437,6 @@ std::shared_ptr<Texture> Playground::CreateTextureCubeForFixture(
return texture;
}
std::shared_ptr<RuntimeStage> Playground::LoadFixtureRuntimeStage(
const char* fixture_name) const {
if (fixture_name == nullptr) {
return nullptr;
}
auto runtime_stage =
std::make_shared<RuntimeStage>(OpenAssetAsMapping(fixture_name));
if (!runtime_stage->IsValid()) {
VALIDATION_LOG << "Could not load valid runtime stage.";
return nullptr;
}
return runtime_stage;
}
void Playground::SetWindowSize(ISize size) {
window_size_ = size;
}

View File

@ -64,9 +64,6 @@ class Playground {
std::shared_ptr<Texture> CreateTextureCubeForFixture(
std::array<const char*, 6> fixture_names) const;
std::shared_ptr<RuntimeStage> LoadFixtureRuntimeStage(
const char* fixture_name) const;
static bool SupportsBackend(PlaygroundBackend backend);
virtual std::unique_ptr<fml::Mapping> OpenAssetAsMapping(

View File

@ -34,6 +34,19 @@ std::unique_ptr<fml::Mapping> PlaygroundTest::OpenAssetAsMapping(
return flutter::testing::OpenFixtureAsMapping(asset_name);
}
std::shared_ptr<RuntimeStage> PlaygroundTest::OpenAssetAsRuntimeStage(
const char* asset_name) const {
auto fixture = flutter::testing::OpenFixtureAsMapping(asset_name);
if (!fixture || fixture->GetSize() == 0) {
return nullptr;
}
auto stage = std::make_unique<RuntimeStage>(std::move(fixture));
if (!stage->IsValid()) {
return nullptr;
}
return stage;
}
static std::string FormatWindowTitle(const std::string& test_name) {
std::stringstream stream;
stream << "Impeller Playground for '" << test_name

View File

@ -27,6 +27,9 @@ class PlaygroundTest : public Playground,
std::unique_ptr<fml::Mapping> OpenAssetAsMapping(
std::string asset_name) const override;
std::shared_ptr<RuntimeStage> OpenAssetAsRuntimeStage(
const char* asset_name) const;
// |Playground|
std::string GetWindowTitle() const override;

View File

@ -17,19 +17,6 @@ RuntimeStagePlayground::RuntimeStagePlayground() = default;
RuntimeStagePlayground::~RuntimeStagePlayground() = default;
std::unique_ptr<RuntimeStage> RuntimeStagePlayground::CreateStageFromFixture(
const std::string& fixture_name) const {
auto fixture = flutter::testing::OpenFixtureAsMapping(fixture_name);
if (!fixture || fixture->GetSize() == 0) {
return nullptr;
}
auto stage = std::make_unique<RuntimeStage>(std::move(fixture));
if (!stage->IsValid()) {
return nullptr;
}
return stage;
}
bool RuntimeStagePlayground::RegisterStage(const RuntimeStage& stage) {
std::promise<bool> registration;
auto future = registration.get_future();

View File

@ -16,9 +16,6 @@ class RuntimeStagePlayground : public PlaygroundTest {
~RuntimeStagePlayground();
std::unique_ptr<RuntimeStage> CreateStageFromFixture(
const std::string& fixture_name) const;
bool RegisterStage(const RuntimeStage& stage);
private:

View File

@ -216,7 +216,7 @@ TEST_P(RuntimeStageTest, CanCreatePipelineFromRuntimeStage) {
if (GetParam() != PlaygroundBackend::kMetal) {
GTEST_SKIP_("Skipped: https://github.com/flutter/flutter/issues/105538");
}
auto stage = CreateStageFromFixture("ink_sparkle.frag.iplr");
auto stage = OpenAssetAsRuntimeStage("ink_sparkle.frag.iplr");
ASSERT_NE(stage, nullptr);
ASSERT_TRUE(RegisterStage(*stage));
auto library = GetContext()->GetShaderLibrary();