summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-10-26 09:09:10 -0400
committerGitHub <noreply@github.com>2020-10-26 09:09:10 -0400
commit958ae890ae8edaabe7a9acc110642996055cf369 (patch)
tree200ee7a9f8d1467baf58a734f58014c8ba34dd83
parente65236b004893227270cef02c09278c1f42f93af (diff)
parent69f8ff1ebeefb5041b61399d82224ffe43ef6f75 (diff)
downloadsdl_ios-958ae890ae8edaabe7a9acc110642996055cf369.tar.gz
Merge pull request #1822 from smartdevicelink/bugfix/issue-1813-some-properties-in-the-OnDriverDistraction-are-missing-nullable-attribute
Add nullable attribute to lockScreenDismissalEnabled and lockScreenDismissalWarning
-rw-r--r--SmartDeviceLink/public/SDLOnDriverDistraction.h4
-rw-r--r--SmartDeviceLink/public/SDLOnDriverDistraction.m8
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m22
3 files changed, 19 insertions, 15 deletions
diff --git a/SmartDeviceLink/public/SDLOnDriverDistraction.h b/SmartDeviceLink/public/SDLOnDriverDistraction.h
index f7df06bd8..e08efc583 100644
--- a/SmartDeviceLink/public/SDLOnDriverDistraction.h
+++ b/SmartDeviceLink/public/SDLOnDriverDistraction.h
@@ -33,14 +33,14 @@ NS_ASSUME_NONNULL_BEGIN
Optional, Boolean
*/
-@property (strong, nonatomic) NSNumber<SDLBool> *lockScreenDismissalEnabled;
+@property (strong, nonatomic, nullable) NSNumber<SDLBool> *lockScreenDismissalEnabled;
/**
Warning message to be displayed on the lock screen when dismissal is enabled. This warning should be used to ensure that the user is not the driver of the vehicle, ex. `Swipe up to dismiss, acknowledging that you are not the driver.`. This parameter must be present if "lockScreenDismissalEnabled" is set to true.
Optional, String
*/
-@property (strong, nonatomic) NSString *lockScreenDismissalWarning;
+@property (strong, nonatomic, nullable) NSString *lockScreenDismissalWarning;
@end
diff --git a/SmartDeviceLink/public/SDLOnDriverDistraction.m b/SmartDeviceLink/public/SDLOnDriverDistraction.m
index 40fb3afa2..4d949ffb7 100644
--- a/SmartDeviceLink/public/SDLOnDriverDistraction.m
+++ b/SmartDeviceLink/public/SDLOnDriverDistraction.m
@@ -30,20 +30,20 @@ NS_ASSUME_NONNULL_BEGIN
return [self.parameters sdl_enumForName:SDLRPCParameterNameState error:&error];
}
-- (void)setLockScreenDismissalEnabled:(NSNumber<SDLBool> *)lockScreenDismissalEnabled {
+- (void)setLockScreenDismissalEnabled:(nullable NSNumber<SDLBool> *)lockScreenDismissalEnabled {
[self.parameters sdl_setObject:lockScreenDismissalEnabled forName:SDLRPCParameterNameLockScreenDismissalEnabled];
}
-- (NSNumber<SDLBool> *)lockScreenDismissalEnabled {
+- (nullable NSNumber<SDLBool> *)lockScreenDismissalEnabled {
NSError *error = nil;
return [self.parameters sdl_objectForName:SDLRPCParameterNameLockScreenDismissalEnabled ofClass:NSNumber.class error:&error];
}
-- (void)setLockScreenDismissalWarning:(NSString *)lockScreenDismissalWarning {
+- (void)setLockScreenDismissalWarning:(nullable NSString *)lockScreenDismissalWarning {
[self.parameters sdl_setObject:lockScreenDismissalWarning forName:SDLRPCParameterNameLockScreenDismissalWarning];
}
-- (NSString *)lockScreenDismissalWarning {
+- (nullable NSString *)lockScreenDismissalWarning {
NSError *error = nil;
return [self.parameters sdl_objectForName:SDLRPCParameterNameLockScreenDismissalWarning ofClass:NSString.class error:&error];
}
diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m
index 280e596a7..33836f9fb 100644
--- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m
@@ -15,26 +15,28 @@
QuickSpecBegin(SDLOnDriverDistractionSpec)
+NSString *testDismissalWarning = @"I got an apple.";
+
describe(@"Getter/Setter Tests", ^ {
it(@"Should set and get correctly", ^ {
SDLOnDriverDistraction *testNotification = [[SDLOnDriverDistraction alloc] init];
testNotification.state = SDLDriverDistractionStateOn;
testNotification.lockScreenDismissalEnabled = @1;
-
+ testNotification.lockScreenDismissalWarning = testDismissalWarning;
+
expect(testNotification.state).to(equal(SDLDriverDistractionStateOn));
expect(testNotification.lockScreenDismissalEnabled).to(beTrue());
-
- testNotification.lockScreenDismissalEnabled = @0;
- expect(testNotification.lockScreenDismissalEnabled).to(beFalse());
+ expect(testNotification.lockScreenDismissalWarning).to(equal(testDismissalWarning));
});
it(@"Should get correctly when initialized", ^ {
- NSMutableDictionary *dictOn = [@{SDLRPCParameterNameNotification:
+ NSDictionary *dictOn = @{SDLRPCParameterNameNotification:
@{SDLRPCParameterNameParameters:
@{SDLRPCParameterNameState:SDLDriverDistractionStateOn,
- SDLRPCParameterNameLockScreenDismissalEnabled: @1},
- SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}} mutableCopy];
+ SDLRPCParameterNameLockScreenDismissalEnabled: @1,
+ SDLRPCParameterNameLockScreenDismissalWarning: testDismissalWarning},
+ SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnDriverDistraction* testNotificationOn = [[SDLOnDriverDistraction alloc] initWithDictionary:dictOn];
@@ -42,12 +44,13 @@ describe(@"Getter/Setter Tests", ^ {
expect(testNotificationOn.state).to(equal(SDLDriverDistractionStateOn));
expect(testNotificationOn.lockScreenDismissalEnabled).to(beTrue());
+ expect(testNotificationOn.lockScreenDismissalWarning).to(equal(testDismissalWarning));
- NSMutableDictionary *dictOff = [@{SDLRPCParameterNameNotification:
+ NSDictionary *dictOff = @{SDLRPCParameterNameNotification:
@{SDLRPCParameterNameParameters:
@{SDLRPCParameterNameState:SDLDriverDistractionStateOff,
SDLRPCParameterNameLockScreenDismissalEnabled: @0},
- SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}} mutableCopy];
+ SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnDriverDistraction *testNotificationOff = [[SDLOnDriverDistraction alloc] initWithDictionary:dictOff];
@@ -61,6 +64,7 @@ describe(@"Getter/Setter Tests", ^ {
SDLOnDriverDistraction *testNotification = [[SDLOnDriverDistraction alloc] init];
expect(testNotification.state).to(beNil());
+ expect(testNotification.lockScreenDismissalWarning).to(beNil());
expect(testNotification.lockScreenDismissalEnabled).to(beNil());
expect(testNotification.lockScreenDismissalEnabled).to(beFalsy());
});