summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatbir Tanda <satbirtanda@gmail.com>2019-07-29 05:14:53 -0700
committerSatbir Tanda <satbirtanda@gmail.com>2019-07-29 05:14:53 -0700
commit09f9ffba3a603102981df685e5ed4bf76a39e531 (patch)
tree07885eae012d4f7680a674ffec36b7cfda24d91c
parentb952df76d93230b52803c0631e4e31b20c9870cd (diff)
downloadsdl_ios-09f9ffba3a603102981df685e5ed4bf76a39e531.tar.gz
Revert "Remove SDLOnLockScreenStatus tests"
This reverts commit d7160549c5bf22050dc16f2abf46e6a463dc02ce.
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj4
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m146
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m63
3 files changed, 213 insertions, 0 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index b4fa15d2b..3ca417ae0 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -85,6 +85,7 @@
162E83171A9BDE8B00906325 /* SDLOnHMIStatusSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82311A9BDE8A00906325 /* SDLOnHMIStatusSpec.m */; };
162E83181A9BDE8B00906325 /* SDLOnKeyboardInputSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82321A9BDE8A00906325 /* SDLOnKeyboardInputSpec.m */; };
162E83191A9BDE8B00906325 /* SDLOnLanguageChangeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82331A9BDE8A00906325 /* SDLOnLanguageChangeSpec.m */; };
+ 162E831A1A9BDE8B00906325 /* SDLOnLockScreenStatusSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82341A9BDE8A00906325 /* SDLOnLockScreenStatusSpec.m */; };
162E831B1A9BDE8B00906325 /* SDLOnPermissionsChangeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82351A9BDE8A00906325 /* SDLOnPermissionsChangeSpec.m */; };
162E831C1A9BDE8B00906325 /* SDLOnSyncPDataSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82361A9BDE8A00906325 /* SDLOnSyncPDataSpec.m */; };
162E831D1A9BDE8B00906325 /* SDLOnSystemRequestSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 162E82371A9BDE8A00906325 /* SDLOnSystemRequestSpec.m */; };
@@ -1700,6 +1701,7 @@
162E82311A9BDE8A00906325 /* SDLOnHMIStatusSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnHMIStatusSpec.m; sourceTree = "<group>"; };
162E82321A9BDE8A00906325 /* SDLOnKeyboardInputSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnKeyboardInputSpec.m; sourceTree = "<group>"; };
162E82331A9BDE8A00906325 /* SDLOnLanguageChangeSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnLanguageChangeSpec.m; sourceTree = "<group>"; };
+ 162E82341A9BDE8A00906325 /* SDLOnLockScreenStatusSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnLockScreenStatusSpec.m; sourceTree = "<group>"; };
162E82351A9BDE8A00906325 /* SDLOnPermissionsChangeSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnPermissionsChangeSpec.m; sourceTree = "<group>"; };
162E82361A9BDE8A00906325 /* SDLOnSyncPDataSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnSyncPDataSpec.m; sourceTree = "<group>"; };
162E82371A9BDE8A00906325 /* SDLOnSystemRequestSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnSystemRequestSpec.m; sourceTree = "<group>"; };
@@ -3377,6 +3379,7 @@
1EE8C4531F38762E00FDC2CF /* SDLOnInteriorVehicleDataSpec.m */,
162E82321A9BDE8A00906325 /* SDLOnKeyboardInputSpec.m */,
162E82331A9BDE8A00906325 /* SDLOnLanguageChangeSpec.m */,
+ 162E82341A9BDE8A00906325 /* SDLOnLockScreenStatusSpec.m */,
162E82351A9BDE8A00906325 /* SDLOnPermissionsChangeSpec.m */,
1EAA470D2032BF1D000FE74B /* SDLOnRCStatusSpec.m */,
162E82361A9BDE8A00906325 /* SDLOnSyncPDataSpec.m */,
@@ -7735,6 +7738,7 @@
1E89B0DE2031636000A47992 /* SDLSeatControlDataSpec.m in Sources */,
88A4A0FA22242AB400C6F01D /* SDLNavigationServiceDataSpec.m in Sources */,
8831FA3D220207DA00B8FFB7 /* SDLServiceUpdateReasonSpec.m in Sources */,
+ 162E831A1A9BDE8B00906325 /* SDLOnLockScreenStatusSpec.m in Sources */,
162E83431A9BDE8B00906325 /* SDLSyncPDataSpec.m in Sources */,
167ED9461A9BCE5D00797BE5 /* SwiftSpec.swift in Sources */,
162E838B1A9BDE8B00906325 /* SDLSoftButtonCapabilitiesSpec.m in Sources */,
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
index e501ccc1d..a2e6eaaa7 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
@@ -9,6 +9,7 @@
#import "SDLLockScreenViewController.h"
#import "SDLNotificationConstants.h"
#import "SDLNotificationDispatcher.h"
+#import "SDLOnLockScreenStatus.h"
#import "SDLOnDriverDistraction.h"
#import "SDLRPCNotificationNotification.h"
@@ -18,6 +19,7 @@ QuickSpecBegin(SDLLockScreenManagerSpec)
describe(@"a lock screen manager", ^{
__block SDLLockScreenManager *testManager = nil;
__block SDLFakeViewControllerPresenter *fakePresenter = nil;
+ __block SDLNotificationDispatcher *testNotificationDispatcher = nil;
beforeEach(^{
fakePresenter = [[SDLFakeViewControllerPresenter alloc] init];
@@ -43,6 +45,21 @@ describe(@"a lock screen manager", ^{
expect(@(fakePresenter.presented)).to(beFalsy());
expect(testManager.lockScreenViewController).to(beNil());
});
+
+ describe(@"when the lock screen status becomes REQUIRED", ^{
+ __block SDLOnLockScreenStatus *testRequiredStatus = nil;
+
+ beforeEach(^{
+ testRequiredStatus = [[SDLOnLockScreenStatus alloc] init];
+ testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired;
+
+ [testNotificationDispatcher postNotificationName:SDLDidChangeLockScreenStatusNotification infoObject:testRequiredStatus];
+ });
+
+ it(@"should not have presented the lock screen", ^{
+ expect(@(fakePresenter.presented)).to(beFalsy());
+ });
+ });
});
});
@@ -66,6 +83,120 @@ describe(@"a lock screen manager", ^{
expect(testManager.lockScreenViewController).toNot(beNil());
expect(testManager.lockScreenViewController).to(beAnInstanceOf([SDLLockScreenViewController class]));
});
+
+ describe(@"when the lock screen status becomes REQUIRED", ^{
+ __block SDLOnLockScreenStatus *testRequiredStatus = nil;
+ __block SDLOnDriverDistraction *testDriverDistraction = nil;
+
+ beforeEach(^{
+ testRequiredStatus = [[SDLOnLockScreenStatus alloc] init];
+ testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired;
+
+ SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testRequiredStatus];
+ [[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
+ });
+
+ it(@"should have presented the lock screen", ^{
+ expect(@(fakePresenter.presented)).to(beTruthy());
+ });
+
+ it(@"should not have a vehicle icon", ^{
+ expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).to(beNil());
+ });
+
+ 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", ^{
+ expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).toNot(beNil());
+ expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).to(equal(testIcon));
+ });
+ });
+
+ describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled 1 bit", ^{
+ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil;
+
+ beforeEach(^{
+ testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
+ testDriverDistraction.lockScreenDismissalEnabled = @1;
+
+ testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction];
+
+ [[NSNotificationCenter defaultCenter] postNotification:testDriverDistractionNotification];
+ });
+
+ it(@"should be able to be dismissed", ^{
+ expect(testManager.lockScreenDismissableEnabled).toEventually(equal(YES));
+ });
+
+ });
+
+ describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled 0 bit", ^{
+ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil;
+
+ beforeEach(^{
+ testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
+ testDriverDistraction.lockScreenDismissalEnabled = @0;
+
+ testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction];
+
+ [[NSNotificationCenter defaultCenter] postNotification:testDriverDistractionNotification];
+ });
+
+ it(@"should not be able to be dismissed", ^{
+ expect(testManager.lockScreenDismissableEnabled).toEventually(equal(NO));
+ });
+
+ });
+
+ describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled nil bit", ^{
+ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil;
+
+ beforeEach(^{
+ testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
+
+ testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction];
+
+ [[NSNotificationCenter defaultCenter] postNotification:testDriverDistractionNotification];
+ });
+
+ it(@"should not be able to be dismissed", ^{
+ expect(testManager.lockScreenDismissableEnabled).toEventually(equal(NO));
+ });
+
+ });
+
+ describe(@"then the manager is stopped", ^{
+ beforeEach(^{
+ [testManager stop];
+ });
+
+ it(@"should have dismissed the lock screen", ^{
+ expect(@(fakePresenter.presented)).to(beFalsy());
+ });
+ });
+
+ describe(@"then the status becomes OFF", ^{
+ __block SDLOnLockScreenStatus *testOffStatus = nil;
+
+ beforeEach(^{
+ testOffStatus = [[SDLOnLockScreenStatus alloc] init];
+ testOffStatus.lockScreenStatus = SDLLockScreenStatusOff;
+
+ SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOffStatus];
+ [[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
+ });
+
+ it(@"should have dismissed the lock screen", ^{
+ expect(@(fakePresenter.presented)).to(beFalsy());
+ });
+ });
+ });
});
});
@@ -131,9 +262,16 @@ describe(@"a lock screen manager", ^{
__block SDLLockScreenManager *testLockScreenManager = nil;
__block SDLLockScreenConfiguration *testLockScreenConfig = nil;
__block id mockViewControllerPresenter = nil;
+ __block SDLRPCNotificationNotification *testLockStatusNotification = nil;
beforeEach(^{
mockViewControllerPresenter = OCMClassMock([SDLFakeViewControllerPresenter class]);
+
+ SDLOnLockScreenStatus *testOptionalStatus = [[SDLOnLockScreenStatus alloc] init];
+ testOptionalStatus.lockScreenStatus = SDLLockScreenStatusOptional;
+ testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOptionalStatus];
+
+ testLockScreenConfig = [SDLLockScreenConfiguration enabledConfiguration];
});
context(@"showInOptionalState is true", ^{
@@ -148,6 +286,10 @@ describe(@"a lock screen manager", ^{
it(@"should present the lock screen if not already presented", ^{
OCMStub([mockViewControllerPresenter lockViewController]).andReturn([OCMArg any]);
OCMStub([mockViewControllerPresenter presented]).andReturn(false);
+
+ [[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
+
+ OCMVerify([mockViewControllerPresenter present]);
});
});
@@ -163,6 +305,10 @@ describe(@"a lock screen manager", ^{
it(@"should dismiss the lock screen if already presented", ^{
OCMStub([mockViewControllerPresenter lockViewController]).andReturn([OCMArg any]);
OCMStub([mockViewControllerPresenter presented]).andReturn(true);
+
+ [[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
+
+ OCMVerify([mockViewControllerPresenter dismiss]);
});
});
});
diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m
new file mode 100644
index 000000000..cd12a3d46
--- /dev/null
+++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m
@@ -0,0 +1,63 @@
+//
+// SDLOnLockScreenStatusSpec.m
+// SmartDeviceLink
+
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+
+#import "SDLOnLockScreenStatus.h"
+#import "SDLHMILevel.h"
+#import "SDLLockScreenStatus.h"
+#import "SDLRPCParameterNames.h"
+#import "SDLRPCFunctionNames.h"
+
+QuickSpecBegin(SDLOnLockScreenStatusSpec)
+
+describe(@"Getter/Setter Tests", ^ {
+ it(@"Should set and get correctly", ^ {
+ SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] init];
+
+ testNotification.driverDistractionStatus = @NO;
+ testNotification.userSelected = @3;
+ testNotification.lockScreenStatus = SDLLockScreenStatusRequired;
+ testNotification.hmiLevel = SDLHMILevelNone;
+
+ expect(testNotification.driverDistractionStatus).to(equal(@NO));
+ expect(testNotification.userSelected).to(equal(@3));
+ expect(testNotification.lockScreenStatus).to(equal(SDLLockScreenStatusRequired));
+ expect(testNotification.hmiLevel).to(equal(SDLHMILevelNone));
+ });
+
+ it(@"Should get correctly when initialized", ^ {
+ NSMutableDictionary* dict = [@{SDLRPCParameterNameNotification:
+ @{SDLRPCParameterNameParameters:
+ @{@"driverDistractionStatus":@NO,
+ @"userSelected":@3,
+ @"OnLockScreenStatus":SDLLockScreenStatusRequired,
+ @"hmiLevel":SDLHMILevelNone},
+ SDLRPCParameterNameOperationName:@"OnLockScreenStatus"}} mutableCopy];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] initWithDictionary:dict];
+#pragma clang diagnostic pop
+
+ expect(testNotification.driverDistractionStatus).to(equal(@NO));
+ expect(testNotification.userSelected).to(equal(@3));
+ expect(testNotification.lockScreenStatus).to(equal(SDLLockScreenStatusRequired));
+ expect(testNotification.hmiLevel).to(equal(SDLHMILevelNone));
+ });
+
+ it(@"Should return nil if not set", ^ {
+ SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] init];
+
+ expect(testNotification.driverDistractionStatus).to(beNil());
+ expect(testNotification.userSelected).to(beNil());
+ expect(testNotification.lockScreenStatus).to(beNil());
+ expect(testNotification.hmiLevel).to(beNil());
+ });
+});
+
+QuickSpecEnd