diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-08-15 08:27:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-15 08:27:59 -0700 |
commit | 6675e813cec84ff95bbf50fc302767c6b22a4d96 (patch) | |
tree | 1288e5078ff67f9dca6fa3f17546e4757d5ea734 /platform | |
parent | c5c713a9451ee8a33b8a687173411620d48d91ea (diff) | |
download | qtlocation-mapboxgl-6675e813cec84ff95bbf50fc302767c6b22a4d96.tar.gz |
[ios, macos] Replaced testAAALoadPacks with a setUp method (#6007)
XCTest apparently no longer executes tests in alphabetical order, so naming the test testAAALoadPacks doesn’t ensure it gets run first. Instead, put the pack loading test inside -setUp, but also put it inside a dispatch_once() block to ensure that it only gets run before the first offline storage test that gets run in the current process.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/test/MGLOfflineStorageTests.m | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/platform/darwin/test/MGLOfflineStorageTests.m b/platform/darwin/test/MGLOfflineStorageTests.m index e44bd06e3d..0661a58ce3 100644 --- a/platform/darwin/test/MGLOfflineStorageTests.m +++ b/platform/darwin/test/MGLOfflineStorageTests.m @@ -8,20 +8,24 @@ @implementation MGLOfflineStorageTests -- (void)testSharedObject { - XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage], [MGLOfflineStorage sharedOfflineStorage], @"There should only be one shared offline storage object."); +- (void)setUp { + [super setUp]; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + [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]; + + XCTAssertNotNil([MGLOfflineStorage sharedOfflineStorage].packs, @"Shared offline storage object should have a non-nil collection of packs by this point."); + }); } -// This test needs to come first so it can test the initial loading of packs. -- (void)testAAALoadPacks { - [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]; - - XCTAssertNotNil([MGLOfflineStorage sharedOfflineStorage].packs, @"Shared offline storage object should have a non-nil collection of packs by this point."); +- (void)testSharedObject { + XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage], [MGLOfflineStorage sharedOfflineStorage], @"There should only be one shared offline storage object."); } - (void)testAddPack { |