diff options
author | Justin Gluck <justin.gluck@livio.io> | 2019-08-08 15:03:26 -0400 |
---|---|---|
committer | Justin Gluck <justin.gluck@livio.io> | 2019-08-08 15:03:26 -0400 |
commit | d16cd3cccd87980a7d7b37cdbc13d91649913948 (patch) | |
tree | d37afba5c70c6832c6408435665da9d9b4dc83df | |
parent | 2d67f022a56153dea8033a9d8b8b83d66a3f48fd (diff) | |
download | sdl_ios-d16cd3cccd87980a7d7b37cdbc13d91649913948.tar.gz |
adding unit tests and updating config
4 files changed, 42 insertions, 8 deletions
diff --git a/SmartDeviceLink/SDLLockScreenConfiguration.h b/SmartDeviceLink/SDLLockScreenConfiguration.h index 854196520..91e4bfabf 100644 --- a/SmartDeviceLink/SDLLockScreenConfiguration.h +++ b/SmartDeviceLink/SDLLockScreenConfiguration.h @@ -30,6 +30,12 @@ NS_ASSUME_NONNULL_BEGIN @property (assign, nonatomic) BOOL enableDismissGesture; /** +* If YES, then the lockscreen will show the vehicle logo. If NO, then the lockscreen will not show the vehicle logo. + Defaults to YES. +*/ +@property (assign, nonatomic) BOOL showDeviceLogo; + +/** * If YES, the lock screen should be managed by SDL and automatically engage when necessary. If NO, then the lock screen will never be engaged. Defaults to YES. */ @property (assign, nonatomic, readonly) BOOL enableAutomaticLockScreen; diff --git a/SmartDeviceLink/SDLLockScreenConfiguration.m b/SmartDeviceLink/SDLLockScreenConfiguration.m index 985657243..f2cf71f9f 100644 --- a/SmartDeviceLink/SDLLockScreenConfiguration.m +++ b/SmartDeviceLink/SDLLockScreenConfiguration.m @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Lifecycle -- (instancetype)initWithAutoLockScreen:(BOOL)enableAutomatic enableInOptional:(BOOL)enableOptional enableDismissGesture:(BOOL)enableDismissGesture backgroundColor:(UIColor *)backgroundColor appIcon:(nullable UIImage *)appIcon viewController:(nullable UIViewController *)customViewController { +- (instancetype)initWithAutoLockScreen:(BOOL)enableAutomatic enableInOptional:(BOOL)enableOptional enableDismissGesture:(BOOL)enableDismissGesture showDeviceLogo:(BOOL)showDeviceLogo backgroundColor:(UIColor *)backgroundColor appIcon:(nullable UIImage *)appIcon viewController:(nullable UIViewController *)customViewController { self = [super init]; if (!self) { return nil; @@ -32,17 +32,17 @@ NS_ASSUME_NONNULL_BEGIN _backgroundColor = backgroundColor; _appIcon = appIcon; _customViewController = customViewController; - _showDeviceLogo = true; + _showDeviceLogo = showDeviceLogo; return self; } + (instancetype)disabledConfiguration { - return [[self alloc] initWithAutoLockScreen:NO enableInOptional:NO enableDismissGesture:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil]; + return [[self alloc] initWithAutoLockScreen:NO enableInOptional:NO enableDismissGesture:NO showDeviceLogo:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil]; } + (instancetype)enabledConfiguration { - return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil]; + return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES showDeviceLogo:YES backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil]; } + (instancetype)enabledConfigurationWithAppIcon:(UIImage *)lockScreenAppIcon backgroundColor:(nullable UIColor *)lockScreenBackgroundColor { @@ -50,11 +50,11 @@ NS_ASSUME_NONNULL_BEGIN lockScreenBackgroundColor = [self.class sdl_defaultBackgroundColor]; } - return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES backgroundColor:lockScreenBackgroundColor appIcon:lockScreenAppIcon viewController:nil]; + return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES showDeviceLogo:YES backgroundColor:lockScreenBackgroundColor appIcon:lockScreenAppIcon viewController:nil]; } + (instancetype)enabledConfigurationWithViewController:(UIViewController *)viewController { - return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES backgroundColor:[self.class sdl_defaultBackgroundColor] appIcon:nil viewController:viewController]; + return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES showDeviceLogo:YES backgroundColor:[self.class sdl_defaultBackgroundColor] appIcon:nil viewController:viewController]; } @@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - NSCopying - (id)copyWithZone:(nullable NSZone *)zone { - SDLLockScreenConfiguration *new = [[SDLLockScreenConfiguration allocWithZone:zone] initWithAutoLockScreen:_enableAutomaticLockScreen enableInOptional:_showInOptionalState enableDismissGesture:_enableDismissGesture backgroundColor:_backgroundColor appIcon:_appIcon viewController:_customViewController]; + SDLLockScreenConfiguration *new = [[SDLLockScreenConfiguration allocWithZone:zone] initWithAutoLockScreen:_enableAutomaticLockScreen enableInOptional:_showInOptionalState enableDismissGesture:_enableDismissGesture showDeviceLogo:_showDeviceLogo backgroundColor:_backgroundColor appIcon:_appIcon viewController:_customViewController]; return new; } diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenConfigurationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenConfigurationSpec.m index f0a9bff24..d35717658 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenConfigurationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenConfigurationSpec.m @@ -17,6 +17,7 @@ describe(@"a lock screen configuration", ^{ expect(testConfig.enableAutomaticLockScreen).to(beFalse()); expect(testConfig.showInOptionalState).to(beFalse()); expect(testConfig.enableDismissGesture).to(beFalse()); + expect(testConfig.showDeviceLogo).to(beFalse()); expect(testConfig.backgroundColor).to(equal([UIColor colorWithRed:(57.0/255.0) green:(78.0/255.0) blue:(96.0/255.0) alpha:1.0])); expect(testConfig.appIcon).to(beNil()); expect(testConfig.customViewController).to(beNil()); @@ -32,6 +33,7 @@ describe(@"a lock screen configuration", ^{ expect(testConfig.enableAutomaticLockScreen).to(beTrue()); expect(testConfig.showInOptionalState).to(beFalse()); expect(testConfig.enableDismissGesture).to(beTrue()); + expect(testConfig.showDeviceLogo).to(beTrue()); expect(testConfig.backgroundColor).to(equal([UIColor colorWithRed:(57.0/255.0) green:(78.0/255.0) blue:(96.0/255.0) alpha:1.0])); expect(testConfig.appIcon).to(beNil()); expect(testConfig.customViewController).to(beNil()); @@ -53,6 +55,7 @@ describe(@"a lock screen configuration", ^{ expect(testConfig.enableAutomaticLockScreen).to(beTrue()); expect(testConfig.showInOptionalState).to(beFalse()); expect(testConfig.enableDismissGesture).to(beTrue()); + expect(testConfig.showDeviceLogo).to(beTrue()); expect(testConfig.backgroundColor).to(equal([UIColor blueColor])); expect(testConfig.appIcon).to(equal(testImage)); expect(testConfig.customViewController).to(beNil()); @@ -72,6 +75,7 @@ describe(@"a lock screen configuration", ^{ expect(testConfig.enableAutomaticLockScreen).to(beTrue()); expect(testConfig.showInOptionalState).to(beFalse()); expect(testConfig.enableDismissGesture).to(beTrue()); + expect(testConfig.showDeviceLogo).to(beTrue()); expect(testConfig.backgroundColor).to(equal([UIColor colorWithRed:(57.0/255.0) green:(78.0/255.0) blue:(96.0/255.0) alpha:1.0])); expect(testConfig.appIcon).to(beNil()); expect(testConfig.customViewController).to(equal(testVC)); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m index 596c863b1..912fe9161 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m @@ -233,7 +233,31 @@ describe(@"a lock screen manager", ^{ }); }); }); - + + context(@"with showDeiveLogo as false", ^{ + beforeEach(^{ + SDLLockScreenConfiguration *config = [SDLLockScreenConfiguration enabledConfiguration]; + config.showDeviceLogo = NO; + + testManager = [[SDLLockScreenManager alloc] initWithConfiguration:config notificationDispatcher:nil presenter:fakePresenter]; + [testManager start]; + }); + + describe(@"when a vehicle icon is received", ^{ + __block UIImage *testIcon = nil; + + beforeEach(^{ + testIcon = [UIImage imageNamed:@"testImagePNG" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidReceiveLockScreenIcon object:nil userInfo:@{ SDLNotificationUserInfoObject: testIcon }]; + }); + + it(@"should have a vehicle icon if showDeviceLogo is set to true", ^{ + expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).to(beNil()); + }); + }); + + }); + context(@"with a custom color configuration", ^{ __block UIColor *testColor = nil; __block UIImage *testImage = nil; |