mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix runtime stage tests (flutter/engine#37025)
This commit is contained in:
parent
0a923d0c24
commit
9f5b68ded6
@ -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 {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user