summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLOfflineStorageTests.mm
diff options
context:
space:
mode:
authorJordan Kiley <jmkiley@users.noreply.github.com>2019-07-16 14:58:32 -0700
committerGitHub <noreply@github.com>2019-07-16 14:58:32 -0700
commit9d8839c4b83e2ea7901e0f06ba1985cd7547f01b (patch)
treeec0707d1d6f7da840e8f04f3ff6152c52be09f6c /platform/darwin/test/MGLOfflineStorageTests.mm
parent0baa54a19433f019ca396ae3e7585c55b1b9503a (diff)
downloadqtlocation-mapboxgl-9d8839c4b83e2ea7901e0f06ba1985cd7547f01b.tar.gz
[ios] Cache Management API (#14978)
Diffstat (limited to 'platform/darwin/test/MGLOfflineStorageTests.mm')
-rw-r--r--platform/darwin/test/MGLOfflineStorageTests.mm62
1 files changed, 62 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLOfflineStorageTests.mm b/platform/darwin/test/MGLOfflineStorageTests.mm
index 5551d8889b..ee4bcc2c65 100644
--- a/platform/darwin/test/MGLOfflineStorageTests.mm
+++ b/platform/darwin/test/MGLOfflineStorageTests.mm
@@ -201,6 +201,68 @@
pack = nil;
}
+- (void)testInvalidatePack {
+ XCTestExpectation *expectation = [self expectationWithDescription:@"Expect offline pack to be invalidated without an error."];
+ MGLCoordinateBounds bounds = {
+ { .latitude = 48.8660, .longitude = 2.3306 },
+ { .latitude = 48.8603, .longitude = 2.3213 },
+ };
+
+ NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
+ MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:styleURL bounds:bounds fromZoomLevel:10 toZoomLevel:11];
+
+ NSString *nameKey = @"Name";
+ NSString *name = @"Paris square";
+
+ NSData *context = [NSKeyedArchiver archivedDataWithRootObject:@{nameKey: name}];
+ [[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack * _Nullable pack, NSError * _Nullable error) {
+ XCTAssertNotNil(pack);
+ [[MGLOfflineStorage sharedOfflineStorage] invalidatePack:pack withCompletionHandler:^(NSError * _Nullable) {
+ XCTAssertNotNil(pack);
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
+ }];
+ [self waitForExpectationsWithTimeout:10 handler:nil];
+}
+
+- (void)testSetMaximumAmbientCache {
+ XCTestExpectation *expectation = [self expectationWithDescription:@"Expect maximum cache size to be raised without an error."];
+ [[MGLOfflineStorage sharedOfflineStorage] setMaximumAmbientCacheSize:0 withCompletionHandler:^(NSError * _Nullable error) {
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:10 handler:nil];
+}
+
+- (void)testInvalidateAmbientCache {
+ XCTestExpectation *expectation = [self expectationWithDescription:@"Expect cache to be invalidated without an error."];
+ [[MGLOfflineStorage sharedOfflineStorage] invalidateAmbientCacheWithCompletionHandler:^(NSError * _Nullable error) {
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:10 handler:nil];
+}
+
+- (void)testClearCache {
+ XCTestExpectation *expectation = [self expectationWithDescription:@"Expect cache to be cleared without an error."];
+ [[MGLOfflineStorage sharedOfflineStorage] clearAmbientCacheWithCompletionHandler:^(NSError * _Nullable error) {
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:10 handler:nil];
+}
+
+- (void)testResetDatabase {
+ XCTestExpectation *expectation = [self expectationWithDescription:@"Expect database to be reset without an error."];
+ [[MGLOfflineStorage sharedOfflineStorage] resetDatabaseWithCompletionHandler:^(NSError * _Nullable error) {
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:10 handler:nil];
+}
+
- (void)testBackupExclusion {
NSURL *cacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
inDomain:NSUserDomainMask