From 1a71d0ca03f6bd6c7e3fa14fd9fedc037c0585a4 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 11 Sep 2019 14:16:53 +0300 Subject: test --- cmake/test.cmake | 1 + test/api/annotations.test.cpp | 60 ++++++++--------- test/api/custom_geometry_source.test.cpp | 4 +- test/api/custom_layer.test.cpp | 4 +- test/api/query.test.cpp | 8 +-- test/api/recycle_map.cpp | 6 +- test/gl/context.test.cpp | 4 +- test/map/map.test.cpp | 40 +++++------ test/map/prefetch.test.cpp | 8 +-- test/renderer/image_manager.test.cpp | 6 +- test/renderer/pattern_atlas.test.cpp | 6 +- test/sprite/sprite_loader.test.cpp | 6 +- test/sprite/sprite_parser.test.cpp | 28 ++++---- test/src/mbgl/test/util.cpp | 10 +-- test/storage/offline_database.test.cpp | 106 +++++++++++++++--------------- test/storage/offline_download.test.cpp | 10 +-- test/storage/sync_file_source.test.cpp | 12 ++-- test/style/expression/expression.test.cpp | 6 +- test/style/source.test.cpp | 4 +- test/style/style.test.cpp | 6 +- test/style/style_layer.test.cpp | 4 +- test/style/style_parser.test.cpp | 8 +-- test/text/glyph_manager.test.cpp | 10 +-- test/text/glyph_pbf.test.cpp | 4 +- test/text/local_glyph_rasterizer.test.cpp | 22 +++---- test/tile/vector_tile.test.cpp | 4 +- test/util/image.test.cpp | 14 ++-- test/util/memory.test.cpp | 4 +- 28 files changed, 205 insertions(+), 200 deletions(-) diff --git a/cmake/test.cmake b/cmake/test.cmake index 3cb0ef3a72..3ba9a67a99 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -24,6 +24,7 @@ target_include_directories(mbgl-test target_link_libraries(mbgl-test PRIVATE googletest + Mapbox::Base::io Mapbox::Base::Extras::args mbgl-core shelf-pack-cpp diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 03330dc4c6..6869b01768 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -17,7 +17,7 @@ using namespace mbgl; namespace { PremultipliedImage namedImage(const std::string& name) { - return decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png")); + return decodeImage(*mapbox::base::io::readFile("test/fixtures/sprites/" + name + ".png")); } std::unique_ptr namedMarker(const std::string& name) { @@ -43,7 +43,7 @@ public: TEST(Annotations, SymbolAnnotation) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point(0, 0), "default_marker" }); test.checkRendering("point_annotation"); @@ -62,7 +62,7 @@ TEST(Annotations, SymbolAnnotationTileBoundary) { // tests precision issue from https://github.com/mapbox/mapbox-gl-native/issues/12472 AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point(0.000000000000001, 0.00000000000001), "default_marker" }); test.map.jumpTo(CameraOptions().withZoom(10)); @@ -77,7 +77,7 @@ TEST(Annotations, LineAnnotation) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); test.checkRendering("line_annotation"); @@ -92,7 +92,7 @@ TEST(Annotations, FillAnnotation) { FillAnnotation annotation { polygon }; annotation.color = Color::red(); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); test.checkRendering("fill_annotation"); @@ -105,7 +105,7 @@ TEST(Annotations, AntimeridianAnnotationSmall) { double antimeridian = 180; test.map.jumpTo(CameraOptions().withCenter(LatLng { 0, antimeridian }).withZoom(0.0)); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); LineString line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; LineAnnotation lineAnnotation { line }; @@ -126,7 +126,7 @@ TEST(Annotations, AntimeridianAnnotationLarge) { double antimeridian = 180; test.map.jumpTo(CameraOptions().withCenter(mbgl::LatLng(0.0, antimeridian)).withZoom(0.0)); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); LineString line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; LineAnnotation lineAnnotation { line }; @@ -151,7 +151,7 @@ TEST(Annotations, OverlappingFillAnnotation) { FillAnnotation overlaidAnnotation { polygon }; overlaidAnnotation.color = Color::red(); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotation(underlaidAnnotation); test.map.addAnnotation(overlaidAnnotation); test.checkRendering("overlapping_fill_annotation"); @@ -160,7 +160,7 @@ TEST(Annotations, OverlappingFillAnnotation) { TEST(Annotations, AddMultiple) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point { -10, 0 }, "default_marker" }); @@ -173,7 +173,7 @@ TEST(Annotations, AddMultiple) { TEST(Annotations, NonImmediateAdd) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.frontend.render(test.map); Polygon polygon = { {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }; @@ -187,7 +187,7 @@ TEST(Annotations, NonImmediateAdd) { TEST(Annotations, UpdateSymbolAnnotationGeometry) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotationImage(namedMarker("flipped_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point { 0, 0 }, "default_marker" }); @@ -201,7 +201,7 @@ TEST(Annotations, UpdateSymbolAnnotationGeometry) { TEST(Annotations, UpdateSymbolAnnotationIcon) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotationImage(namedMarker("flipped_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point { 0, 0 }, "default_marker" }); @@ -219,7 +219,7 @@ TEST(Annotations, UpdateLineAnnotationGeometry) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); test.frontend.render(test.map); @@ -236,7 +236,7 @@ TEST(Annotations, UpdateLineAnnotationStyle) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); test.frontend.render(test.map); @@ -253,7 +253,7 @@ TEST(Annotations, UpdateFillAnnotationGeometry) { FillAnnotation annotation { Polygon { {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} } }; annotation.color = Color::red(); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); test.frontend.render(test.map); @@ -270,7 +270,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) { FillAnnotation annotation { polygon }; annotation.color = Color::red(); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); test.frontend.render(test.map); @@ -283,7 +283,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) { TEST(Annotations, RemovePoint) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point { 0, 0 }, "default_marker" }); @@ -301,7 +301,7 @@ TEST(Annotations, RemoveShape) { annotation.color = Color::red(); annotation.width = { 5 }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); AnnotationID shape = test.map.addAnnotation(annotation); test.frontend.render(test.map); @@ -314,7 +314,7 @@ TEST(Annotations, ImmediateRemoveShape) { AnnotationTest test; test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation { LineString() })); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.frontend.render(test.map); } @@ -322,20 +322,20 @@ TEST(Annotations, ImmediateRemoveShape) { TEST(Annotations, SwitchStyle) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point { 0, 0 }, "default_marker" }); test.frontend.render(test.map); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.checkRendering("switch_style"); } TEST(Annotations, ReaddImage) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point { 0, 0 }, "default_marker" }); @@ -348,7 +348,7 @@ TEST(Annotations, ReaddImage) { TEST(Annotations, QueryRenderedFeatures) { AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.addAnnotation(SymbolAnnotation { Point { 0, 0 }, "default_marker" }); test.map.addAnnotation(SymbolAnnotation { Point { 0, 50 }, "default_marker" }); @@ -372,7 +372,7 @@ TEST(Annotations, QueryFractionalZoomLevels) { auto viewSize = test.frontend.getSize(); auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); std::vector ids; @@ -404,7 +404,7 @@ TEST(Annotations, VisibleFeatures) { auto viewSize = test.frontend.getSize(); auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); test.map.jumpTo(CameraOptions().withCenter(mbgl::LatLng(5.0, 5.0)).withZoom(3.0)); @@ -448,7 +448,7 @@ TEST(Annotations, ViewFrustumCulling) { auto viewSize = test.frontend.getSize(); auto box = ScreenBox { {}, { double(viewSize.width), double(viewSize.height) } }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotationImage(namedMarker("default_marker")); const LatLng center = { 5.0, 5.0 }; test.map.jumpTo(CameraOptions().withCenter(center).withZoom(3.0)); @@ -514,7 +514,7 @@ TEST(Annotations, DebugEmpty) { // should not render them. AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); test.map.jumpTo(CameraOptions().withZoom(1.0)); @@ -527,7 +527,7 @@ TEST(Annotations, DebugSparse) { // tiles because they're all empty. AnnotationTest test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.setDebug(MapDebugOptions::TileBorders); test.map.jumpTo(CameraOptions().withZoom(1.0)); test.map.addAnnotationImage(namedMarker("default_marker")); @@ -545,7 +545,7 @@ TEST(Annotations, ChangeMaxZoom) { annotation.width = { 5 }; test.map.setBounds(BoundOptions().withMaxZoom(6)); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); test.map.setBounds(BoundOptions().withMaxZoom(14)); test.map.jumpTo(CameraOptions().withZoom(*test.map.getBounds().maxZoom)); diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp index f35b4d335c..fa088b5760 100644 --- a/test/api/custom_geometry_source.test.cpp +++ b/test/api/custom_geometry_source.test.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -23,7 +23,7 @@ TEST(CustomGeometrySource, Grid) { Map map(frontend, MapObserver::nullObserver(), MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()), ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets")); - map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/water.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); CustomGeometrySource::Options options; diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 175d053f93..80b385db24 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -97,7 +97,7 @@ TEST(CustomLayer, Basic) { Map map(frontend, MapObserver::nullObserver(), MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()), ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets")); - map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/water.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); map.getStyle().addLayer(std::make_unique( "custom", diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index bf3f64a0c8..1c711dffd9 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -25,9 +25,9 @@ namespace { class QueryTest { public: QueryTest() { - map.getStyle().loadJSON(util::read_file("test/fixtures/api/query_style.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/query_style.json")); map.getStyle().addImage(std::make_unique("test-icon", - decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0)); + decodeImage(*mapbox::base::io::readFile("test/fixtures/sprites/default_marker.png")), 1.0)); frontend.render(map); } @@ -43,7 +43,7 @@ std::vector getTopClusterFeature(QueryTest& test) { test.fileSource->sourceResponse = [&] (const Resource& resource) { EXPECT_EQ("http://url"s, resource.url); Response response; - response.data = std::make_unique(util::read_file("test/fixtures/supercluster/places.json"s)); + response.data = std::make_unique(*mapbox::base::io::readFile("test/fixtures/supercluster/places.json"s)); return response; }; diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp index b3c573b1a2..e716cc8dda 100644 --- a/test/api/recycle_map.cpp +++ b/test/api/recycle_map.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include using namespace mbgl; @@ -36,10 +36,10 @@ TEST(API, RecycleMapUpdateImages) { auto layer = std::make_unique("geometry", "geometry"); layer->setIconImage({ markerName }); - map->getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + map->getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); map->getStyle().addSource(std::move(source)); map->getStyle().addLayer(std::move(layer)); - map->getStyle().addImage(std::make_unique(markerName, decodeImage(util::read_file(markerPath)), 1.0)); + map->getStyle().addImage(std::make_unique(markerName, decodeImage(*mapbox::base::io::readFile(markerPath)), 1.0)); }; // default marker diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp index 770434c5be..3d6fb68ae0 100644 --- a/test/gl/context.test.cpp +++ b/test/gl/context.test.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -96,7 +96,7 @@ TEST(GLContextMode, Shared) { Map map(frontend, MapObserver::nullObserver(), MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()), ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets")); - map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/water.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0)); // Set transparent background layer. diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 8cb781c6df..3183701155 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ TEST(Map, RendererState) { double pitchInDegrees = 45.0; double bearingInDegrees = 30.0; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.map.jumpTo(CameraOptions().withCenter(coordinate).withZoom(zoom).withPitch(pitchInDegrees).withBearing(bearingInDegrees)); test.runLoop.runOnce(); @@ -92,7 +92,7 @@ TEST(Map, RendererState) { } // RendererState::hasImage - test.map.getStyle().addImage(std::make_unique("default_marker", decodeImage(util::read_file("test/fixtures/sprites/default_marker.png")), 1.0)); + test.map.getStyle().addImage(std::make_unique("default_marker", decodeImage(*mapbox::base::io::readFile("test/fixtures/sprites/default_marker.png")), 1.0)); // The frontend has not yet been notified about the newly-added image. EXPECT_FALSE(test.frontend.hasImage("default_marker")); @@ -243,7 +243,7 @@ TEST(Map, Offline) { auto expiredItem = [] (const std::string& path) { Response response; - response.data = std::make_shared(util::read_file("test/fixtures/map/offline/"s + path)); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/map/offline/"s + path)); response.expires = Timestamp{ Seconds(0) }; return response; }; @@ -269,14 +269,14 @@ TEST(Map, Offline) { TEST(Map, SetStyleDefaultCamera) { MapTest<> test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); CameraOptions camera = test.map.getCameraOptions(); EXPECT_DOUBLE_EQ(*camera.zoom, 0.0); EXPECT_DOUBLE_EQ(*camera.pitch, 0.0); EXPECT_DOUBLE_EQ(*camera.bearing, 0.0); EXPECT_EQ(*camera.center, LatLng {}); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty-zoomed.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty-zoomed.json")); camera = test.map.getCameraOptions(); EXPECT_DOUBLE_EQ(*camera.zoom, 0.0); @@ -414,7 +414,7 @@ TEST(Map, StyleFresh) { EXPECT_EQ(1u, test.fileSource->requests.size()); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/api/empty.json")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); response.expires = Timestamp::max(); test.fileSource->respond(Resource::Style, response); @@ -432,7 +432,7 @@ TEST(Map, StyleExpired) { EXPECT_EQ(1u, test.fileSource->requests.size()); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/api/empty.json")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); response.expires = util::now() - 1h; test.fileSource->respond(Resource::Style, response); @@ -468,7 +468,7 @@ TEST(Map, StyleExpiredWithAnnotations) { EXPECT_EQ(1u, test.fileSource->requests.size()); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/api/empty.json")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); response.expires = util::now() - 1h; test.fileSource->respond(Resource::Style, response); @@ -492,7 +492,7 @@ TEST(Map, StyleExpiredWithRender) { EXPECT_EQ(1u, test.fileSource->requests.size()); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/api/empty.json")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); response.expires = util::now() - 1h; test.fileSource->respond(Resource::Style, response); @@ -514,7 +514,7 @@ TEST(Map, StyleEarlyMutation) { test.map.getStyle().addLayer(std::make_unique("bg")); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/api/water.json")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/api/water.json")); test.fileSource->respond(Resource::Style, response); EXPECT_EQ(1u, test.fileSource->requests.size()); @@ -528,7 +528,7 @@ TEST(Map, MapLoadingSignal) { test.observer.willStartLoadingMapCallback = [&]() { emitted = true; }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); EXPECT_TRUE(emitted); } @@ -539,7 +539,7 @@ TEST(Map, MapLoadedSignal) { test.runLoop.stop(); }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); test.runLoop.run(); } @@ -551,7 +551,7 @@ TEST(Map, StyleLoadedSignal) { test.observer.didFinishLoadingStyleCallback = [&]() { emitted = true; }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); EXPECT_TRUE(emitted); // But not when the style couldn't be parsed @@ -602,7 +602,7 @@ TEST(Map, TEST_REQUIRES_SERVER(StyleNotFound)) { TEST(Map, AddLayer) { MapTest<> test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); auto layer = std::make_unique("background"); layer->setBackgroundColor({ { 1, 0, 0, 1 } }); @@ -621,7 +621,7 @@ TEST(Map, WithoutVAOExtension) { gfx::BackendScope scope { *test.frontend.getBackend() }; static_cast(test.frontend.getBackend()->getContext()).disableVAOExtension = true; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/water.json")); test::checkImage("test/fixtures/map/no_vao", test.frontend.render(test.map), 0.002); } @@ -629,7 +629,7 @@ TEST(Map, WithoutVAOExtension) { TEST(Map, RemoveLayer) { MapTest<> test; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/empty.json")); auto layer = std::make_unique("background"); layer->setBackgroundColor({{ 1, 0, 0, 1 }}); @@ -647,7 +647,7 @@ TEST(Map, DisabledSources) { if (res.url == "asset://tile.png") { Response response; response.data = std::make_shared( - util::read_file("test/fixtures/map/disabled_layers/tile.png")); + *mapbox::base::io::readFile("test/fixtures/map/disabled_layers/tile.png")); return {std::move(response)}; } return {}; @@ -774,7 +774,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) { Map map(frontend, observer, MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()), ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets")); - map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/api/water.json")); runLoop.run(); } @@ -827,7 +827,7 @@ TEST(Map, Issue12432) { test.fileSource->tileResponse = [&](const Resource&) { Response result; - result.data = std::make_shared(util::read_file("test/fixtures/map/issue12432/0-0-0.mvt")); + result.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/map/issue12432/0-0-0.mvt")); return result; }; diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp index e1fe1f12f0..ce102c9dea 100644 --- a/test/map/prefetch.test.cpp +++ b/test/map/prefetch.test.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -41,7 +41,7 @@ TEST(Map, PrefetchTiles) { std::vector tiles; fileSource->response = [&] (const Resource& res) -> optional { - static std::string tile = util::read_file("test/fixtures/map/prefetch/tile.png"); + static std::string tile = *mapbox::base::io::readFile("test/fixtures/map/prefetch/tile.png"); auto zoom = std::stoi(res.url); tiles.push_back(zoom); @@ -55,8 +55,8 @@ TEST(Map, PrefetchTiles) { tiles.clear(); // Force tile reloading. - map.getStyle().loadJSON(util::read_file("test/fixtures/map/prefetch/empty.json")); - map.getStyle().loadJSON(util::read_file("test/fixtures/map/prefetch/style.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/map/prefetch/empty.json")); + map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/map/prefetch/style.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(zoom)); // Manhattan runLoop.run(); diff --git a/test/renderer/image_manager.test.cpp b/test/renderer/image_manager.test.cpp index 16700d713f..bd0265be57 100644 --- a/test/renderer/image_manager.test.cpp +++ b/test/renderer/image_manager.test.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -24,8 +24,8 @@ TEST(ImageManager, Basic) { FixtureLog log; ImageManager imageManager; - auto images = parseSprite(util::read_file("test/fixtures/annotations/emerald.png"), - util::read_file("test/fixtures/annotations/emerald.json")); + auto images = parseSprite(*mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"), + *mapbox::base::io::readFile("test/fixtures/annotations/emerald.json")); for (auto& image : images) { imageManager.addImage(image->baseImpl); auto* stored = imageManager.getImage(image->getID()); diff --git a/test/renderer/pattern_atlas.test.cpp b/test/renderer/pattern_atlas.test.cpp index 2a19e463bd..2ba06e0b53 100644 --- a/test/renderer/pattern_atlas.test.cpp +++ b/test/renderer/pattern_atlas.test.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,8 +18,8 @@ TEST(PatternAtlas, Basic) { FixtureLog log; PatternAtlas patternAtlas; - auto images = parseSprite(util::read_file("test/fixtures/annotations/emerald.png"), - util::read_file("test/fixtures/annotations/emerald.json")); + auto images = parseSprite(*mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"), + *mapbox::base::io::readFile("test/fixtures/annotations/emerald.json")); for (auto& image : images) { if (image->getID() == "metro") { ASSERT_TRUE(patternAtlas.addPattern(*image->baseImpl)); diff --git a/test/sprite/sprite_loader.test.cpp b/test/sprite/sprite_loader.test.cpp index 122e711f51..797dc7247d 100644 --- a/test/sprite/sprite_loader.test.cpp +++ b/test/sprite/sprite_loader.test.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -56,14 +56,14 @@ public: Response successfulSpriteImageResponse(const Resource& resource) { EXPECT_EQ("test/fixtures/resources/sprite.png", resource.url); Response response; - response.data = std::make_unique(util::read_file(resource.url)); + response.data = std::make_unique(*mapbox::base::io::readFile(resource.url)); return response; } Response successfulSpriteJSONResponse(const Resource& resource) { EXPECT_EQ("test/fixtures/resources/sprite.json", resource.url); Response response; - response.data = std::make_unique(util::read_file(resource.url)); + response.data = std::make_unique(*mapbox::base::io::readFile(resource.url)); return response; } diff --git a/test/sprite/sprite_parser.test.cpp b/test/sprite/sprite_parser.test.cpp index 529e4c75e8..5ad6688f3d 100644 --- a/test/sprite/sprite_parser.test.cpp +++ b/test/sprite/sprite_parser.test.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -14,7 +14,7 @@ using namespace mbgl; namespace { auto readImage(const std::string& name) { - return decodeImage(util::read_file(name)); + return decodeImage(*mapbox::base::io::readFile(name)); } } // namespace @@ -22,7 +22,7 @@ auto readImage(const std::string& name) { TEST(Sprite, SpriteImageCreationInvalid) { FixtureLog log; - const PremultipliedImage image_1x = decodeImage(util::read_file("test/fixtures/annotations/emerald.png")); + const PremultipliedImage image_1x = decodeImage(*mapbox::base::io::readFile("test/fixtures/annotations/emerald.png")); ASSERT_EQ(200u, image_1x.size.width); ASSERT_EQ(299u, image_1x.size.height); @@ -135,7 +135,7 @@ TEST(Sprite, SpriteImageCreationInvalid) { } TEST(Sprite, SpriteImageCreation1x) { - const PremultipliedImage image_1x = decodeImage(util::read_file("test/fixtures/annotations/emerald.png")); + const PremultipliedImage image_1x = decodeImage(*mapbox::base::io::readFile("test/fixtures/annotations/emerald.png")); ASSERT_EQ(200u, image_1x.size.width); ASSERT_EQ(299u, image_1x.size.height); @@ -152,7 +152,7 @@ TEST(Sprite, SpriteImageCreation1x) { } TEST(Sprite, SpriteImageCreation2x) { - const PremultipliedImage image_2x = decodeImage(util::read_file("test/fixtures/annotations/emerald@2x.png")); + const PremultipliedImage image_2x = decodeImage(*mapbox::base::io::readFile("test/fixtures/annotations/emerald@2x.png")); // "museum_icon":{"x":354,"y":374,"width":36,"height":36,"pixelRatio":2,"sdf":false} const auto sprite = createStyleImage("test", image_2x, 354, 374, 36, 36, 2, false); @@ -165,7 +165,7 @@ TEST(Sprite, SpriteImageCreation2x) { } TEST(Sprite, SpriteImageCreation1_5x) { - const PremultipliedImage image_2x = decodeImage(util::read_file("test/fixtures/annotations/emerald@2x.png")); + const PremultipliedImage image_2x = decodeImage(*mapbox::base::io::readFile("test/fixtures/annotations/emerald@2x.png")); // "museum_icon":{"x":354,"y":374,"width":36,"height":36,"pixelRatio":2,"sdf":false} const auto sprite = createStyleImage("test", image_2x, 354, 374, 36, 36, 1.5, false); @@ -187,8 +187,8 @@ TEST(Sprite, SpriteImageCreation1_5x) { } TEST(Sprite, SpriteParsing) { - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); - const auto json_1x = util::read_file("test/fixtures/annotations/emerald.json"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); + const auto json_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.json"); const auto images = parseSprite(image_1x, json_1x); @@ -281,7 +281,7 @@ TEST(Sprite, SpriteParsing) { } TEST(Sprite, SpriteParsingInvalidJSON) { - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); const auto json_1x = R"JSON({ "image": " })JSON"; try { @@ -297,7 +297,7 @@ TEST(Sprite, SpriteParsingInvalidJSON) { TEST(Sprite, SpriteParsingEmptyImage) { FixtureLog log; - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); const auto json_1x = R"JSON({ "image": {} })JSON"; const auto images = parseSprite(image_1x, json_1x); @@ -314,7 +314,7 @@ TEST(Sprite, SpriteParsingEmptyImage) { TEST(Sprite, SpriteParsingSimpleWidthHeight) { FixtureLog log; - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); const auto json_1x = R"JSON({ "image": { "width": 32, "height": 32 } })JSON"; const auto images = parseSprite(image_1x, json_1x); @@ -324,7 +324,7 @@ TEST(Sprite, SpriteParsingSimpleWidthHeight) { TEST(Sprite, SpriteParsingWidthTooBig) { FixtureLog log; - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); const auto json_1x = R"JSON({ "image": { "width": 65536, "height": 32 } })JSON"; const auto images = parseSprite(image_1x, json_1x); @@ -347,7 +347,7 @@ TEST(Sprite, SpriteParsingWidthTooBig) { TEST(Sprite, SpriteParsingNegativeWidth) { FixtureLog log; - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); const auto json_1x = R"JSON({ "image": { "width": -1, "height": 32 } })JSON"; const auto images = parseSprite(image_1x, json_1x); @@ -370,7 +370,7 @@ TEST(Sprite, SpriteParsingNegativeWidth) { TEST(Sprite, SpriteParsingNullRatio) { FixtureLog log; - const auto image_1x = util::read_file("test/fixtures/annotations/emerald.png"); + const auto image_1x = *mapbox::base::io::readFile("test/fixtures/annotations/emerald.png"); const auto json_1x = R"JSON({ "image": { "width": 32, "height": 32, "pixelRatio": 0 } })JSON"; const auto images = parseSprite(image_1x, json_1x); diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp index 30eea19bdf..71ccc91e06 100644 --- a/test/src/mbgl/test/util.cpp +++ b/test/src/mbgl/test/util.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include @@ -94,14 +94,14 @@ void checkImage(const std::string& base, double pixelThreshold) { #if !TEST_READ_ONLY if (getenv("UPDATE")) { - util::write_file(base + "/expected.png", encodePNG(actual)); + mapbox::base::io::writeFile(base + "/expected.png", encodePNG(actual)); return; } #endif std::string expected_image; try { - expected_image = util::read_file(base + "/expected.png"); + expected_image = *mapbox::base::io::readFile(base + "/expected.png"); } catch (std::exception& ex) { Log::Error(Event::Setup, "Failed to load expected image %s: %s", (base + "/expected.png").c_str(), ex.what()); @@ -113,7 +113,7 @@ void checkImage(const std::string& base, #if !TEST_READ_ONLY - util::write_file(base + "/actual.png", encodePNG(actual)); + mapbox::base::io::writeFile(base + "/actual.png", encodePNG(actual)); #endif ASSERT_EQ(expected.size, actual.size); @@ -128,7 +128,7 @@ void checkImage(const std::string& base, EXPECT_LE(pixels / (expected.size.width * expected.size.height), imageThreshold); #if !TEST_READ_ONLY - util::write_file(base + "/diff.png", encodePNG(diff)); + mapbox::base::io::writeFile(base + "/diff.png", encodePNG(diff)); #endif } diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp index 24234b0624..628f8e4d5d 100644 --- a/test/storage/offline_database.test.cpp +++ b/test/storage/offline_database.test.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -24,9 +24,9 @@ static constexpr const char* filename_test_fs = "file:test/fixtures/offline_data static void deleteDatabaseFiles() { // Delete leftover journaling files as well. - util::deleteFile(filename); - util::deleteFile(filename + "-wal"s); - util::deleteFile(filename + "-journal"s); + mapbox::base::io::deleteFile(filename); + mapbox::base::io::deleteFile(filename + "-wal"s); + mapbox::base::io::deleteFile(filename + "-journal"s); } static std::shared_ptr randomString(size_t size) { @@ -238,7 +238,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(SchemaVersion)) { TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Invalid)) { FixtureLog log; deleteDatabaseFiles(); - util::write_file(filename, "this is an invalid file"); + mapbox::base::io::writeFile(filename, "this is an invalid file"); OfflineDatabase db(filename); // Checking two possibilities for the error string because it apparently changes between SQLite versions. @@ -316,7 +316,7 @@ TEST(OfflineDatabase, PutResource) { TEST(OfflineDatabase, TEST_REQUIRES_WRITE(GetResourceFromOfflineRegion)) { FixtureLog log; deleteDatabaseFiles(); - util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/satellite_test.db", filename); OfflineDatabase db(filename); @@ -521,14 +521,14 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) { deleteDatabaseFiles(); auto databaseSize = [] { - return util::read_file(filename).size(); + return mapbox::base::io::readFile(filename)->size(); }; { OfflineDatabase db(filename); } - size_t initialSize = util::read_file(filename).size(); + size_t initialSize = mapbox::base::io::readFile(filename)->size(); size_t maximumSize = 50 * 1024 * 1024; Response response; @@ -647,7 +647,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) { // Setting the size to zero should effectively // clear the cache now. - EXPECT_EQ(initialSize, util::read_file(filename).size()); + EXPECT_EQ(initialSize, mapbox::base::io::readFile(filename)->size()); } TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) { @@ -658,7 +658,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) { OfflineDatabase dbCreate(filename); } - size_t initialSize = util::read_file(filename).size(); + size_t initialSize = mapbox::base::io::readFile(filename)->size(); { Response response; @@ -687,14 +687,14 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) { // The tiles from the offline region will migrate to the // ambient cache and shrink the database to the maximum // size defined by default. - EXPECT_LE(util::read_file(filename).size(), util::DEFAULT_MAX_CACHE_SIZE); + EXPECT_LE(mapbox::base::io::readFile(filename)->size(), util::DEFAULT_MAX_CACHE_SIZE); // After clearing the cache, the size of the database // should get back to the original size. db.clearAmbientCache(); } - EXPECT_EQ(initialSize, util::read_file(filename).size()); + EXPECT_EQ(initialSize, mapbox::base::io::readFile(filename)->size()); EXPECT_EQ(0u, log.uncheckedCount()); } @@ -895,7 +895,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ClearAmbientCache)) { OfflineDatabase dbCreate(filename); } - size_t initialSize = util::read_file(filename).size(); + size_t initialSize = mapbox::base::io::readFile(filename)->size(); { Response response; @@ -914,7 +914,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ClearAmbientCache)) { db.clearAmbientCache(); } - EXPECT_EQ(initialSize, util::read_file(filename).size()); + EXPECT_EQ(initialSize, mapbox::base::io::readFile(filename)->size()); EXPECT_EQ(0u, log.uncheckedCount()); } @@ -1273,7 +1273,7 @@ TEST(OfflineDatabase, MigrateFromV2Schema) { // v2.db is a v2 database containing a single offline region with a small number of resources. FixtureLog log; deleteDatabaseFiles(); - util::copyFile(filename, "test/fixtures/offline_database/v2.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/v2.db", filename); { OfflineDatabase db(filename); @@ -1297,7 +1297,7 @@ TEST(OfflineDatabase, MigrateFromV3Schema) { // v3.db is a v3 database, migrated from v2. FixtureLog log; deleteDatabaseFiles(); - util::copyFile(filename, "test/fixtures/offline_database/v3.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/v3.db", filename); { OfflineDatabase db(filename); @@ -1318,7 +1318,7 @@ TEST(OfflineDatabase, MigrateFromV4Schema) { // v4.db is a v4 database, migrated from v2 & v3. This database used `journal_mode = WAL` and `synchronous = NORMAL`. FixtureLog log; deleteDatabaseFiles(); - util::copyFile(filename, "test/fixtures/offline_database/v4.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/v4.db", filename); { OfflineDatabase db(filename); @@ -1346,7 +1346,7 @@ TEST(OfflineDatabase, MigrateFromV5Schema) { // v5.db is a v5 database, migrated from v2, v3 & v4. FixtureLog log; deleteDatabaseFiles(); - util::copyFile(filename, "test/fixtures/offline_database/v5.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/v5.db", filename); { OfflineDatabase db(filename); @@ -1375,8 +1375,8 @@ TEST(OfflineDatabase, DowngradeSchema) { // v999.db is a v999 database, it should be deleted // and recreated with the current schema. FixtureLog log; - util::deleteFile(filename); - util::copyFile(filename, "test/fixtures/offline_database/v999.db"); + mapbox::base::io::deleteFile(filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/v999.db", filename); { OfflineDatabase db(filename); @@ -1399,8 +1399,8 @@ TEST(OfflineDatabase, DowngradeSchema) { TEST(OfflineDatabase, CorruptDatabaseOnOpen) { FixtureLog log; - util::deleteFile(filename); - util::copyFile(filename, "test/fixtures/offline_database/corrupt-immediate.db"); + mapbox::base::io::deleteFile(filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/corrupt-immediate.db", filename); // This database is corrupt in a way that will prevent opening the database. OfflineDatabase db(filename); @@ -1421,8 +1421,8 @@ TEST(OfflineDatabase, CorruptDatabaseOnOpen) { TEST(OfflineDatabase, CorruptDatabaseOnQuery) { FixtureLog log; - util::deleteFile(filename); - util::copyFile(filename, "test/fixtures/offline_database/corrupt-delayed.db"); + mapbox::base::io::deleteFile(filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/corrupt-delayed.db", filename); // This database is corrupt in a way that won't manifest itself until we start querying it, // so just opening it will not cause an error. @@ -1527,8 +1527,8 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DisallowedIO)) { #endif // __QT__ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_New) { - util::deleteFile(filename_sideload); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat.db", filename_sideload); OfflineDatabase db(":memory:"); EXPECT_EQ(0u, db.listRegions()->size()); @@ -1545,9 +1545,9 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_New) { TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithSingleRegion_Update)) { deleteDatabaseFiles(); - util::deleteFile(filename_sideload); - util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db"); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/satellite_test.db", filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat.db", filename_sideload); int64_t regionId; { @@ -1575,11 +1575,11 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithSingleRegion_Update)) TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_NoUpdate) { deleteDatabaseFiles(); - util::deleteFile(filename_sideload); + mapbox::base::io::deleteFile(filename_sideload); //Swap sideload/main database from update test and ensure that an older tile is not copied over - util::copyFile(filename_sideload, "test/fixtures/offline_database/satellite_test.db"); - util::copyFile(filename, "test/fixtures/offline_database/sideload_sat.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/satellite_test.db", filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat.db", filename); OfflineDatabase db(filename); auto result = db.mergeDatabase(filename_sideload); @@ -1595,8 +1595,8 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_NoUpdate) { } TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_AmbientTiles) { - util::deleteFile(filename_sideload); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_ambient.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_ambient.db", filename_sideload); OfflineDatabase db(":memory:"); auto result = db.mergeDatabase(filename_sideload); @@ -1610,8 +1610,8 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_AmbientTiles) { } TEST(OfflineDatabase, MergeDatabaseWithMultipleRegions_New) { - util::deleteFile(filename_sideload); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat_multiple.db", filename_sideload); OfflineDatabase db(":memory:"); EXPECT_EQ(0u, db.listRegions()->size()); @@ -1633,9 +1633,9 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegions_New) { TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) { deleteDatabaseFiles(); - util::deleteFile(filename_sideload); - util::copyFile(filename, "test/fixtures/offline_database/sideload_sat.db"); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat.db", filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat_multiple.db", filename_sideload); { OfflineDatabase db(filename); @@ -1675,8 +1675,8 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) { TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyNewTiles) { FixtureLog log; - util::deleteFile(filename_sideload); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat_multiple.db", filename_sideload); OfflineDatabase db(":memory:"); db.setOfflineMapboxTileCountLimit(1); @@ -1690,9 +1690,9 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyNewTiles) { TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyExistingTiles) { FixtureLog log; deleteDatabaseFiles(); - util::deleteFile(filename_sideload); - util::copyFile(filename, "test/fixtures/offline_database/sideload_sat_multiple.db"); - util::copyFile(filename_sideload, "test/fixtures/offline_database/satellite_test.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat_multiple.db", filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/satellite_test.db", filename_sideload); OfflineDatabase db(filename); db.setOfflineMapboxTileCountLimit(2); @@ -1707,8 +1707,8 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyExistingTiles) { TEST(OfflineDatabase, MergeDatabaseWithInvalidPath) { FixtureLog log; - util::deleteFile(filename_sideload); - util::copyFile(filename_sideload, "test/fixtures/offline_database"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database", filename_sideload); OfflineDatabase db(":memory:"); @@ -1722,8 +1722,8 @@ TEST(OfflineDatabase, MergeDatabaseWithInvalidPath) { TEST(OfflineDatabase, MergeDatabaseWithInvalidDb) { FixtureLog log; - util::deleteFile(filename_sideload); - util::copyFile(filename_sideload, "test/fixtures/offline_database/corrupt-immediate.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/corrupt-immediate.db", filename_sideload); OfflineDatabase db(":memory:"); @@ -1740,9 +1740,9 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithDiskFull)) { test::SQLite3TestFS fs; deleteDatabaseFiles(); - util::deleteFile(filename_sideload); - util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db"); - util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat.db"); + mapbox::base::io::deleteFile(filename_sideload); + mapbox::base::io::copyFile("test/fixtures/offline_database/satellite_test.db", filename); + mapbox::base::io::copyFile("test/fixtures/offline_database/sideload_sat.db", filename_sideload); OfflineDatabase db(filename_test_fs); @@ -1761,13 +1761,13 @@ TEST(OfflineDatabase, ChangePath) { OfflineDatabase db(":memory:"); db.changePath(newPath); mapbox::sqlite::Database::open(newPath, mapbox::sqlite::ReadOnly); - util::deleteFile(newPath); + mapbox::base::io::deleteFile(newPath); } TEST(OfflineDatabase, ResetDatabase) { FixtureLog log; deleteDatabaseFiles(); - util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db"); + mapbox::base::io::copyFile("test/fixtures/offline_database/satellite_test.db", filename); OfflineDatabase db(filename); auto result = db.resetDatabase(); diff --git a/test/storage/offline_download.test.cpp b/test/storage/offline_download.test.cpp index 4e967c297c..53176e307d 100644 --- a/test/storage/offline_download.test.cpp +++ b/test/storage/offline_download.test.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -29,9 +29,9 @@ static constexpr const char* filename_test_fs = "file:test/fixtures/offline_down static void deleteDatabaseFiles() { // Delete leftover journaling files as well. - util::deleteFile(filename); - util::deleteFile(filename + "-wal"s); - util::deleteFile(filename + "-journal"s); + mapbox::base::io::deleteFile(filename); + mapbox::base::io::deleteFile(filename + "-wal"s); + mapbox::base::io::deleteFile(filename + "-journal"s); } static FixtureLog::Message warning(ResultCode code, const char* message) { @@ -80,7 +80,7 @@ public: Response response(const std::string& path) { Response result; - result.data = std::make_shared(util::read_file("test/fixtures/offline_download/"s + path)); + result.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/offline_download/"s + path)); size_t uncompressed = result.data->size(); size_t compressed = util::compress(*result.data).size(); size += std::min(uncompressed, compressed); diff --git a/test/storage/sync_file_source.test.cpp b/test/storage/sync_file_source.test.cpp index 4bd964199d..f466ac32aa 100644 --- a/test/storage/sync_file_source.test.cpp +++ b/test/storage/sync_file_source.test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -8,6 +7,8 @@ #include #include +#include + #include using namespace mbgl; @@ -39,12 +40,13 @@ TEST(SyncFileSource, LoadSyncRender) { util::RunLoop loop; auto fs = std::make_shared(); fs->add("mapbox://mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7", - util::read_file("test/fixtures/resources/source_vector.json")); + *mapbox::base::io::readFile("test/fixtures/resources/source_vector.json")); fs->add("mapbox://sprites/mapbox/streets-v9.png", - util::read_file("test/fixtures/resources/sprite.png")); + *mapbox::base::io::readFile("test/fixtures/resources/sprite.png")); fs->add("mapbox://sprites/mapbox/streets-v9.json", - util::read_file("test/fixtures/resources/sprite.json")); + *mapbox::base::io::readFile("test/fixtures/resources/sprite.json")); HeadlessFrontend frontend{ { 512, 512 }, 1.0 }; MapAdapter map{ frontend, MapObserver::nullObserver(), fs, MapOptions() }; - map.getStyle().loadJSON(util::read_file("test/fixtures/resources/style_vector.json")); + map.getStyle().loadJSON( + *mapbox::base::io::readFile("test/fixtures/resources/style_vector.json")); } diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp index dd986c98f5..213963ed12 100644 --- a/test/style/expression/expression.test.cpp +++ b/test/style/expression/expression.test.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -17,7 +17,7 @@ using namespace mbgl::style; TEST(Expression, IsExpression) { rapidjson::GenericDocument, rapidjson::CrtAllocator> spec; - spec.Parse<0>(util::read_file("mapbox-gl-js/src/style-spec/reference/v8.json").c_str()); + spec.Parse<0>(mapbox::base::io::readFile("mapbox-gl-js/src/style-spec/reference/v8.json")->c_str()); ASSERT_FALSE(spec.HasParseError()); ASSERT_TRUE(spec.IsObject() && spec.HasMember("expression_name") && @@ -55,7 +55,7 @@ TEST_P(ExpressionEqualityTest, ExpressionEquality) { std::string error; auto parse = [&](std::string filename, std::string& error_) -> std::unique_ptr { rapidjson::GenericDocument, rapidjson::CrtAllocator> document; - document.Parse<0>(util::read_file(filename).c_str()); + document.Parse<0>(mapbox::base::io::readFile(filename)->c_str()); assert(!document.HasParseError()); const JSValue* expression = &document; expression::ParsingContext ctx; diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index ca0e79f46a..0e7b3c4356 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -729,7 +729,7 @@ TEST(Source, ImageSourceImageUpdate) { test.fileSource->response = [&] (const Resource& resource) { EXPECT_EQ("http://url", resource.url); Response response; - response.data = std::make_unique(util::read_file("test/fixtures/image/no_profile.png")); + response.data = std::make_unique(*mapbox::base::io::readFile("test/fixtures/image/no_profile.png")); return response; }; test.styleObserver.sourceChanged = [&] (Source&) { diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp index 72f74d3b01..c8d15d20fc 100644 --- a/test/style/style.test.cpp +++ b/test/style/style.test.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -63,7 +63,7 @@ TEST(Style, DuplicateSource) { StubFileSource fileSource; Style::Impl style { fileSource, 1.0 }; - style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); + style.loadJSON(*mapbox::base::io::readFile("test/fixtures/resources/style-unused-sources.json")); style.addSource(std::make_unique("sourceId", "mapbox://mapbox.mapbox-terrain-v2")); @@ -84,7 +84,7 @@ TEST(Style, RemoveSourceInUse) { StubFileSource fileSource; Style::Impl style { fileSource, 1.0 }; - style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); + style.loadJSON(*mapbox::base::io::readFile("test/fixtures/resources/style-unused-sources.json")); style.addSource(std::make_unique("sourceId", "mapbox://mapbox.mapbox-terrain-v2")); style.addLayer(std::make_unique("layerId", "sourceId")); diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp index d6a926c631..2f41fdf9c4 100644 --- a/test/style/style_layer.test.cpp +++ b/test/style/style_layer.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include @@ -284,7 +284,7 @@ TEST(Layer, DuplicateLayer) { // Setup style StubFileSource fileSource; Style::Impl style { fileSource, 1.0 }; - style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); + style.loadJSON(*mapbox::base::io::readFile("test/fixtures/resources/style-unused-sources.json")); // Add initial layer style.addLayer(std::make_unique("line", "unusedsource")); diff --git a/test/style/style_parser.test.cpp b/test/style/style_parser.test.cpp index a18a9bbf57..3236be5caf 100644 --- a/test/style/style_parser.test.cpp +++ b/test/style/style_parser.test.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -26,7 +26,7 @@ TEST_P(StyleParserTest, ParseStyle) { const std::string base = std::string("test/fixtures/style_parser/") + GetParam(); rapidjson::GenericDocument, rapidjson::CrtAllocator> infoDoc; - infoDoc.Parse<0>(util::read_file(base + ".info.json").c_str()); + infoDoc.Parse<0>(mapbox::base::io::readFile(base + ".info.json")->c_str()); ASSERT_FALSE(infoDoc.HasParseError()); ASSERT_TRUE(infoDoc.IsObject()); @@ -34,7 +34,7 @@ TEST_P(StyleParserTest, ParseStyle) { Log::setObserver(std::unique_ptr(observer)); style::Parser parser; - auto error = parser.parse(util::read_file(base + ".style.json")); + auto error = parser.parse(*mapbox::base::io::readFile(base + ".style.json")); if (error) { Log::Error(Event::ParseStyle, "Failed to parse style: %s", util::toString(error).c_str()); @@ -96,7 +96,7 @@ INSTANTIATE_TEST_CASE_P(StyleParser, StyleParserTest, ::testing::ValuesIn([] { TEST(StyleParser, FontStacks) { style::Parser parser; - parser.parse(util::read_file("test/fixtures/style_parser/font_stacks.json")); + parser.parse(*mapbox::base::io::readFile("test/fixtures/style_parser/font_stacks.json")); std::set expected; expected.insert(FontStack({"a"})); expected.insert(FontStack({"a", "b"})); diff --git a/test/text/glyph_manager.test.cpp b/test/text/glyph_manager.test.cpp index 1e9aef38ed..d87e5cda76 100644 --- a/test/text/glyph_manager.test.cpp +++ b/test/text/glyph_manager.test.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include using namespace mbgl; @@ -92,7 +92,7 @@ TEST(GlyphManager, LoadingSuccess) { test.fileSource.glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; @@ -260,7 +260,7 @@ TEST(GlyphManager, LoadLocalCJKGlyphAfterLoadingRangeFromURL) { test.fileSource.glyphsResponse = [&] (const Resource&) { firstGlyphResponse = true; Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs-12244-12543.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs-12244-12543.pbf")); return response; }; @@ -311,7 +311,7 @@ TEST(GlyphManager, LoadingInvalid) { test.fileSource.glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/fake_glyphs-0-255.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/fake_glyphs-0-255.pbf")); return response; }; @@ -371,7 +371,7 @@ TEST(GlyphManager, ImmediateFileSource) { test.fileSource.glyphsResponse = [&] (const Resource&) { Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; diff --git a/test/text/glyph_pbf.test.cpp b/test/text/glyph_pbf.test.cpp index c222ec1dd9..afb73eb3dd 100644 --- a/test/text/glyph_pbf.test.cpp +++ b/test/text/glyph_pbf.test.cpp @@ -1,13 +1,13 @@ #include #include -#include +#include using namespace mbgl; TEST(GlyphPBF, Parsing) { // The fake glyphs contain a number of invalid glyphs, which should be skipped by the parser. - auto sdfs = parseGlyphPBF(GlyphRange { 0, 255 }, util::read_file("test/fixtures/resources/fake_glyphs-0-255.pbf")); + auto sdfs = parseGlyphPBF(GlyphRange { 0, 255 }, *mapbox::base::io::readFile("test/fixtures/resources/fake_glyphs-0-255.pbf")); EXPECT_TRUE(sdfs.size() == 1); auto& sdf = sdfs[0]; diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp index 2722ee5849..7b6aed10aa 100644 --- a/test/text/local_glyph_rasterizer.test.cpp +++ b/test/text/local_glyph_rasterizer.test.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -60,10 +60,10 @@ TEST(LocalGlyphRasterizer, PingFang) { test.fileSource->glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/local_glyphs/mixed.json")); #if defined(__APPLE__) && !defined(__QT__) test.checkRendering("ping_fang"); #elif defined(__QT__) @@ -80,11 +80,11 @@ TEST(LocalGlyphRasterizer, NotoSansCJK) { test.fileSource->glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/local_glyphs/mixed.json")); test.checkRendering("noto_sans_cjk_kr_regular_qt"); } #endif // defined(__linux__) && defined(__QT__) @@ -97,10 +97,10 @@ TEST(LocalGlyphRasterizer, NoLocal) { test.fileSource->glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; - test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/local_glyphs/mixed.json")); test.checkRendering("no_local", 0.001, 0.1); } @@ -113,11 +113,11 @@ TEST(LocalGlyphRasterizer, NoLocalWithContentInsets) { test.fileSource->glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; auto viewSize = test.frontend.getSize(); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/local_glyphs/mixed.json")); // Expected image was created using center offset as in the line below - content insets, // with no pitch defined, should produce the same output. @@ -136,11 +136,11 @@ TEST(LocalGlyphRasterizer, NoLocalWithContentInsetsAndPitch) { test.fileSource->glyphsResponse = [&] (const Resource& resource) { EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); Response response; - response.data = std::make_shared(util::read_file("test/fixtures/resources/glyphs.pbf")); + response.data = std::make_shared(*mapbox::base::io::readFile("test/fixtures/resources/glyphs.pbf")); return response; }; auto viewSize = test.frontend.getSize(); - test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/mixed.json")); + test.map.getStyle().loadJSON(*mapbox::base::io::readFile("test/fixtures/local_glyphs/mixed.json")); // Expected image was verified using no-padding render, offsetted to right // using bitmap editor. diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index 940c0272db..ce63fc8181 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -16,6 +16,8 @@ #include #include +#include + #include using namespace mbgl; @@ -73,7 +75,7 @@ TEST(VectorTile, Issue8542) { } TEST(VectorTileData, ParseResults) { - VectorTileData data(std::make_shared(util::read_file("test/fixtures/map/issue12432/0-0-0.mvt"))); + VectorTileData data(std::make_shared(*mapbox::base::io::readFile("test/fixtures/map/issue12432/0-0-0.mvt"))); std::vector layerNames = data.layerNames(); ASSERT_EQ(layerNames.size(), 2u); diff --git a/test/util/image.test.cpp b/test/util/image.test.cpp index c2922415cb..31b1f53089 100644 --- a/test/util/image.test.cpp +++ b/test/util/image.test.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include using namespace mbgl; @@ -35,7 +35,7 @@ TEST(Image, PNGRoundTripAlpha) { } TEST(Image, PNGReadNoProfile) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/no_profile.png")); + PremultipliedImage image = decodeImage(*mapbox::base::io::readFile("test/fixtures/image/no_profile.png")); EXPECT_EQ(128, image.data[0]); EXPECT_EQ(0, image.data[1]); EXPECT_EQ(0, image.data[2]); @@ -43,7 +43,7 @@ TEST(Image, PNGReadNoProfile) { } TEST(Image, PNGReadNoProfileAlpha) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/no_profile_alpha.png")); + PremultipliedImage image = decodeImage(*mapbox::base::io::readFile("test/fixtures/image/no_profile_alpha.png")); EXPECT_EQ(64, image.data[0]); EXPECT_EQ(0, image.data[1]); EXPECT_EQ(0, image.data[2]); @@ -51,7 +51,7 @@ TEST(Image, PNGReadNoProfileAlpha) { } TEST(Image, PNGReadProfile) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/profile.png")); + PremultipliedImage image = decodeImage(*mapbox::base::io::readFile("test/fixtures/image/profile.png")); EXPECT_EQ(128, image.data[0]); EXPECT_EQ(0, image.data[1]); EXPECT_EQ(0, image.data[2]); @@ -59,7 +59,7 @@ TEST(Image, PNGReadProfile) { } TEST(Image, PNGReadProfileAlpha) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/profile_alpha.png")); + PremultipliedImage image = decodeImage(*mapbox::base::io::readFile("test/fixtures/image/profile_alpha.png")); EXPECT_EQ(64, image.data[0]); EXPECT_EQ(0, image.data[1]); EXPECT_EQ(0, image.data[2]); @@ -67,13 +67,13 @@ TEST(Image, PNGReadProfileAlpha) { } TEST(Image, PNGTile) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/tile.png")); + PremultipliedImage image = decodeImage(*mapbox::base::io::readFile("test/fixtures/image/tile.png")); EXPECT_EQ(256u, image.size.width); EXPECT_EQ(256u, image.size.height); } TEST(Image, JPEGTile) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/tile.jpeg")); + PremultipliedImage image = decodeImage(*mapbox::base::io::readFile("test/fixtures/image/tile.jpeg")); EXPECT_EQ(256u, image.size.width); EXPECT_EQ(256u, image.size.height); } diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp index bf14c70419..29330b2164 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -46,7 +46,7 @@ private: result.data = it->second; } else { auto data = std::make_shared( - util::read_file("test/fixtures/resources/"s + path)); + *mapbox::base::io::readFile("test/fixtures/resources/"s + path)); cache.insert(it, std::make_pair(path, data)); result.data = data; -- cgit v1.2.1