#include #include #include #include #include #include #include #include #include #include #include using namespace mbgl; class RasterTileTest { public: FakeFileSource fileSource; TransformState transformState; util::RunLoop loop; ThreadPool threadPool { 1 }; AnnotationManager annotationManager { 1.0 }; style::Style style { threadPool, fileSource, 1.0 }; Tileset tileset { { "https://example.com" }, { 0, 22 }, "none" }; style::UpdateParameters updateParameters { 1.0, MapDebugOptions(), transformState, threadPool, fileSource, MapMode::Continuous, annotationManager, style }; }; TEST(RasterTile, setError) { RasterTileTest test; RasterTile tile(OverscaledTileID(0, 0, 0), test.updateParameters, test.tileset); tile.setError(std::make_exception_ptr(std::runtime_error("test"))); EXPECT_FALSE(tile.isRenderable()); EXPECT_TRUE(tile.isLoaded()); EXPECT_TRUE(tile.isComplete()); } TEST(RasterTile, onError) { RasterTileTest test; RasterTile tile(OverscaledTileID(0, 0, 0), test.updateParameters, test.tileset); tile.onError(std::make_exception_ptr(std::runtime_error("test"))); EXPECT_FALSE(tile.isRenderable()); EXPECT_TRUE(tile.isLoaded()); EXPECT_TRUE(tile.isComplete()); } TEST(RasterTile, onParsed) { RasterTileTest test; RasterTile tile(OverscaledTileID(0, 0, 0), test.updateParameters, test.tileset); tile.onParsed(std::make_unique(UnassociatedImage{})); EXPECT_TRUE(tile.isRenderable()); EXPECT_TRUE(tile.isLoaded()); EXPECT_TRUE(tile.isComplete()); } TEST(RasterTile, onParsedEmpty) { RasterTileTest test; RasterTile tile(OverscaledTileID(0, 0, 0), test.updateParameters, test.tileset); tile.onParsed(nullptr); EXPECT_FALSE(tile.isRenderable()); EXPECT_TRUE(tile.isLoaded()); EXPECT_TRUE(tile.isComplete()); }