summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-03-27 22:40:15 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-03-29 11:46:27 -0700
commit8c8b0580388460c0addafb49c852ea8986b47ac4 (patch)
tree2e55e038689eba4d0faf71c251adca8543ea8075 /platform/osx
parentaff1196d02cd06e71c7b2a15454384fd302946b1 (diff)
downloadqtlocation-mapboxgl-8c8b0580388460c0addafb49c852ea8986b47ac4.tar.gz
[ios, osx] Include progress in progress change notification
An MGLOfflinePackProgressChangedNotification notification now includes the pack’s state and progress values, which match the values in the corresponding MGLOfflinePack properties. Implemented NSValue category methods to store MGLOfflinePackProgress inside a dictionary.
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/test/MGLOfflinePackTests.m15
-rw-r--r--platform/osx/test/MGLOfflineStorageTests.m12
2 files changed, 27 insertions, 0 deletions
diff --git a/platform/osx/test/MGLOfflinePackTests.m b/platform/osx/test/MGLOfflinePackTests.m
index c33a72cc08..41262d16c7 100644
--- a/platform/osx/test/MGLOfflinePackTests.m
+++ b/platform/osx/test/MGLOfflinePackTests.m
@@ -22,4 +22,19 @@
XCTAssertThrowsSpecificNamed([invalidPack suspend], NSException, @"Invalid offline pack", @"Invalid offline pack should raise an exception when being suspended.");
}
+- (void)testProgressBoxing {
+ MGLOfflinePackProgress progress = {
+ .countOfResourcesCompleted = 1,
+ .countOfResourcesExpected = 2,
+ .countOfBytesCompleted = 7,
+ .maximumResourcesExpected = UINT64_MAX,
+ };
+ MGLOfflinePackProgress roundTrippedProgress = [NSValue valueWithMGLOfflinePackProgress:progress].MGLOfflinePackProgressValue;
+
+ XCTAssertEqual(progress.countOfResourcesCompleted, roundTrippedProgress.countOfResourcesCompleted, @"Completed resources should round-trip.");
+ XCTAssertEqual(progress.countOfResourcesExpected, roundTrippedProgress.countOfResourcesExpected, @"Expected resources should round-trip.");
+ XCTAssertEqual(progress.countOfBytesCompleted, roundTrippedProgress.countOfBytesCompleted, @"Completed bytes should round-trip.");
+ XCTAssertEqual(progress.maximumResourcesExpected, roundTrippedProgress.maximumResourcesExpected, @"Maximum expected resources should round-trip.");
+}
+
@end
diff --git a/platform/osx/test/MGLOfflineStorageTests.m b/platform/osx/test/MGLOfflineStorageTests.m
index ff738f9239..3657f93d48 100644
--- a/platform/osx/test/MGLOfflineStorageTests.m
+++ b/platform/osx/test/MGLOfflineStorageTests.m
@@ -82,6 +82,18 @@
[self expectationForNotification:MGLOfflinePackProgressChangedNotification object:pack handler:^BOOL(NSNotification * _Nonnull notification) {
MGLOfflinePack *notificationPack = notification.object;
XCTAssert([notificationPack isKindOfClass:[MGLOfflinePack class]], @"Object of notification should be an MGLOfflinePack.");
+
+ NSDictionary *userInfo = notification.userInfo;
+ XCTAssertNotNil(userInfo, @"Progress change notification should have a userInfo dictionary.");
+
+ NSNumber *stateNumber = userInfo[MGLOfflinePackStateUserInfoKey];
+ XCTAssert([stateNumber isKindOfClass:[NSNumber class]], @"Progress change notification’s state should be an NSNumber.");
+ XCTAssertEqual(stateNumber.integerValue, pack.state, @"State in a progress change notification should match the pack’s state.");
+
+ NSValue *progressValue = userInfo[MGLOfflinePackProgressUserInfoKey];
+ XCTAssert([progressValue isKindOfClass:[NSValue class]], @"Progress change notification’s progress should be an NSValue.");
+ XCTAssertEqualObjects(progressValue, [NSValue valueWithMGLOfflinePackProgress:pack.progress], @"Progress change notification’s progress should match pack’s progress.");
+
return notificationPack == pack && pack.state == MGLOfflinePackStateInactive;
}];
[self waitForExpectationsWithTimeout:1 handler:nil];