From b5e6f6cdde9b7af632e1db7d9f960420973d7940 Mon Sep 17 00:00:00 2001 From: jmkiley Date: Fri, 28 Jun 2019 15:33:04 -0700 Subject: [ios] add completion to invalidateOfflineRegionForPack, start tests --- platform/darwin/src/MGLOfflineStorage.mm | 4 ++++ platform/darwin/test/MGLOfflineStorageTests.mm | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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 -- cgit v1.2.1