diff options
author | Satbir Tanda <satbirtanda@gmail.com> | 2019-07-30 13:22:25 -0700 |
---|---|---|
committer | Satbir Tanda <satbirtanda@gmail.com> | 2019-07-30 13:22:25 -0700 |
commit | 7ebc8591ce375efd78a1ff3a1a2fff6de69932f2 (patch) | |
tree | 911534136e2b4717036f11814d47d204d2ddd923 | |
parent | 6802c009c4800626eb909f21e33a7aefbbd56b01 (diff) | |
download | sdl_ios-7ebc8591ce375efd78a1ff3a1a2fff6de69932f2.tar.gz |
Add pragma for deprecating SDLOnLockScreenStatus
Make recommended fixes, fix spec
7 files changed, 56 insertions, 16 deletions
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m index 781ff2998..81654b074 100644 --- a/SmartDeviceLink/SDLLockScreenManager.m +++ b/SmartDeviceLink/SDLLockScreenManager.m @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic, nullable) SDLOnDriverDistraction *lastDriverDistractionNotification; @property (assign, nonatomic, readwrite, getter=isLockScreenDismissable) BOOL lockScreenDismissable; -@property (assign, nonatomic) BOOL lockScreenDismissed; +@property (assign, nonatomic) BOOL lockScreenDismissedByUser; @end @@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN _lockScreenDismissable = NO; _config = config; _presenter = presenter; - _lockScreenDismissed = NO; + _lockScreenDismissedByUser = NO; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenStatusDidChange:) name:SDLDidChangeLockScreenStatusNotification object:dispatcher]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenIconReceived:) name:SDLDidReceiveLockScreenIcon object:dispatcher]; @@ -153,11 +153,11 @@ NS_ASSUME_NONNULL_BEGIN // Present the VC depending on the lock screen status if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) { - if (!self.presenter.presented && self.canPresent && !self.lockScreenDismissed) { + if (!self.presenter.presented && self.canPresent && !self.lockScreenDismissedByUser) { [self.presenter present]; } } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) { - if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent && !self.lockScreenDismissed) { + if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent && !self.lockScreenDismissedByUser) { [self.presenter present]; } else if (!self.config.showInOptionalState && self.presenter.presented) { [self.presenter dismiss]; @@ -171,13 +171,13 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdl_updateLockScreenDismissable { if (self.lastDriverDistractionNotification == nil || self.lastDriverDistractionNotification.lockScreenDismissalEnabled == nil || - ![self.lastDriverDistractionNotification.lockScreenDismissalEnabled boolValue]) { + !self.lastDriverDistractionNotification.lockScreenDismissalEnabled.boolValue) { self.lockScreenDismissable = NO; } else { self.lockScreenDismissable = YES; } - if (!self.lockScreenDismissed) { + if (!self.lockScreenDismissedByUser) { [self sdl_updateLockscreenViewControllerWithDismissableState:self.lockScreenDismissable]; } } @@ -194,7 +194,7 @@ NS_ASSUME_NONNULL_BEGIN if (enabled) { [lockscreenViewController addDismissGestureWithCallback:^{ [strongSelf.presenter dismiss]; - strongSelf.lockScreenDismissed = YES; + strongSelf.lockScreenDismissedByUser = YES; }]; lockscreenViewController.lockedLabelText = strongSelf.lastDriverDistractionNotification.lockScreenDismissalWarning; } else { diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.h b/SmartDeviceLink/SDLLockScreenStatusManager.h index 2a37b9d83..90b3d85a3 100644 --- a/SmartDeviceLink/SDLLockScreenStatusManager.h +++ b/SmartDeviceLink/SDLLockScreenStatusManager.h @@ -18,7 +18,10 @@ NS_ASSUME_NONNULL_BEGIN @property (assign, nonatomic) BOOL driverDistracted; @property (nullable, strong, nonatomic) SDLHMILevel hmiLevel; @property (strong, nonatomic, readonly) SDLLockScreenStatus lockScreenStatus; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" @property (strong, nonatomic, readonly) SDLOnLockScreenStatus *lockScreenStatusNotification; +#pragma clang diagnostic pop @end diff --git a/SmartDeviceLink/SDLProxyListener.h b/SmartDeviceLink/SDLProxyListener.h index ea19fde07..d16e82648 100644 --- a/SmartDeviceLink/SDLProxyListener.h +++ b/SmartDeviceLink/SDLProxyListener.h @@ -1049,7 +1049,10 @@ NS_ASSUME_NONNULL_BEGIN * * @param notification A SDLOnLockScreenStatus object */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" - (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification; +#pragma clang diagnostic pop /** * Called when an On Permissions Change notification is received from Core diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m index a2e6eaaa7..542ce850b 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m @@ -47,10 +47,17 @@ describe(@"a lock screen manager", ^{ }); describe(@"when the lock screen status becomes REQUIRED", ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __block SDLOnLockScreenStatus *testRequiredStatus = nil; - +#pragma clang diagnostic pop + beforeEach(^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" testRequiredStatus = [[SDLOnLockScreenStatus alloc] init]; +#pragma clang diagnostic pop + testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired; [testNotificationDispatcher postNotificationName:SDLDidChangeLockScreenStatusNotification infoObject:testRequiredStatus]; @@ -85,11 +92,17 @@ describe(@"a lock screen manager", ^{ }); describe(@"when the lock screen status becomes REQUIRED", ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __block SDLOnLockScreenStatus *testRequiredStatus = nil; +#pragma clang diagnostic pop __block SDLOnDriverDistraction *testDriverDistraction = nil; beforeEach(^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" testRequiredStatus = [[SDLOnLockScreenStatus alloc] init]; +#pragma clang diagnostic pop testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired; SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testRequiredStatus]; @@ -118,12 +131,12 @@ describe(@"a lock screen manager", ^{ }); }); - describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled 1 bit", ^{ + describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled as true", ^{ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil; beforeEach(^{ testDriverDistraction = [[SDLOnDriverDistraction alloc] init]; - testDriverDistraction.lockScreenDismissalEnabled = @1; + testDriverDistraction.lockScreenDismissalEnabled = @YES; testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction]; @@ -131,7 +144,7 @@ describe(@"a lock screen manager", ^{ }); it(@"should be able to be dismissed", ^{ - expect(testManager.lockScreenDismissableEnabled).toEventually(equal(YES)); + expect(testManager.isLockScreenDismissable).toEventually(equal(YES)); }); }); @@ -149,7 +162,7 @@ describe(@"a lock screen manager", ^{ }); it(@"should not be able to be dismissed", ^{ - expect(testManager.lockScreenDismissableEnabled).toEventually(equal(NO)); + expect(testManager.isLockScreenDismissable).toEventually(equal(NO)); }); }); @@ -166,7 +179,7 @@ describe(@"a lock screen manager", ^{ }); it(@"should not be able to be dismissed", ^{ - expect(testManager.lockScreenDismissableEnabled).toEventually(equal(NO)); + expect(testManager.isLockScreenDismissable).toEventually(equal(NO)); }); }); @@ -182,10 +195,16 @@ describe(@"a lock screen manager", ^{ }); describe(@"then the status becomes OFF", ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __block SDLOnLockScreenStatus *testOffStatus = nil; +#pragma clang diagnostic pop beforeEach(^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" testOffStatus = [[SDLOnLockScreenStatus alloc] init]; +#pragma clang diagnostic pop testOffStatus.lockScreenStatus = SDLLockScreenStatusOff; SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOffStatus]; @@ -266,8 +285,10 @@ describe(@"a lock screen manager", ^{ beforeEach(^{ mockViewControllerPresenter = OCMClassMock([SDLFakeViewControllerPresenter class]); - +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLOnLockScreenStatus *testOptionalStatus = [[SDLOnLockScreenStatus alloc] init]; +#pragma clang diagnostic pop testOptionalStatus.lockScreenStatus = SDLLockScreenStatusOptional; testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOptionalStatus]; diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m index 98a574f95..acf64f0b8 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m @@ -227,7 +227,11 @@ describe(@"the lockscreen status manager", ^{ }); describe(@"when getting lock screen status notification", ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __block SDLOnLockScreenStatus *onLockScreenStatusNotification = nil; +#pragma clang diagnostic pop + beforeEach(^{ lockScreenManager.userSelected = YES; lockScreenManager.driverDistracted = NO; diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m index 669553313..280e596a7 100644 --- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m @@ -48,7 +48,10 @@ describe(@"Getter/Setter Tests", ^ { @{SDLRPCParameterNameState:SDLDriverDistractionStateOff, SDLRPCParameterNameLockScreenDismissalEnabled: @0}, SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}} mutableCopy]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLOnDriverDistraction *testNotificationOff = [[SDLOnDriverDistraction alloc] initWithDictionary:dictOff]; +#pragma clang diagnostic pop expect(testNotificationOff.state).to(equal(SDLDriverDistractionStateOff)); expect(testNotificationOff.lockScreenDismissalEnabled).to(beFalse()); diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m index cd12a3d46..4f4a574ee 100644 --- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m @@ -18,8 +18,11 @@ QuickSpecBegin(SDLOnLockScreenStatusSpec) describe(@"Getter/Setter Tests", ^ { it(@"Should set and get correctly", ^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] init]; - +#pragma clang diagnostic pop + testNotification.driverDistractionStatus = @NO; testNotification.userSelected = @3; testNotification.lockScreenStatus = SDLLockScreenStatusRequired; @@ -51,8 +54,11 @@ describe(@"Getter/Setter Tests", ^ { }); it(@"Should return nil if not set", ^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] init]; - +#pragma clang diagnostic pop + expect(testNotification.driverDistractionStatus).to(beNil()); expect(testNotification.userSelected).to(beNil()); expect(testNotification.lockScreenStatus).to(beNil()); |