summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-25 14:51:27 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-25 14:51:27 -0700
commite916cc811c781404d305af946ae127d4da338a38 (patch)
tree71b6147b4fb2828de8d418972e631a17e3598be0
parent8ce0fb4739f68cd3d5b65b0ded0346053855fa3f (diff)
downloadqtlocation-mapboxgl-e916cc811c781404d305af946ae127d4da338a38.tar.gz
[tests] Rationalize test fixtures (#4834)
Place them in a directory corresponding to the test .cpp file name.
-rw-r--r--.gitignore5
-rw-r--r--test/fixtures/map/offline/0-0-0.vector.pbf (renamed from test/fixtures/offline/0-0-0.vector.pbf)bin482553 -> 482553 bytes
-rw-r--r--test/fixtures/map/offline/expected.png (renamed from test/fixtures/offline/expected.png)bin47842 -> 47842 bytes
-rw-r--r--test/fixtures/map/offline/glyph.pbf (renamed from test/fixtures/offline/glyph.pbf)bin74722 -> 74722 bytes
-rw-r--r--test/fixtures/map/offline/sprite.json (renamed from test/fixtures/offline/sprite.json)0
-rw-r--r--test/fixtures/map/offline/sprite.png (renamed from test/fixtures/offline/sprite.png)bin3351 -> 3351 bytes
-rw-r--r--test/fixtures/map/offline/streets.json (renamed from test/fixtures/offline/streets.json)2
-rw-r--r--test/fixtures/map/offline/style.json (renamed from test/fixtures/offline/style.json)6
-rw-r--r--test/fixtures/offline_database/v2.db (renamed from test/fixtures/offline/v2.db)bin43008 -> 43008 bytes
-rw-r--r--test/fixtures/offline_download/0-0-0.vector.pbfbin0 -> 482553 bytes
-rw-r--r--test/fixtures/offline_download/empty.style.json (renamed from test/fixtures/offline/empty.style.json)0
-rw-r--r--test/fixtures/offline_download/geojson.json (renamed from test/fixtures/offline/geojson.json)0
-rw-r--r--test/fixtures/offline_download/geojson_source.style.json (renamed from test/fixtures/offline/geojson_source.style.json)2
-rw-r--r--test/fixtures/offline_download/glyph.pbfbin0 -> 74722 bytes
-rw-r--r--test/fixtures/offline_download/inline_source.style.json (renamed from test/fixtures/offline/inline_source.style.json)2
-rw-r--r--test/fixtures/offline_download/mapbox_source.style.json (renamed from test/fixtures/offline/mapbox_source.style.json)0
-rw-r--r--test/fixtures/offline_download/sprite.json10
-rw-r--r--test/fixtures/offline_download/sprite.pngbin0 -> 3351 bytes
-rw-r--r--test/fixtures/offline_download/streets.json14
-rw-r--r--test/fixtures/offline_download/style.json41
-rw-r--r--test/map/map.cpp20
-rw-r--r--test/storage/offline_database.cpp186
-rw-r--r--test/storage/offline_download.cpp118
23 files changed, 163 insertions, 243 deletions
diff --git a/.gitignore b/.gitignore
index ff4a3aa827..91df4776b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/test/fixtures/offline/0-0-0.vector.pbf b/test/fixtures/map/offline/0-0-0.vector.pbf
index a0f049ad43..a0f049ad43 100644
--- a/test/fixtures/offline/0-0-0.vector.pbf
+++ b/test/fixtures/map/offline/0-0-0.vector.pbf
Binary files differ
diff --git a/test/fixtures/offline/expected.png b/test/fixtures/map/offline/expected.png
index 1b1c2be4c6..1b1c2be4c6 100644
--- a/test/fixtures/offline/expected.png
+++ b/test/fixtures/map/offline/expected.png
Binary files differ
diff --git a/test/fixtures/offline/glyph.pbf b/test/fixtures/map/offline/glyph.pbf
index 0d160f7898..0d160f7898 100644
--- a/test/fixtures/offline/glyph.pbf
+++ b/test/fixtures/map/offline/glyph.pbf
Binary files differ
diff --git a/test/fixtures/offline/sprite.json b/test/fixtures/map/offline/sprite.json
index e640365519..e640365519 100644
--- a/test/fixtures/offline/sprite.json
+++ b/test/fixtures/map/offline/sprite.json
diff --git a/test/fixtures/offline/sprite.png b/test/fixtures/map/offline/sprite.png
index a02d8eb542..a02d8eb542 100644
--- a/test/fixtures/offline/sprite.png
+++ b/test/fixtures/map/offline/sprite.png
Binary files differ
diff --git a/test/fixtures/offline/streets.json b/test/fixtures/map/offline/streets.json
index 805bd68f45..62bf704c1a 100644
--- a/test/fixtures/offline/streets.json
+++ b/test/fixtures/map/offline/streets.json
@@ -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" ]
}
diff --git a/test/fixtures/offline/style.json b/test/fixtures/map/offline/style.json
index c34ee59893..978df3aae3 100644
--- a/test/fixtures/offline/style.json
+++ b/test/fixtures/map/offline/style.json
@@ -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",
diff --git a/test/fixtures/offline/v2.db b/test/fixtures/offline_database/v2.db
index 8fadec4abe..8fadec4abe 100644
--- a/test/fixtures/offline/v2.db
+++ b/test/fixtures/offline_database/v2.db
Binary files differ
diff --git a/test/fixtures/offline_download/0-0-0.vector.pbf b/test/fixtures/offline_download/0-0-0.vector.pbf
new file mode 100644
index 0000000000..a0f049ad43
--- /dev/null
+++ b/test/fixtures/offline_download/0-0-0.vector.pbf
Binary files differ
diff --git a/test/fixtures/offline/empty.style.json b/test/fixtures/offline_download/empty.style.json
index 61a8fadcdb..61a8fadcdb 100644
--- a/test/fixtures/offline/empty.style.json
+++ b/test/fixtures/offline_download/empty.style.json
diff --git a/test/fixtures/offline/geojson.json b/test/fixtures/offline_download/geojson.json
index 8b3698faf7..8b3698faf7 100644
--- a/test/fixtures/offline/geojson.json
+++ b/test/fixtures/offline_download/geojson.json
diff --git a/test/fixtures/offline/geojson_source.style.json b/test/fixtures/offline_download/geojson_source.style.json
index 511fca9fd0..ae313e319e 100644
--- a/test/fixtures/offline/geojson_source.style.json
+++ b/test/fixtures/offline_download/geojson_source.style.json
@@ -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": []
diff --git a/test/fixtures/offline_download/glyph.pbf b/test/fixtures/offline_download/glyph.pbf
new file mode 100644
index 0000000000..0d160f7898
--- /dev/null
+++ b/test/fixtures/offline_download/glyph.pbf
Binary files differ
diff --git a/test/fixtures/offline/inline_source.style.json b/test/fixtures/offline_download/inline_source.style.json
index 87155d07d8..ec928c6234 100644
--- a/test/fixtures/offline/inline_source.style.json
+++ b/test/fixtures/offline_download/inline_source.style.json
@@ -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": [{
diff --git a/test/fixtures/offline/mapbox_source.style.json b/test/fixtures/offline_download/mapbox_source.style.json
index 75bfd6667d..75bfd6667d 100644
--- a/test/fixtures/offline/mapbox_source.style.json
+++ b/test/fixtures/offline_download/mapbox_source.style.json
diff --git a/test/fixtures/offline_download/sprite.json b/test/fixtures/offline_download/sprite.json
new file mode 100644
index 0000000000..e640365519
--- /dev/null
+++ b/test/fixtures/offline_download/sprite.json
@@ -0,0 +1,10 @@
+{
+ "noise": {
+ "x": 0,
+ "y": 0,
+ "width": 32,
+ "height": 32,
+ "pixelRatio": 1,
+ "sdf": false
+ }
+}
diff --git a/test/fixtures/offline_download/sprite.png b/test/fixtures/offline_download/sprite.png
new file mode 100644
index 0000000000..a02d8eb542
--- /dev/null
+++ b/test/fixtures/offline_download/sprite.png
Binary files differ
diff --git a/test/fixtures/offline_download/streets.json b/test/fixtures/offline_download/streets.json
new file mode 100644
index 0000000000..62bf704c1a
--- /dev/null
+++ b/test/fixtures/offline_download/streets.json
@@ -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" ]
+}
diff --git a/test/fixtures/offline_download/style.json b/test/fixtures/offline_download/style.json
new file mode 100644
index 0000000000..978df3aae3
--- /dev/null
+++ b/test/fixtures/offline_download/style.json
@@ -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
+ }
+ }]
+}
diff --git a/test/map/map.cpp b/test/map/map.cpp
index 1e8c1b2a4e..2c5756b156 100644
--- a/test/map/map.cpp
+++ b/test/map/map.cpp
@@ -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);
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index e211aba2d7..6833a058a9 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -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"));
}
diff --git a/test/storage/offline_download.cpp b/test/storage/offline_download.cpp
index 0898043232..7ac9b94e81 100644
--- a/test/storage/offline_download.cpp
+++ b/test/storage/offline_download.cpp
@@ -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>();