summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-08-21 17:41:22 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-08-28 07:14:54 -0700
commitd4f41364140cc37820f9a9bbff58e5e124097469 (patch)
tree75f644d9a34923965de46e532c93d5f393557167 /test
parenteb72fe580b61b68cb24f9ae57b210857a430bfdc (diff)
downloadqtlocation-mapboxgl-d4f41364140cc37820f9a9bbff58e5e124097469.tar.gz
Enforce Offline tile limit when merging sideloaded databases
Diffstat (limited to 'test')
-rw-r--r--test/storage/offline_database.test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index 7511924d80..41eae6f103 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -1266,6 +1266,37 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) {
}
}
+TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyNewTiles) {
+ FixtureLog log;
+ util::deleteFile(filename_sideload);
+ util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db");
+
+ OfflineDatabase db(":memory:");
+ db.setOfflineMapboxTileCountLimit(1);
+
+ auto result = db.mergeDatabase(filename_sideload);
+ EXPECT_FALSE(result);
+ EXPECT_EQ(1u, log.count({ EventSeverity::Error, Event::Database, -1, "Mapbox tile limit exceeded" }));
+ EXPECT_EQ(0u, log.uncheckedCount());
+}
+
+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");
+
+ OfflineDatabase db(filename);
+ db.setOfflineMapboxTileCountLimit(2);
+
+ auto result = db.mergeDatabase(filename_sideload);
+ EXPECT_THROW(std::rethrow_exception(result.error()), MapboxTileLimitExceededException);
+
+ EXPECT_EQ(1u, log.count({ EventSeverity::Error, Event::Database, -1, "Mapbox tile limit exceeded" }));
+ EXPECT_EQ(0u, log.uncheckedCount());
+}
+
TEST(OfflineDatabase, MergeDatabaseWithInvalidPath) {
FixtureLog log;