diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2019-06-28 15:33:04 -0700 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2019-07-09 15:03:39 -0700 |
commit | b5e6f6cdde9b7af632e1db7d9f960420973d7940 (patch) | |
tree | 7974792982d9873b592963c43076cf7bc5cb49e4 | |
parent | db94c9c964bfb2454373fd1f5dd5472a6b679de0 (diff) | |
download | qtlocation-mapboxgl-b5e6f6cdde9b7af632e1db7d9f960420973d7940.tar.gz |
[ios] add completion to invalidateOfflineRegionForPack, start tests
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 4 | ||||
-rw-r--r-- | platform/darwin/test/MGLOfflineStorageTests.mm | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 6a6df0e480..f84db344b5 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -452,6 +452,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio mbgl::OfflineRegion& region = *pack.mbglOfflineRegion; NSError *error; if (!pack.mbglOfflineRegion) { + completion(nil); return; } @@ -462,6 +463,9 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio }]; } }); + dispatch_async(dispatch_get_main_queue(), [&, completion, error](void) { + completion(error); + }); } - (void)reloadPacks { diff --git a/platform/darwin/test/MGLOfflineStorageTests.mm b/platform/darwin/test/MGLOfflineStorageTests.mm index 5551d8889b..f91c8958d3 100644 --- a/platform/darwin/test/MGLOfflineStorageTests.mm +++ b/platform/darwin/test/MGLOfflineStorageTests.mm @@ -413,4 +413,23 @@ CFRunLoopRun(); } +- (void)testInvalidateAmbientCache { + [[MGLOfflineStorage sharedOfflineStorage] invalidateAmbientCacheWithCompletion:^(NSError * _Nullable error) { + XCTAssertNil(error); + }]; +} + +- (void)testClearCache { + [[MGLOfflineStorage sharedOfflineStorage] clearAmbientCacheWithCompletion:^(NSError * _Nullable error) { + XCTAssertNil(error); + }]; +} + +- (void)testResetDatabase { + [[MGLOfflineStorage sharedOfflineStorage] resetDatabaseWithCompletionHandler:^(NSError * _Nullable error) { + XCTAssertNil(error); + }]; +} + + @end |