diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-08-21 22:38:36 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-21 16:13:35 -0700 |
commit | 2c8e030550024380753a4ebb758e18f1db16edbe (patch) | |
tree | b3d164161d475dac6ed83df86a12936f5be7f32d | |
parent | 6a2ce352d1eec6dc166e351e06c6b10c633eb07c (diff) | |
download | qtlocation-mapboxgl-2c8e030550024380753a4ebb758e18f1db16edbe.tar.gz |
[ios, macos] Short-circuit packs test
If the packs property is already populated, there’s no need to wait for a change notification.
-rw-r--r-- | platform/darwin/test/MGLOfflineStorageTests.m | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/platform/darwin/test/MGLOfflineStorageTests.m b/platform/darwin/test/MGLOfflineStorageTests.m index 0661a58ce3..c2a8e152d1 100644 --- a/platform/darwin/test/MGLOfflineStorageTests.m +++ b/platform/darwin/test/MGLOfflineStorageTests.m @@ -13,12 +13,15 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) { + XCTestExpectation *expectation = [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) { NSKeyValueChange changeKind = [change[NSKeyValueChangeKindKey] unsignedIntegerValue]; return changeKind = NSKeyValueChangeSetting; }]; - - [self waitForExpectationsWithTimeout:1 handler:nil]; + if ([MGLOfflineStorage sharedOfflineStorage].packs) { + [expectation fulfill]; + } else { + [self waitForExpectationsWithTimeout:1 handler:nil]; + } XCTAssertNotNil([MGLOfflineStorage sharedOfflineStorage].packs, @"Shared offline storage object should have a non-nil collection of packs by this point."); }); |