From 2c8e030550024380753a4ebb758e18f1db16edbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 21 Aug 2016 22:38:36 -0700 Subject: [PATCH] [ios, macos] Short-circuit packs test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the packs property is already populated, there’s no need to wait for a change notification. --- platform/darwin/test/MGLOfflineStorageTests.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/darwin/test/MGLOfflineStorageTests.m b/platform/darwin/test/MGLOfflineStorageTests.m index 0661a58ce..c2a8e152d 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."); });