fix: distinguish raster array field snapshots
This commit is contained in:
@@ -54,6 +54,14 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
|
||||
std::string fixtureBytes(const std::string& fixtureID, const std::string& file) {
|
||||
return util::read_file("particle-fixtures/" + fixtureID + "/" + file);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
using namespace mbgl;
|
||||
using SourceType = mbgl::style::SourceType;
|
||||
|
||||
@@ -156,6 +164,61 @@ TEST(Source, RasterArrayRenderItem) {
|
||||
EXPECT_FALSE(item->hasRenderPass(RenderPass::Translucent));
|
||||
}
|
||||
|
||||
TEST(Source, RasterArraySnapshotsUseProcessWideGenerations) {
|
||||
SourceTest test;
|
||||
const auto eastMetadata = fixtureBytes("uniform-east", "metadata.json");
|
||||
const auto eastField = fixtureBytes("uniform-east", "field.f32");
|
||||
const auto northMetadata = fixtureBytes("uniform-north", "metadata.json");
|
||||
const auto northField = fixtureBytes("uniform-north", "field.f32");
|
||||
|
||||
test.fileSource->sourceResponse = [&](const Resource& resource) -> Response {
|
||||
Response response;
|
||||
if (resource.url == "east-metadata") {
|
||||
response.data = std::make_unique<std::string>(eastMetadata);
|
||||
} else if (resource.url == "east-field") {
|
||||
response.data = std::make_unique<std::string>(eastField);
|
||||
} else if (resource.url == "north-metadata") {
|
||||
response.data = std::make_unique<std::string>(northMetadata);
|
||||
} else if (resource.url == "north-field") {
|
||||
response.data = std::make_unique<std::string>(northField);
|
||||
} else {
|
||||
ADD_FAILURE() << "Unexpected RasterArray resource: " << resource.url;
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
style::RasterArraySource east{"source", "uniform-east", "east-metadata", "east-field"};
|
||||
east.setObserver(&test.styleObserver);
|
||||
style::RasterArraySource north{"source", "uniform-north", "north-metadata", "north-field"};
|
||||
north.setObserver(&test.styleObserver);
|
||||
|
||||
uint8_t loadedSources = 0;
|
||||
test.styleObserver.sourceChanged = [&](Source&) {
|
||||
if (++loadedSources == 2) {
|
||||
test.end();
|
||||
}
|
||||
};
|
||||
east.loadDescription(*test.fileSource);
|
||||
north.loadDescription(*test.fileSource);
|
||||
|
||||
test.run();
|
||||
ASSERT_TRUE(east.impl().field);
|
||||
ASSERT_TRUE(north.impl().field);
|
||||
|
||||
EXPECT_NE(east.impl().field->generation, north.impl().field->generation);
|
||||
}
|
||||
|
||||
TEST(Source, RasterArrayFieldIdentityIncludesFixtureAndDataVersion) {
|
||||
const auto east = particle::OfflineFixtureParticleAdapter::load("uniform-east", 7);
|
||||
const auto northWithSameGeneration = particle::OfflineFixtureParticleAdapter::load("uniform-north", 7);
|
||||
auto eastWithNewDataVersion = east;
|
||||
++eastWithNewDataVersion.dataVersion;
|
||||
|
||||
EXPECT_TRUE(particle::fieldIdentityChanged(east, northWithSameGeneration));
|
||||
EXPECT_TRUE(particle::fieldIdentityChanged(east, eastWithNewDataVersion));
|
||||
EXPECT_FALSE(particle::fieldIdentityChanged(east, east));
|
||||
}
|
||||
|
||||
TEST(Source, LoadingCorrupt) {
|
||||
SourceTest test;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user