[tests] Rationalize test fixtures (#4834)
Place them in a directory corresponding to the test .cpp file name.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -14,8 +14,9 @@ xcuserdata
|
||||
/test/fixtures/*/*_actual.*
|
||||
/test/fixtures/api/1.png
|
||||
/test/fixtures/api/2.png
|
||||
/test/fixtures/database/*.db
|
||||
/test/fixtures/offline/v3.db
|
||||
/test/fixtures/offline_database/offline.db
|
||||
/test/fixtures/offline_database/invalid.db
|
||||
/test/fixtures/offline_database/v3.db
|
||||
/test/fixtures/**/actual.png
|
||||
/test/fixtures/**/diff.png
|
||||
/test/output
|
||||
|
||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
@@ -10,5 +10,5 @@
|
||||
"name": "Streets",
|
||||
"scheme": "xyz",
|
||||
"tilejson": "2.0.0",
|
||||
"tiles": [ "http://127.0.0.1:3000/offline/{z}-{x}-{y}.vector.pbf" ]
|
||||
"tiles": [ "http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf" ]
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"type": "vector",
|
||||
"url": "http://127.0.0.1:3000/offline/streets.json"
|
||||
"url": "http://127.0.0.1:3000/streets.json"
|
||||
}
|
||||
},
|
||||
"glyphs": "http://127.0.0.1:3000/offline/{fontstack}/{range}.pbf",
|
||||
"sprite": "http://127.0.0.1:3000/offline/sprite",
|
||||
"glyphs": "http://127.0.0.1:3000/{fontstack}/{range}.pbf",
|
||||
"sprite": "http://127.0.0.1:3000/sprite",
|
||||
"layers": [{
|
||||
"id": "background",
|
||||
"type": "background",
|
||||
BIN
test/fixtures/offline_download/0-0-0.vector.pbf
vendored
Normal file
BIN
test/fixtures/offline_download/0-0-0.vector.pbf
vendored
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
"sources": {
|
||||
"geojson": {
|
||||
"type": "geojson",
|
||||
"data": "http://127.0.0.1:3000/offline/geojson.json"
|
||||
"data": "http://127.0.0.1:3000/geojson.json"
|
||||
}
|
||||
},
|
||||
"layers": []
|
||||
BIN
test/fixtures/offline_download/glyph.pbf
vendored
Normal file
BIN
test/fixtures/offline_download/glyph.pbf
vendored
Normal file
Binary file not shown.
@@ -5,7 +5,7 @@
|
||||
"type": "vector",
|
||||
"maxzoom": 15,
|
||||
"minzoom": 0,
|
||||
"tiles": [ "http://127.0.0.1:3000/offline/{z}-{x}-{y}.vector.pbf" ]
|
||||
"tiles": [ "http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf" ]
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
10
test/fixtures/offline_download/sprite.json
vendored
Normal file
10
test/fixtures/offline_download/sprite.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"noise": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 32,
|
||||
"height": 32,
|
||||
"pixelRatio": 1,
|
||||
"sdf": false
|
||||
}
|
||||
}
|
||||
BIN
test/fixtures/offline_download/sprite.png
vendored
Normal file
BIN
test/fixtures/offline_download/sprite.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
14
test/fixtures/offline_download/streets.json
vendored
Normal file
14
test/fixtures/offline_download/streets.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"bounds": [ -180, -85.0511, 180, 85.0511 ],
|
||||
"center": [ 0, 0, 0 ],
|
||||
"description": "",
|
||||
"format": "pbf",
|
||||
"id": "streets",
|
||||
"maskLevel": 8,
|
||||
"maxzoom": 15,
|
||||
"minzoom": 0,
|
||||
"name": "Streets",
|
||||
"scheme": "xyz",
|
||||
"tilejson": "2.0.0",
|
||||
"tiles": [ "http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf" ]
|
||||
}
|
||||
41
test/fixtures/offline_download/style.json
vendored
Normal file
41
test/fixtures/offline_download/style.json
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"version": 8,
|
||||
"name": "Water",
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"type": "vector",
|
||||
"url": "http://127.0.0.1:3000/streets.json"
|
||||
}
|
||||
},
|
||||
"glyphs": "http://127.0.0.1:3000/{fontstack}/{range}.pbf",
|
||||
"sprite": "http://127.0.0.1:3000/sprite",
|
||||
"layers": [{
|
||||
"id": "background",
|
||||
"type": "background",
|
||||
"paint": {
|
||||
"background-color": "red"
|
||||
}
|
||||
}, {
|
||||
"id": "water",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "water",
|
||||
"paint": {
|
||||
"fill-pattern": "noise"
|
||||
}
|
||||
}, {
|
||||
"id": "admin",
|
||||
"type": "symbol",
|
||||
"source": "mapbox",
|
||||
"source-layer": "admin",
|
||||
"layout": {
|
||||
"text-font": ["Helvetica"],
|
||||
"text-field": "Text"
|
||||
},
|
||||
"paint": {
|
||||
"text-color": "black",
|
||||
"text-halo-color": "white",
|
||||
"text-halo-width": 2
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -21,24 +21,24 @@ TEST(Map, Offline) {
|
||||
|
||||
auto expiredItem = [] (const std::string& path) {
|
||||
Response response;
|
||||
response.data = std::make_shared<std::string>(util::read_file("test/fixtures/"s + path));
|
||||
response.data = std::make_shared<std::string>(util::read_file("test/fixtures/map/offline/"s + path));
|
||||
response.expires = SystemClock::from_time_t(0);
|
||||
return response;
|
||||
};
|
||||
|
||||
const std::string prefix = "http://127.0.0.1:3000";
|
||||
fileSource.put(Resource::style(prefix + "/offline/style.json"), expiredItem("offline/style.json"));
|
||||
fileSource.put(Resource::source(prefix + "/offline/streets.json"), expiredItem("offline/streets.json"));
|
||||
fileSource.put(Resource::spriteJSON(prefix + "/offline/sprite", 1.0), expiredItem("offline/sprite.json"));
|
||||
fileSource.put(Resource::spriteImage(prefix + "/offline/sprite", 1.0), expiredItem("offline/sprite.png"));
|
||||
fileSource.put(Resource::tile(prefix + "/offline/{z}-{x}-{y}.vector.pbf", 1.0, 0, 0, 0), expiredItem("offline/0-0-0.vector.pbf"));
|
||||
fileSource.put(Resource::glyphs(prefix + "/offline/{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("offline/glyph.pbf"));
|
||||
const std::string prefix = "http://127.0.0.1:3000/";
|
||||
fileSource.put(Resource::style(prefix + "style.json"), expiredItem("style.json"));
|
||||
fileSource.put(Resource::source(prefix + "streets.json"), expiredItem("streets.json"));
|
||||
fileSource.put(Resource::spriteJSON(prefix + "sprite", 1.0), expiredItem("sprite.json"));
|
||||
fileSource.put(Resource::spriteImage(prefix + "sprite", 1.0), expiredItem("sprite.png"));
|
||||
fileSource.put(Resource::tile(prefix + "{z}-{x}-{y}.vector.pbf", 1.0, 0, 0, 0), expiredItem("0-0-0.vector.pbf"));
|
||||
fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf"));
|
||||
NetworkStatus::Set(NetworkStatus::Status::Offline);
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleURL(prefix + "/offline/style.json");
|
||||
map.setStyleURL(prefix + "style.json");
|
||||
|
||||
test::checkImage("test/fixtures/offline",
|
||||
test::checkImage("test/fixtures/map/offline",
|
||||
test::render(map),
|
||||
0.0015,
|
||||
0.1);
|
||||
|
||||
@@ -80,30 +80,15 @@ private:
|
||||
|
||||
}
|
||||
|
||||
//TEST(OfflineDatabase, NonexistentDirectory) {
|
||||
// using namespace mbgl;
|
||||
//
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// OfflineDatabase db("test/fixtures/404/offline.db");
|
||||
//
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// EXPECT_FALSE(bool(res));
|
||||
// });
|
||||
//
|
||||
// auto observer = Log::removeObserver();
|
||||
// EXPECT_EQ(1ul, dynamic_cast<FixtureLogObserver*>(observer.get())->count({ EventSeverity::Error, Event::Database, 14, "unable to open database file" }));
|
||||
//}
|
||||
|
||||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Create)) {
|
||||
using namespace mbgl;
|
||||
|
||||
createDir("test/fixtures/database");
|
||||
deleteFile("test/fixtures/database/offline.db");
|
||||
createDir("test/fixtures/offline_database");
|
||||
deleteFile("test/fixtures/offline_database/offline.db");
|
||||
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
OfflineDatabase db("test/fixtures/database/offline.db");
|
||||
OfflineDatabase db("test/fixtures/offline_database/offline.db");
|
||||
EXPECT_FALSE(bool(db.get({ Resource::Unknown, "mapbox://test" })));
|
||||
|
||||
Log::removeObserver();
|
||||
@@ -112,9 +97,9 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Create)) {
|
||||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(SchemaVersion)) {
|
||||
using namespace mbgl;
|
||||
|
||||
createDir("test/fixtures/database");
|
||||
deleteFile("test/fixtures/database/offline.db");
|
||||
std::string path("test/fixtures/database/offline.db");
|
||||
createDir("test/fixtures/offline_database");
|
||||
deleteFile("test/fixtures/offline_database/offline.db");
|
||||
std::string path("test/fixtures/offline_database/offline.db");
|
||||
|
||||
{
|
||||
sqlite3* db = nullptr;
|
||||
@@ -134,150 +119,19 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(SchemaVersion)) {
|
||||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Invalid)) {
|
||||
using namespace mbgl;
|
||||
|
||||
createDir("test/fixtures/database");
|
||||
deleteFile("test/fixtures/database/invalid.db");
|
||||
writeFile("test/fixtures/database/invalid.db", "this is an invalid file");
|
||||
createDir("test/fixtures/offline_database");
|
||||
deleteFile("test/fixtures/offline_database/invalid.db");
|
||||
writeFile("test/fixtures/offline_database/invalid.db", "this is an invalid file");
|
||||
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
OfflineDatabase db("test/fixtures/database/invalid.db");
|
||||
OfflineDatabase db("test/fixtures/offline_database/invalid.db");
|
||||
|
||||
auto observer = Log::removeObserver();
|
||||
auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
|
||||
EXPECT_EQ(1ul, flo->count({ EventSeverity::Warning, Event::Database, -1, "Removing existing incompatible offline database" }));
|
||||
}
|
||||
|
||||
//TEST(OfflineDatabase, DatabaseLockedRead) {
|
||||
// using namespace mbgl;
|
||||
//
|
||||
// // Create a locked file.
|
||||
// createDir("test/fixtures/database");
|
||||
// deleteFile("test/fixtures/database/locked.db");
|
||||
// FileLock guard("test/fixtures/database/locked.db");
|
||||
//
|
||||
// OfflineDatabase db("test/fixtures/database/locked.db");
|
||||
//
|
||||
// {
|
||||
// // First request should fail.
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// EXPECT_FALSE(bool(res));
|
||||
// });
|
||||
//
|
||||
// // Make sure that we got a few "database locked" errors
|
||||
// auto observer = Log::removeObserver();
|
||||
// auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
|
||||
// EXPECT_EQ(4ul, flo->count({ EventSeverity::Error, Event::Database, 5, "database is locked" }));
|
||||
// }
|
||||
//
|
||||
// // Then, unlock the file and try again.
|
||||
// guard.unlock();
|
||||
//
|
||||
// {
|
||||
// // First, try getting a file (the cache value should not exist).
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// EXPECT_FALSE(bool(res));
|
||||
// });
|
||||
//
|
||||
// // Make sure that we got a no errors
|
||||
// Log::removeObserver();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//TEST(OfflineDatabase, DatabaseLockedWrite) {
|
||||
// using namespace mbgl;
|
||||
//
|
||||
// // Create a locked file.
|
||||
// createDir("test/fixtures/database");
|
||||
// deleteFile("test/fixtures/database/locked.db");
|
||||
// FileLock guard("test/fixtures/database/locked.db");
|
||||
//
|
||||
// OfflineDatabase db("test/fixtures/database/locked.db");
|
||||
//
|
||||
// {
|
||||
// // Adds a file (which should fail).
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// db.put({ Resource::Unknown, "mapbox://test" }, Response());
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// EXPECT_FALSE(bool(res));
|
||||
// });
|
||||
//
|
||||
// auto observer = Log::removeObserver();
|
||||
// auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
|
||||
// EXPECT_EQ(8ul, flo->count({ EventSeverity::Error, Event::Database, 5, "database is locked" }));
|
||||
// }
|
||||
//
|
||||
// // Then, unlock the file and try again.
|
||||
// guard.unlock();
|
||||
//
|
||||
// {
|
||||
// // Then, set a file and obtain it again.
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// Response response;
|
||||
// response.data = std::make_shared<std::string>("Demo");
|
||||
// db.put({ Resource::Unknown, "mapbox://test" }, response);
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// ASSERT_TRUE(bool(res));
|
||||
// ASSERT_TRUE(res->data.get());
|
||||
// EXPECT_EQ("Demo", *res->data);
|
||||
// });
|
||||
//
|
||||
// // Make sure that we got a no errors
|
||||
// Log::removeObserver();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//TEST(OfflineDatabase, DatabaseDeleted) {
|
||||
// using namespace mbgl;
|
||||
//
|
||||
// // Create a locked file.
|
||||
// createDir("test/fixtures/database");
|
||||
// deleteFile("test/fixtures/database/locked.db");
|
||||
//
|
||||
// OfflineDatabase db("test/fixtures/database/locked.db");
|
||||
//
|
||||
// {
|
||||
// // Adds a file.
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// Response response;
|
||||
// response.data = std::make_shared<std::string>("Demo");
|
||||
// db.put({ Resource::Unknown, "mapbox://test" }, response);
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// ASSERT_TRUE(bool(res));
|
||||
// ASSERT_TRUE(res->data.get());
|
||||
// EXPECT_EQ("Demo", *res->data);
|
||||
// });
|
||||
//
|
||||
// Log::removeObserver();
|
||||
// }
|
||||
//
|
||||
// deleteFile("test/fixtures/database/locked.db");
|
||||
//
|
||||
// {
|
||||
// // Adds a file.
|
||||
// Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
//
|
||||
// Response response;
|
||||
// response.data = std::make_shared<std::string>("Demo");
|
||||
// db.put({ Resource::Unknown, "mapbox://test" }, response);
|
||||
// db.get({ Resource::Unknown, "mapbox://test" }, [] (optional<Response> res) {
|
||||
// ASSERT_TRUE(bool(res));
|
||||
// ASSERT_TRUE(res->data.get());
|
||||
// EXPECT_EQ("Demo", *res->data);
|
||||
// });
|
||||
//
|
||||
// auto observer = Log::removeObserver();
|
||||
// auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
|
||||
// EXPECT_EQ(1ul, flo->count({ EventSeverity::Error, Event::Database, 8, "attempt to write a readonly database" }));
|
||||
// }
|
||||
//}
|
||||
|
||||
TEST(OfflineDatabase, PutDoesNotStoreConnectionErrors) {
|
||||
using namespace mbgl;
|
||||
|
||||
@@ -491,11 +345,11 @@ TEST(OfflineDatabase, CreateRegionInfiniteMaxZoom) {
|
||||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ConcurrentUse)) {
|
||||
using namespace mbgl;
|
||||
|
||||
createDir("test/fixtures/database");
|
||||
deleteFile("test/fixtures/database/offline.db");
|
||||
createDir("test/fixtures/offline_database");
|
||||
deleteFile("test/fixtures/offline_database/offline.db");
|
||||
|
||||
OfflineDatabase db1("test/fixtures/database/offline.db");
|
||||
OfflineDatabase db2("test/fixtures/database/offline.db");
|
||||
OfflineDatabase db1("test/fixtures/offline_database/offline.db");
|
||||
OfflineDatabase db2("test/fixtures/offline_database/offline.db");
|
||||
|
||||
Resource resource { Resource::Style, "http://example.com/" };
|
||||
Response response;
|
||||
@@ -671,18 +525,18 @@ TEST(OfflineDatabase, MigrateFromV2Schema) {
|
||||
|
||||
// v2.db is a v2 database containing a single offline region with a small number of resources.
|
||||
|
||||
deleteFile("test/fixtures/offline/v3.db");
|
||||
writeFile("test/fixtures/offline/v3.db", util::read_file("test/fixtures/offline/v2.db"));
|
||||
deleteFile("test/fixtures/offline_database/v3.db");
|
||||
writeFile("test/fixtures/offline_database/v3.db", util::read_file("test/fixtures/offline_database/v2.db"));
|
||||
|
||||
{
|
||||
OfflineDatabase db("test/fixtures/offline/v3.db", 0);
|
||||
OfflineDatabase db("test/fixtures/offline_database/v3.db", 0);
|
||||
auto regions = db.listRegions();
|
||||
for (auto& region : regions) {
|
||||
db.deleteRegion(std::move(region));
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(3, databaseUserVersion("test/fixtures/offline/v3.db"));
|
||||
EXPECT_LT(databasePageCount("test/fixtures/offline/v3.db"),
|
||||
databasePageCount("test/fixtures/offline/v2.db"));
|
||||
EXPECT_EQ(3, databaseUserVersion("test/fixtures/offline_database/v3.db"));
|
||||
EXPECT_LT(databasePageCount("test/fixtures/offline_database/v3.db"),
|
||||
databasePageCount("test/fixtures/offline_database/v2.db"));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
Response response(const std::string& path) {
|
||||
Response result;
|
||||
result.data = std::make_shared<std::string>(util::read_file("test/fixtures/"s + path));
|
||||
result.data = std::make_shared<std::string>(util::read_file("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);
|
||||
@@ -61,12 +61,12 @@ TEST(OfflineDownload, NoSubresources) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/empty.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("empty.style.json");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
@@ -101,22 +101,22 @@ TEST(OfflineDownload, InlineSource) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/inline_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("inline_source.style.json");
|
||||
};
|
||||
|
||||
test.fileSource.tileResponse = [&] (const Resource& resource) {
|
||||
const Resource::TileData& tile = *resource.tileData;
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
|
||||
EXPECT_EQ("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
|
||||
EXPECT_EQ(1, tile.pixelRatio);
|
||||
EXPECT_EQ(0, tile.x);
|
||||
EXPECT_EQ(0, tile.y);
|
||||
EXPECT_EQ(0, tile.z);
|
||||
return test.response("offline/0-0-0.vector.pbf");
|
||||
return test.response("0-0-0.vector.pbf");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
@@ -141,17 +141,17 @@ TEST(OfflineDownload, GeoJSONSource) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/geojson_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("geojson_source.style.json");
|
||||
};
|
||||
|
||||
test.fileSource.sourceResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/geojson.json", resource.url);
|
||||
return test.response("offline/geojson.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/geojson.json", resource.url);
|
||||
return test.response("geojson.json");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
@@ -176,41 +176,41 @@ TEST(OfflineDownload, Activate) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("style.json");
|
||||
};
|
||||
|
||||
test.fileSource.spriteImageResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/sprite.png", resource.url);
|
||||
return test.response("offline/sprite.png");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/sprite.png", resource.url);
|
||||
return test.response("sprite.png");
|
||||
};
|
||||
|
||||
test.fileSource.spriteJSONResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/sprite.json", resource.url);
|
||||
return test.response("offline/sprite.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/sprite.json", resource.url);
|
||||
return test.response("sprite.json");
|
||||
};
|
||||
|
||||
test.fileSource.glyphsResponse = [&] (const Resource&) {
|
||||
return test.response("offline/glyph.pbf");
|
||||
return test.response("glyph.pbf");
|
||||
};
|
||||
|
||||
test.fileSource.sourceResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/streets.json", resource.url);
|
||||
return test.response("offline/streets.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/streets.json", resource.url);
|
||||
return test.response("streets.json");
|
||||
};
|
||||
|
||||
test.fileSource.tileResponse = [&] (const Resource& resource) {
|
||||
const Resource::TileData& tile = *resource.tileData;
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
|
||||
EXPECT_EQ("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
|
||||
EXPECT_EQ(1, tile.pixelRatio);
|
||||
EXPECT_EQ(0, tile.x);
|
||||
EXPECT_EQ(0, tile.y);
|
||||
EXPECT_EQ(0, tile.z);
|
||||
return test.response("offline/0-0-0.vector.pbf");
|
||||
return test.response("0-0-0.vector.pbf");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
@@ -243,7 +243,7 @@ TEST(OfflineDownload, GetStatusNoResources) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
OfflineRegionStatus status = download.getStatus();
|
||||
|
||||
@@ -260,12 +260,12 @@ TEST(OfflineDownload, GetStatusStyleComplete) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.db.putRegionResource(1,
|
||||
Resource::style("http://127.0.0.1:3000/offline/style.json"),
|
||||
test.response("offline/style.json"));
|
||||
Resource::style("http://127.0.0.1:3000/style.json"),
|
||||
test.response("style.json"));
|
||||
|
||||
OfflineRegionStatus status = download.getStatus();
|
||||
|
||||
@@ -282,16 +282,16 @@ TEST(OfflineDownload, GetStatusStyleAndSourceComplete) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.db.putRegionResource(1,
|
||||
Resource::style("http://127.0.0.1:3000/offline/style.json"),
|
||||
test.response("offline/style.json"));
|
||||
Resource::style("http://127.0.0.1:3000/style.json"),
|
||||
test.response("style.json"));
|
||||
|
||||
test.db.putRegionResource(1,
|
||||
Resource::source("http://127.0.0.1:3000/offline/streets.json"),
|
||||
test.response("offline/streets.json"));
|
||||
Resource::source("http://127.0.0.1:3000/streets.json"),
|
||||
test.response("streets.json"));
|
||||
|
||||
OfflineRegionStatus status = download.getStatus();
|
||||
|
||||
@@ -308,7 +308,7 @@ TEST(OfflineDownload, RequestError) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource&) {
|
||||
@@ -336,12 +336,12 @@ TEST(OfflineDownload, RequestErrorsAreRetried) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource&) {
|
||||
test.fileSource.styleResponse = [&] (const Resource&) {
|
||||
return test.response("offline/empty.style.json");
|
||||
return test.response("empty.style.json");
|
||||
};
|
||||
|
||||
Response response;
|
||||
@@ -369,7 +369,7 @@ TEST(OfflineDownload, TileCountLimitExceededNoTileResponse) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
uint64_t tileLimit = 0;
|
||||
@@ -377,8 +377,8 @@ TEST(OfflineDownload, TileCountLimitExceededNoTileResponse) {
|
||||
test.db.setOfflineMapboxTileCountLimit(tileLimit);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/mapbox_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("mapbox_source.style.json");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
@@ -411,7 +411,7 @@ TEST(OfflineDownload, TileCountLimitExceededWithTileResponse) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
uint64_t tileLimit = 1;
|
||||
@@ -419,8 +419,8 @@ TEST(OfflineDownload, TileCountLimitExceededWithTileResponse) {
|
||||
test.db.setOfflineMapboxTileCountLimit(tileLimit);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/mapbox_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("mapbox_source.style.json");
|
||||
};
|
||||
|
||||
test.fileSource.tileResponse = [&] (const Resource& resource) {
|
||||
@@ -430,7 +430,7 @@ TEST(OfflineDownload, TileCountLimitExceededWithTileResponse) {
|
||||
EXPECT_EQ(0, tile.x);
|
||||
EXPECT_EQ(0, tile.y);
|
||||
EXPECT_EQ(0, tile.z);
|
||||
return test.response("offline/0-0-0.vector.pbf");
|
||||
return test.response("0-0-0.vector.pbf");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
@@ -465,17 +465,17 @@ TEST(OfflineDownload, WithPreviouslyExistingTile) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/inline_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("inline_source.style.json");
|
||||
};
|
||||
|
||||
test.db.put(
|
||||
Resource::tile("http://127.0.0.1:3000/offline/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
|
||||
test.response("offline/0-0-0.vector.pbf"));
|
||||
Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
|
||||
test.response("0-0-0.vector.pbf"));
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
|
||||
@@ -499,17 +499,17 @@ TEST(OfflineDownload, ReactivatePreviouslyCompletedDownload) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/inline_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("inline_source.style.json");
|
||||
};
|
||||
|
||||
test.db.put(
|
||||
Resource::tile("http://127.0.0.1:3000/offline/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
|
||||
test.response("offline/0-0-0.vector.pbf"));
|
||||
Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
|
||||
test.response("0-0-0.vector.pbf"));
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
observer->statusChangedFn = [&] (OfflineRegionStatus status) {
|
||||
@@ -525,7 +525,7 @@ TEST(OfflineDownload, ReactivatePreviouslyCompletedDownload) {
|
||||
|
||||
OfflineDownload redownload(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
std::vector<OfflineRegionStatus> statusesAfterReactivate;
|
||||
@@ -566,12 +566,12 @@ TEST(OfflineDownload, Deactivate) {
|
||||
OfflineRegion region = test.createRegion();
|
||||
OfflineDownload download(
|
||||
region.getID(),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
|
||||
test.db, test.fileSource);
|
||||
|
||||
test.fileSource.styleResponse = [&] (const Resource& resource) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
|
||||
return test.response("offline/mapbox_source.style.json");
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("mapbox_source.style.json");
|
||||
};
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
|
||||
Reference in New Issue
Block a user