summaryrefslogtreecommitdiff
path: root/test/storage
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-06-14 15:11:32 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-06-18 16:26:51 +0300
commit68e3cbacbc35ae6cd6c1e0fe2ab59ed262c32786 (patch)
treea8eb342508e1b089d05eb4c35bb1ce424ecee088 /test/storage
parent78eeffe1717a37a91e6c59681421a20c52a4d003 (diff)
downloadqtlocation-mapboxgl-68e3cbacbc35ae6cd6c1e0fe2ab59ed262c32786.tar.gz
[core] Add method for setting a maximum size for the ambient cache
- Removed this parameter from the constructor, now that we have a method to set it. - Add the method and enforce the limits if the ambient cache exceeds the size.
Diffstat (limited to 'test/storage')
-rw-r--r--test/storage/offline_database.test.cpp47
1 files changed, 34 insertions, 13 deletions
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index 5801c77fef..882a10e9ef 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -318,7 +318,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(GetResourceFromOfflineRegion)) {
deleteDatabaseFiles();
util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db");
- OfflineDatabase db(filename, mapbox::sqlite::ReadOnly);
+ OfflineDatabase db(filename);
Resource resource = Resource::style("mapbox://styles/mapbox/satellite-v9");
ASSERT_TRUE(db.get(resource));
@@ -755,7 +755,8 @@ TEST(OfflineDatabase, PutReturnsSize) {
TEST(OfflineDatabase, PutEvictsLeastRecentlyUsedResources) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
+ db.setMaximumAmbientCacheSize(1024 * 100);
Response response;
response.data = randomString(1024);
@@ -773,7 +774,9 @@ TEST(OfflineDatabase, PutEvictsLeastRecentlyUsedResources) {
TEST(OfflineDatabase, PutRegionResourceDoesNotEvict) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
+ db.setMaximumAmbientCacheSize(1024 * 100);
+
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, true };
auto region = db.createRegion(definition, OfflineRegionMetadata());
ASSERT_TRUE(region);
@@ -793,7 +796,8 @@ TEST(OfflineDatabase, PutRegionResourceDoesNotEvict) {
TEST(OfflineDatabase, PutFailsWhenEvictionInsuffices) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
+ db.setMaximumAmbientCacheSize(1024 * 100);
Response big;
big.data = randomString(1024 * 100);
@@ -849,7 +853,9 @@ TEST(OfflineDatabase, GetRegionCompletedStatus) {
TEST(OfflineDatabase, HasRegionResource) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
+ db.setMaximumAmbientCacheSize(1024 * 100);
+
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, true };
auto region = db.createRegion(definition, OfflineRegionMetadata());
ASSERT_TRUE(region);
@@ -873,7 +879,9 @@ TEST(OfflineDatabase, HasRegionResource) {
TEST(OfflineDatabase, HasRegionResourceTile) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
+ db.setMaximumAmbientCacheSize(1024 * 100);
+
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, false };
auto region = db.createRegion(definition, OfflineRegionMetadata());
ASSERT_TRUE(region);
@@ -968,7 +976,9 @@ TEST(OfflineDatabase, OfflineMapboxTileCount) {
TEST(OfflineDatabase, BatchInsertion) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
+ db.setMaximumAmbientCacheSize(1024 * 100);
+
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, true };
auto region = db.createRegion(definition, OfflineRegionMetadata());
ASSERT_TRUE(region);
@@ -993,8 +1003,10 @@ TEST(OfflineDatabase, BatchInsertion) {
TEST(OfflineDatabase, BatchInsertionMapboxTileCountExceeded) {
FixtureLog log;
- OfflineDatabase db(":memory:", 1024 * 100);
+ OfflineDatabase db(":memory:");
db.setOfflineMapboxTileCountLimit(1);
+ db.setMaximumAmbientCacheSize(1024 * 100);
+
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, false };
auto region = db.createRegion(definition, OfflineRegionMetadata());
ASSERT_TRUE(region);
@@ -1031,7 +1043,9 @@ TEST(OfflineDatabase, MigrateFromV2Schema) {
util::copyFile(filename, "test/fixtures/offline_database/v2.db");
{
- OfflineDatabase db(filename, 0);
+ OfflineDatabase db(filename);
+ db.setMaximumAmbientCacheSize(0);
+
auto regions = db.listRegions();
ASSERT_TRUE(regions);
for (auto& region : regions.value()) {
@@ -1053,7 +1067,9 @@ TEST(OfflineDatabase, MigrateFromV3Schema) {
util::copyFile(filename, "test/fixtures/offline_database/v3.db");
{
- OfflineDatabase db(filename, 0);
+ OfflineDatabase db(filename);
+ db.setMaximumAmbientCacheSize(0);
+
auto regions = db.listRegions().value();
for (auto& region : regions) {
db.deleteRegion(std::move(region));
@@ -1072,7 +1088,9 @@ TEST(OfflineDatabase, MigrateFromV4Schema) {
util::copyFile(filename, "test/fixtures/offline_database/v4.db");
{
- OfflineDatabase db(filename, 0);
+ OfflineDatabase db(filename);
+ db.setMaximumAmbientCacheSize(0);
+
auto regions = db.listRegions().value();
for (auto& region : regions) {
db.deleteRegion(std::move(region));
@@ -1098,7 +1116,9 @@ TEST(OfflineDatabase, MigrateFromV5Schema) {
util::copyFile(filename, "test/fixtures/offline_database/v5.db");
{
- OfflineDatabase db(filename, 0);
+ OfflineDatabase db(filename);
+ db.setMaximumAmbientCacheSize(0);
+
auto regions = db.listRegions().value();
for (auto& region : regions) {
db.deleteRegion(std::move(region));
@@ -1126,7 +1146,8 @@ TEST(OfflineDatabase, DowngradeSchema) {
util::copyFile(filename, "test/fixtures/offline_database/v999.db");
{
- OfflineDatabase db(filename, 0);
+ OfflineDatabase db(filename);
+ db.setMaximumAmbientCacheSize(0);
}
EXPECT_EQ(6, databaseUserVersion(filename));