diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2020-03-05 10:47:02 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2020-03-05 10:47:02 -0500 |
commit | 4c7900e48a416209b76c60c24ce5c2eadb11d950 (patch) | |
tree | f12825a4513bcd475719bb1b7a623b29094f4af8 | |
parent | 17adb0307279793c38ac10d72f90f5f895dfc9ee (diff) | |
download | sdl_ios-4c7900e48a416209b76c60c24ce5c2eadb11d950.tar.gz |
Update tests with new RPC initializers
4 files changed, 109 insertions, 50 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m index b605c268f..204eb9464 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m @@ -99,6 +99,7 @@ describe(@"choice set manager tests", ^{ disabledWindowCapability = [[SDLWindowCapability alloc] init]; disabledWindowCapability.textFields = @[]; blankWindowCapability = [[SDLWindowCapability alloc] init]; + blankWindowCapability.textFields = @[]; }); it(@"should be in the correct startup state", ^{ @@ -108,7 +109,7 @@ describe(@"choice set manager tests", ^{ expect(testManager.keyboardConfiguration).to(equal(defaultProperties)); }); - fdescribe(@"receiving an HMI status update", ^{ + describe(@"receiving an HMI status update", ^{ __block SDLOnHMIStatus *newStatus = nil; beforeEach(^{ newStatus = [[SDLOnHMIStatus alloc] init]; diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m index 61b1165d3..918a34667 100644 --- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m @@ -19,37 +19,55 @@ QuickSpecBegin(SDLOnHMIStatusSpec) describe(@"Getter/Setter Tests", ^ { + __block SDLHMILevel testLevel = nil; + __block SDLSystemContext testContext = nil; + __block SDLAudioStreamingState testAudioState = nil; + __block SDLVideoStreamingState testVideoState = nil; + __block NSNumber<SDLInt> *testWindowID = nil; + + beforeEach(^{ + testLevel = SDLHMILevelFull; + testContext = SDLSystemContextAlert; + testAudioState = SDLAudioStreamingStateAttenuated; + testVideoState = SDLVideoStreamingStateStreamable; + testWindowID = @0; + }); + it(@"Should set and get correctly", ^ { SDLOnHMIStatus* testNotification = [[SDLOnHMIStatus alloc] init]; - testNotification.hmiLevel = SDLHMILevelLimited; - testNotification.audioStreamingState = SDLAudioStreamingStateAttenuated; - testNotification.systemContext = SDLSystemContextHMIObscured; - testNotification.videoStreamingState = SDLVideoStreamingStateStreamable; + testNotification.hmiLevel = testLevel; + testNotification.audioStreamingState = testAudioState; + testNotification.systemContext = testContext; + testNotification.videoStreamingState = testVideoState; + testNotification.windowID = testWindowID; - expect(testNotification.hmiLevel).to(equal(SDLHMILevelLimited)); - expect(testNotification.audioStreamingState).to(equal(SDLAudioStreamingStateAttenuated)); - expect(testNotification.systemContext).to(equal(SDLSystemContextHMIObscured)); - expect(testNotification.videoStreamingState).to(equal(SDLVideoStreamingStateStreamable)); + expect(testNotification.hmiLevel).to(equal(testLevel)); + expect(testNotification.audioStreamingState).to(equal(testAudioState)); + expect(testNotification.systemContext).to(equal(testContext)); + expect(testNotification.videoStreamingState).to(equal(testVideoState)); + expect(testNotification.windowID).to(equal(testWindowID)); }); it(@"Should get correctly when initialized", ^ { - NSMutableDictionary* dict = [@{SDLRPCParameterNameNotification: - @{SDLRPCParameterNameParameters: - @{SDLRPCParameterNameHMILevel: SDLHMILevelLimited, - SDLRPCParameterNameAudioStreamingState: SDLAudioStreamingStateAttenuated, - SDLRPCParameterNameSystemContext: SDLSystemContextHMIObscured, - SDLRPCParameterNameVideoStreamingState: SDLVideoStreamingStateStreamable}, - SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnHMIStatus}} mutableCopy]; + NSDictionary* dict = @{SDLRPCParameterNameNotification: + @{SDLRPCParameterNameParameters: + @{SDLRPCParameterNameHMILevel: testLevel, + SDLRPCParameterNameAudioStreamingState: testAudioState, + SDLRPCParameterNameSystemContext: testContext, + SDLRPCParameterNameVideoStreamingState: testVideoState, + SDLRPCParameterNameWindowId: testWindowID}, + SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnHMIStatus}}; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLOnHMIStatus* testNotification = [[SDLOnHMIStatus alloc] initWithDictionary:dict]; #pragma clang diagnostic pop - expect(testNotification.hmiLevel).to(equal(SDLHMILevelLimited)); - expect(testNotification.audioStreamingState).to(equal(SDLAudioStreamingStateAttenuated)); - expect(testNotification.systemContext).to(equal(SDLSystemContextHMIObscured)); - expect(testNotification.videoStreamingState).to(equal(SDLVideoStreamingStateStreamable)); + expect(testNotification.hmiLevel).to(equal(testLevel)); + expect(testNotification.audioStreamingState).to(equal(testAudioState)); + expect(testNotification.systemContext).to(equal(testContext)); + expect(testNotification.videoStreamingState).to(equal(testVideoState)); + expect(testNotification.windowID).to(equal(testWindowID)); }); it(@"Should return nil if not set", ^ { @@ -59,6 +77,16 @@ describe(@"Getter/Setter Tests", ^ { expect(testNotification.audioStreamingState).to(beNil()); expect(testNotification.systemContext).to(beNil()); expect(testNotification.videoStreamingState).to(beNil()); + expect(testNotification.windowID).to(beNil()); + }); + + it(@"should initialize properly with initWithHMILevel:systemContext:audioStreamingState:videoStreamingState:windowID:", ^{ + SDLOnHMIStatus *testStatus = [[SDLOnHMIStatus alloc] initWithHMILevel:testLevel systemContext:testContext audioStreamingState:testAudioState videoStreamingState:testVideoState windowID:testWindowID]; + expect(testStatus.hmiLevel).to(equal(testLevel)); + expect(testStatus.systemContext).to(equal(testContext)); + expect(testStatus.audioStreamingState).to(equal(testAudioState)); + expect(testStatus.videoStreamingState).to(equal(testVideoState)); + expect(testStatus.windowID).to(equal(testWindowID)); }); }); diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m index 26317d657..25d17673b 100644 --- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m @@ -17,33 +17,41 @@ QuickSpecBegin(SDLImageFieldSpec) -SDLImageResolution* resolution = [[SDLImageResolution alloc] init]; - describe(@"Getter/Setter Tests", ^ { + __block SDLImageFieldName testName = nil; + __block NSArray<SDLFileType> *testFileTypes = nil; + __block SDLImageResolution *testResolution = nil; + + beforeEach(^{ + testName = SDLImageFieldNameAppIcon; + testFileTypes = @[SDLFileTypePNG, SDLFileTypeJPEG]; + testResolution = [[SDLImageResolution alloc] initWithWidth:800 height:800]; + }); + it(@"Should set and get correctly", ^ { SDLImageField* testStruct = [[SDLImageField alloc] init]; - testStruct.name = SDLImageFieldNameTurnIcon; - testStruct.imageTypeSupported = [@[SDLFileTypePNG, SDLFileTypeJPEG] copy]; - testStruct.imageResolution = resolution; + testStruct.name = testName; + testStruct.imageTypeSupported = testFileTypes; + testStruct.imageResolution = testResolution; - expect(testStruct.name).to(equal(SDLImageFieldNameTurnIcon)); - expect(testStruct.imageTypeSupported).to(equal([@[SDLFileTypePNG, SDLFileTypeJPEG] copy])); - expect(testStruct.imageResolution).to(equal(resolution)); + expect(testStruct.name).to(equal(testName)); + expect(testStruct.imageTypeSupported).to(equal(testFileTypes)); + expect(testStruct.imageResolution).to(equal(testResolution)); }); it(@"Should get correctly when initialized", ^ { - NSMutableDictionary* dict = [@{SDLRPCParameterNameName:SDLImageFieldNameTurnIcon, - SDLRPCParameterNameImageTypeSupported:[@[SDLFileTypePNG, SDLFileTypeJPEG] copy], - SDLRPCParameterNameImageResolution:resolution} mutableCopy]; + NSDictionary *dict = @{SDLRPCParameterNameName: testName, + SDLRPCParameterNameImageTypeSupported: testFileTypes, + SDLRPCParameterNameImageResolution: testResolution}; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLImageField* testStruct = [[SDLImageField alloc] initWithDictionary:dict]; #pragma clang diagnostic pop - expect(testStruct.name).to(equal(SDLImageFieldNameTurnIcon)); - expect(testStruct.imageTypeSupported).to(equal([@[SDLFileTypePNG, SDLFileTypeJPEG] copy])); - expect(testStruct.imageResolution).to(equal(resolution)); + expect(testStruct.name).to(equal(testName)); + expect(testStruct.imageTypeSupported).to(equal(testFileTypes)); + expect(testStruct.imageResolution).to(equal(testResolution)); }); it(@"Should return nil if not set", ^ { @@ -53,6 +61,14 @@ describe(@"Getter/Setter Tests", ^ { expect(testStruct.imageTypeSupported).to(beNil()); expect(testStruct.imageResolution).to(beNil()); }); + + it(@"should initialize correctly with initWithName:imageTypeSupported:imageResolution:", ^{ + SDLImageField *testStruct = [[SDLImageField alloc] initWithName:testName imageTypeSupported:testFileTypes imageResolution:testResolution]; + + expect(testStruct.name).to(equal(testName)); + expect(testStruct.imageTypeSupported).to(equal(testFileTypes)); + expect(testStruct.imageResolution).to(equal(testResolution)); + }); }); QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m index 330d53a3f..fcde49e1e 100644 --- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m @@ -17,34 +17,39 @@ QuickSpecBegin(SDLTextFieldSpec) describe(@"Getter/Setter Tests", ^ { + __block SDLTextFieldName testName = SDLTextFieldNameETA; + __block SDLCharacterSet testCharacterSet = SDLCharacterSetCID1; + __block NSUInteger testWidth = 100; + __block NSUInteger testRows = 4; + it(@"Should set and get correctly", ^ { SDLTextField* testStruct = [[SDLTextField alloc] init]; - testStruct.name = SDLTextFieldNameTertiaryText; - testStruct.characterSet = SDLCharacterSetType5; - testStruct.width = @111; - testStruct.rows = @4; + testStruct.name = testName; + testStruct.characterSet = testCharacterSet; + testStruct.width = @(testWidth); + testStruct.rows = @(testRows); - expect(testStruct.name).to(equal(SDLTextFieldNameTertiaryText)); - expect(testStruct.characterSet).to(equal(SDLCharacterSetType5)); - expect(testStruct.width).to(equal(@111)); - expect(testStruct.rows).to(equal(@4)); + expect(testStruct.name).to(equal(testName)); + expect(testStruct.characterSet).to(equal(testCharacterSet)); + expect(testStruct.width).to(equal(@(testWidth))); + expect(testStruct.rows).to(equal(@(testRows))); }); it(@"Should get correctly when initialized", ^ { - NSMutableDictionary* dict = [@{SDLRPCParameterNameName:SDLTextFieldNameTertiaryText, - SDLRPCParameterNameCharacterSet:SDLCharacterSetType5, - SDLRPCParameterNameWidth:@111, - SDLRPCParameterNameRows:@4} mutableCopy]; + NSDictionary *dict = @{SDLRPCParameterNameName:testName, + SDLRPCParameterNameCharacterSet:testCharacterSet, + SDLRPCParameterNameWidth:@(testWidth), + SDLRPCParameterNameRows:@(testRows)}; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLTextField* testStruct = [[SDLTextField alloc] initWithDictionary:dict]; #pragma clang diagnostic pop - expect(testStruct.name).to(equal(SDLTextFieldNameTertiaryText)); - expect(testStruct.characterSet).to(equal(SDLCharacterSetType5)); - expect(testStruct.width).to(equal(@111)); - expect(testStruct.rows).to(equal(@4)); + expect(testStruct.name).to(equal(testName)); + expect(testStruct.characterSet).to(equal(testCharacterSet)); + expect(testStruct.width).to(equal(@(testWidth))); + expect(testStruct.rows).to(equal(@(testRows))); }); it(@"Should return nil if not set", ^ { @@ -55,6 +60,15 @@ describe(@"Getter/Setter Tests", ^ { expect(testStruct.width).to(beNil()); expect(testStruct.rows).to(beNil()); }); + + it(@"should initialize correctly with initWithName:characterSet:width:rows:", ^{ + SDLTextField *testStruct = [[SDLTextField alloc] initWithName:testName characterSet:testCharacterSet width:testWidth rows:testRows]; + + expect(testStruct.name).to(equal(testName)); + expect(testStruct.characterSet).to(equal(testCharacterSet)); + expect(testStruct.width).to(equal(@(testWidth))); + expect(testStruct.rows).to(equal(@(testRows))); + }); }); QuickSpecEnd |