diff options
Diffstat (limited to 'SmartDeviceLinkTests')
256 files changed, 18453 insertions, 0 deletions
diff --git a/SmartDeviceLinkTests/Assets/testFileJSON.json b/SmartDeviceLinkTests/Assets/testFileJSON.json new file mode 100644 index 000000000..3d3340762 --- /dev/null +++ b/SmartDeviceLinkTests/Assets/testFileJSON.json @@ -0,0 +1,4 @@ +{ + "test": "hello", + "test2": 2 +}
\ No newline at end of file diff --git a/SmartDeviceLinkTests/Assets/testImageBMP.bmp b/SmartDeviceLinkTests/Assets/testImageBMP.bmp Binary files differnew file mode 100644 index 000000000..d05b724d0 --- /dev/null +++ b/SmartDeviceLinkTests/Assets/testImageBMP.bmp diff --git a/SmartDeviceLinkTests/Assets/testImageJPEG.jpeg b/SmartDeviceLinkTests/Assets/testImageJPEG.jpeg Binary files differnew file mode 100644 index 000000000..8a9702ede --- /dev/null +++ b/SmartDeviceLinkTests/Assets/testImageJPEG.jpeg diff --git a/SmartDeviceLinkTests/Assets/testImageJPG.jpg b/SmartDeviceLinkTests/Assets/testImageJPG.jpg Binary files differnew file mode 100644 index 000000000..8a9702ede --- /dev/null +++ b/SmartDeviceLinkTests/Assets/testImageJPG.jpg diff --git a/SmartDeviceLinkTests/Assets/testImagePNG.png b/SmartDeviceLinkTests/Assets/testImagePNG.png Binary files differnew file mode 100644 index 000000000..017399a8e --- /dev/null +++ b/SmartDeviceLinkTests/Assets/testImagePNG.png diff --git a/SmartDeviceLinkTests/Assets/testImageTIFF.tiff b/SmartDeviceLinkTests/Assets/testImageTIFF.tiff Binary files differnew file mode 100644 index 000000000..af249fdc2 --- /dev/null +++ b/SmartDeviceLinkTests/Assets/testImageTIFF.tiff diff --git a/SmartDeviceLinkTests/DevAPISpecs/NSMapTable+SubscriptingSpec.m b/SmartDeviceLinkTests/DevAPISpecs/NSMapTable+SubscriptingSpec.m new file mode 100644 index 000000000..b88a2345d --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/NSMapTable+SubscriptingSpec.m @@ -0,0 +1,32 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "NSMapTable+Subscripting.h" + +QuickSpecBegin(NSMapTable_SubscriptingSpec) + +describe(@"A map table with the subscripting category imported", ^{ + __block NSMapTable *testMapTable = nil; + + beforeEach(^{ + testMapTable = [NSMapTable strongToStrongObjectsMapTable]; + }); + + describe(@"adding an object", ^{ + __block NSString *testKey = nil; + __block NSString *testObject = nil; + + beforeEach(^{ + testKey = @"Key"; + testObject = @"Object"; + + testMapTable[testKey] = testObject; + }); + + it(@"should properly add the key and object", ^{ + expect(testMapTable[testKey]).to(equal(testObject)); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLArtworkSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLArtworkSpec.m new file mode 100644 index 000000000..9c0dc8c1a --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLArtworkSpec.m @@ -0,0 +1,93 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLArtwork.h" +#import "SDLFileType.h" + +QuickSpecBegin(SDLArtworkSpec) + +describe(@"SDLArtwork", ^{ + __block SDLArtwork *testArtwork = nil; + + describe(@"when created", ^{ + context(@"As a PNG", ^{ + __block NSString *testArtworkName = nil; + __block UIImage *testImage = nil; + __block SDLArtworkImageFormat testFormat = NSNotFound; + + beforeEach(^{ + testImage = [UIImage imageNamed:@"testImagePNG" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil]; + testArtworkName = @"Test Artwork"; + testFormat = SDLArtworkImageFormatPNG; + + testArtwork = [[SDLArtwork alloc] initWithImage:testImage name:testArtworkName persistent:NO asImageFormat:testFormat]; + }); + + it(@"should correctly store image data", ^{ + expect(testArtwork.data).to(equal(UIImagePNGRepresentation(testImage))); + }); + + it(@"should correctly store name", ^{ + expect(testArtwork.name).to(equal(testArtworkName)); + }); + + it(@"should correctly store format", ^{ + expect(testArtwork.fileType).to(equal([SDLFileType GRAPHIC_PNG])); + }); + + it(@"should correctly store persistence", ^{ + expect(@(testArtwork.persistent)).to(equal(@NO)); + }); + }); + + context(@"As a JPG", ^{ + __block NSString *testArtworkName = nil; + __block UIImage *testImage = nil; + __block SDLArtworkImageFormat testFormat = NSNotFound; + + beforeEach(^{ + testImage = [UIImage imageNamed:@"testImagePNG" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil]; + testArtworkName = @"Test Artwork"; + testFormat = SDLArtworkImageFormatJPG; + + testArtwork = [[SDLArtwork alloc] initWithImage:testImage name:testArtworkName persistent:NO asImageFormat:testFormat]; + }); + + it(@"should correctly store image data", ^{ + expect(testArtwork.data).to(equal(UIImageJPEGRepresentation(testImage, 0.85))); + }); + + it(@"should correctly store name", ^{ + expect(testArtwork.name).to(equal(testArtworkName)); + }); + + it(@"should correctly store format", ^{ + expect(testArtwork.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + }); + + it(@"should correctly store persistence", ^{ + expect(@(testArtwork.persistent)).to(equal(@NO)); + }); + }); + + describe(@"to be persistent", ^{ + __block NSString *testArtworkName = nil; + __block UIImage *testImage = nil; + __block SDLArtworkImageFormat testFormat = NSNotFound; + + beforeEach(^{ + testImage = [UIImage imageNamed:@"testImagePNG" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil]; + testArtworkName = @"Test Artwork"; + testFormat = SDLArtworkImageFormatPNG; + + testArtwork = [[SDLArtwork alloc] initWithImage:testImage name:testArtworkName persistent:YES asImageFormat:testFormat]; + }); + + it(@"is persistent", ^{ + expect(@(testArtwork.persistent)).to(equal(@YES)); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteFileOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteFileOperationSpec.m new file mode 100644 index 000000000..a86796abe --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteFileOperationSpec.m @@ -0,0 +1,100 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteFile.h" +#import "SDLDeleteFileOperation.h" +#import "SDLDeleteFileResponse.h" +#import "SDLError.h" +#import "TestConnectionManager.h" + +QuickSpecBegin(SDLDeleteFileOperationSpec) + +describe(@"Delete File Operation", ^{ + __block TestConnectionManager *testConnectionManager = nil; + __block SDLDeleteFileOperation *testOperation = nil; + + __block NSString *deleteFileName = nil; + __block BOOL successResult = NO; + __block NSUInteger bytesAvailableResult = NO; + __block NSError *errorResult = nil; + + beforeEach(^{ + deleteFileName = @"Some File"; + testConnectionManager = [[TestConnectionManager alloc] init]; + + testOperation = [[SDLDeleteFileOperation alloc] initWithFileName:deleteFileName connectionManager:testConnectionManager completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + successResult = success; + bytesAvailableResult = bytesAvailable; + errorResult = error; + }]; + }); + + it(@"should have a priority of 'very high'", ^{ + expect(@(testOperation.queuePriority)).to(equal(@(NSOperationQueuePriorityVeryHigh))); + }); + + describe(@"running the operation", ^{ + beforeEach(^{ + [testOperation start]; + }); + + it(@"should send a list files request", ^{ + expect(testConnectionManager.receivedRequests.lastObject).to(beAnInstanceOf([SDLDeleteFile class])); + }); + + context(@"when a good response comes back", ^{ + __block SDLDeleteFileResponse *goodResponse = nil; + __block NSNumber *responseSpaceAvailable = nil; + + beforeEach(^{ + responseSpaceAvailable = @(11212512); + + goodResponse = [[SDLDeleteFileResponse alloc] init]; + goodResponse.success = @YES; + goodResponse.spaceAvailable = responseSpaceAvailable; + + [testConnectionManager respondToLastRequestWithResponse:goodResponse]; + }); + + it(@"should have called the completion handler with proper data", ^{ + expect(@(successResult)).to(equal(@YES)); + expect(@(bytesAvailableResult)).to(equal(responseSpaceAvailable)); + expect(errorResult).to(beNil()); + }); + + it(@"should be set to finished", ^{ + expect(@(testOperation.finished)).to(equal(@YES)); + expect(@(testOperation.executing)).to(equal(@NO)); + }); + }); + + context(@"when a bad response comes back", ^{ + __block SDLDeleteFileResponse *badResponse = nil; + __block NSNumber *responseSpaceAvailable = nil; + + __block NSString *responseErrorDescription = nil; + __block NSString *responseErrorReason = nil; + + beforeEach(^{ + responseSpaceAvailable = @(0); + + responseErrorDescription = @"some description"; + responseErrorReason = @"some reason"; + + badResponse = [[SDLDeleteFileResponse alloc] init]; + badResponse.success = @NO; + badResponse.spaceAvailable = responseSpaceAvailable; + + [testConnectionManager respondToLastRequestWithResponse:badResponse error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]]; + }); + + it(@"should have called completion handler with error", ^{ + expect(errorResult.localizedDescription).to(match(responseErrorDescription)); + expect(errorResult.localizedFailureReason).to(match(responseErrorReason)); + expect(@(successResult)).to(equal(@NO)); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m new file mode 100644 index 000000000..338e69aef --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m @@ -0,0 +1,528 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteFileResponse.h" +#import "SDLError.h" +#import "SDLFile.h" +#import "SDLFileManager.h" +#import "SDLFileType.h" +#import "SDLListFiles.h" +#import "SDLListFilesOperation.h" +#import "SDLListFilesResponse.h" +#import "SDLNotificationConstants.h" +#import "SDLPutFile.h" +#import "SDLPutFileResponse.h" +#import "SDLRPCResponse.h" +#import "TestConnectionManager.h" + + +QuickSpecBegin(SDLFileManagerSpec) + +describe(@"SDLFileManager", ^{ + __block TestConnectionManager *testConnectionManager = nil; + __block SDLFileManager *testFileManager = nil; + + beforeEach(^{ + testConnectionManager = [[TestConnectionManager alloc] init]; + testFileManager = [[SDLFileManager alloc] initWithConnectionManager:testConnectionManager]; + testFileManager.suspended = YES; + }); + + describe(@"before starting", ^{ + it(@"should be in the shutdown state", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateShutdown)); + }); + + it(@"bytesAvailable should be 0", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(@0)); + }); + + it(@"remoteFileNames should be empty", ^{ + expect(testFileManager.remoteFileNames).to(beEmpty()); + }); + + it(@"allowOverwrite should be NO by default", ^{ + expect(@(testFileManager.allowOverwrite)).to(equal(@NO)); + }); + + it(@"should have no pending operations", ^{ + expect(testFileManager.pendingTransactions).to(beEmpty()); + }); + }); + + describe(@"after receiving a start message", ^{ + __block BOOL startupSuccess = NO; + __block NSError *startupError = nil; + + beforeEach(^{ + [testFileManager startManagerWithCompletionHandler:^(BOOL success, NSError * _Nullable error) { + startupSuccess = success; + startupError = error; + }]; + + testFileManager.suspended = NO; + }); + + it(@"should have queued a ListFiles request", ^{ + expect(testFileManager.pendingTransactions).to(haveCount(@1)); + expect(testFileManager.pendingTransactions.firstObject).to(beAnInstanceOf([SDLListFilesOperation class])); + }); + + it(@"should be in the fetching initial list state", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateFetchingInitialList)); + }); + + describe(@"after receiving a ListFiles response", ^{ + __block SDLListFilesResponse *testListFilesResponse = nil; + __block NSSet<NSString *> *testInitialFileNames = nil; + __block NSNumber *testInitialSpaceAvailable = nil; + + beforeEach(^{ + testInitialFileNames = [NSSet setWithArray:@[@"testFile1", @"testFile2", @"testFile3"]]; + testInitialSpaceAvailable = @0; + + testListFilesResponse = [[SDLListFilesResponse alloc] init]; + testListFilesResponse.spaceAvailable = testInitialSpaceAvailable; + testListFilesResponse.filenames = [NSMutableArray arrayWithArray:[testInitialFileNames allObjects]]; + + [testConnectionManager respondToLastRequestWithResponse:testListFilesResponse]; + }); + + it(@"should be in the ready state", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + + it(@"should properly set the remote file names", ^{ + expect(testFileManager.remoteFileNames).to(equal(testInitialFileNames)); + }); + + it(@"should properly set the space available", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(testInitialSpaceAvailable)); + }); + + describe(@"deleting a file", ^{ + __block BOOL completionSuccess = NO; + __block NSUInteger completionBytesAvailable = 0; + __block NSError *completionError = nil; + + context(@"when the file is unknown", ^{ + beforeEach(^{ + NSString *someUnknownFileName = @"Some Unknown File Name"; + [testFileManager deleteRemoteFileWithName:someUnknownFileName completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + completionSuccess = success; + completionBytesAvailable = bytesAvailable; + completionError = error; + }]; + }); + + it(@"should return NO for success", ^{ + expect(@(completionSuccess)).to(equal(@NO)); + }); + + it(@"should return 0 for bytesAvailable", ^{ + expect(@(completionBytesAvailable)).to(equal(@0)); + }); + + it(@"should return the correct error", ^{ + expect(completionError).to(equal([NSError sdl_fileManager_noKnownFileError])); + }); + + it(@"should still contain all files", ^{ + expect(testFileManager.remoteFileNames).to(haveCount(@(testInitialFileNames.count))); + }); + }); + + context(@"when the file is known", ^{ + __block NSUInteger newSpaceAvailable = 600; + __block NSString *someKnownFileName = nil; + __block BOOL completionSuccess = NO; + __block NSUInteger completionBytesAvailable = 0; + __block NSError *completionError = nil; + + beforeEach(^{ + someKnownFileName = [testInitialFileNames anyObject]; + [testFileManager deleteRemoteFileWithName:someKnownFileName completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + completionSuccess = success; + completionBytesAvailable = bytesAvailable; + completionError = error; + }]; + + SDLDeleteFileResponse *deleteResponse = [[SDLDeleteFileResponse alloc] init]; + deleteResponse.success = @YES; + deleteResponse.spaceAvailable = @(newSpaceAvailable); + + [testConnectionManager respondToLastRequestWithResponse:deleteResponse]; + }); + + it(@"should return YES for success", ^{ + expect(@(completionSuccess)).to(equal(@YES)); + }); + + it(@"should return correct number of bytesAvailable", ^{ + expect(@(completionBytesAvailable)).to(equal(@(newSpaceAvailable))); + }); + + it(@"should set the new number of bytes to file manager's bytesAvailable property", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(@(newSpaceAvailable))); + }); + + it(@"should return without an error", ^{ + expect(completionError).to(beNil()); + }); + + xit(@"should have removed the file", ^{ + expect(testFileManager.remoteFileNames).toNot(contain(someKnownFileName)); + }); + }); + }); + + describe(@"uploading a new file", ^{ + __block NSString *testFileName = nil; + __block SDLFile *testUploadFile = nil; + __block BOOL completionSuccess = NO; + __block NSUInteger completionBytesAvailable = 0; + __block NSError *completionError = nil; + + __block SDLPutFile *sentPutFile = nil; + __block NSData *testFileData = nil; + + context(@"when there is a remote file named the same thing", ^{ + beforeEach(^{ + testFileName = [testInitialFileNames anyObject]; + testFileData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding]; + testUploadFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"]; + }); + + context(@"when allowing overwriting", ^{ + beforeEach(^{ + testFileManager.allowOverwrite = YES; + + [testFileManager uploadFile:testUploadFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + completionSuccess = success; + completionBytesAvailable = bytesAvailable; + completionError = error; + }]; + + sentPutFile = testConnectionManager.receivedRequests.lastObject; + }); + + it(@"should set the file manager state to be waiting", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + + it(@"should create a putfile that is the correct size", ^{ + expect(sentPutFile.length).to(equal(@(testFileData.length))); + }); + + it(@"should create a putfile with the correct data", ^{ + expect(sentPutFile.bulkData).to(equal(testFileData)); + }); + + it(@"should create a putfile with the correct file type", ^{ + expect(sentPutFile.fileType.value).to(match([SDLFileType BINARY].value)); + }); + + context(@"when the connection returns without error", ^{ + __block SDLPutFileResponse *testResponse = nil; + __block NSNumber *testResponseSuccess = nil; + __block NSNumber *testResponseBytesAvailable = nil; + + beforeEach(^{ + testResponseBytesAvailable = @750; + testResponseSuccess = @YES; + + testResponse = [[SDLPutFileResponse alloc] init]; + testResponse.success = testResponseSuccess; + testResponse.spaceAvailable = testResponseBytesAvailable; + + [testConnectionManager respondToLastRequestWithResponse:testResponse]; + }); + + it(@"should set the bytes available correctly", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should call the completion handler with the new bytes available", ^{ + expect(@(completionBytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should still have the file name available", ^{ + expect(testFileManager.remoteFileNames).to(contain(testFileName)); + }); + + it(@"should call the completion handler with success YES", ^{ + expect(@(completionSuccess)).to(equal(@YES)); + }); + + it(@"should call the completion handler with nil error", ^{ + expect(completionError).to(beNil()); + }); + + it(@"should have the file manager state as ready", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + }); + + context(@"when the connection returns failure", ^{ + __block SDLPutFileResponse *testResponse = nil; + __block NSNumber *testResponseBytesAvailable = nil; + __block NSNumber *testResponseSuccess = nil; + + beforeEach(^{ + testResponseBytesAvailable = @750; + testResponseSuccess = @NO; + + testResponse = [[SDLPutFileResponse alloc] init]; + testResponse.spaceAvailable = testResponseBytesAvailable; + testResponse.success = testResponseSuccess; + + [testConnectionManager respondToLastRequestWithResponse:testResponse]; + }); + + it(@"should set the bytes available correctly", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should call the completion handler with the new bytes available", ^{ + expect(@(completionBytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should still have the file name available", ^{ + expect(testFileManager.remoteFileNames).to(contain(testFileName)); + }); + + it(@"should call the completion handler with success YES", ^{ + expect(@(completionSuccess)).to(equal(testResponseSuccess)); + }); + + it(@"should call the completion handler with nil error", ^{ + expect(completionError).to(beNil()); + }); + + it(@"should set the file manager state to ready", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + }); + + context(@"when the connection errors without a response", ^{ + beforeEach(^{ + [testConnectionManager respondToLastRequestWithResponse:nil error:[NSError sdl_lifecycle_notReadyError]]; + }); + + it(@"should still have the file name available", ^{ + expect(testFileManager.remoteFileNames).to(contain(testFileName)); + }); + + it(@"should call the completion handler with nil error", ^{ + expect(completionError).to(equal([NSError sdl_lifecycle_notReadyError])); + }); + + it(@"should set the file manager state to ready", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + }); + }); + + context(@"when allow overwrite is false", ^{ + __block SDLRPCRequest *lastRequest = nil; + + beforeEach(^{ + testFileManager.allowOverwrite = NO; + + [testFileManager uploadFile:testUploadFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + completionSuccess = success; + completionBytesAvailable = bytesAvailable; + completionError = error; + }]; + + lastRequest = testConnectionManager.receivedRequests.lastObject; + }); + + it(@"should not have sent any putfiles", ^{ + expect(lastRequest).toNot(beAnInstanceOf([SDLPutFile class])); + }); + + it(@"should fail", ^{ + expect(@(completionSuccess)).to(equal(@NO)); + }); + + it(@"should return the same bytes as the file manager", ^{ + expect(@(completionBytesAvailable)).to(equal(@(testFileManager.bytesAvailable))); + }); + + it(@"should return an error", ^{ + expect(completionError).to(equal([NSError sdl_fileManager_cannotOverwriteError])); + }); + }); + }); + + context(@"when there is not a remote file named the same thing", ^{ + beforeEach(^{ + testFileName = @"not a test file"; + testFileData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding]; + testUploadFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"]; + + [testFileManager uploadFile:testUploadFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + completionSuccess = success; + completionBytesAvailable = bytesAvailable; + completionError = error; + }]; + + sentPutFile = (SDLPutFile *)testConnectionManager.receivedRequests.lastObject; + }); + + it(@"should not have testFileName in the files set", ^{ + expect(testInitialFileNames).toNot(contain(testFileName)); + }); + + context(@"when the connection returns without error", ^{ + __block SDLPutFileResponse *testResponse = nil; + __block NSNumber *testResponseSuccess = nil; + __block NSNumber *testResponseBytesAvailable = nil; + + beforeEach(^{ + testResponseBytesAvailable = @750; + testResponseSuccess = @YES; + + testResponse = [[SDLPutFileResponse alloc] init]; + testResponse.success = testResponseSuccess; + testResponse.spaceAvailable = testResponseBytesAvailable; + + [testConnectionManager respondToLastRequestWithResponse:testResponse]; + }); + + it(@"should set the bytes available correctly", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should call the completion handler with the new bytes available", ^{ + expect(@(completionBytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should add the file name", ^{ + expect(testFileManager.remoteFileNames).to(contain(testFileName)); + }); + + it(@"should call the completion handler with success YES", ^{ + expect(@(completionSuccess)).to(equal(@YES)); + }); + + it(@"should call the completion handler with nil error", ^{ + expect(completionError).to(beNil()); + }); + + it(@"should set the file manager state to ready", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + }); + + context(@"when the connection returns failure", ^{ + __block SDLPutFileResponse *testResponse = nil; + __block NSNumber *testResponseBytesAvailable = nil; + __block NSNumber *testResponseSuccess = nil; + + beforeEach(^{ + testResponseBytesAvailable = @750; + testResponseSuccess = @NO; + + testResponse = [[SDLPutFileResponse alloc] init]; + testResponse.spaceAvailable = testResponseBytesAvailable; + testResponse.success = testResponseSuccess; + + [testConnectionManager respondToLastRequestWithResponse:testResponse]; + }); + + it(@"should set the bytes available correctly", ^{ + expect(@(testFileManager.bytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should call the completion handler with the new bytes available", ^{ + expect(@(completionBytesAvailable)).to(equal(testResponseBytesAvailable)); + }); + + it(@"should not have the file name available", ^{ + expect(testFileManager.remoteFileNames).toNot(contain(testFileName)); + }); + + it(@"should call the completion handler with success YES", ^{ + expect(@(completionSuccess)).to(equal(testResponseSuccess)); + }); + + it(@"should call the completion handler with nil error", ^{ + expect(completionError).to(beNil()); + }); + + it(@"should set the file manager state to ready", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + }); + + context(@"when the connection errors without a response", ^{ + beforeEach(^{ + [testConnectionManager respondToLastRequestWithResponse:nil error:[NSError sdl_lifecycle_notReadyError]]; + }); + + it(@"should not have the file name available", ^{ + expect(testFileManager.remoteFileNames).toNot(contain(testFileName)); + }); + + it(@"should call the completion handler with nil error", ^{ + expect(completionError).to(equal([NSError sdl_lifecycle_notReadyError])); + }); + + it(@"should set the file manager state to ready", ^{ + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); + }); + }); + }); + }); + + describe(@"force uploading a file", ^{ + __block NSString *testFileName = nil; + __block SDLFile *testUploadFile = nil; + __block BOOL completionSuccess = NO; + __block NSUInteger completionBytesAvailable = 0; + __block NSError *completionError = nil; + + __block SDLPutFile *sentPutFile = nil; + __block NSData *testFileData = nil; + + context(@"when there is a remote file named the same thing", ^{ + beforeEach(^{ + testFileName = [testInitialFileNames anyObject]; + testFileData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding]; + testUploadFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"]; + }); + + context(@"when disallowing overwriting", ^{ + beforeEach(^{ + testFileManager.allowOverwrite = NO; + + [testFileManager forceUploadFile:testUploadFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + completionSuccess = success; + completionBytesAvailable = bytesAvailable; + completionError = error; + }]; + + sentPutFile = testConnectionManager.receivedRequests.lastObject; + }); + + it(@"should create a putfile that is the correct size", ^{ + expect(sentPutFile.length).to(equal(@(testFileData.length))); + }); + + it(@"should create a putfile with the correct data", ^{ + expect(sentPutFile.bulkData).to(equal(testFileData)); + }); + + it(@"should create a putfile with the correct file type", ^{ + expect(sentPutFile.fileType.value).to(equal([SDLFileType BINARY].value)); + }); + }); + }); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m new file mode 100644 index 000000000..43ed5ca1d --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m @@ -0,0 +1,210 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFile.h" +#import "SDLFileType.h" + + +QuickSpecBegin(SDLFileSpec) + +describe(@"SDLFile", ^{ + __block SDLFile *testFile = nil; + + context(@"when created with data", ^{ + __block NSData *testData = nil; + __block NSString *testName = nil; + __block NSString *testFileType = nil; + __block BOOL testPersistence = NO; + + context(@"using test data", ^{ + testName = @"Example Name"; + testData = [@"Example Data" dataUsingEncoding:NSUTF8StringEncoding]; + testFileType = @"mp3"; + testPersistence = YES; + + beforeEach(^{ + testFile = [[SDLFile alloc] initWithData:testData name:testName fileExtension:testFileType persistent:testPersistence]; + }); + + it(@"should store the data in a temp file", ^{ + expect(testFile.fileURL).toNot(beNil()); + expect(@([[NSFileManager defaultManager] fileExistsAtPath:testFile.fileURL.path])).to(equal(@YES)); + }); + + it(@"should correctly store data", ^{ + expect(testFile.data).to(equal(testData)); + }); + + it(@"should correctly store name", ^{ + expect(testFile.name).to(equal(testName)); + }); + + it(@"should correctly store file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType AUDIO_MP3])); + }); + }); + }); + + context(@"when created with a file", ^{ + __block NSURL *testFileURL = nil; + __block NSString *testFileName = nil; + + context(@"when created with a non-extant file url", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"imageThatDoesNotExist" withExtension:@"jpg"]; + testFileName = @"someImage"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should be nil", ^{ + expect(testFile).to(beNil()); + }); + }); + + context(@"when created with an extant file url", ^{ + context(@"that is ephemeral", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImageJPG" withExtension:@"jpg"]; + testFileName = @"someImage"; + + testFile = [SDLFile ephemeralFileAtFileURL:testFileURL name:testFileName]; + }); + + it(@"should correctly store data", ^{ + expect(testFile.data).to(equal([NSData dataWithContentsOfURL:testFileURL])); + }); + + it(@"should correctly store name", ^{ + expect(testFile.name).to(match(testFileName)); + }); + + it(@"should correctly store file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + }); + + it(@"should correctly store persistence", ^{ + expect(@(testFile.persistent)).to(equal(@NO)); + }); + }); + + context(@"That is persistent", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImageJPG" withExtension:@"jpg"]; + testFileName = @"someImage"; + + testFile = [SDLFile persistentFileAtFileURL:testFileURL name:testFileName]; + }); + + it(@"should correctly store data", ^{ + expect(testFile.data).to(equal([NSData dataWithContentsOfURL:testFileURL])); + }); + + it(@"should correctly store name", ^{ + expect(testFile.name).to(equal(testFileName)); + }); + + it(@"should correctly store file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + }); + + it(@"should correctly store persistence", ^{ + expect(@(testFile.persistent)).to(equal(@YES)); + }); + }); + }); + + describe(@"it should recognize file of type", ^{ + context(@"jpg", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImageJPG" withExtension:@"jpg"]; + testFileName = @"someJPG"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should properly interpret file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + }); + }); + + context(@"jpeg", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImageJPEG" withExtension:@"jpeg"]; + testFileName = @"someJPEG"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should properly interpret file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + }); + }); + + context(@"png", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImagePNG" withExtension:@"png"]; + testFileName = @"somePNG"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should properly interpret file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType GRAPHIC_PNG])); + }); + }); + + context(@"bmp", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImageBMP" withExtension:@"bmp"]; + testFileName = @"someBMP"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should properly interpret file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType GRAPHIC_BMP])); + }); + }); + + // TODO: Audio tests + + context(@"json", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testFileJSON" withExtension:@"json"]; + testFileName = @"someJSON"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should properly interpret file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType JSON])); + }); + }); + + context(@"binary", ^{ + beforeEach(^{ + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + testFileURL = [testBundle URLForResource:@"testImageTIFF" withExtension:@"tiff"]; + testFileName = @"someTIFF"; + + testFile = [[SDLFile alloc] initWithFileURL:testFileURL name:testFileName persistent:NO]; + }); + + it(@"should properly interpret file type", ^{ + expect(testFile.fileType).to(equal([SDLFileType BINARY])); + }); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m new file mode 100644 index 000000000..472a590e0 --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m @@ -0,0 +1,108 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLError.h" +#import "SDLListFiles.h" +#import "SDLListFilesResponse.h" +#import "SDLListFilesOperation.h" +#import "TestConnectionManager.h" + + +QuickSpecBegin(SDLListFilesOperationSpec) + +describe(@"List Files Operation", ^{ + __block TestConnectionManager *testConnectionManager = nil; + __block SDLListFilesOperation *testOperation = nil; + + __block BOOL successResult = NO; + __block NSUInteger bytesAvailableResult = NO; + __block NSError *errorResult = nil; + __block NSArray<NSString *> *fileNamesResult = nil; + + beforeEach(^{ + testConnectionManager = [[TestConnectionManager alloc] init]; + testOperation = [[SDLListFilesOperation alloc] initWithConnectionManager:testConnectionManager completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSArray<NSString *> * _Nonnull fileNames, NSError * _Nullable error) { + successResult = success; + bytesAvailableResult = bytesAvailable; + fileNamesResult = fileNames; + errorResult = error; + }]; + }); + + it(@"should have a priority of 'very high'", ^{ + expect(@(testOperation.queuePriority)).to(equal(@(NSOperationQueuePriorityVeryHigh))); + }); + + describe(@"running the operation", ^{ + beforeEach(^{ + [testOperation start]; + }); + + it(@"should send a list files request", ^{ + expect(testConnectionManager.receivedRequests.lastObject).to(beAnInstanceOf([SDLListFiles class])); + }); + + context(@"when a good response comes back", ^{ + __block SDLListFilesResponse *goodResponse = nil; + __block NSNumber *responseSpaceAvailable = nil; + __block NSMutableArray *responseFileNames = nil; + + beforeEach(^{ + responseSpaceAvailable = @(11212512); + responseFileNames = [NSMutableArray arrayWithArray:@[@"test1", @"test2"]]; + + goodResponse = [[SDLListFilesResponse alloc] init]; + goodResponse.success = @YES; + goodResponse.spaceAvailable = responseSpaceAvailable; + goodResponse.filenames = responseFileNames; + + [testConnectionManager respondToLastRequestWithResponse:goodResponse]; + }); + + it(@"should have called the completion handler with proper data", ^{ + expect(@(successResult)).to(equal(@YES)); + expect(@(bytesAvailableResult)).to(equal(responseSpaceAvailable)); + expect(fileNamesResult).to(haveCount(@(responseFileNames.count))); + expect(fileNamesResult).to(contain(responseFileNames.firstObject)); + expect(errorResult).to(beNil()); + }); + + it(@"should be set to finished", ^{ + expect(@(testOperation.finished)).to(equal(@YES)); + expect(@(testOperation.executing)).to(equal(@NO)); + }); + }); + + context(@"when a bad response comes back", ^{ + __block SDLListFilesResponse *badResponse = nil; + __block NSNumber *responseSpaceAvailable = nil; + __block NSMutableArray *responseFileNames = nil; + + __block NSString *responseErrorDescription = nil; + __block NSString *responseErrorReason = nil; + + beforeEach(^{ + responseSpaceAvailable = @(0); + responseFileNames = [NSMutableArray arrayWithArray:@[]]; + + responseErrorDescription = @"some description"; + responseErrorReason = @"some reason"; + + badResponse = [[SDLListFilesResponse alloc] init]; + badResponse.success = @NO; + badResponse.spaceAvailable = responseSpaceAvailable; + badResponse.filenames = responseFileNames; + + [testConnectionManager respondToLastRequestWithResponse:badResponse error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]]; + }); + + it(@"should have called completion handler with error", ^{ + expect(errorResult.localizedDescription).to(match(responseErrorDescription)); + expect(errorResult.localizedFailureReason).to(match(responseErrorReason)); + expect(@(successResult)).to(equal(@NO)); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m new file mode 100644 index 000000000..a0adc126a --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m @@ -0,0 +1,166 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import <SmartDeviceLink/NSNumber+NumberType.h> +#import <SmartDeviceLink/SDLPermissionConstants.h> +#import "SDLPermissionFilter.h" + +QuickSpecBegin(SDLPermissionFilterSpec) + +describe(@"A filter", ^{ + __block NSString *testRPCName1 = nil; + __block NSString *testRPCName2 = nil; + + beforeEach(^{ + testRPCName1 = @"testRPCName1"; + testRPCName2 = @"testRPCName2"; + }); + + describe(@"should initialize correctly", ^{ + __block NSArray<SDLPermissionRPCName *> *testRPCNames = nil; + __block SDLPermissionGroupType testGroupType = SDLPermissionGroupTypeAny; + __block SDLPermissionFilter *testFilter = nil; + + __block NSDictionary<SDLPermissionRPCName *, NSNumber<SDLBool> *> *testObserverReturnChangedDict = nil; + + beforeEach(^{ + testRPCNames = @[testRPCName1, testRPCName2]; + testGroupType = SDLPermissionGroupTypeAny; + }); + + context(@"using initWithRPCNames:changeType:observer:", ^{ + beforeEach(^{ + testFilter = [[SDLPermissionFilter alloc] initWithRPCNames:testRPCNames groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + testObserverReturnChangedDict = changedDict; + }]; + }); + + it(@"should initialize the identifier as an NSUUID", ^{ + expect(testFilter.identifier).to(beAnInstanceOf([NSUUID class])); + }); + + it(@"should set the rpcNames array correctly", ^{ + expect(testFilter.rpcNames).to(equal(testRPCNames)); + }); + + describe(@"it should set up the observer correctly", ^{ + __block NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> *testObserverChangedDict = nil; + __block NSNumber<SDLBool> *testRPCName1Bool = nil; + __block NSNumber<SDLBool> *testRPCName2Bool = nil; + __block SDLPermissionGroupStatus testObserverGroupStatus = SDLPermissionGroupStatusUnknown; + + beforeEach(^{ + testRPCName1Bool = @YES; + testRPCName2Bool = @NO; + testObserverChangedDict = @{testRPCName1: testRPCName1Bool, + testRPCName2: testRPCName2Bool}; + testObserverGroupStatus = SDLPermissionGroupStatusMixed; + + testFilter.observer(testObserverChangedDict, testObserverGroupStatus); + }); + + it(@"should call the changedDict correctly", ^{ + expect(testObserverReturnChangedDict).to(equal(testObserverChangedDict)); + }); + + it(@"should call the status correctly", ^{ + expect(@(testObserverGroupStatus)).to(equal(@(testObserverGroupStatus))); + }); + }); + }); + + context(@"using filterWithRPCNames:changeType:observer:", ^{ + beforeEach(^{ + testFilter = [SDLPermissionFilter filterWithRPCNames:testRPCNames groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + testObserverReturnChangedDict = changedDict; + }]; + }); + + it(@"should initialize the identifier as an NSUUID", ^{ + expect(testFilter.identifier).to(beAnInstanceOf([NSUUID class])); + }); + + it(@"should set the rpcNames array correctly", ^{ + expect(testFilter.rpcNames).to(equal(testRPCNames)); + }); + + describe(@"it should set up the observer correctly", ^{ + __block NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> *testObserverChangedDict = nil; + __block NSNumber<SDLBool> *testRPCName1Bool = nil; + __block NSNumber<SDLBool> *testRPCName2Bool = nil; + __block SDLPermissionGroupStatus testObserverGroupStatus = SDLPermissionGroupStatusUnknown; + + beforeEach(^{ + testRPCName1Bool = @YES; + testRPCName2Bool = @NO; + testObserverChangedDict = @{testRPCName1: testRPCName1Bool, + testRPCName2: testRPCName2Bool}; + testObserverGroupStatus = SDLPermissionGroupStatusMixed; + + testFilter.observer(testObserverChangedDict, testObserverGroupStatus); + }); + + it(@"should call the changedDict correctly", ^{ + expect(testObserverReturnChangedDict).to(equal(testObserverChangedDict)); + }); + + it(@"should call the status correctly", ^{ + expect(@(testObserverGroupStatus)).to(equal(@(testObserverGroupStatus))); + }); + }); + }); + }); + + describe(@"copying a filter", ^{ + __block SDLPermissionFilter *testFilter = nil; + __block SDLPermissionFilter *testCopiedFilter = nil; + + beforeEach(^{ + testFilter = [SDLPermissionFilter filterWithRPCNames:@[testRPCName1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {}]; + testCopiedFilter = [testFilter copy]; + }); + + it(@"should say copied filters are not the same instance", ^{ + expect(testCopiedFilter).toNot(beIdenticalTo(testFilter)); + }); + + it(@"should copy the identifier correctly", ^{ + expect(testCopiedFilter.identifier).to(equal(testFilter.identifier)); + }); + + it(@"should copy the filter array correctly", ^{ + expect(testCopiedFilter.rpcNames).to(equal(testFilter.rpcNames)); + }); + + it(@"should copy the change type correctly", ^{ + expect(@(testCopiedFilter.groupType)).to(equal(@(testFilter.groupType))); + }); + + it(@"should copy the observer correctly", ^{ + expect(testCopiedFilter.observer).to(equal(testFilter.observer)); + }); + }); + + describe(@"testing equality", ^{ + __block SDLPermissionFilter *testSameFilter1 = nil; + __block SDLPermissionFilter *testSameFilter2 = nil; + __block SDLPermissionFilter *testDifferentFilter = nil; + + beforeEach(^{ + testSameFilter1 = [SDLPermissionFilter filterWithRPCNames:@[testRPCName1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {}]; + testSameFilter2 = [testSameFilter1 copy]; + + testDifferentFilter = [SDLPermissionFilter filterWithRPCNames:@[testRPCName1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {}]; + }); + + it(@"should say copied filters are the same", ^{ + expect(testSameFilter1).to(equal(testSameFilter2)); + }); + + it(@"should say new filters are different", ^{ + expect(testSameFilter1).toNot(equal(testDifferentFilter)); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m new file mode 100644 index 000000000..3cea7aa5b --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m @@ -0,0 +1,949 @@ + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMILevel.h" +#import "SDLHMIPermissions.h" +#import "SDLNotificationConstants.h" +#import "SDLParameterPermissions.h" +#import "SDLPermissionItem.h" +#import "SDLPermissionManager.h" + +QuickSpecBegin(SDLPermissionsManagerSpec) + +describe(@"SDLPermissionsManager", ^{ + __block SDLPermissionManager *testPermissionsManager = nil; + __block NSNotification *testPermissionsNotification = nil; + __block NSString *testRPCNameAllAllowed = nil; + __block NSString *testRPCNameAllDisallowed = nil; + __block NSString *testRPCNameFullLimitedAllowed = nil; + __block NSString *testRPCNameFullLimitedBackgroundAllowed = nil; + __block SDLPermissionItem *testPermissionAllAllowed = nil; + __block SDLHMIPermissions *testHMIPermissionsAllAllowed = nil; + __block SDLPermissionItem *testPermissionAllDisallowed = nil; + __block SDLHMIPermissions *testHMIPermissionsAllDisallowed = nil; + __block SDLPermissionItem *testPermissionFullLimitedAllowed = nil; + __block SDLHMIPermissions *testHMIPermissionsFullLimitedAllowed = nil; + __block SDLPermissionItem *testPermissionFullLimitedBackgroundAllowed = nil; + __block SDLHMIPermissions *testHMIPermissionsFullLimitedBackgroundAllowed = nil; + + __block NSNotification *limitedHMINotification = nil; + __block NSNotification *backgroundHMINotification = nil; + __block NSNotification *noneHMINotification = nil; + + beforeEach(^{ + // Permission Names + testRPCNameAllAllowed = @"AllAllowed"; + testRPCNameAllDisallowed = @"AllDisallowed"; + testRPCNameFullLimitedAllowed = @"FullAndLimitedAllowed"; + testRPCNameFullLimitedBackgroundAllowed = @"FullAndLimitedAndBackgroundAllowed"; + + // Create a manager + testPermissionsManager = [[SDLPermissionManager alloc] init]; + + // Permission states + testHMIPermissionsAllAllowed = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsAllAllowed.allowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL], [SDLHMILevel LIMITED], [SDLHMILevel NONE]]]; + + testHMIPermissionsAllDisallowed = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsAllDisallowed.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL], [SDLHMILevel LIMITED], [SDLHMILevel NONE]]]; + + testHMIPermissionsFullLimitedAllowed = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsFullLimitedAllowed.allowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel FULL], [SDLHMILevel LIMITED]]]; + testHMIPermissionsFullLimitedAllowed.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel BACKGROUND], [SDLHMILevel NONE]]]; + + testHMIPermissionsFullLimitedBackgroundAllowed = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsFullLimitedBackgroundAllowed.allowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel FULL], [SDLHMILevel LIMITED], [SDLHMILevel BACKGROUND]]]; + testHMIPermissionsFullLimitedBackgroundAllowed.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel NONE]]]; + + // Assemble Permissions + SDLParameterPermissions *testParameterPermissions = [[SDLParameterPermissions alloc] init]; + + testPermissionAllAllowed = [[SDLPermissionItem alloc] init]; + testPermissionAllAllowed.rpcName = testRPCNameAllAllowed; + testPermissionAllAllowed.hmiPermissions = testHMIPermissionsAllAllowed; + testPermissionAllAllowed.parameterPermissions = testParameterPermissions; + + testPermissionAllDisallowed = [[SDLPermissionItem alloc] init]; + testPermissionAllDisallowed.rpcName = testRPCNameAllDisallowed; + testPermissionAllDisallowed.hmiPermissions = testHMIPermissionsAllDisallowed; + testPermissionAllDisallowed.parameterPermissions = testParameterPermissions; + + testPermissionFullLimitedAllowed = [[SDLPermissionItem alloc] init]; + testPermissionFullLimitedAllowed.rpcName = testRPCNameFullLimitedAllowed; + testPermissionFullLimitedAllowed.hmiPermissions = testHMIPermissionsFullLimitedAllowed; + testPermissionFullLimitedAllowed.parameterPermissions = testParameterPermissions; + + testPermissionFullLimitedBackgroundAllowed = [[SDLPermissionItem alloc] init]; + testPermissionFullLimitedBackgroundAllowed.rpcName = testRPCNameFullLimitedBackgroundAllowed; + testPermissionFullLimitedBackgroundAllowed.hmiPermissions = testHMIPermissionsFullLimitedBackgroundAllowed; + testPermissionFullLimitedBackgroundAllowed.parameterPermissions = testParameterPermissions; + + // Permission Notifications + testPermissionsNotification = [NSNotification notificationWithName:SDLDidChangePermissionsNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: @[testPermissionAllAllowed, testPermissionAllDisallowed, testPermissionFullLimitedAllowed, testPermissionFullLimitedBackgroundAllowed]}]; + limitedHMINotification = [NSNotification notificationWithName:SDLDidChangeHMIStatusNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: [SDLHMILevel LIMITED]}]; + backgroundHMINotification = [NSNotification notificationWithName:SDLDidChangeHMIStatusNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: [SDLHMILevel BACKGROUND]}]; + noneHMINotification = [NSNotification notificationWithName:SDLDidChangeHMIStatusNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: [SDLHMILevel NONE]}]; + }); + + describe(@"checking if a permission is allowed", ^{ + __block NSString *someRPCName = nil; + __block BOOL testResultBOOL = NO; + + context(@"when no permissions exist", ^{ + beforeEach(^{ + someRPCName = @"some rpc name"; + + testResultBOOL = [testPermissionsManager isRPCAllowed:someRPCName]; + }); + + it(@"should not be allowed", ^{ + expect(@(testResultBOOL)).to(equal(@NO)); + }); + }); + + context(@"when permissions exist but no HMI level", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultBOOL = [testPermissionsManager isRPCAllowed:testRPCNameAllAllowed]; + }); + + it(@"should not be allowed", ^{ + expect(@(testResultBOOL)).to(equal(@NO)); + }); + }); + + context(@"when permissions exist", ^{ + context(@"and the permission is allowed", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultBOOL = [testPermissionsManager isRPCAllowed:testRPCNameAllAllowed]; + }); + + it(@"should be allowed", ^{ + expect(@(testResultBOOL)).to(equal(@YES)); + }); + }); + + context(@"and the permission is denied", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultBOOL = [testPermissionsManager isRPCAllowed:testRPCNameAllDisallowed]; + }); + + it(@"should be denied", ^{ + expect(@(testResultBOOL)).to(equal(@NO)); + }); + }); + }); + }); + + describe(@"checking the group status of RPCs", ^{ + __block SDLPermissionGroupStatus testResultStatus = SDLPermissionGroupStatusUnknown; + + context(@"with no permissions data", ^{ + beforeEach(^{ + testResultStatus = [testPermissionsManager groupStatusOfRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed]]; + }); + + it(@"should return unknown", ^{ + expect(@(testResultStatus)).to(equal(@(SDLPermissionGroupStatusUnknown))); + }); + }); + + context(@"for an all allowed group", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultStatus = [testPermissionsManager groupStatusOfRPCs:@[testRPCNameAllAllowed, testRPCNameFullLimitedAllowed]]; + }); + + it(@"should return mixed", ^{ + expect(@(testResultStatus)).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + }); + + context(@"for an all disallowed group", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:backgroundHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultStatus = [testPermissionsManager groupStatusOfRPCs:@[testRPCNameFullLimitedAllowed, testRPCNameAllDisallowed]]; + }); + + it(@"should return mixed", ^{ + expect(@(testResultStatus)).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + }); + + context(@"for a mixed group", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultStatus = [testPermissionsManager groupStatusOfRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed]]; + }); + + it(@"should return mixed", ^{ + expect(@(testResultStatus)).to(equal(@(SDLPermissionGroupStatusMixed))); + }); + }); + }); + + describe(@"checking the status of RPCs", ^{ + __block NSDictionary<SDLPermissionRPCName *, NSNumber<SDLBool> *> *testResultPermissionStatusDict = nil; + + context(@"with no permissions data", ^{ + beforeEach(^{ + testResultPermissionStatusDict = [testPermissionsManager statusOfRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed]]; + }); + + it(@"should return NO for RPC All Allowed", ^{ + expect(testResultPermissionStatusDict[testRPCNameAllAllowed]).to(equal(@NO)); + }); + + it(@"should return NO for RPC All Disallowed", ^{ + expect(testResultPermissionStatusDict[testRPCNameAllDisallowed]).to(equal(@NO)); + }); + }); + + context(@"with permissions data", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + testResultPermissionStatusDict = [testPermissionsManager statusOfRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed]]; + }); + + it(@"should return YES for RPC All Allowed", ^{ + expect(testResultPermissionStatusDict[testRPCNameAllAllowed]).to(equal(@YES)); + }); + + it(@"should return NO for RPC All Disallowed", ^{ + expect(testResultPermissionStatusDict[testRPCNameAllDisallowed]).to(equal(@NO)); + }); + }); + }); + + describe(@"adding and using observers", ^{ + describe(@"adding new observers", ^{ + context(@"when no data is present", ^{ + __block BOOL testObserverCalled = NO; + __block SDLPermissionGroupStatus testObserverStatus = SDLPermissionGroupStatusUnknown; + __block NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> *testObserverChangeDict = nil; + + beforeEach(^{ + testObserverCalled = NO; + testObserverStatus = SDLPermissionGroupStatusUnknown; + testObserverChangeDict = nil; + + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + testObserverChangeDict = change; + testObserverStatus = status; + testObserverCalled = YES; + }]; + }); + + it(@"should call the observer", ^{ + expect(@(testObserverCalled)).to(equal(@YES)); + }); + + it(@"should return Unknown for the group status", ^{ + expect(@(testObserverStatus)).to(equal(@(SDLPermissionGroupStatusUnknown))); + }); + + it(@"should return NO for All Allowed RPC allowed", ^{ + expect(testObserverChangeDict[testRPCNameAllAllowed]).to(equal(@NO)); + }); + + it(@"should return NO for All Disallowed RPC allowed", ^{ + expect(testObserverChangeDict[testRPCNameAllDisallowed]).to(equal(@NO)); + }); + }); + + context(@"when data is already present", ^{ + __block NSInteger numberOfTimesObserverCalled = 0; + __block NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> *testObserverBlockChangedDict = nil; + __block SDLPermissionGroupStatus testObserverReturnStatus = SDLPermissionGroupStatusUnknown; + + context(@"to match an ANY observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + // This should be called twice, once for each RPC being observed. It should be called immediately since data should already be present + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + testObserverBlockChangedDict = changedDict; + testObserverReturnStatus = status; + }]; + }); + + it(@"should call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should have the all allowed rpc as YES", ^{ + expect(testObserverBlockChangedDict[testRPCNameAllAllowed]).to(equal(@YES)); + }); + + it(@"should have the all disallowed rpc as NO", ^{ + expect(testObserverBlockChangedDict[testRPCNameAllDisallowed]).to(equal(@NO)); + }); + + it(@"should only have the two rpcs in the dictionary", ^{ + expect(testObserverBlockChangedDict.allKeys).to(haveCount(@2)); + }); + + it(@"should return the proper status", ^{ + expect(@(testObserverReturnStatus)).to(equal(@(SDLPermissionGroupStatusMixed))); + }); + }); + + context(@"to match an all allowed observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level LIMITED + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + // This should be called twice, once for each RPC being observed. It should be called immediately since data should already be present + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + testObserverBlockChangedDict = change; + testObserverReturnStatus = status; + }]; + }); + + it(@"should call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should have the all allowed rpc as YES", ^{ + expect(testObserverBlockChangedDict[testRPCNameAllAllowed]).to(equal(@YES)); + }); + + it(@"should have the full & limited rpc as YES", ^{ + expect(testObserverBlockChangedDict[testRPCNameFullLimitedAllowed]).to(equal(@YES)); + }); + + it(@"should only have the two rpcs in the dictionary", ^{ + expect(testObserverBlockChangedDict.allKeys).to(haveCount(@2)); + }); + + it(@"should return allowed for the group status", ^{ + expect(@(testObserverReturnStatus)).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + }); + + context(@"that does not match an all allowed observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level NONE + [[NSNotificationCenter defaultCenter] postNotification:noneHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + // This should be called twice, once for each RPC being observed. It should be called immediately since data should already be present + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllDisallowed, testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + testObserverReturnStatus = status; + }]; + }); + + it(@"should call the observer", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should tell us the status is Disallowed", ^{ + expect(@(testObserverReturnStatus)).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + }); + }); + }); + + context(@"updating an observer with new permission data", ^{ + __block NSInteger numberOfTimesObserverCalled = 0; + + __block SDLPermissionItem *testPermissionUpdated = nil; + __block NSMutableArray<NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> *> *changeDicts = nil; + __block NSMutableArray<NSNumber<SDLUInt> *> *testStatuses = nil; + + context(@"to match an ANY observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + changeDicts = [NSMutableArray array]; + testStatuses = [NSMutableArray array]; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level LIMITED + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:changedDict]; + }]; + + // Create a permission update disallowing our current HMI level for the observed permission + SDLParameterPermissions *testParameterPermissions = [[SDLParameterPermissions alloc] init]; + SDLHMIPermissions *testHMIPermissionsUpdated = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsUpdated.allowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]]]; + testHMIPermissionsUpdated.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel LIMITED], [SDLHMILevel NONE]]]; + + testPermissionUpdated = [[SDLPermissionItem alloc] init]; + testPermissionUpdated.rpcName = testRPCNameAllAllowed; + testPermissionUpdated.hmiPermissions = testHMIPermissionsUpdated; + testPermissionUpdated.parameterPermissions = testParameterPermissions; + + // Send the permission update + NSNotification *updatedNotification = [NSNotification notificationWithName:SDLDidChangePermissionsNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: @[testPermissionUpdated]}]; + [[NSNotificationCenter defaultCenter] postNotification:updatedNotification]; + }); + + it(@"should call the observer twice", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + + it(@"should have the All Allowed RPC in the first change dict", ^{ + expect(changeDicts[0].allKeys).to(contain(testRPCNameAllAllowed)); + }); + + it(@"should have the All Disallowed RPC in the first change dict", ^{ + expect(changeDicts[0].allKeys).to(contain(testRPCNameAllDisallowed)); + }); + + it(@"should have the All Allowed RPC in the second change dict", ^{ + expect(changeDicts[1].allKeys).to(contain(testRPCNameAllAllowed)); + }); + + it(@"should have the All Disallowed RPC in the second change dict", ^{ + expect(changeDicts[1].allKeys).to(contain(testRPCNameAllDisallowed)); + }); + + it(@"should have the correct permission state for the all allowed RPC in the first change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[0][testRPCNameAllAllowed]; + expect(isAllowed).to(equal(@YES)); + }); + + it(@"should have the correct permission state for the all disallowed RPC in the first change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[0][testRPCNameAllDisallowed]; + expect(isAllowed).to(equal(@NO)); + }); + + it(@"should have the correct permission state for the all allowed RPC in the updated change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[1][testRPCNameAllAllowed]; + expect(isAllowed).to(equal(@NO)); + }); + + it(@"should have the correct permission state for the all disallowed RPC in the updated change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[1][testRPCNameAllDisallowed]; + expect(isAllowed).to(equal(@NO)); + }); + }); + + context(@"to match an all allowed observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + changeDicts = [NSMutableArray array]; + testStatuses = [NSMutableArray array]; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level BACKGROUND + [[NSNotificationCenter defaultCenter] postNotification:backgroundHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + context(@"so that it becomes All Allowed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllDisallowed, testRPCNameFullLimitedBackgroundAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:change]; + [testStatuses addObject:@(status)]; + }]; + + // Create a permission update allowing our current HMI level for the observed permission + SDLParameterPermissions *testParameterPermissions = [[SDLParameterPermissions alloc] init]; + SDLHMIPermissions *testHMIPermissionsUpdated = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsUpdated.allowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel LIMITED], [SDLHMILevel NONE], [SDLHMILevel BACKGROUND], [SDLHMILevel FULL]]]; + testHMIPermissionsUpdated.userDisallowed = [NSMutableArray arrayWithArray:@[]]; + + testPermissionUpdated = [[SDLPermissionItem alloc] init]; + testPermissionUpdated.rpcName = testRPCNameAllDisallowed; + testPermissionUpdated.hmiPermissions = testHMIPermissionsUpdated; + testPermissionUpdated.parameterPermissions = testParameterPermissions; + + // Send the permission update + NSNotification *updatedNotification = [NSNotification notificationWithName:SDLDidChangePermissionsNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: @[testPermissionUpdated]}]; + [[NSNotificationCenter defaultCenter] postNotification:updatedNotification]; + }); + + it(@"should call the observer twice", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + + it(@"should have two RPCs in the first change dict", ^{ + expect(changeDicts[0].allKeys).to(haveCount(@2)); + }); + + it(@"should have two RPCs in the second change dict", ^{ + expect(changeDicts[1].allKeys).to(haveCount(@2)); + }); + + it(@"should have the first status should be mixed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusMixed))); + }); + + it(@"should have the second status as allowed", ^{ + expect(testStatuses[1]).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + }); + + context(@"so that it goes from All Allowed to mixed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:change]; + [testStatuses addObject:@(status)]; + }]; + + // Create a permission update disallowing our current HMI level for the observed permission + SDLParameterPermissions *testParameterPermissions = [[SDLParameterPermissions alloc] init]; + SDLHMIPermissions *testHMIPermissionsUpdated = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsUpdated.allowed = [NSMutableArray arrayWithArray:@[]]; + testHMIPermissionsUpdated.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL], [SDLHMILevel LIMITED], [SDLHMILevel NONE]]]; + + testPermissionUpdated = [[SDLPermissionItem alloc] init]; + testPermissionUpdated.rpcName = testRPCNameAllAllowed; + testPermissionUpdated.hmiPermissions = testHMIPermissionsUpdated; + testPermissionUpdated.parameterPermissions = testParameterPermissions; + + // Send the permission update + NSNotification *updatedNotification = [NSNotification notificationWithName:SDLDidChangePermissionsNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: @[testPermissionUpdated]}]; + [[NSNotificationCenter defaultCenter] postNotification:updatedNotification]; + }); + + it(@"should call the observer twice", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + + it(@"should have Allowed as the first status", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + + it(@"should have Disallowed as the second status", ^{ + expect(testStatuses[1]).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + + it(@"should have the RPC in the first change dict", ^{ + expect(changeDicts[0].allKeys).to(contain(testRPCNameAllAllowed)); + }); + + it(@"should have the RPC in the second change dict", ^{ + expect(changeDicts[1].allKeys).to(contain(testRPCNameAllAllowed)); + }); + + it(@"should have the correct permissions for the RPC in the first change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[0][testRPCNameAllAllowed]; + expect(isAllowed).to(equal(@YES)); + }); + + it(@"should have the correct permissions for the RPC in the second change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[1][testRPCNameAllAllowed]; + expect(isAllowed).to(equal(@NO)); + }); + }); + }); + + context(@"to not match an all allowed observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + changeDicts = [NSMutableArray array]; + testStatuses = [NSMutableArray array]; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level BACKGROUND + [[NSNotificationCenter defaultCenter] postNotification:backgroundHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + context(@"from mixed to disallowed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:change]; + [testStatuses addObject:@(status)]; + }]; + + // Create a permission update disallowing our current HMI level for the observed permission + SDLParameterPermissions *testParameterPermissions = [[SDLParameterPermissions alloc] init]; + SDLHMIPermissions *testHMIPermissionsUpdated = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsUpdated.allowed = [NSMutableArray arrayWithArray:@[]]; + testHMIPermissionsUpdated.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL], [SDLHMILevel LIMITED], [SDLHMILevel NONE]]]; + + testPermissionUpdated = [[SDLPermissionItem alloc] init]; + testPermissionUpdated.rpcName = testRPCNameAllAllowed; + testPermissionUpdated.hmiPermissions = testHMIPermissionsUpdated; + testPermissionUpdated.parameterPermissions = testParameterPermissions; + + // Send the permission update + NSNotification *updatedNotification = [NSNotification notificationWithName:SDLDidChangePermissionsNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: @[testPermissionUpdated]}]; + [[NSNotificationCenter defaultCenter] postNotification:updatedNotification]; + }); + + it(@"should only call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should have the first status as mixed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusMixed))); + }); + }); + + context(@"from disallowed to mixed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameFullLimitedAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:change]; + [testStatuses addObject:@(status)]; + }]; + + // Create a permission update disallowing our current HMI level for the observed permission + SDLParameterPermissions *testParameterPermissions = [[SDLParameterPermissions alloc] init]; + SDLHMIPermissions *testHMIPermissionsUpdated = [[SDLHMIPermissions alloc] init]; + testHMIPermissionsUpdated.allowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel LIMITED], [SDLHMILevel BACKGROUND]]]; + testHMIPermissionsUpdated.userDisallowed = [NSMutableArray arrayWithArray:@[[SDLHMILevel FULL], [SDLHMILevel NONE]]]; + + testPermissionUpdated = [[SDLPermissionItem alloc] init]; + testPermissionUpdated.rpcName = testRPCNameAllAllowed; + testPermissionUpdated.hmiPermissions = testHMIPermissionsUpdated; + testPermissionUpdated.parameterPermissions = testParameterPermissions; + + // Send the permission update + NSNotification *updatedNotification = [NSNotification notificationWithName:SDLDidChangePermissionsNotification object:nil userInfo:@{SDLNotificationUserInfoNotificationObject: @[testPermissionUpdated]}]; + [[NSNotificationCenter defaultCenter] postNotification:updatedNotification]; + }); + + it(@"should only call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should have the first status as disallowed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + }); + }); + }); + + context(@"updating an observer with a new HMI level", ^{ + __block NSInteger numberOfTimesObserverCalled = 0; + __block NSMutableArray<NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> *> *changeDicts = nil; + __block NSMutableArray<NSNumber<SDLUInt> *> *testStatuses = nil; + + context(@"to match an ANY observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + changeDicts = [NSMutableArray array]; + testStatuses = [NSMutableArray array]; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level BACKGROUND + [[NSNotificationCenter defaultCenter] postNotification:backgroundHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:changedDict]; + [testStatuses addObject:@(status)]; + }]; + + // Upgrade the HMI level to LIMITED + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + }); + + it(@"should call the observer twice", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + + it(@"should have the correct permission state for the all allowed RPC in the first change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[0][testRPCNameAllAllowed]; + expect(isAllowed).to(equal(@YES)); + }); + + it(@"should have the correct permissions for the full / limited RPC in the first change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[0][testRPCNameFullLimitedAllowed]; + expect(isAllowed).to(equal(@NO)); + }); + + it(@"should have the correct permission state for the all allowed RPC in the updated change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[1][testRPCNameAllAllowed]; + expect(isAllowed).to(equal(@YES)); + }); + + it(@"should have the correct permission state for the full / limited RPC in the updated change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[1][testRPCNameFullLimitedAllowed]; + expect(isAllowed).to(equal(@YES)); + }); + + it(@"should have the first status as mixed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusMixed))); + }); + + it(@"should have the second status as allowed", ^{ + expect(testStatuses[1]).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + }); + + context(@"to match an all allowed observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + changeDicts = [NSMutableArray array]; + testStatuses = [NSMutableArray array]; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level BACKGROUND + [[NSNotificationCenter defaultCenter] postNotification:backgroundHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + context(@"so that it becomes All Allowed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:changedDict]; + [testStatuses addObject:@(status)]; + }]; + + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + }); + + it(@"should call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + + it(@"should have the first status as disallowed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + + it(@"should have the second status as allowed", ^{ + expect(testStatuses[1]).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + }); + + context(@"so that it goes from All Allowed to at least some disallowed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameFullLimitedBackgroundAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:changedDict]; + [testStatuses addObject:@(status)]; + }]; + + [[NSNotificationCenter defaultCenter] postNotification:noneHMINotification]; + }); + + it(@"should call the observer twice", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + + it(@"should have the RPC in the first change dict", ^{ + expect(changeDicts[0].allKeys).to(contain(testRPCNameFullLimitedBackgroundAllowed)); + }); + + it(@"should have the RPC in the second change dict", ^{ + expect(changeDicts[1].allKeys).to(contain(testRPCNameFullLimitedBackgroundAllowed)); + }); + + it(@"should have the correct permissions for the RPC in the first change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[0][testRPCNameFullLimitedBackgroundAllowed]; + expect(isAllowed).to(equal(@YES)); + }); + + it(@"should have the RPC in the updated change dict", ^{ + NSNumber<SDLBool> *isAllowed = changeDicts[1][testRPCNameFullLimitedBackgroundAllowed]; + expect(isAllowed).to(equal(@NO)); + }); + + it(@"should have the first status as allowed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusAllowed))); + }); + + it(@"should have the second status as disallowed", ^{ + expect(testStatuses[1]).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + }); + }); + + context(@"to not match an all allowed observer", ^{ + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + changeDicts = [NSMutableArray array]; + testStatuses = [NSMutableArray array]; + + // Post the notification before setting the observer to make sure data is already present + // HMI Full & Limited allowed, hmi level BACKGROUND + [[NSNotificationCenter defaultCenter] postNotification:backgroundHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + context(@"that goes from disallowed to mixed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameFullLimitedAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:changedDict]; + [testStatuses addObject:@(status)]; + }]; + + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + }); + + it(@"should only call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should have the first status as disallowed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusDisallowed))); + }); + }); + + context(@"that goes from mixed to disallowed", ^{ + beforeEach(^{ + // Set an observer that should be called immediately for the preexisting data, then called again when new data is sent + [testPermissionsManager addObserverForRPCs:@[testRPCNameFullLimitedAllowed, testRPCNameFullLimitedBackgroundAllowed] groupType:SDLPermissionGroupTypeAllAllowed withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + [changeDicts addObject:changedDict]; + [testStatuses addObject:@(status)]; + }]; + + [[NSNotificationCenter defaultCenter] postNotification:noneHMINotification]; + }); + + it(@"should only call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + + it(@"should have the first status as disallowed", ^{ + expect(testStatuses[0]).to(equal(@(SDLPermissionGroupStatusMixed))); + }); + }); + }); + }); + }); + + describe(@"removing observers", ^{ + context(@"removing the only observer", ^{ + __block NSInteger numberOfTimesObserverCalled = 0; + + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + + // Add two observers + NSUUID *observerId = [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + }]; + + // Remove one observer + [testPermissionsManager removeObserverForIdentifier:observerId]; + + // Post a notification + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + it(@"should only call the observer once", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@1)); + }); + }); + + context(@"removing a single observer and leaving one remaining", ^{ + __block NSUInteger numberOfTimesObserverCalled = 0; + + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + + // Add two observers + NSUUID *testRemovedObserverId = [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + }]; + + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameFullLimitedAllowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + }]; + + // Remove one observer + [testPermissionsManager removeObserverForIdentifier:testRemovedObserverId]; + + // Post a notification + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + it(@"should call three observers", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@3)); + }); + }); + + context(@"removing all observers", ^{ + __block NSInteger numberOfTimesObserverCalled = 0; + + beforeEach(^{ + // Reset vars + numberOfTimesObserverCalled = 0; + + // Add two observers + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + }]; + + [testPermissionsManager addObserverForRPCs:@[testRPCNameAllAllowed, testRPCNameAllDisallowed] groupType:SDLPermissionGroupTypeAny withBlock:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) { + numberOfTimesObserverCalled++; + }]; + + // Remove all observers + [testPermissionsManager removeAllObservers]; + + // Add some permissions + [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; + [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; + }); + + it(@"should not call the observer", ^{ + expect(@(numberOfTimesObserverCalled)).to(equal(@2)); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m new file mode 100644 index 000000000..991a5d5c5 --- /dev/null +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m @@ -0,0 +1,111 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLError.h" +#import "SDLFile.h" +#import "SDLFileWrapper.h" +#import "SDLPutFile.h" +#import "SDLPutFileResponse.h" +#import "SDLUploadFileOperation.h" +#import "TestConnectionManager.h" + +QuickSpecBegin(SDLUploadFileOperationSpec) + +describe(@"Upload File Operation", ^{ + __block NSString *testFileName = nil; + __block NSData *testFileData = nil; + __block SDLFile *testFile = nil; + __block SDLFileWrapper *testFileWrapper = nil; + + __block TestConnectionManager *testConnectionManager = nil; + __block SDLUploadFileOperation *testOperation = nil; + + __block BOOL successResult = NO; + __block NSUInteger bytesAvailableResult = NO; + __block NSError *errorResult = nil; + + beforeEach(^{ + testFileName = @"test file"; + testFileData = [@"test1234" dataUsingEncoding:NSUTF8StringEncoding]; + testFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"]; + testFileWrapper = [SDLFileWrapper wrapperWithFile:testFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + successResult = success; + bytesAvailableResult = bytesAvailable; + errorResult = error; + }]; + + testConnectionManager = [[TestConnectionManager alloc] init]; + testOperation = [[SDLUploadFileOperation alloc] initWithFile:testFileWrapper connectionManager:testConnectionManager]; + }); + + it(@"should have a priority of 'very high'", ^{ + expect(@(testOperation.queuePriority)).to(equal(@(NSOperationQueuePriorityVeryHigh))); + }); + + describe(@"running the operation", ^{ + beforeEach(^{ + [testOperation start]; + }); + + it(@"should send a list files request", ^{ + expect(testConnectionManager.receivedRequests.lastObject).to(beAnInstanceOf([SDLPutFile class])); + }); + + context(@"when a good response comes back", ^{ + __block SDLPutFileResponse *goodResponse = nil; + __block NSNumber *responseSpaceAvailable = nil; + __block NSMutableArray *responseFileNames = nil; + + beforeEach(^{ + responseSpaceAvailable = @(11212512); + responseFileNames = [NSMutableArray arrayWithArray:@[@"test1", @"test2"]]; + + goodResponse = [[SDLPutFileResponse alloc] init]; + goodResponse.success = @YES; + goodResponse.spaceAvailable = responseSpaceAvailable; + + [testConnectionManager respondToLastRequestWithResponse:goodResponse]; + }); + + it(@"should have called the completion handler with proper data", ^{ + expect(@(successResult)).to(equal(@YES)); + expect(@(bytesAvailableResult)).to(equal(responseSpaceAvailable)); + expect(errorResult).to(beNil()); + }); + + it(@"should be set to finished", ^{ + expect(@(testOperation.finished)).to(equal(@YES)); + expect(@(testOperation.executing)).to(equal(@NO)); + }); + }); + + context(@"when a bad response comes back", ^{ + __block SDLPutFileResponse *badResponse = nil; + __block NSNumber *responseSpaceAvailable = nil; + + __block NSString *responseErrorDescription = nil; + __block NSString *responseErrorReason = nil; + + beforeEach(^{ + responseSpaceAvailable = @(0); + + responseErrorDescription = @"some description"; + responseErrorReason = @"some reason"; + + badResponse = [[SDLPutFileResponse alloc] init]; + badResponse.success = @NO; + badResponse.spaceAvailable = responseSpaceAvailable; + + [testConnectionManager respondToLastRequestWithResponse:badResponse error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]]; + }); + + it(@"should have called completion handler with error", ^{ + expect(errorResult.localizedDescription).to(match(responseErrorDescription)); + expect(errorResult.localizedFailureReason).to(match(responseErrorReason)); + expect(@(successResult)).to(equal(@NO)); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/Info.plist b/SmartDeviceLinkTests/Info.plist new file mode 100644 index 000000000..ba72822e8 --- /dev/null +++ b/SmartDeviceLinkTests/Info.plist @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> +</dict> +</plist> diff --git a/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m new file mode 100644 index 000000000..573003bc8 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m @@ -0,0 +1,29 @@ +// +// SDLProtocolHeaderSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLProtocolHeader.h" +#import "SDLV1ProtocolHeader.h" +#import "SDLV2ProtocolHeader.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLProtocolHeaderSpec) + +describe(@"HeaderForVersion Tests", ^ { + it(@"Should return the correct header", ^ { + expect([SDLProtocolHeader headerForVersion:1]).to(beAKindOf(SDLV1ProtocolHeader.class)); + expect([SDLProtocolHeader headerForVersion:2]).to(beAKindOf(SDLV2ProtocolHeader.class)); + }); + + it(@"Should return latest version for unknown version", ^ { + expect([SDLProtocolHeader headerForVersion:5]).to(raiseException().named(NSInvalidArgumentException)); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m new file mode 100644 index 000000000..ae17425ab --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m @@ -0,0 +1,89 @@ +// +// SDLV1ProtocolHeaderSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLV1ProtocolHeader.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLV1ProtocolHeaderSpec) + +__block SDLV1ProtocolHeader* testHeader; +__block NSData* testData; + +beforeSuite(^ { + //Set up test header + testHeader = [[SDLV1ProtocolHeader alloc] init]; + + testHeader.compressed = YES; + testHeader.frameType = SDLFrameType_Control; + testHeader.serviceType = SDLServiceType_RPC; + testHeader.frameData = SDLFrameData_StartSession; + testHeader.sessionID = 0x53; + testHeader.bytesInPayload = 0x1234; + + const char testBytes[8] = {0x18 | (SDLFrameType_Control & 0xFF), SDLServiceType_RPC, SDLFrameData_StartSession, 0x53, 0x00, 0x00, 0x12, 0x34}; + testData = [NSData dataWithBytes:testBytes length:8]; +}); + +describe(@"Getter/Setter Tests", ^ { + it(@"Should get readonly values correctly", ^ { + expect(@(testHeader.version)).to(equal(@1)); + expect(@(testHeader.size)).to(equal(@8)); + }); + + it(@"Should set and get correctly", ^ { + expect(@(testHeader.compressed)).to(equal(@YES)); + expect(@(testHeader.frameType)).to(equal(@(SDLFrameType_Control))); + expect(@(testHeader.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(testHeader.frameData)).to(equal(@(SDLFrameData_StartSession))); + expect(@(testHeader.sessionID)).to(equal(@0x53)); + expect(@(testHeader.bytesInPayload)).to(equal(@0x1234)); + }); +}); + +describe(@"Copy Tests", ^ { + it(@"Should copy correctly", ^ { + SDLV1ProtocolHeader* headerCopy = [testHeader copy]; + + expect(@(headerCopy.version)).to(equal(@1)); + expect(@(headerCopy.size)).to(equal(@8)); + + expect(@(headerCopy.compressed)).to(equal(@YES)); + expect(@(headerCopy.frameType)).to(equal(@(SDLFrameType_Control))); + expect(@(headerCopy.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(headerCopy.frameData)).to(equal(@(SDLFrameData_StartSession))); + expect(@(headerCopy.sessionID)).to(equal(@0x53)); + expect(@(headerCopy.bytesInPayload)).to(equal(@0x1234)); + + expect(headerCopy).toNot(beIdenticalTo(testHeader)); + }); +}); + +describe(@"Data Tests", ^ { + it (@"Should convert to byte data correctly", ^ { + expect(testHeader.data).to(equal(testData)); + }); +}); + +describe(@"RPCPayloadWithData Test", ^ { + it (@"Should convert from byte data correctly", ^ { + SDLV1ProtocolHeader* constructedHeader = [[SDLV1ProtocolHeader alloc] init]; + + [constructedHeader parse:testData]; + + expect(@(constructedHeader.compressed)).to(equal(@YES)); + expect(@(constructedHeader.frameType)).to(equal(@(SDLFrameType_Control))); + expect(@(constructedHeader.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(constructedHeader.frameData)).to(equal(@(SDLFrameData_StartSession))); + expect(@(constructedHeader.sessionID)).to(equal(@0x53)); + expect(@(constructedHeader.bytesInPayload)).to(equal(@0x1234)); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m new file mode 100644 index 000000000..1530b8cba --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m @@ -0,0 +1,93 @@ +// +// SDLV2ProtocolHeaderSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLV2ProtocolHeader.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLV2ProtocolHeaderSpec) + +__block SDLV2ProtocolHeader* testHeader; +__block NSData* testData; + +beforeSuite(^ { + //Set up test header + testHeader = [[SDLV2ProtocolHeader alloc] init]; + + testHeader.compressed = YES; + testHeader.frameType = SDLFrameType_Control; + testHeader.serviceType = SDLServiceType_RPC; + testHeader.frameData = SDLFrameData_StartSession; + testHeader.sessionID = 0x53; + testHeader.bytesInPayload = 0x1234; + testHeader.messageID = 0x6DAB424F; + + const char testBytes[12] = {0x28 | (SDLFrameType_Control & 0xFF), SDLServiceType_RPC, SDLFrameData_StartSession, 0x53, 0x00, 0x00, 0x12, 0x34, 0x6D, 0xAB, 0x42, 0x4F}; + testData = [NSData dataWithBytes:testBytes length:12]; +}); + +describe(@"Getter/Setter Tests", ^ { + it(@"Should get readonly values correctly", ^ { + expect(@(testHeader.version)).to(equal(@2)); + expect(@(testHeader.size)).to(equal(@12)); + }); + + it(@"Should set and get correctly", ^ { + expect(@(testHeader.compressed)).to(equal(@YES)); + expect(@(testHeader.frameType)).to(equal(@(SDLFrameType_Control))); + expect(@(testHeader.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(testHeader.frameData)).to(equal(@(SDLFrameData_StartSession))); + expect(@(testHeader.sessionID)).to(equal(@0x53)); + expect(@(testHeader.bytesInPayload)).to(equal(@0x1234)); + expect(@(testHeader.messageID)).to(equal(@0x6DAB424F)); + }); +}); + +describe(@"Copy Tests", ^ { + it(@"Should copy correctly", ^ { + SDLV2ProtocolHeader* headerCopy = [testHeader copy]; + + expect(@(headerCopy.version)).to(equal(@2)); + expect(@(headerCopy.size)).to(equal(@12)); + + expect(@(headerCopy.compressed)).to(equal(@YES)); + expect(@(headerCopy.frameType)).to(equal(@(SDLFrameType_Control))); + expect(@(headerCopy.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(headerCopy.frameData)).to(equal(@(SDLFrameData_StartSession))); + expect(@(headerCopy.sessionID)).to(equal(@0x53)); + expect(@(headerCopy.bytesInPayload)).to(equal(@0x1234)); + expect(@(testHeader.messageID)).to(equal(@0x6DAB424F)); + + expect(headerCopy).toNot(beIdenticalTo(testHeader)); + }); +}); + +describe(@"Data Tests", ^ { + it (@"Should convert to byte data correctly", ^ { + expect(testHeader.data).to(equal(testData)); + }); +}); + +describe(@"RPCPayloadWithData Test", ^ { + it (@"Should convert from byte data correctly", ^ { + SDLV2ProtocolHeader* constructedHeader = [[SDLV2ProtocolHeader alloc] init]; + + [constructedHeader parse:testData]; + + expect(@(constructedHeader.compressed)).to(equal(@YES)); + expect(@(constructedHeader.frameType)).to(equal(@(SDLFrameType_Control))); + expect(@(constructedHeader.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(constructedHeader.frameData)).to(equal(@(SDLFrameData_StartSession))); + expect(@(constructedHeader.sessionID)).to(equal(@0x53)); + expect(@(constructedHeader.bytesInPayload)).to(equal(@0x1234)); + expect(@(testHeader.messageID)).to(equal(@0x6DAB424F)); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m new file mode 100644 index 000000000..12b634218 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m @@ -0,0 +1,72 @@ +// +// SDLProtocolMessageSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLProtocolHeader.h" +#import "SDLProtocolMessage.h" +#import "SDLV1ProtocolHeader.h" +#import "SDLV1ProtocolMessage.h" +#import "SDLV2ProtocolHeader.h" +#import "SDLV2ProtocolMessage.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLProtocolMessageSpec) + +describe(@"MessageWithHeader Tests", ^ { + it(@"Should return an appropriate object", ^ { + NSData* testPayload = [NSData dataWithBytes:"Test Data" length:strlen("Test Data")]; + SDLV1ProtocolHeader* testHeaderV1 = [[SDLV1ProtocolHeader alloc] init]; + SDLProtocolMessage* testMessageV1 = [SDLProtocolMessage messageWithHeader:testHeaderV1 andPayload:testPayload]; + + expect(testMessageV1).to(beAKindOf(SDLV1ProtocolMessage.class)); + expect(testMessageV1.header).to(equal(testHeaderV1)); + expect(testMessageV1.payload).to(equal(testPayload)); + + SDLV2ProtocolHeader* testHeaderV2 = [[SDLV2ProtocolHeader alloc] init]; + SDLProtocolMessage* testMessageV2 = [SDLProtocolMessage messageWithHeader:testHeaderV2 andPayload:testPayload]; + + expect(testMessageV2).to(beAKindOf(SDLV2ProtocolMessage.class)); + expect(testMessageV2.header).to(equal(testHeaderV2)); + expect(testMessageV2.payload).to(equal(testPayload)); + }); +}); + +describe(@"DetermineVersion Tests", ^ { + it(@"Should return the correct version", ^ { + const char bytesV1[8] = {0x10 | SDLFrameType_First, SDLServiceType_BulkData, SDLFrameData_StartSessionACK, 0x5E, 0x00, 0x00, 0x00, 0x00}; + NSData* messageV1 = [NSData dataWithBytes:bytesV1 length:8]; + expect(@([SDLProtocolMessage determineVersion:messageV1])).to(equal(@1)); + + const char bytesV2[12] = {0x20 | SDLFrameType_First, SDLServiceType_BulkData, SDLFrameData_StartSessionACK, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44}; + NSData* messageV2 = [NSData dataWithBytes:bytesV2 length:12]; + expect(@([SDLProtocolMessage determineVersion:messageV2])).to(equal(@2)); + }); +}); + +describe(@"Data tests", ^ { + it(@"Should return the correct data", ^ { + SDLProtocolMessage* testMessage = [[SDLProtocolMessage alloc] init]; + + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + + id headerMock = OCMPartialMock(testHeader); + const char headerData[12] = {0x20 | SDLFrameType_First, SDLServiceType_BulkData, SDLFrameData_StartSessionACK, 0x5E, 0x0E, 0x00, 0x00, strlen("Test Data"), 0x65, 0x22, 0x41, 0x38}; + [[[headerMock stub] andReturn:[NSData dataWithBytes:headerData length:12]] data]; + + testMessage.header = testHeader; + testMessage.payload = [NSData dataWithBytes:"Test Data" length:strlen("Test Data")]; + + NSMutableData* testData = [NSMutableData dataWithBytes:headerData length:12]; + [testData appendBytes:"Test Data" length:strlen("Test Data")]; + expect(testMessage.data).to(equal([testData copy])); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m new file mode 100644 index 000000000..373575a4d --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m @@ -0,0 +1,511 @@ +// +// SDLProtocolSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLAbstractTransport.h" +#import "SDLProtocolHeader.h" +#import "SDLProtocol.h" +#import "SDLProtocolMessage.h" +#import "SDLProtocolReceivedMessageRouter.h" +#import "SDLRPCRequest.h" +#import "SDLNames.h" +#import "SDLV1ProtocolMessage.h" +#import "SDLV2ProtocolMessage.h" +#import "SDLV1ProtocolHeader.h" +#import "SDLV2ProtocolHeader.h" + + +QuickSpecBegin(SDLProtocolSpec) + +//Test dictionaries +NSDictionary* dictionaryV1 = @{NAMES_request: + @{NAMES_operation_name:@"DeleteCommand", + NAMES_correlationID:@0x98765, + NAMES_parameters: + @{NAMES_cmdID:@55}}}; +NSDictionary* dictionaryV2 = @{NAMES_cmdID:@55}; + +describe(@"SendStartSession Tests", ^ { + it(@"Should send the correct data", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + const char testHeader[8] = {0x10 | SDLFrameType_Control, SDLServiceType_BulkData, SDLFrameData_StartSession, 0x00, 0x00, 0x00, 0x00, 0x00}; + expect(dataSent).to(equal([NSData dataWithBytes:testHeader length:8])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + + [testProtocol sendStartSessionWithType:SDLServiceType_BulkData]; + + expect(@(verified)).toEventually(beTruthy()); + }); +}); + +describe(@"SendEndSession Tests", ^ { + context(@"During V1 session", ^ { + it(@"Should send the correct data", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0x03 version:0x01]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + const char testHeader[8] = {0x10 | SDLFrameType_Control, SDLServiceType_RPC, SDLFrameData_EndSession, 0x03, 0x00, 0x00, 0x00, 0x00}; + expect(dataSent).to(equal([NSData dataWithBytes:testHeader length:8])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + + [testProtocol sendEndSessionWithType:SDLServiceType_RPC]; + + expect(@(verified)).toEventually(beTruthy()); + }); + }); + + context(@"During V2 session", ^ { + it(@"Should send the correct data", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0x61 version:0x02]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + const char testHeader[12] = {0x20 | SDLFrameType_Control, SDLServiceType_RPC, SDLFrameData_EndSession, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + expect(dataSent).to(equal([NSData dataWithBytes:testHeader length:12])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + + [testProtocol sendEndSessionWithType:SDLServiceType_RPC]; + + expect(@(verified)).toEventually(beTruthy()); + }); + }); +}); + +describe(@"SendRPCRequest Tests", ^ { + __block id mockRequest; + beforeEach(^ { + mockRequest = OCMPartialMock([[SDLRPCRequest alloc] init]); + }); + + context(@"During V1 session", ^ { + it(@"Should send the correct data", ^ { + [[[[mockRequest stub] andReturn:dictionaryV1] ignoringNonObjectArgs] serializeAsDictionary:1]; + + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0xFF version:0x01]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + NSData* jsonTestData = [NSJSONSerialization dataWithJSONObject:dictionaryV1 options:0 error:0]; + NSUInteger dataLength = jsonTestData.length; + + const char testHeader[8] = {0x10 | SDLFrameType_Single, SDLServiceType_RPC, SDLFrameData_SingleFrame, 0xFF, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + NSMutableData* testData = [NSMutableData dataWithBytes:testHeader length:8]; + [testData appendData:jsonTestData]; + + expect(dataSent).to(equal([testData copy])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + + [testProtocol sendRPC:mockRequest]; + + expect(@(verified)).toEventually(beTruthy()); + }); + }); + + context(@"During V2 session", ^ { + it(@"Should send the correct data bulk data when bulk data is available", ^ { + [[[[mockRequest stub] andReturn:dictionaryV2] ignoringNonObjectArgs] serializeAsDictionary:2]; + [[[mockRequest stub] andReturn:@0x98765] correlationID]; + [[[mockRequest stub] andReturn:@"DeleteCommand"] getFunctionName]; + [[[mockRequest stub] andReturn:[NSData dataWithBytes:"COMMAND" length:strlen("COMMAND")]] bulkData]; + + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0x01 version:0x02]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + NSData* jsonTestData = [NSJSONSerialization dataWithJSONObject:dictionaryV2 options:0 error:0]; + NSUInteger dataLength = jsonTestData.length; + + const char testPayloadHeader[12] = {0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x87, 0x65, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + + NSMutableData* payloadData = [NSMutableData dataWithBytes:testPayloadHeader length:12]; + [payloadData appendData:jsonTestData]; + [payloadData appendBytes:"COMMAND" length:strlen("COMMAND")]; + + const char testHeader[12] = {0x20 | SDLFrameType_Single, SDLServiceType_BulkData, SDLFrameData_SingleFrame, 0x01, (payloadData.length >> 24) & 0xFF, (payloadData.length >> 16) & 0xFF,(payloadData.length >> 8) & 0xFF, payloadData.length & 0xFF, 0x00, 0x00, 0x00, 0x01}; + + NSMutableData* testData = [NSMutableData dataWithBytes:testHeader length:12]; + [testData appendData:payloadData]; + + expect(dataSent).to(equal([testData copy])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + + [testProtocol sendRPC:mockRequest]; + + expect(@(verified)).toEventually(beTruthy()); + }); + }); +}); + +describe(@"HandleBytesFromTransport Tests", ^ { + context(@"During V1 session", ^ { + it(@"Should parse the data correctly", ^ { + id routerMock = OCMClassMock(SDLProtocolReceivedMessageRouter.class); + + //Override initialization methods so that our protocol will use our object instead + [[[routerMock stub] andReturn:routerMock] alloc]; + (void)[[[routerMock stub] andReturn:routerMock] init]; + + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0x43 version:0x01]; + + NSData* jsonTestData = [NSJSONSerialization dataWithJSONObject:dictionaryV1 options:0 error:0]; + NSUInteger dataLength = jsonTestData.length; + + __block BOOL verified = NO; + [[[routerMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained SDLV1ProtocolMessage* message; + [invocation getArgument:&message atIndex:2]; + + SDLV1ProtocolMessage* messageReceived = message; + + expect(messageReceived.payload).to(equal(jsonTestData)); + expect(@(messageReceived.header.version)).to(equal(@1)); + expect(@(messageReceived.header.compressed)).to(equal(@NO)); + expect(@(messageReceived.header.frameType)).to(equal(@(SDLFrameType_Single))); + expect(@(messageReceived.header.sessionID)).to(equal(@0xFF)); + expect(@(messageReceived.header.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(messageReceived.header.frameData)).to(equal(@(SDLFrameData_SingleFrame))); + expect(@(messageReceived.header.bytesInPayload)).to(equal(@(dataLength))); + }] handleReceivedMessage:[OCMArg any]]; + + const char testHeader[8] = {0x10 | SDLFrameType_Single, SDLServiceType_RPC, SDLFrameData_SingleFrame, 0xFF, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + NSMutableData* testData = [NSMutableData dataWithBytes:testHeader length:8]; + [testData appendData:jsonTestData]; + + [testProtocol handleBytesFromTransport:testData]; + + expect(@(verified)).toEventually(beTruthy()); + }); + }); + + context(@"During V2 session", ^ { + it(@"Should parse the data correctly", ^ { + id routerMock = OCMClassMock(SDLProtocolReceivedMessageRouter.class); + + //Override initialization methods so that our protocol will use our object instead + [[[routerMock stub] andReturn:routerMock] alloc]; + (void)[[[routerMock stub] andReturn:routerMock] init]; + + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0xF5 version:0x02]; + + NSData* jsonTestData = [NSJSONSerialization dataWithJSONObject:dictionaryV2 options:0 error:0]; + NSUInteger dataLength = jsonTestData.length; + + const char testPayloadHeader[12] = {0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x87, 0x65, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + + NSMutableData* payloadData = [NSMutableData dataWithBytes:testPayloadHeader length:12]; + [payloadData appendData:jsonTestData]; + [payloadData appendBytes:"COMMAND" length:strlen("COMMAND")]; + + __block BOOL verified = NO; + [[[routerMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained SDLV2ProtocolMessage* message; + [invocation getArgument:&message atIndex:2]; + + SDLV2ProtocolMessage* messageReceived = message; + + expect(messageReceived.payload).to(equal(payloadData)); + expect(@(messageReceived.header.version)).to(equal(@2)); + expect(@(messageReceived.header.compressed)).to(equal(@NO)); + expect(@(messageReceived.header.frameType)).to(equal(@(SDLFrameType_Single))); + expect(@(messageReceived.header.sessionID)).to(equal(@0x01)); + expect(@(messageReceived.header.serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(messageReceived.header.frameData)).to(equal(@(SDLFrameData_SingleFrame))); + expect(@(messageReceived.header.bytesInPayload)).to(equal(@(payloadData.length))); + expect(@(((SDLV2ProtocolHeader*)messageReceived.header).messageID)).to(equal(@1)); + + }] handleReceivedMessage:[OCMArg any]]; + testProtocol.transport = routerMock; + + const char testHeader[12] = {0x20 | SDLFrameType_Single, SDLServiceType_RPC, SDLFrameData_SingleFrame, 0x01, (payloadData.length >> 24) & 0xFF, (payloadData.length >> 16) & 0xFF, + (payloadData.length >> 8) & 0xFF, payloadData.length & 0xFF, 0x00, 0x00, 0x00, 0x01}; + + NSMutableData* testData = [NSMutableData dataWithBytes:testHeader length:12]; + [testData appendData:payloadData]; + + [testProtocol handleBytesFromTransport:testData]; + + expect(@(verified)).toEventually(beTruthy()); + }); + }); +}); + +describe(@"SendHeartbeat Tests", ^ { + context(@"During V1 session", ^ { + it(@"Should send the correct data", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0x43 version:0x01]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + const char testHeader[8] = {0x10 | SDLFrameType_Control, 0x00, SDLFrameData_Heartbeat, 0x43, 0x00, 0x00, 0x00, 0x00}; + expect(dataSent).to(equal([NSData dataWithBytes:testHeader length:8])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [testProtocol sendHeartbeat]; +#pragma clang diagnostic pop + + expect(@(verified)).toEventually(beTruthy()); + }); + }); + + context(@"During V2 session", ^ { + it(@"Should send the correct data", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + [testProtocol handleProtocolStartSessionACK:SDLServiceType_RPC sessionID:0xF5 version:0x02]; + + __block BOOL verified = NO; + id transportMock = OCMClassMock([SDLAbstractTransport class]); + [[[transportMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSData* data; + [invocation getArgument:&data atIndex:2]; + NSData* dataSent = [data copy]; + + const char testHeader[12] = {0x20 | SDLFrameType_Control, 0x00, SDLFrameData_Heartbeat, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + expect(dataSent).to(equal([NSData dataWithBytes:testHeader length:12])); + }] sendData:[OCMArg any]]; + testProtocol.transport = transportMock; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [testProtocol sendHeartbeat]; +#pragma clang diagnostic pop + + expect(@(verified)).toEventually(beTruthy()); + }); + }); +}); + +describe(@"HandleProtocolSessionStarted Tests", ^ { + it(@"Should pass information along to delegate", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + Byte serviceType; + Byte sessionID; + Byte version; + + [invocation getArgument:&serviceType atIndex:2]; + [invocation getArgument:&sessionID atIndex:3]; + [invocation getArgument:&version atIndex:4]; + + expect(@(serviceType)).to(equal(@(SDLServiceType_BulkData))); + expect(@(sessionID)).to(equal(@0x44)); + expect(@(version)).to(equal(@0x03)); + }] ignoringNonObjectArgs] handleProtocolStartSessionACK:0 sessionID:0 version:0]; + + [testProtocol.protocolDelegateTable addObject:delegateMock]; + + [testProtocol handleProtocolStartSessionACK:SDLServiceType_BulkData sessionID:0x44 version:0x03]; + + expect(@(verified)).to(beTruthy()); + }); +}); + +describe(@"HandleHeartbeatForSession Tests", ^{ + // TODO: Test automatically sending data to head unit (dependency injection?) + it(@"Should pass information along to delegate", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + Byte sessionID; + + [invocation getArgument:&sessionID atIndex:2]; + + expect(@(sessionID)).to(equal(@0x44)); + }] ignoringNonObjectArgs] handleHeartbeatForSession:0]; + + [testProtocol.protocolDelegateTable addObject:delegateMock]; + + [testProtocol handleHeartbeatForSession:0x44]; + + expect(@(verified)).to(beTruthy()); + }); +}); + +describe(@"OnProtocolMessageReceived Tests", ^ { + it(@"Should pass information along to delegate", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + SDLProtocolMessage* testMessage = [[SDLProtocolMessage alloc] init]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained SDLProtocolMessage* message; + + [invocation getArgument:&message atIndex:2]; + + expect(message).to(beIdenticalTo(testMessage)); + }] ignoringNonObjectArgs] onProtocolMessageReceived:[OCMArg any]]; + + [testProtocol.protocolDelegateTable addObject:delegateMock]; + + [testProtocol onProtocolMessageReceived:testMessage]; + + expect(@(verified)).toEventually(beTruthy()); + }); +}); + +describe(@"OnProtocolOpened Tests", ^ { + it(@"Should pass information along to delegate", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + }] onProtocolOpened]; + + [testProtocol.protocolDelegateTable addObject:delegateMock]; + + [testProtocol onProtocolOpened]; + + expect(@(verified)).toEventually(beTruthy()); + }); +}); + +describe(@"OnProtocolClosed Tests", ^ { + it(@"Should pass information along to delegate", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + }] onProtocolClosed]; + + [testProtocol.protocolDelegateTable addObject:delegateMock]; + + [testProtocol onProtocolClosed]; + + expect(@(verified)).toEventually(beTruthy()); + }); +}); + +describe(@"OnError Tests", ^ { + it(@"Should pass information along to delegate", ^ { + SDLProtocol* testProtocol = [[SDLProtocol alloc] init]; + + NSException* testException = [[NSException alloc] initWithName:@"Name" reason:@"No Reason" userInfo:@{}]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained NSString* message; + __unsafe_unretained NSException* exception; + + [invocation getArgument:&message atIndex:2]; + [invocation getArgument:&exception atIndex:3]; + + expect(message).to(equal(@"Nothing actually happened")); + expect(exception).to(equal(testException)); + }] onError:[OCMArg any] exception:[OCMArg any]]; + + [testProtocol.protocolDelegateTable addObject:delegateMock]; + + [testProtocol onError:@"Nothing actually happened" exception:testException]; + + expect(@(verified)).toEventually(beTruthy()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m new file mode 100644 index 000000000..0a40b94f3 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m @@ -0,0 +1,32 @@ +// +// SDLV1ProtocolMessageSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLV1ProtocolMessage.h" +#import "SDLV1ProtocolHeader.h" + + +QuickSpecBegin(SDLV1ProtocolMessageSpec) + +describe(@"RPCDictionary Tests", ^ { + it(@"Should return the correct dictionary", ^ { + SDLV1ProtocolHeader* testHeader = [[SDLV1ProtocolHeader alloc] init]; + NSDictionary* testDictionary = @{@"Oyster": @"Soup", + @"Soup": @"Kitchen", + @"Kitchen": @"Floor", + @"Floor": @"Wax", + @"Wax": @"Museum"}; + SDLV1ProtocolMessage* testMessage = [[SDLV1ProtocolMessage alloc] initWithHeader:testHeader andPayload:[NSJSONSerialization dataWithJSONObject:testDictionary options:0 error:0]]; + + expect([testMessage rpcDictionary]).to(equal(testDictionary)); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m new file mode 100644 index 000000000..84a053004 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m @@ -0,0 +1,57 @@ +// +// SDLV2ProtocolMessageSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLV2ProtocolMessage.h" +#import "SDLV2ProtocolHeader.h" +#import "SDLRPCPayload.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLV2ProtocolMessageSpec) + +describe(@"RPCDictionary Tests", ^ { + it(@"Should return the correct dictionary", ^ { + SDLServiceType serviceType = SDLServiceType_RPC; + + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + id headerMock = OCMPartialMock(testHeader); + [[[headerMock stub] andReturnValue:[NSValue value:&serviceType withObjCType:@encode(SDLServiceType)]] serviceType]; + + NSDictionary* dictionary = @{@"A": @1, + @"B": @2, + @"C": @3, + @"D": @4, + @"E": @5}; + UInt32 correlationID = 99; + UInt32 functionID = 26; + Byte rpcType = 0; + + SDLRPCPayload* testPayload = [[SDLRPCPayload alloc] init]; + id payloadMock = OCMPartialMock(testPayload); + [[[payloadMock stub] andReturn:[NSJSONSerialization dataWithJSONObject:dictionary options:0 error:0]] jsonData]; + [[[payloadMock stub] andReturnValue:[NSValue value:&correlationID withObjCType:@encode(UInt32)]] correlationID]; + [[[payloadMock stub] andReturnValue:[NSValue value:&functionID withObjCType:@encode(UInt32)]] functionID]; + [[[payloadMock stub] andReturnValue:[NSValue value:&rpcType withObjCType:@encode(Byte)]] rpcType]; + [[[payloadMock stub] andReturn:[NSData dataWithBytes:"Database" length:strlen("Database")]] binaryData]; + + id payloadClassMock = OCMClassMock(SDLRPCPayload.class); + [[[payloadClassMock stub] andReturn:testPayload] rpcPayloadWithData:[OCMArg any]]; + + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testHeader andPayload:[[NSMutableData alloc] initWithCapacity:0]]; + + expect([testMessage rpcDictionary]).to(equal(@{NAMES_request: + @{NAMES_operation_name:NAMES_Slider, + NAMES_correlationID:@99, + NAMES_parameters:dictionary}, + NAMES_bulkData:[NSData dataWithBytes:"Database" length:strlen("Database")]})); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m new file mode 100644 index 000000000..c393e2f7e --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m @@ -0,0 +1,57 @@ +// +// SDLAbstractProtocolSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLAbstractProtocol.h" +#import "SDLProtocolListener.h" + +QuickSpecBegin(SDLAbstractProtocolSpec) + +describe(@"OnTransportConnected Tests", ^ { + it(@"Should invoke the correct method", ^ { + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + SDLAbstractProtocol* abstractProtocol = [[SDLAbstractProtocol alloc] init]; + [abstractProtocol.protocolDelegateTable addObject:delegateMock]; + + __block BOOL verified = NO; + [[[delegateMock stub] andDo:^(NSInvocation* invocation) {verified = YES;}] onProtocolOpened]; + + [abstractProtocol onTransportConnected]; + + //Verifications don't work with Nimble at this point + //OCMVerify([delegateMock onProtocolOpened]); + + //Workaround for now + expect(@(verified)).to(beTruthy()); + }); +}); + +describe(@"OnTransportDisconnected Tests", ^ { + it(@"Should invoke the correct method", ^ { + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + SDLAbstractProtocol* abstractProtocol = [[SDLAbstractProtocol alloc] init]; + [abstractProtocol.protocolDelegateTable addObject:delegateMock]; + + __block BOOL verified = NO; + [[[delegateMock stub] andDo:^(NSInvocation* invocation) {verified = YES;}] onProtocolClosed]; + + [abstractProtocol onTransportDisconnected]; + + //Verifications don't work with Nimble at this point + //OCMVerify([delegateMock onProtocolClosed]); + + //Workaround for now + expect(@(verified)).to(beTruthy()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m new file mode 100644 index 000000000..eff1ae3b2 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m @@ -0,0 +1,152 @@ +// +// FunctionIDSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFunctionID.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLFunctionIDSpec) + +SDLFunctionID* functionID = [[SDLFunctionID alloc] init]; + +describe(@"GetFunctionName Tests", ^ { + it(@"Should return the correct function name", ^ { + expect([functionID getFunctionName:1]).to(equal(NAMES_RegisterAppInterface)); + expect([functionID getFunctionName:2]).to(equal(NAMES_UnregisterAppInterface)); + expect([functionID getFunctionName:3]).to(equal(NAMES_SetGlobalProperties)); + expect([functionID getFunctionName:4]).to(equal(NAMES_ResetGlobalProperties)); + expect([functionID getFunctionName:5]).to(equal(NAMES_AddCommand)); + expect([functionID getFunctionName:6]).to(equal(NAMES_DeleteCommand)); + expect([functionID getFunctionName:7]).to(equal(NAMES_AddSubMenu)); + expect([functionID getFunctionName:8]).to(equal(NAMES_DeleteSubMenu)); + expect([functionID getFunctionName:9]).to(equal(NAMES_CreateInteractionChoiceSet)); + expect([functionID getFunctionName:10]).to(equal(NAMES_PerformInteraction)); + expect([functionID getFunctionName:11]).to(equal(NAMES_DeleteInteractionChoiceSet)); + expect([functionID getFunctionName:12]).to(equal(NAMES_Alert)); + expect([functionID getFunctionName:13]).to(equal(NAMES_Show)); + expect([functionID getFunctionName:14]).to(equal(NAMES_Speak)); + expect([functionID getFunctionName:15]).to(equal(NAMES_SetMediaClockTimer)); + expect([functionID getFunctionName:16]).to(equal(NAMES_PerformAudioPassThru)); + expect([functionID getFunctionName:17]).to(equal(NAMES_EndAudioPassThru)); + expect([functionID getFunctionName:18]).to(equal(NAMES_SubscribeButton)); + expect([functionID getFunctionName:19]).to(equal(NAMES_UnsubscribeButton)); + expect([functionID getFunctionName:20]).to(equal(NAMES_SubscribeVehicleData)); + expect([functionID getFunctionName:21]).to(equal(NAMES_UnsubscribeVehicleData)); + expect([functionID getFunctionName:22]).to(equal(NAMES_GetVehicleData)); + expect([functionID getFunctionName:23]).to(equal(NAMES_ReadDID)); + expect([functionID getFunctionName:24]).to(equal(NAMES_GetDTCs)); + expect([functionID getFunctionName:25]).to(equal(NAMES_ScrollableMessage)); + expect([functionID getFunctionName:26]).to(equal(NAMES_Slider)); + expect([functionID getFunctionName:27]).to(equal(NAMES_ShowConstantTBT)); + expect([functionID getFunctionName:28]).to(equal(NAMES_AlertManeuver)); + expect([functionID getFunctionName:29]).to(equal(NAMES_UpdateTurnList)); + expect([functionID getFunctionName:30]).to(equal(NAMES_ChangeRegistration)); + expect([functionID getFunctionName:31]).to(equal(NAMES_GenericResponse)); + expect([functionID getFunctionName:32]).to(equal(NAMES_PutFile)); + expect([functionID getFunctionName:33]).to(equal(NAMES_DeleteFile)); + expect([functionID getFunctionName:34]).to(equal(NAMES_ListFiles)); + expect([functionID getFunctionName:35]).to(equal(NAMES_SetAppIcon)); + expect([functionID getFunctionName:36]).to(equal(NAMES_SetDisplayLayout)); + expect([functionID getFunctionName:37]).to(equal(NAMES_DiagnosticMessage)); + expect([functionID getFunctionName:38]).to(equal(NAMES_SystemRequest)); + expect([functionID getFunctionName:39]).to(equal(NAMES_SendLocation)); + expect([functionID getFunctionName:40]).to(equal(NAMES_DialNumber)); + expect([functionID getFunctionName:32768]).to(equal(NAMES_OnHMIStatus)); + expect([functionID getFunctionName:32769]).to(equal(NAMES_OnAppInterfaceUnregistered)); + expect([functionID getFunctionName:32770]).to(equal(NAMES_OnButtonEvent)); + expect([functionID getFunctionName:32771]).to(equal(NAMES_OnButtonPress)); + expect([functionID getFunctionName:32772]).to(equal(NAMES_OnVehicleData)); + expect([functionID getFunctionName:32773]).to(equal(NAMES_OnCommand)); + expect([functionID getFunctionName:32774]).to(equal(NAMES_OnTBTClientState)); + expect([functionID getFunctionName:32775]).to(equal(NAMES_OnDriverDistraction)); + expect([functionID getFunctionName:32776]).to(equal(NAMES_OnPermissionsChange)); + expect([functionID getFunctionName:32777]).to(equal(NAMES_OnAudioPassThru)); + expect([functionID getFunctionName:32778]).to(equal(NAMES_OnLanguageChange)); + expect([functionID getFunctionName:32779]).to(equal(NAMES_OnKeyboardInput)); + expect([functionID getFunctionName:32780]).to(equal(NAMES_OnTouchEvent)); + expect([functionID getFunctionName:32781]).to(equal(NAMES_OnSystemRequest)); + expect([functionID getFunctionName:32782]).to(equal(NAMES_OnHashChange)); + + //Not listed in Spec + expect([functionID getFunctionName:65536]).to(equal(NAMES_EncodedSyncPData)); + expect([functionID getFunctionName:65537]).to(equal(NAMES_SyncPData)); + + expect([functionID getFunctionName:98304]).to(equal(NAMES_OnEncodedSyncPData)); + expect([functionID getFunctionName:98305]).to(equal(NAMES_OnSyncPData)); + }); +}); + +describe(@"GetFunctionID Tests", ^ { + it(@"Should return the correct function ID", ^ { + expect([functionID getFunctionID:NAMES_RegisterAppInterface]).to(equal(@1)); + expect([functionID getFunctionID:NAMES_UnregisterAppInterface]).to(equal(@2)); + expect([functionID getFunctionID:NAMES_SetGlobalProperties]).to(equal(@3)); + expect([functionID getFunctionID:NAMES_ResetGlobalProperties]).to(equal(@4)); + expect([functionID getFunctionID:NAMES_AddCommand]).to(equal(@5)); + expect([functionID getFunctionID:NAMES_DeleteCommand]).to(equal(@6)); + expect([functionID getFunctionID:NAMES_AddSubMenu]).to(equal(@7)); + expect([functionID getFunctionID:NAMES_DeleteSubMenu]).to(equal(@8)); + expect([functionID getFunctionID:NAMES_CreateInteractionChoiceSet]).to(equal(@9)); + expect([functionID getFunctionID:NAMES_PerformInteraction]).to(equal(@10)); + expect([functionID getFunctionID:NAMES_DeleteInteractionChoiceSet]).to(equal(@11)); + expect([functionID getFunctionID:NAMES_Alert]).to(equal(@12)); + expect([functionID getFunctionID:NAMES_Show]).to(equal(@13)); + expect([functionID getFunctionID:NAMES_Speak]).to(equal(@14)); + expect([functionID getFunctionID:NAMES_SetMediaClockTimer]).to(equal(@15)); + expect([functionID getFunctionID:NAMES_PerformAudioPassThru]).to(equal(@16)); + expect([functionID getFunctionID:NAMES_EndAudioPassThru]).to(equal(@17)); + expect([functionID getFunctionID:NAMES_SubscribeButton]).to(equal(@18)); + expect([functionID getFunctionID:NAMES_UnsubscribeButton]).to(equal(@19)); + expect([functionID getFunctionID:NAMES_SubscribeVehicleData]).to(equal(@20)); + expect([functionID getFunctionID:NAMES_UnsubscribeVehicleData]).to(equal(@21)); + expect([functionID getFunctionID:NAMES_GetVehicleData]).to(equal(@22)); + expect([functionID getFunctionID:NAMES_ReadDID]).to(equal(@23)); + expect([functionID getFunctionID:NAMES_GetDTCs]).to(equal(@24)); + expect([functionID getFunctionID:NAMES_ScrollableMessage]).to(equal(@25)); + expect([functionID getFunctionID:NAMES_Slider]).to(equal(@26)); + expect([functionID getFunctionID:NAMES_ShowConstantTBT]).to(equal(@27)); + expect([functionID getFunctionID:NAMES_AlertManeuver]).to(equal(@28)); + expect([functionID getFunctionID:NAMES_UpdateTurnList]).to(equal(@29)); + expect([functionID getFunctionID:NAMES_ChangeRegistration]).to(equal(@30)); + expect([functionID getFunctionID:NAMES_GenericResponse]).to(equal(@31)); + expect([functionID getFunctionID:NAMES_PutFile]).to(equal(@32)); + expect([functionID getFunctionID:NAMES_DeleteFile]).to(equal(@33)); + expect([functionID getFunctionID:NAMES_ListFiles]).to(equal(@34)); + expect([functionID getFunctionID:NAMES_SetAppIcon]).to(equal(@35)); + expect([functionID getFunctionID:NAMES_SetDisplayLayout]).to(equal(@36)); + expect([functionID getFunctionID:NAMES_DiagnosticMessage]).to(equal(@37)); + expect([functionID getFunctionID:NAMES_SystemRequest]).to(equal(@38)); + expect([functionID getFunctionID:NAMES_SendLocation]).to(equal(@39)); + expect([functionID getFunctionID:NAMES_DialNumber]).to(equal(@40)); + expect([functionID getFunctionID:NAMES_OnHMIStatus]).to(equal(@32768)); + expect([functionID getFunctionID:NAMES_OnAppInterfaceUnregistered]).to(equal(@32769)); + expect([functionID getFunctionID:NAMES_OnButtonEvent]).to(equal(@32770)); + expect([functionID getFunctionID:NAMES_OnButtonPress]).to(equal(@32771)); + expect([functionID getFunctionID:NAMES_OnVehicleData]).to(equal(@32772)); + expect([functionID getFunctionID:NAMES_OnCommand]).to(equal(@32773)); + expect([functionID getFunctionID:NAMES_OnTBTClientState]).to(equal(@32774)); + expect([functionID getFunctionID:NAMES_OnDriverDistraction]).to(equal(@32775)); + expect([functionID getFunctionID:NAMES_OnPermissionsChange]).to(equal(@32776)); + expect([functionID getFunctionID:NAMES_OnAudioPassThru]).to(equal(@32777)); + expect([functionID getFunctionID:NAMES_OnLanguageChange]).to(equal(@32778)); + expect([functionID getFunctionID:NAMES_OnKeyboardInput]).to(equal(@32779)); + expect([functionID getFunctionID:NAMES_OnTouchEvent]).to(equal(@32780)); + expect([functionID getFunctionID:NAMES_OnSystemRequest]).to(equal(@32781)); + expect([functionID getFunctionID:NAMES_OnHashChange]).to(equal(@32782)); + + //Not listed in Spec + expect([functionID getFunctionID:NAMES_EncodedSyncPData]).to(equal(@65536)); + expect([functionID getFunctionID:NAMES_SyncPData]).to(equal(@65537)); + + expect([functionID getFunctionID:NAMES_OnEncodedSyncPData]).to(equal(@98304)); + expect([functionID getFunctionID:NAMES_OnSyncPData]).to(equal(@98305)); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m new file mode 100644 index 000000000..d31a6e061 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m @@ -0,0 +1,100 @@ +// +// SDLProtocolMessageAssemblerSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLProtocolMessageAssembler.h" +#import "SDLV2ProtocolHeader.h" +#import "SDLV2ProtocolMessage.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLProtocolMessageAssemblerSpec) + +describe(@"HandleMessage Tests", ^ { + it(@"Should assemble the message properly", ^ { + const NSUInteger dataLength = 2000; + + char dummyBytes[dataLength]; + + const char testPayloadHeader[12] = {0x20, 0x55, 0x64, 0x73, 0x12, 0x34, 0x43, 0x21, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + + NSMutableData* payloadData = [NSMutableData dataWithBytes:testPayloadHeader length:12]; + [payloadData appendBytes:dummyBytes length:dataLength]; + + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] init]; + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + + //First frame + testHeader.frameType = SDLFrameType_First; + testHeader.serviceType = SDLServiceType_BulkData; + testHeader.frameData = 1; + testHeader.sessionID = 0x16; + testHeader.bytesInPayload = 8; + + testMessage.header = testHeader; + + const char firstPayload[8] = {(payloadData.length >> 24) & 0xFF, (payloadData.length >> 16) & 0xFF, (payloadData.length >> 8) & 0xFF, payloadData.length & 0xFF, 0x00, 0x00, 0x00, ceil(payloadData.length / 500.0)}; + testMessage.payload = [NSData dataWithBytes:firstPayload length:8]; + + SDLProtocolMessageAssembler* assembler = [[SDLProtocolMessageAssembler alloc] initWithSessionID:0x16]; + + __block BOOL verified = NO; + + SDLMessageAssemblyCompletionHandler incompleteHandler = ^void(BOOL done, SDLProtocolMessage* assembledMessage) { + verified = YES; + + expect(@(done)).to(equal(@NO)); + expect(assembledMessage).to(beNil()); + }; + + [assembler handleMessage:testMessage withCompletionHandler:incompleteHandler]; + + expect(@(verified)).to(beTruthy()); + verified = NO; + + testMessage.header.frameType = SDLFrameType_Consecutive; + testMessage.header.bytesInPayload = 500; + + NSUInteger frameNumber = 1; + NSUInteger offset = 0; + while ((offset + 500) < payloadData.length) { + //Consecutive frames + testMessage.header.frameData = frameNumber; + testMessage.payload = [payloadData subdataWithRange:NSMakeRange(offset, 500)]; + [assembler handleMessage:testMessage withCompletionHandler:incompleteHandler]; + + expect(@(verified)).to(beTruthy()); + verified = NO; + + frameNumber++; + offset += 500; + } + + //Final frame + testMessage.header.frameData = 0; + testMessage.payload = [payloadData subdataWithRange:NSMakeRange(offset, payloadData.length - offset)]; + [assembler handleMessage:testMessage withCompletionHandler: ^void(BOOL done, SDLProtocolMessage* assembledMessage) { + verified = YES; + + // FIXME: At the moment, this test fails because the completion handler is accidentally called twice + expect(@(done)).to(equal(@YES)); + + expect(assembledMessage.payload).to(equal(payloadData)); + expect(@(assembledMessage.header.frameType)).to(equal(@(SDLFrameType_Single))); + expect(@(assembledMessage.header.serviceType)).to(equal(@(SDLServiceType_BulkData))); + expect(@(assembledMessage.header.frameData)).to(equal(@(SDLFrameData_SingleFrame))); + expect(@(assembledMessage.header.sessionID)).to(equal(@0x16)); + expect(@(assembledMessage.header.bytesInPayload)).to(equal(@(payloadData.length))); + }]; + + expect(@(verified)).to(beTruthy()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m new file mode 100644 index 000000000..04fb30c5e --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m @@ -0,0 +1,95 @@ +// +// SDLProtocolMessageDisassemblerSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLGlobals.h" +#import "SDLProtocolMessageDisassembler.h" +#import "SDLV2ProtocolHeader.h" +#import "SDLV2ProtocolMessage.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLProtocolMessageDisassemblerSpec) + +describe(@"Disassemble Tests", ^ { + it(@"Should assemble the message properly", ^ { + //Allocate 2000 bytes, and use it as sample data + const NSUInteger dataLength = 2000; + char dummyBytes[dataLength]; + + SDLGlobals *globals = [[SDLGlobals alloc] init]; + globals.maxHeadUnitVersion = 2; + + const char testPayloadHeader[12] = {0x20, 0x55, 0x64, 0x73, 0x12, 0x34, 0x43, 0x21, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + + NSMutableData* payloadData = [NSMutableData dataWithBytes:testPayloadHeader length:12]; + [payloadData appendBytes:dummyBytes length:dataLength]; + + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] init]; + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + + testHeader.frameType = SDLFrameType_Single; + testHeader.serviceType = SDLServiceType_BulkData; + testHeader.frameData = SDLFrameData_SingleFrame; + testHeader.sessionID = 0x84; + testHeader.bytesInPayload = (UInt32)payloadData.length; + + testMessage.header = testHeader; + testMessage.payload = payloadData; + + NSArray* messageList = [SDLProtocolMessageDisassembler disassemble:testMessage withLimit:globals.maxMTUSize]; + + //Payload length per message + UInt32 payloadLength = 1012; // v1/2 MTU(1024) - header length(12) + + const char firstPayload[8] = {(payloadData.length >> 24) & 0xFF, (payloadData.length >> 16) & 0xFF, (payloadData.length >> 8) & 0xFF, payloadData.length & 0xFF, 0x00, 0x00, 0x00, ceil(1.0 * payloadData.length / payloadLength)}; + + SDLProtocolMessage* message = messageList[0]; + + //First frame + expect(message.payload).to(equal([NSData dataWithBytes:firstPayload length:8])); + + expect(@(message.header.frameType)).to(equal(@(SDLFrameType_First))); + expect(@(message.header.serviceType)).to(equal(@(SDLServiceType_BulkData))); + expect(@(message.header.frameData)).to(equal(@(SDLFrameData_FirstFrame))); + expect(@(message.header.sessionID)).to(equal(@0x84)); + expect(@(message.header.bytesInPayload)).to(equal(@8)); + + NSUInteger offset = 0; + for (int i = 1; i < messageList.count - 1; i++) { + message = messageList[i]; + + //Consecutive frames + expect(message.payload).to(equal([NSData dataWithData:[payloadData subdataWithRange:NSMakeRange(offset, payloadLength)]])); + + expect(@(message.header.frameType)).to(equal(@(SDLFrameType_Consecutive))); + expect(@(message.header.serviceType)).to(equal(@(SDLServiceType_BulkData))); + expect(@(message.header.frameData)).to(equal(@(i))); + expect(@(message.header.sessionID)).to(equal(@0x84)); + expect(@(message.header.bytesInPayload)).to(equal(@(payloadLength))); + + offset += payloadLength; + } + + message = [messageList lastObject]; + + NSUInteger remaining = payloadData.length - offset; + + //Last frame + expect(message.payload).to(equal([NSData dataWithData:[payloadData subdataWithRange:NSMakeRange(offset, remaining)]])); + + expect(@(message.header.frameType)).to(equal(@(SDLFrameType_Consecutive))); + expect(@(message.header.serviceType)).to(equal(@(SDLServiceType_BulkData))); + expect(@(message.header.frameData)).to(equal(@(SDLFrameData_ConsecutiveLastFrame))); + expect(@(message.header.sessionID)).to(equal(@0x84)); + expect(@(message.header.bytesInPayload)).to(equal(@(remaining))); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m new file mode 100644 index 000000000..6e22fd901 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m @@ -0,0 +1,176 @@ +// +// SDLProtocolReceivedMessageRouterSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OCMock/OCMock.h> + +#import "SDLProtocolReceivedMessageRouter.h" +#import "SDLV2ProtocolHeader.h" +#import "SDLV2ProtocolMessage.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLProtocolReceivedMessageRouterSpec) + +describe(@"HandleReceivedMessage Tests", ^ { + context(@"When handling control message", ^ { + it(@"Should route message correctly", ^ { + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] init]; + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + + testHeader.frameType = SDLFrameType_Control; + testHeader.serviceType = SDLServiceType_RPC; + testHeader.frameData = SDLFrameData_StartSessionACK; + testHeader.sessionID = 0x93; + testHeader.bytesInPayload = 0; + + testMessage.header = testHeader; + testMessage.payload = [NSData data]; + + __block BOOL verified = NO; + [[[[delegateMock stub] andDo: ^(NSInvocation* invocation) { + verified = YES; + Byte serviceType; + Byte sessionID; + Byte version; + + [invocation getArgument:&serviceType atIndex:2]; + [invocation getArgument:&sessionID atIndex:3]; + [invocation getArgument:&version atIndex:4]; + + expect(@(serviceType)).to(equal(@(SDLServiceType_RPC))); + expect(@(sessionID)).to(equal(@0x93)); + expect(@(version)).to(equal(@0x02)); + }] ignoringNonObjectArgs] handleProtocolStartSessionACK:0 sessionID:0 version:0]; + + SDLProtocolReceivedMessageRouter* router = [[SDLProtocolReceivedMessageRouter alloc] init]; + router.delegate = delegateMock; + + [router handleReceivedMessage:testMessage]; + + expect(@(verified)).to(beTruthy()); + }); + }); + + context(@"When handling single frame message", ^ { + it(@"Should route message correctly", ^ { + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] init]; + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + + testHeader.frameType = SDLFrameType_Single; + testHeader.serviceType = SDLServiceType_RPC; + testHeader.frameData = SDLFrameData_SingleFrame; + testHeader.sessionID = 0x07; + testHeader.bytesInPayload = 0; + + testMessage.header = testHeader; + + testMessage.payload = [NSData data]; + + __block BOOL verified = NO; + [[[[delegateMock stub] andDo: ^(NSInvocation* invocation) { + verified = YES; + + __unsafe_unretained SDLProtocolMessage* message; + + [invocation getArgument:&message atIndex:2]; + + SDLV2ProtocolMessage* messageReceived = (SDLV2ProtocolMessage*)message; + + expect(messageReceived).to(beIdenticalTo(testMessage)); + }] ignoringNonObjectArgs] onProtocolMessageReceived:[OCMArg any]]; + + SDLProtocolReceivedMessageRouter* router = [[SDLProtocolReceivedMessageRouter alloc] init]; + router.delegate = delegateMock; + + [router handleReceivedMessage:testMessage]; + + expect(@(verified)).to(beTruthy()); + }); + }); + + context(@"When handling multi-frame message", ^ { + it(@"Should route message correctly", ^ { + //Allocate 2000 bytes and use it as test data + const NSUInteger dataLength = 2000; + char dummyBytes[dataLength]; + + const char testPayloadHeader[12] = {0x20, 0x55, 0x64, 0x73, 0x12, 0x34, 0x43, 0x21, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF}; + + NSMutableData* payloadData = [NSMutableData dataWithBytes:testPayloadHeader length:12]; + [payloadData appendBytes:dummyBytes length:dataLength]; + + SDLV2ProtocolMessage* testMessage = [[SDLV2ProtocolMessage alloc] init]; + SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] init]; + + //First frame + testHeader.frameType = SDLFrameType_First; + testHeader.serviceType = SDLServiceType_BulkData; + testHeader.frameData = 1; + testHeader.sessionID = 0x33; + testHeader.bytesInPayload = 8; + + testMessage.header = testHeader; + + const char firstPayload[8] = {(payloadData.length >> 24) & 0xFF, (payloadData.length >> 16) & 0xFF, (payloadData.length >> 8) & 0xFF, payloadData.length & 0xFF, 0x00, 0x00, 0x00, ceil(payloadData.length / 500.0)}; + testMessage.payload = [NSData dataWithBytes:firstPayload length:8]; + + SDLProtocolReceivedMessageRouter* router = [[SDLProtocolReceivedMessageRouter alloc] init]; + + [router handleReceivedMessage:testMessage]; + + testMessage.header.frameType = SDLFrameType_Consecutive; + testMessage.header.bytesInPayload = 500; + + NSUInteger frameNumber = 1; + NSUInteger offset = 0; + while ((offset + 500) < payloadData.length) { + //Consectutive frames + testMessage.header.frameData = frameNumber; + testMessage.payload = [payloadData subdataWithRange:NSMakeRange(offset, 500)]; + [router handleReceivedMessage:testMessage]; + + frameNumber++; + offset += 500; + } + + //Final frame + testMessage.header.frameData = 0; + testMessage.payload = [payloadData subdataWithRange:NSMakeRange(offset, payloadData.length - offset)]; + + id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener)); + + __block BOOL verified = NO; + [[[delegateMock stub] andDo:^(NSInvocation* invocation) { + verified = YES; + + //Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 + __unsafe_unretained SDLProtocolMessage* message; + [invocation getArgument:&message atIndex:2]; + SDLProtocolMessage* assembledMessage = message; + + expect(assembledMessage.payload).to(equal(payloadData)); + expect(@(assembledMessage.header.frameType)).to(equal(@(SDLFrameType_Single))); + expect(@(assembledMessage.header.serviceType)).to(equal(@(SDLServiceType_BulkData))); + expect(@(assembledMessage.header.frameData)).to(equal(@(SDLFrameData_SingleFrame))); + expect(@(assembledMessage.header.sessionID)).to(equal(@0x33)); + expect(@(assembledMessage.header.bytesInPayload)).to(equal(@(payloadData.length))); + }] onProtocolMessageReceived:[OCMArg any]]; + + router.delegate = delegateMock; + [router handleReceivedMessage:testMessage]; + + expect(@(verified)).to(beTruthy()); + }); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenManagerSpec.m new file mode 100644 index 000000000..76c85b9f4 --- /dev/null +++ b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenManagerSpec.m @@ -0,0 +1,235 @@ +// +// SDLHexUtilitySpec.m +// SmartDeviceLink-iOS + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMILevel.h" +#import "SDLOnLockScreenStatus.h" +#import "SDLLockScreenManager.h" +#import "SDLLockScreenStatus.h" + + +QuickSpecBegin(SDLLockScreenManagerSpec) + +describe(@"the lockscreen manager", ^{ + __block SDLLockScreenManager *lockScreenManager; + beforeEach(^{ + lockScreenManager = [[SDLLockScreenManager alloc] init]; + }); + + it(@"should properly initialize user selected app boolean to false", ^{ + expect(@(lockScreenManager.userSelected)).to(beFalse()); + }); + + it(@"should properly initialize driver is distracted boolean to false", ^{ + expect(@(lockScreenManager.driverDistracted)).to(beFalse()); + }); + + it(@"should properly initialize hmi level object to nil", ^{ + expect(lockScreenManager.hmiLevel).to(beNil()); + }); + + describe(@"when setting HMI level", ^{ + context(@"to FULL", ^{ + beforeEach(^{ + lockScreenManager.userSelected = NO; + lockScreenManager.hmiLevel = [SDLHMILevel FULL]; + }); + + it(@"should set user selected to true", ^{ + expect(@(lockScreenManager.userSelected)).to(beTrue()); + }); + }); + + context(@"to LIMITED", ^{ + beforeEach(^{ + lockScreenManager.userSelected = NO; + lockScreenManager.hmiLevel = [SDLHMILevel LIMITED]; + }); + + it(@"should set user selected to true", ^{ + expect(@(lockScreenManager.userSelected)).to(beTrue()); + }); + }); + + context(@"to BACKGROUND", ^{ + beforeEach(^{ + lockScreenManager.hmiLevel = [SDLHMILevel BACKGROUND]; + }); + + context(@"when user selected is false", ^{ + beforeEach(^{ + lockScreenManager.userSelected = NO; + }); + + it(@"should not alter the value", ^{ + expect(@(lockScreenManager.userSelected)).to(beFalse()); + }); + }); + + context(@"when user selected is true", ^{ + beforeEach(^{ + lockScreenManager.userSelected = YES; + }); + + it(@"should not alter the value", ^{ + expect(@(lockScreenManager.userSelected)).to(beTrue()); + }); + }); + }); + + context(@"to NONE", ^{ + beforeEach(^{ + lockScreenManager.userSelected = YES; + lockScreenManager.hmiLevel = [SDLHMILevel NONE]; + }); + + it(@"should set user selected to false", ^{ + expect(@(lockScreenManager.userSelected)).to(beFalse()); + }); + }); + }); + + describe(@"when getting lock screen status", ^{ + context(@"when HMI level is nil", ^{ + beforeEach(^{ + lockScreenManager.hmiLevel = nil; + }); + + it(@"should return lock screen off", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus OFF])); + }); + }); + + context(@"when HMI level is NONE", ^{ + beforeEach(^{ + lockScreenManager.hmiLevel = [SDLHMILevel NONE]; + }); + + it(@"should return lock screen off", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus OFF])); + }); + }); + + context(@"when HMI level is BACKGROUND", ^{ + beforeEach(^{ + lockScreenManager.hmiLevel = [SDLHMILevel BACKGROUND]; + }); + + context(@"when user selected is true", ^{ + beforeEach(^{ + lockScreenManager.userSelected = YES; + }); + + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); + }); + + context(@"when user selected is false", ^{ + beforeEach(^{ + lockScreenManager.userSelected = NO; + }); + + it(@"should return lock screen off", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus OFF])); + }); + }); + }); + + context(@"when HMI level is LIMITED", ^{ + beforeEach(^{ + lockScreenManager.hmiLevel = [SDLHMILevel LIMITED]; + }); + + context(@"if we do not set the driver distraction state", ^{ + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); + }); + + context(@"if we set the driver distraction state to false", ^{ + beforeEach(^{ + lockScreenManager.driverDistracted = NO; + }); + + it(@"should return lock screen optional", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus OPTIONAL])); + }); + }); + + context(@"if we set the driver distraction state to true", ^{ + beforeEach(^{ + lockScreenManager.driverDistracted = YES; + }); + + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); + }); + }); + + context(@"when HMI level is FULL", ^{ + beforeEach(^{ + lockScreenManager.hmiLevel = [SDLHMILevel FULL]; + }); + + context(@"if we do not set the driver distraction state", ^{ + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); + }); + + context(@"if we set the driver distraction state to false", ^{ + beforeEach(^{ + lockScreenManager.driverDistracted = NO; + }); + + it(@"should return lock screen optional", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus OPTIONAL])); + }); + }); + + context(@"if we set the driver distraction state to true", ^{ + beforeEach(^{ + lockScreenManager.driverDistracted = YES; + }); + + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); + }); + }); + }); + + describe(@"when getting lock screen status notification", ^{ + __block SDLOnLockScreenStatus *onLockScreenStatusNotification = nil; + beforeEach(^{ + lockScreenManager.userSelected = YES; + lockScreenManager.driverDistracted = NO; + lockScreenManager.hmiLevel = [SDLHMILevel LIMITED]; + + onLockScreenStatusNotification = lockScreenManager.lockScreenStatusNotification; + }); + + it(@"should properly return user selected", ^{ + expect(onLockScreenStatusNotification.userSelected).to(beTrue()); + }); + + it(@"should properly return driver distraction status", ^{ + expect(onLockScreenStatusNotification.driverDistractionStatus).to(beFalse()); + }); + + it(@"should properly return HMI level", ^{ + expect(onLockScreenStatusNotification.hmiLevel).to(equal([SDLHMILevel LIMITED])); + }); + + it(@"should properly return lock screen status", ^{ + expect(onLockScreenStatusNotification.lockScreenStatus).to(equal([SDLLockScreenStatus OPTIONAL])); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAmbientLightStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAmbientLightStatusSpec.m new file mode 100644 index 000000000..c5259da1d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAmbientLightStatusSpec.m @@ -0,0 +1,71 @@ +// +// SDLAmbientLightStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAmbientLightStatus.h" + +QuickSpecBegin(SDLAmbientLightStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLAmbientLightStatus NIGHT].value).to(equal(@"NIGHT")); + expect([SDLAmbientLightStatus TWILIGHT_1].value).to(equal(@"TWILIGHT_1")); + expect([SDLAmbientLightStatus TWILIGHT_2].value).to(equal(@"TWILIGHT_2")); + expect([SDLAmbientLightStatus TWILIGHT_3].value).to(equal(@"TWILIGHT_3")); + expect([SDLAmbientLightStatus TWILIGHT_4].value).to(equal(@"TWILIGHT_4")); + expect([SDLAmbientLightStatus DAY].value).to(equal(@"DAY")); + expect([SDLAmbientLightStatus UNKNOWN].value).to(equal(@"UNKNOWN")); + expect([SDLAmbientLightStatus INVALID].value).to(equal(@"INVALID")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLAmbientLightStatus valueOf:@"NIGHT"]).to(equal([SDLAmbientLightStatus NIGHT])); + expect([SDLAmbientLightStatus valueOf:@"TWILIGHT_1"]).to(equal([SDLAmbientLightStatus TWILIGHT_1])); + expect([SDLAmbientLightStatus valueOf:@"TWILIGHT_2"]).to(equal([SDLAmbientLightStatus TWILIGHT_2])); + expect([SDLAmbientLightStatus valueOf:@"TWILIGHT_3"]).to(equal([SDLAmbientLightStatus TWILIGHT_3])); + expect([SDLAmbientLightStatus valueOf:@"TWILIGHT_4"]).to(equal([SDLAmbientLightStatus TWILIGHT_4])); + expect([SDLAmbientLightStatus valueOf:@"DAY"]).to(equal([SDLAmbientLightStatus DAY])); + expect([SDLAmbientLightStatus valueOf:@"UNKNOWN"]).to(equal([SDLAmbientLightStatus UNKNOWN])); + expect([SDLAmbientLightStatus valueOf:@"INVALID"]).to(equal([SDLAmbientLightStatus INVALID])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLAmbientLightStatus valueOf:nil]).to(beNil()); + expect([SDLAmbientLightStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLAmbientLightStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLAmbientLightStatus NIGHT], + [SDLAmbientLightStatus TWILIGHT_1], + [SDLAmbientLightStatus TWILIGHT_2], + [SDLAmbientLightStatus TWILIGHT_3], + [SDLAmbientLightStatus TWILIGHT_4], + [SDLAmbientLightStatus DAY], + [SDLAmbientLightStatus UNKNOWN], + [SDLAmbientLightStatus INVALID]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAppHMITypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAppHMITypeSpec.m new file mode 100644 index 000000000..4e55a1543 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAppHMITypeSpec.m @@ -0,0 +1,77 @@ +// +// SDLAppHMITypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAppHMIType.h" + +QuickSpecBegin(SDLAppHMITypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLAppHMIType DEFAULT].value).to(equal(@"DEFAULT")); + expect([SDLAppHMIType COMMUNICATION].value).to(equal(@"COMMUNICATION")); + expect([SDLAppHMIType MEDIA].value).to(equal(@"MEDIA")); + expect([SDLAppHMIType MESSAGING].value).to(equal(@"MESSAGING")); + expect([SDLAppHMIType NAVIGATION].value).to(equal(@"NAVIGATION")); + expect([SDLAppHMIType INFORMATION].value).to(equal(@"INFORMATION")); + expect([SDLAppHMIType SOCIAL].value).to(equal(@"SOCIAL")); + expect([SDLAppHMIType BACKGROUND_PROCESS].value).to(equal(@"BACKGROUND_PROCESS")); + expect([SDLAppHMIType TESTING].value).to(equal(@"TESTING")); + expect([SDLAppHMIType SYSTEM].value).to(equal(@"SYSTEM")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLAppHMIType valueOf:@"DEFAULT"]).to(equal([SDLAppHMIType DEFAULT])); + expect([SDLAppHMIType valueOf:@"COMMUNICATION"]).to(equal([SDLAppHMIType COMMUNICATION])); + expect([SDLAppHMIType valueOf:@"MEDIA"]).to(equal([SDLAppHMIType MEDIA])); + expect([SDLAppHMIType valueOf:@"MESSAGING"]).to(equal([SDLAppHMIType MESSAGING])); + expect([SDLAppHMIType valueOf:@"NAVIGATION"]).to(equal([SDLAppHMIType NAVIGATION])); + expect([SDLAppHMIType valueOf:@"INFORMATION"]).to(equal([SDLAppHMIType INFORMATION])); + expect([SDLAppHMIType valueOf:@"SOCIAL"]).to(equal([SDLAppHMIType SOCIAL])); + expect([SDLAppHMIType valueOf:@"BACKGROUND_PROCESS"]).to(equal([SDLAppHMIType BACKGROUND_PROCESS])); + expect([SDLAppHMIType valueOf:@"TESTING"]).to(equal([SDLAppHMIType TESTING])); + expect([SDLAppHMIType valueOf:@"SYSTEM"]).to(equal([SDLAppHMIType SYSTEM])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLAppHMIType valueOf:nil]).to(beNil()); + expect([SDLAppHMIType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLAppHMIType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLAppHMIType DEFAULT], + [SDLAppHMIType COMMUNICATION], + [SDLAppHMIType MEDIA], + [SDLAppHMIType MESSAGING], + [SDLAppHMIType NAVIGATION], + [SDLAppHMIType INFORMATION], + [SDLAppHMIType SOCIAL], + [SDLAppHMIType BACKGROUND_PROCESS], + [SDLAppHMIType TESTING], + [SDLAppHMIType SYSTEM]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAppInterfaceUnregisteredReasonSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAppInterfaceUnregisteredReasonSpec.m new file mode 100644 index 000000000..a8927c447 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAppInterfaceUnregisteredReasonSpec.m @@ -0,0 +1,85 @@ +// +// SDLAppInterfaceUnregisteredReasonSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAppInterfaceUnregisteredReason.h" + +//Commented tests refer to values defined in the spec, but are not implemented + +QuickSpecBegin(SDLAppInterfaceUnregisteredReasonSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + //expect([SDLAppInterfaceUnregisteredReason USER_EXIT].value).to(equal(@"USER_EXIT")); + expect([SDLAppInterfaceUnregisteredReason IGNITION_OFF].value).to(equal(@"IGNITION_OFF")); + expect([SDLAppInterfaceUnregisteredReason BLUETOOTH_OFF].value).to(equal(@"BLUETOOTH_OFF")); + expect([SDLAppInterfaceUnregisteredReason USB_DISCONNECTED].value).to(equal(@"USB_DISCONNECTED")); + expect([SDLAppInterfaceUnregisteredReason REQUEST_WHILE_IN_NONE_HMI_LEVEL].value).to(equal(@"REQUEST_WHILE_IN_NONE_HMI_LEVEL")); + expect([SDLAppInterfaceUnregisteredReason TOO_MANY_REQUESTS].value).to(equal(@"TOO_MANY_REQUESTS")); + expect([SDLAppInterfaceUnregisteredReason DRIVER_DISTRACTION_VIOLATION].value).to(equal(@"DRIVER_DISTRACTION_VIOLATION")); + expect([SDLAppInterfaceUnregisteredReason LANGUAGE_CHANGE].value).to(equal(@"LANGUAGE_CHANGE")); + expect([SDLAppInterfaceUnregisteredReason MASTER_RESET].value).to(equal(@"MASTER_RESET")); + expect([SDLAppInterfaceUnregisteredReason FACTORY_DEFAULTS].value).to(equal(@"FACTORY_DEFAULTS")); + expect([SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED].value).to(equal(@"APP_UNAUTHORIZED")); + //expect([SDLAppInterfaceUnregisteredReason PROTOCOL_VIOLATION].value).to(equal(@"PROTOCOL_VIOLATION")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + //expect([SDLAppInterfaceUnregisteredReason valueOf:@"USER_EXIT"]).to(equal([SDLAppInterfaceUnregisteredReason USER_EXIT])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"IGNITION_OFF"]).to(equal([SDLAppInterfaceUnregisteredReason IGNITION_OFF])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"BLUETOOTH_OFF"]).to(equal([SDLAppInterfaceUnregisteredReason BLUETOOTH_OFF])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"USB_DISCONNECTED"]).to(equal([SDLAppInterfaceUnregisteredReason USB_DISCONNECTED])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"REQUEST_WHILE_IN_NONE_HMI_LEVEL"]).to(equal([SDLAppInterfaceUnregisteredReason REQUEST_WHILE_IN_NONE_HMI_LEVEL])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"TOO_MANY_REQUESTS"]).to(equal([SDLAppInterfaceUnregisteredReason TOO_MANY_REQUESTS])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"DRIVER_DISTRACTION_VIOLATION"]).to(equal([SDLAppInterfaceUnregisteredReason DRIVER_DISTRACTION_VIOLATION])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"LANGUAGE_CHANGE"]).to(equal([SDLAppInterfaceUnregisteredReason LANGUAGE_CHANGE])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"MASTER_RESET"]).to(equal([SDLAppInterfaceUnregisteredReason MASTER_RESET])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"FACTORY_DEFAULTS"]).to(equal([SDLAppInterfaceUnregisteredReason FACTORY_DEFAULTS])); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"APP_UNAUTHORIZED"]).to(equal([SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED])); + //expect([SDLAppInterfaceUnregisteredReason valueOf:@"PROTOCOL_VIOLATION"]).to(equal([SDLAppInterfaceUnregisteredReason PROTOCOL_VIOLATION])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLAppInterfaceUnregisteredReason valueOf:nil]).to(beNil()); + expect([SDLAppInterfaceUnregisteredReason valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLAppInterfaceUnregisteredReason values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[//[SDLAppInterfaceUnregisteredReason USER_EXIT], + [SDLAppInterfaceUnregisteredReason IGNITION_OFF], + [SDLAppInterfaceUnregisteredReason BLUETOOTH_OFF], + [SDLAppInterfaceUnregisteredReason USB_DISCONNECTED], + [SDLAppInterfaceUnregisteredReason REQUEST_WHILE_IN_NONE_HMI_LEVEL], + [SDLAppInterfaceUnregisteredReason TOO_MANY_REQUESTS], + [SDLAppInterfaceUnregisteredReason DRIVER_DISTRACTION_VIOLATION], + [SDLAppInterfaceUnregisteredReason LANGUAGE_CHANGE], + [SDLAppInterfaceUnregisteredReason MASTER_RESET], + [SDLAppInterfaceUnregisteredReason FACTORY_DEFAULTS], + [SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED]] copy]; + //[SDLAppInterfaceUnregisteredReason PROTOCOL_VIOLATION] + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAudioStreamingStateSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAudioStreamingStateSpec.m new file mode 100644 index 000000000..0787d7321 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAudioStreamingStateSpec.m @@ -0,0 +1,56 @@ +// +// SDLAudioStreamingStateSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAudioStreamingState.h" + +QuickSpecBegin(SDLAudioStreamingStateSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLAudioStreamingState AUDIBLE].value).to(equal(@"AUDIBLE")); + expect([SDLAudioStreamingState ATTENUATED].value).to(equal(@"ATTENUATED")); + expect([SDLAudioStreamingState NOT_AUDIBLE].value).to(equal(@"NOT_AUDIBLE")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLAudioStreamingState valueOf:@"AUDIBLE"]).to(equal([SDLAudioStreamingState AUDIBLE])); + expect([SDLAudioStreamingState valueOf:@"ATTENUATED"]).to(equal([SDLAudioStreamingState ATTENUATED])); + expect([SDLAudioStreamingState valueOf:@"NOT_AUDIBLE"]).to(equal([SDLAudioStreamingState NOT_AUDIBLE])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLAudioStreamingState valueOf:nil]).to(beNil()); + expect([SDLAudioStreamingState valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLAudioStreamingState values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLAudioStreamingState AUDIBLE], + [SDLAudioStreamingState ATTENUATED], + [SDLAudioStreamingState NOT_AUDIBLE]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAudioTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAudioTypeSpec.m new file mode 100644 index 000000000..8587b7ee1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLAudioTypeSpec.m @@ -0,0 +1,50 @@ +// +// SDLAudioTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAudioType.h" + +QuickSpecBegin(SDLAudioTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLAudioType PCM].value).to(equal(@"PCM")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLAudioType valueOf:@"PCM"]).to(equal([SDLAudioType PCM])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLAudioType valueOf:nil]).to(beNil()); + expect([SDLAudioType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLAudioType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLAudioType PCM]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLBitsPerSampleSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLBitsPerSampleSpec.m new file mode 100644 index 000000000..bcc5dd01c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLBitsPerSampleSpec.m @@ -0,0 +1,53 @@ +// +// SDLBitsPerSampleSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLBitsPerSample.h" + +QuickSpecBegin(SDLBitsPerSampleSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLBitsPerSample _8_BIT].value).to(equal(@"8_BIT")); + expect([SDLBitsPerSample _16_BIT].value).to(equal(@"16_BIT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLBitsPerSample valueOf:@"8_BIT"]).to(equal([SDLBitsPerSample _8_BIT])); + expect([SDLBitsPerSample valueOf:@"16_BIT"]).to(equal([SDLBitsPerSample _16_BIT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLBitsPerSample valueOf:nil]).to(beNil()); + expect([SDLBitsPerSample valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLBitsPerSample values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLBitsPerSample _8_BIT], + [SDLBitsPerSample _16_BIT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonEventModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonEventModeSpec.m new file mode 100644 index 000000000..4f6e6d054 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonEventModeSpec.m @@ -0,0 +1,53 @@ +// +// SDLButtonEventModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonEventMode.h" + +QuickSpecBegin(SDLButtonEventModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLButtonEventMode BUTTONUP].value).to(equal(@"BUTTONUP")); + expect([SDLButtonEventMode BUTTONDOWN].value).to(equal(@"BUTTONDOWN")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLButtonEventMode valueOf:@"BUTTONUP"]).to(equal([SDLButtonEventMode BUTTONUP])); + expect([SDLButtonEventMode valueOf:@"BUTTONDOWN"]).to(equal([SDLButtonEventMode BUTTONDOWN])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLButtonEventMode valueOf:nil]).to(beNil()); + expect([SDLButtonEventMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLButtonEventMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLButtonEventMode BUTTONUP], + [SDLButtonEventMode BUTTONDOWN]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonNameSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonNameSpec.m new file mode 100644 index 000000000..6b9c64900 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonNameSpec.m @@ -0,0 +1,98 @@ +// +// SDLButtonNameSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonName.h" + +QuickSpecBegin(SDLButtonNameSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLButtonName OK].value).to(equal(@"OK")); + expect([SDLButtonName SEEKLEFT].value).to(equal(@"SEEKLEFT")); + expect([SDLButtonName SEEKRIGHT].value).to(equal(@"SEEKRIGHT")); + expect([SDLButtonName TUNEUP].value).to(equal(@"TUNEUP")); + expect([SDLButtonName TUNEDOWN].value).to(equal(@"TUNEDOWN")); + expect([SDLButtonName PRESET_0].value).to(equal(@"PRESET_0")); + expect([SDLButtonName PRESET_1].value).to(equal(@"PRESET_1")); + expect([SDLButtonName PRESET_2].value).to(equal(@"PRESET_2")); + expect([SDLButtonName PRESET_3].value).to(equal(@"PRESET_3")); + expect([SDLButtonName PRESET_4].value).to(equal(@"PRESET_4")); + expect([SDLButtonName PRESET_5].value).to(equal(@"PRESET_5")); + expect([SDLButtonName PRESET_6].value).to(equal(@"PRESET_6")); + expect([SDLButtonName PRESET_7].value).to(equal(@"PRESET_7")); + expect([SDLButtonName PRESET_8].value).to(equal(@"PRESET_8")); + expect([SDLButtonName PRESET_9].value).to(equal(@"PRESET_9")); + expect([SDLButtonName CUSTOM_BUTTON].value).to(equal(@"CUSTOM_BUTTON")); + expect([SDLButtonName SEARCH].value).to(equal(@"SEARCH")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLButtonName valueOf:@"OK"]).to(equal([SDLButtonName OK])); + expect([SDLButtonName valueOf:@"SEEKLEFT"]).to(equal([SDLButtonName SEEKLEFT])); + expect([SDLButtonName valueOf:@"SEEKRIGHT"]).to(equal([SDLButtonName SEEKRIGHT])); + expect([SDLButtonName valueOf:@"TUNEUP"]).to(equal([SDLButtonName TUNEUP])); + expect([SDLButtonName valueOf:@"TUNEDOWN"]).to(equal([SDLButtonName TUNEDOWN])); + expect([SDLButtonName valueOf:@"PRESET_0"]).to(equal([SDLButtonName PRESET_0])); + expect([SDLButtonName valueOf:@"PRESET_1"]).to(equal([SDLButtonName PRESET_1])); + expect([SDLButtonName valueOf:@"PRESET_2"]).to(equal([SDLButtonName PRESET_2])); + expect([SDLButtonName valueOf:@"PRESET_3"]).to(equal([SDLButtonName PRESET_3])); + expect([SDLButtonName valueOf:@"PRESET_4"]).to(equal([SDLButtonName PRESET_4])); + expect([SDLButtonName valueOf:@"PRESET_5"]).to(equal([SDLButtonName PRESET_5])); + expect([SDLButtonName valueOf:@"PRESET_6"]).to(equal([SDLButtonName PRESET_6])); + expect([SDLButtonName valueOf:@"PRESET_7"]).to(equal([SDLButtonName PRESET_7])); + expect([SDLButtonName valueOf:@"PRESET_8"]).to(equal([SDLButtonName PRESET_8])); + expect([SDLButtonName valueOf:@"PRESET_9"]).to(equal([SDLButtonName PRESET_9])); + expect([SDLButtonName valueOf:@"CUSTOM_BUTTON"]).to(equal([SDLButtonName CUSTOM_BUTTON])); + expect([SDLButtonName valueOf:@"SEARCH"]).to(equal([SDLButtonName SEARCH])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLButtonName valueOf:nil]).to(beNil()); + expect([SDLButtonName valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLButtonName values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLButtonName OK], + [SDLButtonName SEEKLEFT], + [SDLButtonName SEEKRIGHT], + [SDLButtonName TUNEUP], + [SDLButtonName TUNEDOWN], + [SDLButtonName PRESET_0], + [SDLButtonName PRESET_1], + [SDLButtonName PRESET_2], + [SDLButtonName PRESET_3], + [SDLButtonName PRESET_4], + [SDLButtonName PRESET_5], + [SDLButtonName PRESET_6], + [SDLButtonName PRESET_7], + [SDLButtonName PRESET_8], + [SDLButtonName PRESET_9], + [SDLButtonName CUSTOM_BUTTON], + [SDLButtonName SEARCH]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonPressModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonPressModeSpec.m new file mode 100644 index 000000000..eb6b2fa35 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLButtonPressModeSpec.m @@ -0,0 +1,53 @@ +// +// SDLButtonPressModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonPressMode.h" + +QuickSpecBegin(SDLButtonPressModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLButtonPressMode LONG].value).to(equal(@"LONG")); + expect([SDLButtonPressMode SHORT].value).to(equal(@"SHORT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLButtonPressMode valueOf:@"LONG"]).to(equal([SDLButtonPressMode LONG])); + expect([SDLButtonPressMode valueOf:@"SHORT"]).to(equal([SDLButtonPressMode SHORT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLButtonPressMode valueOf:nil]).to(beNil()); + expect([SDLButtonPressMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLButtonPressMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLButtonPressMode LONG], + [SDLButtonPressMode SHORT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCarModeStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCarModeStatusSpec.m new file mode 100644 index 000000000..78f04e837 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCarModeStatusSpec.m @@ -0,0 +1,60 @@ +// +// SDLCarModeStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCarModeStatus.h" + +QuickSpecBegin(SDLCarModeStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLCarModeStatus NORMAL].value).to(equal(@"NORMAL")); + expect([SDLCarModeStatus FACTORY].value).to(equal(@"FACTORY")); + expect([SDLCarModeStatus TRANSPORT].value).to(equal(@"TRANSPORT")); + expect([SDLCarModeStatus CRASH].value).to(equal(@"CRASH")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLCarModeStatus valueOf:@"NORMAL"]).to(equal([SDLCarModeStatus NORMAL])); + expect([SDLCarModeStatus valueOf:@"FACTORY"]).to(equal([SDLCarModeStatus FACTORY])); + expect([SDLCarModeStatus valueOf:@"TRANSPORT"]).to(equal([SDLCarModeStatus TRANSPORT])); + expect([SDLCarModeStatus valueOf:@"CRASH"]).to(equal([SDLCarModeStatus CRASH])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLCarModeStatus valueOf:nil]).to(beNil()); + expect([SDLCarModeStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLCarModeStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLCarModeStatus NORMAL], + [SDLCarModeStatus FACTORY], + [SDLCarModeStatus TRANSPORT], + [SDLCarModeStatus CRASH]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd + diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCharacterSetSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCharacterSetSpec.m new file mode 100644 index 000000000..df29296a5 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCharacterSetSpec.m @@ -0,0 +1,59 @@ +// +// SDLCharacterSetSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCharacterSet.h" + +QuickSpecBegin(SDLCharacterSetSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLCharacterSet TYPE2SET].value).to(equal(@"TYPE2SET")); + expect([SDLCharacterSet TYPE5SET].value).to(equal(@"TYPE5SET")); + expect([SDLCharacterSet CID1SET].value).to(equal(@"CID1SET")); + expect([SDLCharacterSet CID2SET].value).to(equal(@"CID2SET")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLCharacterSet valueOf:@"TYPE2SET"]).to(equal([SDLCharacterSet TYPE2SET])); + expect([SDLCharacterSet valueOf:@"TYPE5SET"]).to(equal([SDLCharacterSet TYPE5SET])); + expect([SDLCharacterSet valueOf:@"CID1SET"]).to(equal([SDLCharacterSet CID1SET])); + expect([SDLCharacterSet valueOf:@"CID2SET"]).to(equal([SDLCharacterSet CID2SET])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLCharacterSet valueOf:nil]).to(beNil()); + expect([SDLCharacterSet valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLCharacterSet values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLCharacterSet TYPE2SET], + [SDLCharacterSet TYPE5SET], + [SDLCharacterSet CID1SET], + [SDLCharacterSet CID2SET]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCompassDirectionSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCompassDirectionSpec.m new file mode 100644 index 000000000..49a10e02d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLCompassDirectionSpec.m @@ -0,0 +1,71 @@ +// +// SDLCompassDirectionSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCompassDirection.h" + +QuickSpecBegin(SDLCompassDirectionSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLCompassDirection NORTH].value).to(equal(@"NORTH")); + expect([SDLCompassDirection NORTHWEST].value).to(equal(@"NORTHWEST")); + expect([SDLCompassDirection WEST].value).to(equal(@"WEST")); + expect([SDLCompassDirection SOUTHWEST].value).to(equal(@"SOUTHWEST")); + expect([SDLCompassDirection SOUTH].value).to(equal(@"SOUTH")); + expect([SDLCompassDirection SOUTHEAST].value).to(equal(@"SOUTHEAST")); + expect([SDLCompassDirection EAST].value).to(equal(@"EAST")); + expect([SDLCompassDirection NORTHEAST].value).to(equal(@"NORTHEAST")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLCompassDirection valueOf:@"NORTH"]).to(equal([SDLCompassDirection NORTH])); + expect([SDLCompassDirection valueOf:@"NORTHWEST"]).to(equal([SDLCompassDirection NORTHWEST])); + expect([SDLCompassDirection valueOf:@"WEST"]).to(equal([SDLCompassDirection WEST])); + expect([SDLCompassDirection valueOf:@"SOUTHWEST"]).to(equal([SDLCompassDirection SOUTHWEST])); + expect([SDLCompassDirection valueOf:@"SOUTH"]).to(equal([SDLCompassDirection SOUTH])); + expect([SDLCompassDirection valueOf:@"SOUTHEAST"]).to(equal([SDLCompassDirection SOUTHEAST])); + expect([SDLCompassDirection valueOf:@"EAST"]).to(equal([SDLCompassDirection EAST])); + expect([SDLCompassDirection valueOf:@"NORTHEAST"]).to(equal([SDLCompassDirection NORTHEAST])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLCompassDirection valueOf:nil]).to(beNil()); + expect([SDLCompassDirection valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLCompassDirection values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLCompassDirection NORTH], + [SDLCompassDirection NORTHWEST], + [SDLCompassDirection WEST], + [SDLCompassDirection SOUTHWEST], + [SDLCompassDirection SOUTH], + [SDLCompassDirection SOUTHEAST], + [SDLCompassDirection EAST], + [SDLCompassDirection NORTHEAST]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLComponentVolumeStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLComponentVolumeStatusSpec.m new file mode 100644 index 000000000..491e802aa --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLComponentVolumeStatusSpec.m @@ -0,0 +1,65 @@ +// +// SDLComponentVolumeStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLComponentVolumeStatus.h" + +QuickSpecBegin(SDLComponentVolumeStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLComponentVolumeStatus UNKNOWN].value).to(equal(@"UNKNOWN")); + expect([SDLComponentVolumeStatus NORMAL].value).to(equal(@"NORMAL")); + expect([SDLComponentVolumeStatus LOW].value).to(equal(@"LOW")); + expect([SDLComponentVolumeStatus FAULT].value).to(equal(@"FAULT")); + expect([SDLComponentVolumeStatus ALERT].value).to(equal(@"ALERT")); + expect([SDLComponentVolumeStatus NOT_SUPPORTED].value).to(equal(@"NOT_SUPPORTED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLComponentVolumeStatus valueOf:@"UNKNOWN"]).to(equal([SDLComponentVolumeStatus UNKNOWN])); + expect([SDLComponentVolumeStatus valueOf:@"NORMAL"]).to(equal([SDLComponentVolumeStatus NORMAL])); + expect([SDLComponentVolumeStatus valueOf:@"LOW"]).to(equal([SDLComponentVolumeStatus LOW])); + expect([SDLComponentVolumeStatus valueOf:@"FAULT"]).to(equal([SDLComponentVolumeStatus FAULT])); + expect([SDLComponentVolumeStatus valueOf:@"ALERT"]).to(equal([SDLComponentVolumeStatus ALERT])); + expect([SDLComponentVolumeStatus valueOf:@"NOT_SUPPORTED"]).to(equal([SDLComponentVolumeStatus NOT_SUPPORTED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLComponentVolumeStatus valueOf:nil]).to(beNil()); + expect([SDLComponentVolumeStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLComponentVolumeStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLComponentVolumeStatus UNKNOWN], + [SDLComponentVolumeStatus NORMAL], + [SDLComponentVolumeStatus LOW], + [SDLComponentVolumeStatus FAULT], + [SDLComponentVolumeStatus ALERT], + [SDLComponentVolumeStatus NOT_SUPPORTED]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDeviceLevelStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDeviceLevelStatusSpec.m new file mode 100644 index 000000000..70f1bfb61 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDeviceLevelStatusSpec.m @@ -0,0 +1,65 @@ +// +// SDLDeviceLevelStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeviceLevelStatus.h" + +QuickSpecBegin(SDLDeviceLevelStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLDeviceLevelStatus ZERO_LEVEL_BARS].value).to(equal(@"ZERO_LEVEL_BARS")); + expect([SDLDeviceLevelStatus ONE_LEVEL_BARS].value).to(equal(@"ONE_LEVEL_BARS")); + expect([SDLDeviceLevelStatus TWO_LEVEL_BARS].value).to(equal(@"TWO_LEVEL_BARS")); + expect([SDLDeviceLevelStatus THREE_LEVEL_BARS].value).to(equal(@"THREE_LEVEL_BARS")); + expect([SDLDeviceLevelStatus FOUR_LEVEL_BARS].value).to(equal(@"FOUR_LEVEL_BARS")); + expect([SDLDeviceLevelStatus NOT_PROVIDED].value).to(equal(@"NOT_PROVIDED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLDeviceLevelStatus valueOf:@"ZERO_LEVEL_BARS"]).to(equal([SDLDeviceLevelStatus ZERO_LEVEL_BARS])); + expect([SDLDeviceLevelStatus valueOf:@"ONE_LEVEL_BARS"]).to(equal([SDLDeviceLevelStatus ONE_LEVEL_BARS])); + expect([SDLDeviceLevelStatus valueOf:@"TWO_LEVEL_BARS"]).to(equal([SDLDeviceLevelStatus TWO_LEVEL_BARS])); + expect([SDLDeviceLevelStatus valueOf:@"THREE_LEVEL_BARS"]).to(equal([SDLDeviceLevelStatus THREE_LEVEL_BARS])); + expect([SDLDeviceLevelStatus valueOf:@"FOUR_LEVEL_BARS"]).to(equal([SDLDeviceLevelStatus FOUR_LEVEL_BARS])); + expect([SDLDeviceLevelStatus valueOf:@"NOT_PROVIDED"]).to(equal([SDLDeviceLevelStatus NOT_PROVIDED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLDeviceLevelStatus valueOf:nil]).to(beNil()); + expect([SDLDeviceLevelStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLDeviceLevelStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLDeviceLevelStatus ZERO_LEVEL_BARS], + [SDLDeviceLevelStatus ONE_LEVEL_BARS], + [SDLDeviceLevelStatus TWO_LEVEL_BARS], + [SDLDeviceLevelStatus THREE_LEVEL_BARS], + [SDLDeviceLevelStatus FOUR_LEVEL_BARS], + [SDLDeviceLevelStatus NOT_PROVIDED]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDimensionSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDimensionSpec.m new file mode 100644 index 000000000..e65ee8201 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDimensionSpec.m @@ -0,0 +1,56 @@ +// +// SDLDimensionSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDimension.h" + +QuickSpecBegin(SDLDimensionSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLDimension NO_FIX].value).to(equal(@"NO_FIX")); + expect([SDLDimension _2D].value).to(equal(@"2D")); + expect([SDLDimension _3D].value).to(equal(@"3D")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLDimension valueOf:@"NO_FIX"]).to(equal([SDLDimension NO_FIX])); + expect([SDLDimension valueOf:@"2D"]).to(equal([SDLDimension _2D])); + expect([SDLDimension valueOf:@"3D"]).to(equal([SDLDimension _3D])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLDimension valueOf:nil]).to(beNil()); + expect([SDLDimension valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLDimension values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLDimension NO_FIX], + [SDLDimension _2D], + [SDLDimension _3D]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDisplayTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDisplayTypeSpec.m new file mode 100644 index 000000000..964736fbc --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDisplayTypeSpec.m @@ -0,0 +1,80 @@ +// +// SDLDisplayTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDisplayType.h" + +QuickSpecBegin(SDLDisplayTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLDisplayType CID].value).to(equal(@"CID")); + expect([SDLDisplayType TYPE2].value).to(equal(@"TYPE2")); + expect([SDLDisplayType TYPE5].value).to(equal(@"TYPE5")); + expect([SDLDisplayType NGN].value).to(equal(@"NGN")); + expect([SDLDisplayType GEN2_6_DMA].value).to(equal(@"GEN2_6_DMA")); + expect([SDLDisplayType GEN2_8_DMA].value).to(equal(@"GEN2_8_DMA")); + expect([SDLDisplayType MFD3].value).to(equal(@"MFD3")); + expect([SDLDisplayType MFD4].value).to(equal(@"MFD4")); + expect([SDLDisplayType MFD5].value).to(equal(@"MFD5")); + //NOT DEFINED IN SPEC + expect([SDLDisplayType GEN3_8_INCH].value).to(equal(@"GEN3_8-INCH")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLDisplayType valueOf:@"CID"]).to(equal([SDLDisplayType CID])); + expect([SDLDisplayType valueOf:@"TYPE2"]).to(equal([SDLDisplayType TYPE2])); + expect([SDLDisplayType valueOf:@"TYPE5"]).to(equal([SDLDisplayType TYPE5])); + expect([SDLDisplayType valueOf:@"NGN"]).to(equal([SDLDisplayType NGN])); + expect([SDLDisplayType valueOf:@"GEN2_6_DMA"]).to(equal([SDLDisplayType GEN2_6_DMA])); + expect([SDLDisplayType valueOf:@"GEN2_8_DMA"]).to(equal([SDLDisplayType GEN2_8_DMA])); + expect([SDLDisplayType valueOf:@"MFD3"]).to(equal([SDLDisplayType MFD3])); + expect([SDLDisplayType valueOf:@"MFD4"]).to(equal([SDLDisplayType MFD4])); + expect([SDLDisplayType valueOf:@"MFD5"]).to(equal([SDLDisplayType MFD5])); + //NOT DEFINED IN SPEC + expect([SDLDisplayType valueOf:@"GEN3_8-INCH"]).to(equal([SDLDisplayType GEN3_8_INCH])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLDisplayType valueOf:nil]).to(beNil()); + expect([SDLDisplayType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLDisplayType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLDisplayType CID], + [SDLDisplayType TYPE2], + [SDLDisplayType TYPE5], + [SDLDisplayType NGN], + [SDLDisplayType GEN2_6_DMA], + [SDLDisplayType GEN2_8_DMA], + [SDLDisplayType MFD3], + [SDLDisplayType MFD4], + [SDLDisplayType MFD5], + //NOT DEFINED IN SPEC + [SDLDisplayType GEN3_8_INCH]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDriverDistractionStateSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDriverDistractionStateSpec.m new file mode 100644 index 000000000..8280259bc --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLDriverDistractionStateSpec.m @@ -0,0 +1,53 @@ +// +// SDLDriverDistractionStateSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDriverDistractionState.h" + +QuickSpecBegin(SDLDriverDistractionStateSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLDriverDistractionState DD_OFF].value).to(equal(@"DD_OFF")); + expect([SDLDriverDistractionState DD_ON].value).to(equal(@"DD_ON")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLDriverDistractionState valueOf:@"DD_OFF"]).to(equal([SDLDriverDistractionState DD_OFF])); + expect([SDLDriverDistractionState valueOf:@"DD_ON"]).to(equal([SDLDriverDistractionState DD_ON])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLDriverDistractionState valueOf:nil]).to(beNil()); + expect([SDLDriverDistractionState valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLDriverDistractionState values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLDriverDistractionState DD_OFF], + [SDLDriverDistractionState DD_ON]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLECallConfirmationStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLECallConfirmationStatusSpec.m new file mode 100644 index 000000000..aa5398c94 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLECallConfirmationStatusSpec.m @@ -0,0 +1,68 @@ +// +// SDLECallConfirmationStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLECallConfirmationStatus.h" + +QuickSpecBegin(SDLECallConfirmationStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLECallConfirmationStatus NORMAL].value).to(equal(@"NORMAL")); + expect([SDLECallConfirmationStatus CALL_IN_PROGRESS].value).to(equal(@"CALL_IN_PROGRESS")); + expect([SDLECallConfirmationStatus CALL_CANCELLED].value).to(equal(@"CALL_CANCELLED")); + expect([SDLECallConfirmationStatus CALL_COMPLETED].value).to(equal(@"CALL_COMPLETED")); + expect([SDLECallConfirmationStatus CALL_UNSUCCESSFUL].value).to(equal(@"CALL_UNSUCCESSFUL")); + expect([SDLECallConfirmationStatus ECALL_CONFIGURED_OFF].value).to(equal(@"ECALL_CONFIGURED_OFF")); + expect([SDLECallConfirmationStatus CALL_COMPLETE_DTMF_TIMEOUT].value).to(equal(@"CALL_COMPLETE_DTMF_TIMEOUT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLECallConfirmationStatus valueOf:@"NORMAL"]).to(equal([SDLECallConfirmationStatus NORMAL])); + expect([SDLECallConfirmationStatus valueOf:@"CALL_IN_PROGRESS"]).to(equal([SDLECallConfirmationStatus CALL_IN_PROGRESS])); + expect([SDLECallConfirmationStatus valueOf:@"CALL_CANCELLED"]).to(equal([SDLECallConfirmationStatus CALL_CANCELLED])); + expect([SDLECallConfirmationStatus valueOf:@"CALL_COMPLETED"]).to(equal([SDLECallConfirmationStatus CALL_COMPLETED])); + expect([SDLECallConfirmationStatus valueOf:@"CALL_UNSUCCESSFUL"]).to(equal([SDLECallConfirmationStatus CALL_UNSUCCESSFUL])); + expect([SDLECallConfirmationStatus valueOf:@"ECALL_CONFIGURED_OFF"]).to(equal([SDLECallConfirmationStatus ECALL_CONFIGURED_OFF])); + expect([SDLECallConfirmationStatus valueOf:@"CALL_COMPLETE_DTMF_TIMEOUT"]).to(equal([SDLECallConfirmationStatus CALL_COMPLETE_DTMF_TIMEOUT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLECallConfirmationStatus valueOf:nil]).to(beNil()); + expect([SDLECallConfirmationStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLECallConfirmationStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLECallConfirmationStatus NORMAL], + [SDLECallConfirmationStatus CALL_IN_PROGRESS], + [SDLECallConfirmationStatus CALL_CANCELLED], + [SDLECallConfirmationStatus CALL_COMPLETED], + [SDLECallConfirmationStatus CALL_UNSUCCESSFUL], + [SDLECallConfirmationStatus ECALL_CONFIGURED_OFF], + [SDLECallConfirmationStatus CALL_COMPLETE_DTMF_TIMEOUT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLEmergencyEventTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLEmergencyEventTypeSpec.m new file mode 100644 index 000000000..ff0126233 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLEmergencyEventTypeSpec.m @@ -0,0 +1,68 @@ +// +// SDLEmergencyEventTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEmergencyEventType.h" + +QuickSpecBegin(SDLEmergencyEventTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLEmergencyEventType NO_EVENT].value).to(equal(@"NO_EVENT")); + expect([SDLEmergencyEventType FRONTAL].value).to(equal(@"FRONTAL")); + expect([SDLEmergencyEventType SIDE].value).to(equal(@"SIDE")); + expect([SDLEmergencyEventType REAR].value).to(equal(@"REAR")); + expect([SDLEmergencyEventType ROLLOVER].value).to(equal(@"ROLLOVER")); + expect([SDLEmergencyEventType NOT_SUPPORTED].value).to(equal(@"NOT_SUPPORTED")); + expect([SDLEmergencyEventType FAULT].value).to(equal(@"FAULT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLEmergencyEventType valueOf:@"NO_EVENT"]).to(equal([SDLEmergencyEventType NO_EVENT])); + expect([SDLEmergencyEventType valueOf:@"FRONTAL"]).to(equal([SDLEmergencyEventType FRONTAL])); + expect([SDLEmergencyEventType valueOf:@"SIDE"]).to(equal([SDLEmergencyEventType SIDE])); + expect([SDLEmergencyEventType valueOf:@"REAR"]).to(equal([SDLEmergencyEventType REAR])); + expect([SDLEmergencyEventType valueOf:@"ROLLOVER"]).to(equal([SDLEmergencyEventType ROLLOVER])); + expect([SDLEmergencyEventType valueOf:@"NOT_SUPPORTED"]).to(equal([SDLEmergencyEventType NOT_SUPPORTED])); + expect([SDLEmergencyEventType valueOf:@"FAULT"]).to(equal([SDLEmergencyEventType FAULT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLEmergencyEventType valueOf:nil]).to(beNil()); + expect([SDLEmergencyEventType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLEmergencyEventType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLEmergencyEventType NO_EVENT], + [SDLEmergencyEventType FRONTAL], + [SDLEmergencyEventType SIDE], + [SDLEmergencyEventType REAR], + [SDLEmergencyEventType ROLLOVER], + [SDLEmergencyEventType NOT_SUPPORTED], + [SDLEmergencyEventType FAULT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLFileTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLFileTypeSpec.m new file mode 100644 index 000000000..77eab74dc --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLFileTypeSpec.m @@ -0,0 +1,71 @@ +// +// SDLFileTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFileType.h" + +QuickSpecBegin(SDLFileTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLFileType GRAPHIC_BMP].value).to(equal(@"GRAPHIC_BMP")); + expect([SDLFileType GRAPHIC_JPEG].value).to(equal(@"GRAPHIC_JPEG")); + expect([SDLFileType GRAPHIC_PNG].value).to(equal(@"GRAPHIC_PNG")); + expect([SDLFileType AUDIO_WAVE].value).to(equal(@"AUDIO_WAVE")); + expect([SDLFileType AUDIO_MP3].value).to(equal(@"AUDIO_MP3")); + expect([SDLFileType AUDIO_AAC].value).to(equal(@"AUDIO_AAC")); + expect([SDLFileType BINARY].value).to(equal(@"BINARY")); + expect([SDLFileType JSON].value).to(equal(@"JSON")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLFileType valueOf:@"GRAPHIC_BMP"]).to(equal([SDLFileType GRAPHIC_BMP])); + expect([SDLFileType valueOf:@"GRAPHIC_JPEG"]).to(equal([SDLFileType GRAPHIC_JPEG])); + expect([SDLFileType valueOf:@"GRAPHIC_PNG"]).to(equal([SDLFileType GRAPHIC_PNG])); + expect([SDLFileType valueOf:@"AUDIO_WAVE"]).to(equal([SDLFileType AUDIO_WAVE])); + expect([SDLFileType valueOf:@"AUDIO_MP3"]).to(equal([SDLFileType AUDIO_MP3])); + expect([SDLFileType valueOf:@"AUDIO_AAC"]).to(equal([SDLFileType AUDIO_AAC])); + expect([SDLFileType valueOf:@"BINARY"]).to(equal([SDLFileType BINARY])); + expect([SDLFileType valueOf:@"JSON"]).to(equal([SDLFileType JSON])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLFileType valueOf:nil]).to(beNil()); + expect([SDLFileType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLFileType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLFileType GRAPHIC_BMP], + [SDLFileType GRAPHIC_JPEG], + [SDLFileType GRAPHIC_PNG], + [SDLFileType AUDIO_WAVE], + [SDLFileType AUDIO_MP3], + [SDLFileType AUDIO_AAC], + [SDLFileType BINARY], + [SDLFileType JSON]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLFuelCutoffStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLFuelCutoffStatusSpec.m new file mode 100644 index 000000000..d4833ff40 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLFuelCutoffStatusSpec.m @@ -0,0 +1,56 @@ +// +// SDLFuelCutoffStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFuelCutoffStatus.h" + +QuickSpecBegin(SDLFuelCutoffStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLFuelCutoffStatus TERMINATE_FUEL].value).to(equal(@"TERMINATE_FUEL")); + expect([SDLFuelCutoffStatus NORMAL_OPERATION].value).to(equal(@"NORMAL_OPERATION")); + expect([SDLFuelCutoffStatus FAULT].value).to(equal(@"FAULT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLFuelCutoffStatus valueOf:@"TERMINATE_FUEL"]).to(equal([SDLFuelCutoffStatus TERMINATE_FUEL])); + expect([SDLFuelCutoffStatus valueOf:@"NORMAL_OPERATION"]).to(equal([SDLFuelCutoffStatus NORMAL_OPERATION])); + expect([SDLFuelCutoffStatus valueOf:@"FAULT"]).to(equal([SDLFuelCutoffStatus FAULT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLFuelCutoffStatus valueOf:nil]).to(beNil()); + expect([SDLFuelCutoffStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLFuelCutoffStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLFuelCutoffStatus TERMINATE_FUEL], + [SDLFuelCutoffStatus NORMAL_OPERATION], + [SDLFuelCutoffStatus FAULT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLGlobalProperySpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLGlobalProperySpec.m new file mode 100644 index 000000000..2844dcf41 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLGlobalProperySpec.m @@ -0,0 +1,68 @@ +// +// SDLGlobalPropertySpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLGlobalProperty.h" + +QuickSpecBegin(SDLGlobalPropertySpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLGlobalProperty HELPPROMPT].value).to(equal(@"HELPPROMPT")); + expect([SDLGlobalProperty TIMEOUTPROMPT].value).to(equal(@"TIMEOUTPROMPT")); + expect([SDLGlobalProperty VRHELPTITLE].value).to(equal(@"VRHELPTITLE")); + expect([SDLGlobalProperty VRHELPITEMS].value).to(equal(@"VRHELPITEMS")); + expect([SDLGlobalProperty MENUNAME].value).to(equal(@"MENUNAME")); + expect([SDLGlobalProperty MENUICON].value).to(equal(@"MENUICON")); + expect([SDLGlobalProperty KEYBOARDPROPERTIES].value).to(equal(@"KEYBOARDPROPERTIES")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLGlobalProperty valueOf:@"HELPPROMPT"]).to(equal([SDLGlobalProperty HELPPROMPT])); + expect([SDLGlobalProperty valueOf:@"TIMEOUTPROMPT"]).to(equal([SDLGlobalProperty TIMEOUTPROMPT])); + expect([SDLGlobalProperty valueOf:@"VRHELPTITLE"]).to(equal([SDLGlobalProperty VRHELPTITLE])); + expect([SDLGlobalProperty valueOf:@"VRHELPITEMS"]).to(equal([SDLGlobalProperty VRHELPITEMS])); + expect([SDLGlobalProperty valueOf:@"MENUNAME"]).to(equal([SDLGlobalProperty MENUNAME])); + expect([SDLGlobalProperty valueOf:@"MENUICON"]).to(equal([SDLGlobalProperty MENUICON])); + expect([SDLGlobalProperty valueOf:@"KEYBOARDPROPERTIES"]).to(equal([SDLGlobalProperty KEYBOARDPROPERTIES])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLGlobalProperty valueOf:nil]).to(beNil()); + expect([SDLGlobalProperty valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLGlobalProperty values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLGlobalProperty HELPPROMPT], + [SDLGlobalProperty TIMEOUTPROMPT], + [SDLGlobalProperty VRHELPTITLE], + [SDLGlobalProperty VRHELPITEMS], + [SDLGlobalProperty MENUNAME], + [SDLGlobalProperty MENUICON], + [SDLGlobalProperty KEYBOARDPROPERTIES]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLHMILevelSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLHMILevelSpec.m new file mode 100644 index 000000000..8b9d9f9b7 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLHMILevelSpec.m @@ -0,0 +1,59 @@ +// +// SDLHMILevelSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMILevel.h" + +QuickSpecBegin(SDLHMILevelSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLHMILevel FULL].value).to(equal(@"FULL")); + expect([SDLHMILevel LIMITED].value).to(equal(@"LIMITED")); + expect([SDLHMILevel BACKGROUND].value).to(equal(@"BACKGROUND")); + expect([SDLHMILevel NONE].value).to(equal(@"NONE")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLHMILevel valueOf:@"FULL"]).to(equal([SDLHMILevel FULL])); + expect([SDLHMILevel valueOf:@"LIMITED"]).to(equal([SDLHMILevel LIMITED])); + expect([SDLHMILevel valueOf:@"BACKGROUND"]).to(equal([SDLHMILevel BACKGROUND])); + expect([SDLHMILevel valueOf:@"NONE"]).to(equal([SDLHMILevel NONE])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLHMILevel valueOf:nil]).to(beNil()); + expect([SDLHMILevel valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLHMILevel values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLHMILevel FULL], + [SDLHMILevel LIMITED], + [SDLHMILevel BACKGROUND], + [SDLHMILevel NONE]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLHMIZoneCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLHMIZoneCapabilitiesSpec.m new file mode 100644 index 000000000..d19e1f855 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLHMIZoneCapabilitiesSpec.m @@ -0,0 +1,53 @@ +// +// SDLHMIZoneCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMIZoneCapabilities.h" + +QuickSpecBegin(SDLHmiZoneCapabilitiesSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLHMIZoneCapabilities FRONT].value).to(equal(@"FRONT")); + expect([SDLHMIZoneCapabilities BACK].value).to(equal(@"BACK")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLHMIZoneCapabilities valueOf:@"FRONT"]).to(equal([SDLHMIZoneCapabilities FRONT])); + expect([SDLHMIZoneCapabilities valueOf:@"BACK"]).to(equal([SDLHMIZoneCapabilities BACK])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLHMIZoneCapabilities valueOf:nil]).to(beNil()); + expect([SDLHMIZoneCapabilities valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLHMIZoneCapabilities values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLHMIZoneCapabilities FRONT], + [SDLHMIZoneCapabilities BACK]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLIgnitionStableStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLIgnitionStableStatusSpec.m new file mode 100644 index 000000000..bbe507499 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLIgnitionStableStatusSpec.m @@ -0,0 +1,56 @@ +// +// SDLIgnitionStableStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLIgnitionStableStatus.h" + +QuickSpecBegin(SDLIgnitionStableStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLIgnitionStableStatus IGNITION_SWITCH_NOT_STABLE].value).to(equal(@"IGNITION_SWITCH_NOT_STABLE")); + expect([SDLIgnitionStableStatus IGNITION_SWITCH_STABLE].value).to(equal(@"IGNITION_SWITCH_STABLE")); + expect([SDLIgnitionStableStatus MISSING_FROM_TRANSMITTER].value).to(equal(@"MISSING_FROM_TRANSMITTER")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLIgnitionStableStatus valueOf:@"IGNITION_SWITCH_NOT_STABLE"]).to(equal([SDLIgnitionStableStatus IGNITION_SWITCH_NOT_STABLE])); + expect([SDLIgnitionStableStatus valueOf:@"IGNITION_SWITCH_STABLE"]).to(equal([SDLIgnitionStableStatus IGNITION_SWITCH_STABLE])); + expect([SDLIgnitionStableStatus valueOf:@"MISSING_FROM_TRANSMITTER"]).to(equal([SDLIgnitionStableStatus MISSING_FROM_TRANSMITTER])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLIgnitionStableStatus valueOf:nil]).to(beNil()); + expect([SDLIgnitionStableStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLIgnitionStableStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLIgnitionStableStatus IGNITION_SWITCH_NOT_STABLE], + [SDLIgnitionStableStatus IGNITION_SWITCH_STABLE], + [SDLIgnitionStableStatus MISSING_FROM_TRANSMITTER]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLIgnitionStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLIgnitionStatusSpec.m new file mode 100644 index 000000000..c36c30c23 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLIgnitionStatusSpec.m @@ -0,0 +1,65 @@ +// +// SDLIgnitionStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLIgnitionStatus.h" + +QuickSpecBegin(SDLIgnitionStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLIgnitionStatus UNKNOWN].value).to(equal(@"UNKNOWN")); + expect([SDLIgnitionStatus OFF].value).to(equal(@"OFF")); + expect([SDLIgnitionStatus ACCESSORY].value).to(equal(@"ACCESSORY")); + expect([SDLIgnitionStatus RUN].value).to(equal(@"RUN")); + expect([SDLIgnitionStatus START].value).to(equal(@"START")); + expect([SDLIgnitionStatus INVALID].value).to(equal(@"INVALID")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLIgnitionStatus valueOf:@"UNKNOWN"]).to(equal([SDLIgnitionStatus UNKNOWN])); + expect([SDLIgnitionStatus valueOf:@"OFF"]).to(equal([SDLIgnitionStatus OFF])); + expect([SDLIgnitionStatus valueOf:@"ACCESSORY"]).to(equal([SDLIgnitionStatus ACCESSORY])); + expect([SDLIgnitionStatus valueOf:@"RUN"]).to(equal([SDLIgnitionStatus RUN])); + expect([SDLIgnitionStatus valueOf:@"START"]).to(equal([SDLIgnitionStatus START])); + expect([SDLIgnitionStatus valueOf:@"INVALID"]).to(equal([SDLIgnitionStatus INVALID])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLIgnitionStatus valueOf:nil]).to(beNil()); + expect([SDLIgnitionStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLIgnitionStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLIgnitionStatus UNKNOWN], + [SDLIgnitionStatus OFF], + [SDLIgnitionStatus ACCESSORY], + [SDLIgnitionStatus RUN], + [SDLIgnitionStatus START], + [SDLIgnitionStatus INVALID]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLImageFieldNameSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLImageFieldNameSpec.m new file mode 100644 index 000000000..5b19dc384 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLImageFieldNameSpec.m @@ -0,0 +1,86 @@ +// +// SDLImageFieldNameSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImageFieldName.h" + +QuickSpecBegin(SDLImageFieldNameSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLImageFieldName softButtonImage].value).to(equal(@"softButtonImage")); + expect([SDLImageFieldName choiceImage].value).to(equal(@"choiceImage")); + expect([SDLImageFieldName choiceSecondaryImage].value).to(equal(@"choiceSecondaryImage")); + expect([SDLImageFieldName vrHelpItem].value).to(equal(@"vrHelpItem")); + expect([SDLImageFieldName turnIcon].value).to(equal(@"turnIcon")); + expect([SDLImageFieldName menuIcon].value).to(equal(@"menuIcon")); + expect([SDLImageFieldName cmdIcon].value).to(equal(@"cmdIcon")); + expect([SDLImageFieldName appIcon].value).to(equal(@"appIcon")); + expect([SDLImageFieldName graphic].value).to(equal(@"graphic")); + expect([SDLImageFieldName showConstantTBTIcon].value).to(equal(@"showConstantTBTIcon")); + expect([SDLImageFieldName showConstantTBTNextTurnIcon].value).to(equal(@"showConstantTBTNextTurnIcon")); + expect([SDLImageFieldName locationImage].value).to(equal(@"locationImage")); + }); +}); + +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLImageFieldName valueOf:@"softButtonImage"]).to(equal([SDLImageFieldName softButtonImage])); + expect([SDLImageFieldName valueOf:@"choiceImage"]).to(equal([SDLImageFieldName choiceImage])); + expect([SDLImageFieldName valueOf:@"choiceSecondaryImage"]).to(equal([SDLImageFieldName choiceSecondaryImage])); + expect([SDLImageFieldName valueOf:@"vrHelpItem"]).to(equal([SDLImageFieldName vrHelpItem])); + expect([SDLImageFieldName valueOf:@"turnIcon"]).to(equal([SDLImageFieldName turnIcon])); + expect([SDLImageFieldName valueOf:@"menuIcon"]).to(equal([SDLImageFieldName menuIcon])); + expect([SDLImageFieldName valueOf:@"cmdIcon"]).to(equal([SDLImageFieldName cmdIcon])); + expect([SDLImageFieldName valueOf:@"appIcon"]).to(equal([SDLImageFieldName appIcon])); + expect([SDLImageFieldName valueOf:@"graphic"]).to(equal([SDLImageFieldName graphic])); + expect([SDLImageFieldName valueOf:@"showConstantTBTIcon"]).to(equal([SDLImageFieldName showConstantTBTIcon])); + expect([SDLImageFieldName valueOf:@"showConstantTBTNextTurnIcon"]).to(equal([SDLImageFieldName showConstantTBTNextTurnIcon])); + expect([SDLImageFieldName valueOf:@"locationImage"]).to(equal([SDLImageFieldName locationImage])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLImageFieldName valueOf:nil]).to(beNil()); + expect([SDLImageFieldName valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); + +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLImageFieldName values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLImageFieldName softButtonImage], + [SDLImageFieldName choiceImage], + [SDLImageFieldName choiceSecondaryImage], + [SDLImageFieldName vrHelpItem], + [SDLImageFieldName turnIcon], + [SDLImageFieldName menuIcon], + [SDLImageFieldName cmdIcon], + [SDLImageFieldName appIcon], + [SDLImageFieldName graphic], + [SDLImageFieldName showConstantTBTIcon], + [SDLImageFieldName locationImage], + [SDLImageFieldName showConstantTBTNextTurnIcon]] copy]; + + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLImageTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLImageTypeSpec.m new file mode 100644 index 000000000..1a63bf7f8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLImageTypeSpec.m @@ -0,0 +1,53 @@ +// +// SDLImageTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImageType.h" + +QuickSpecBegin(SDLImageTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLImageType STATIC].value).to(equal(@"STATIC")); + expect([SDLImageType DYNAMIC].value).to(equal(@"DYNAMIC")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLImageType valueOf:@"STATIC"]).to(equal([SDLImageType STATIC])); + expect([SDLImageType valueOf:@"DYNAMIC"]).to(equal([SDLImageType DYNAMIC])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLImageType valueOf:nil]).to(beNil()); + expect([SDLImageType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLImageType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLImageType STATIC], + [SDLImageType DYNAMIC]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLInteractionModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLInteractionModeSpec.m new file mode 100644 index 000000000..95341e347 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLInteractionModeSpec.m @@ -0,0 +1,56 @@ +// +// SDLInteractionModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLInteractionMode.h" + +QuickSpecBegin(SDLInteractionModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLInteractionMode MANUAL_ONLY].value).to(equal(@"MANUAL_ONLY")); + expect([SDLInteractionMode VR_ONLY].value).to(equal(@"VR_ONLY")); + expect([SDLInteractionMode BOTH].value).to(equal(@"BOTH")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLInteractionMode valueOf:@"MANUAL_ONLY"]).to(equal([SDLInteractionMode MANUAL_ONLY])); + expect([SDLInteractionMode valueOf:@"VR_ONLY"]).to(equal([SDLInteractionMode VR_ONLY])); + expect([SDLInteractionMode valueOf:@"BOTH"]).to(equal([SDLInteractionMode BOTH])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLInteractionMode valueOf:nil]).to(beNil()); + expect([SDLInteractionMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLInteractionMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLInteractionMode MANUAL_ONLY], + [SDLInteractionMode VR_ONLY], + [SDLInteractionMode BOTH]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeyboardEventSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeyboardEventSpec.m new file mode 100644 index 000000000..560876185 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeyboardEventSpec.m @@ -0,0 +1,64 @@ +// +// SDLKeyboardEventSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLKeyboardEvent.h" + +QuickSpecBegin(SDLKeyboardEventSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLKeyboardEvent KEYPRESS].value).to(equal(@"KEYPRESS")); + expect([SDLKeyboardEvent ENTRY_SUBMITTED].value).to(equal(@"ENTRY_SUBMITTED")); + expect([SDLKeyboardEvent ENTRY_CANCELLED].value).to(equal(@"ENTRY_CANCELLED")); + expect([SDLKeyboardEvent ENTRY_ABORTED].value).to(equal(@"ENTRY_ABORTED")); + expect([SDLKeyboardEvent ENTRY_VOICE].value).to(equal(@"ENTRY_VOICE")); + }); +}); + +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLKeyboardEvent valueOf:@"KEYPRESS"]).to(equal([SDLKeyboardEvent KEYPRESS])); + expect([SDLKeyboardEvent valueOf:@"ENTRY_SUBMITTED"]).to(equal([SDLKeyboardEvent ENTRY_SUBMITTED])); + expect([SDLKeyboardEvent valueOf:@"ENTRY_CANCELLED"]).to(equal([SDLKeyboardEvent ENTRY_CANCELLED])); + expect([SDLKeyboardEvent valueOf:@"ENTRY_ABORTED"]).to(equal([SDLKeyboardEvent ENTRY_ABORTED])); + expect([SDLKeyboardEvent valueOf:@"ENTRY_VOICE"]).to(equal([SDLKeyboardEvent ENTRY_VOICE])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLKeyboardEvent valueOf:nil]).to(beNil()); + expect([SDLKeyboardEvent valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); + +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLKeyboardEvent values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLKeyboardEvent KEYPRESS], + [SDLKeyboardEvent ENTRY_SUBMITTED], + [SDLKeyboardEvent ENTRY_CANCELLED], + [SDLKeyboardEvent ENTRY_ABORTED], + [SDLKeyboardEvent ENTRY_VOICE]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeyboardLayoutSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeyboardLayoutSpec.m new file mode 100644 index 000000000..c55d8cd28 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeyboardLayoutSpec.m @@ -0,0 +1,56 @@ +// +// SDLKeyboardLayoutSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLKeyboardLayout.h" + +QuickSpecBegin(SDLKeyboardLayoutSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLKeyboardLayout QWERTY].value).to(equal(@"QWERTY")); + expect([SDLKeyboardLayout QWERTZ].value).to(equal(@"QWERTZ")); + expect([SDLKeyboardLayout AZERTY].value).to(equal(@"AZERTY")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLKeyboardLayout valueOf:@"QWERTY"]).to(equal([SDLKeyboardLayout QWERTY])); + expect([SDLKeyboardLayout valueOf:@"QWERTZ"]).to(equal([SDLKeyboardLayout QWERTZ])); + expect([SDLKeyboardLayout valueOf:@"AZERTY"]).to(equal([SDLKeyboardLayout AZERTY])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLKeyboardLayout valueOf:nil]).to(beNil()); + expect([SDLKeyboardLayout valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLKeyboardLayout values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLKeyboardLayout QWERTY], + [SDLKeyboardLayout QWERTZ], + [SDLKeyboardLayout AZERTY]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeypressModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeypressModeSpec.m new file mode 100644 index 000000000..d7304fe5e --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLKeypressModeSpec.m @@ -0,0 +1,56 @@ +// +// SDLKeypressModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLKeypressMode.h" + +QuickSpecBegin(SDLKeypressModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLKeypressMode SINGLE_KEYPRESS].value).to(equal(@"SINGLE_KEYPRESS")); + expect([SDLKeypressMode QUEUE_KEYPRESSES].value).to(equal(@"QUEUE_KEYPRESSES")); + expect([SDLKeypressMode RESEND_CURRENT_ENTRY].value).to(equal(@"RESEND_CURRENT_ENTRY")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLKeypressMode valueOf:@"SINGLE_KEYPRESS"]).to(equal([SDLKeypressMode SINGLE_KEYPRESS])); + expect([SDLKeypressMode valueOf:@"QUEUE_KEYPRESSES"]).to(equal([SDLKeypressMode QUEUE_KEYPRESSES])); + expect([SDLKeypressMode valueOf:@"RESEND_CURRENT_ENTRY"]).to(equal([SDLKeypressMode RESEND_CURRENT_ENTRY])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLKeypressMode valueOf:nil]).to(beNil()); + expect([SDLKeypressMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLKeypressMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLKeypressMode SINGLE_KEYPRESS], + [SDLKeypressMode QUEUE_KEYPRESSES], + [SDLKeypressMode RESEND_CURRENT_ENTRY]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLanguageSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLanguageSpec.m new file mode 100644 index 000000000..1c3ec06e0 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLanguageSpec.m @@ -0,0 +1,119 @@ +// +// SDLLanguageSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLLanguage.h" + +QuickSpecBegin(SDLLanguageSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLLanguage EN_US].value).to(equal(@"EN-US")); + expect([SDLLanguage ES_MX].value).to(equal(@"ES-MX")); + expect([SDLLanguage FR_CA].value).to(equal(@"FR-CA")); + expect([SDLLanguage DE_DE].value).to(equal(@"DE-DE")); + expect([SDLLanguage ES_ES].value).to(equal(@"ES-ES")); + expect([SDLLanguage EN_GB].value).to(equal(@"EN-GB")); + expect([SDLLanguage RU_RU].value).to(equal(@"RU-RU")); + expect([SDLLanguage TR_TR].value).to(equal(@"TR-TR")); + expect([SDLLanguage PL_PL].value).to(equal(@"PL-PL")); + expect([SDLLanguage FR_FR].value).to(equal(@"FR-FR")); + expect([SDLLanguage IT_IT].value).to(equal(@"IT-IT")); + expect([SDLLanguage SV_SE].value).to(equal(@"SV-SE")); + expect([SDLLanguage PT_PT].value).to(equal(@"PT-PT")); + expect([SDLLanguage NL_NL].value).to(equal(@"NL-NL")); + expect([SDLLanguage EN_AU].value).to(equal(@"EN-AU")); + expect([SDLLanguage ZH_CN].value).to(equal(@"ZH-CN")); + expect([SDLLanguage ZH_TW].value).to(equal(@"ZH-TW")); + expect([SDLLanguage JA_JP].value).to(equal(@"JA-JP")); + expect([SDLLanguage AR_SA].value).to(equal(@"AR-SA")); + expect([SDLLanguage KO_KR].value).to(equal(@"KO-KR")); + expect([SDLLanguage PT_BR].value).to(equal(@"PT-BR")); + expect([SDLLanguage CS_CZ].value).to(equal(@"CS-CZ")); + expect([SDLLanguage DA_DK].value).to(equal(@"DA-DK")); + expect([SDLLanguage NO_NO].value).to(equal(@"NO-NO")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLLanguage valueOf:@"EN-US"]).to(equal([SDLLanguage EN_US])); + expect([SDLLanguage valueOf:@"ES-MX"]).to(equal([SDLLanguage ES_MX])); + expect([SDLLanguage valueOf:@"FR-CA"]).to(equal([SDLLanguage FR_CA])); + expect([SDLLanguage valueOf:@"DE-DE"]).to(equal([SDLLanguage DE_DE])); + expect([SDLLanguage valueOf:@"ES-ES"]).to(equal([SDLLanguage ES_ES])); + expect([SDLLanguage valueOf:@"EN-GB"]).to(equal([SDLLanguage EN_GB])); + expect([SDLLanguage valueOf:@"RU-RU"]).to(equal([SDLLanguage RU_RU])); + expect([SDLLanguage valueOf:@"TR-TR"]).to(equal([SDLLanguage TR_TR])); + expect([SDLLanguage valueOf:@"PL-PL"]).to(equal([SDLLanguage PL_PL])); + expect([SDLLanguage valueOf:@"FR-FR"]).to(equal([SDLLanguage FR_FR])); + expect([SDLLanguage valueOf:@"IT-IT"]).to(equal([SDLLanguage IT_IT])); + expect([SDLLanguage valueOf:@"SV-SE"]).to(equal([SDLLanguage SV_SE])); + expect([SDLLanguage valueOf:@"PT-PT"]).to(equal([SDLLanguage PT_PT])); + expect([SDLLanguage valueOf:@"NL-NL"]).to(equal([SDLLanguage NL_NL])); + expect([SDLLanguage valueOf:@"EN-AU"]).to(equal([SDLLanguage EN_AU])); + expect([SDLLanguage valueOf:@"ZH-CN"]).to(equal([SDLLanguage ZH_CN])); + expect([SDLLanguage valueOf:@"ZH-TW"]).to(equal([SDLLanguage ZH_TW])); + expect([SDLLanguage valueOf:@"JA-JP"]).to(equal([SDLLanguage JA_JP])); + expect([SDLLanguage valueOf:@"AR-SA"]).to(equal([SDLLanguage AR_SA])); + expect([SDLLanguage valueOf:@"KO-KR"]).to(equal([SDLLanguage KO_KR])); + expect([SDLLanguage valueOf:@"PT-BR"]).to(equal([SDLLanguage PT_BR])); + expect([SDLLanguage valueOf:@"CS-CZ"]).to(equal([SDLLanguage CS_CZ])); + expect([SDLLanguage valueOf:@"DA-DK"]).to(equal([SDLLanguage DA_DK])); + expect([SDLLanguage valueOf:@"NO-NO"]).to(equal([SDLLanguage NO_NO])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLLanguage valueOf:nil]).to(beNil()); + expect([SDLLanguage valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLLanguage values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLLanguage EN_US], + [SDLLanguage ES_MX], + [SDLLanguage FR_CA], + [SDLLanguage DE_DE], + [SDLLanguage ES_ES], + [SDLLanguage EN_GB], + [SDLLanguage RU_RU], + [SDLLanguage TR_TR], + [SDLLanguage PL_PL], + [SDLLanguage FR_FR], + [SDLLanguage IT_IT], + [SDLLanguage SV_SE], + [SDLLanguage PT_PT], + [SDLLanguage NL_NL], + [SDLLanguage EN_AU], + [SDLLanguage ZH_CN], + [SDLLanguage ZH_TW], + [SDLLanguage JA_JP], + [SDLLanguage AR_SA], + [SDLLanguage KO_KR], + [SDLLanguage PT_BR], + [SDLLanguage CS_CZ], + [SDLLanguage DA_DK], + [SDLLanguage NO_NO]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLayoutModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLayoutModeSpec.m new file mode 100644 index 000000000..6aea31374 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLayoutModeSpec.m @@ -0,0 +1,62 @@ +// +// SDLLayoutModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLLayoutMode.h" + +QuickSpecBegin(SDLLayoutModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLLayoutMode ICON_ONLY].value).to(equal(@"ICON_ONLY")); + expect([SDLLayoutMode ICON_WITH_SEARCH].value).to(equal(@"ICON_WITH_SEARCH")); + expect([SDLLayoutMode LIST_ONLY].value).to(equal(@"LIST_ONLY")); + expect([SDLLayoutMode LIST_WITH_SEARCH].value).to(equal(@"LIST_WITH_SEARCH")); + expect([SDLLayoutMode KEYBOARD].value).to(equal(@"KEYBOARD")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLLayoutMode valueOf:@"ICON_ONLY"]).to(equal([SDLLayoutMode ICON_ONLY])); + expect([SDLLayoutMode valueOf:@"ICON_WITH_SEARCH"]).to(equal([SDLLayoutMode ICON_WITH_SEARCH])); + expect([SDLLayoutMode valueOf:@"LIST_ONLY"]).to(equal([SDLLayoutMode LIST_ONLY])); + expect([SDLLayoutMode valueOf:@"LIST_WITH_SEARCH"]).to(equal([SDLLayoutMode LIST_WITH_SEARCH])); + expect([SDLLayoutMode valueOf:@"KEYBOARD"]).to(equal([SDLLayoutMode KEYBOARD])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLLayoutMode valueOf:nil]).to(beNil()); + expect([SDLLayoutMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLLayoutMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLLayoutMode ICON_ONLY], + [SDLLayoutMode ICON_WITH_SEARCH], + [SDLLayoutMode LIST_ONLY], + [SDLLayoutMode LIST_WITH_SEARCH], + [SDLLayoutMode KEYBOARD]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLockScreenStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLockScreenStatusSpec.m new file mode 100644 index 000000000..a6d7ecdac --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLLockScreenStatusSpec.m @@ -0,0 +1,56 @@ +// +// SDLLockScreenStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLLockScreenStatus.h" + +QuickSpecBegin(SDLLockScreenStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLLockScreenStatus OFF].value).to(equal(@"OFF")); + expect([SDLLockScreenStatus OPTIONAL].value).to(equal(@"OPTIONAL")); + expect([SDLLockScreenStatus REQUIRED].value).to(equal(@"REQUIRED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLLockScreenStatus valueOf:@"OFF"]).to(equal([SDLLockScreenStatus OFF])); + expect([SDLLockScreenStatus valueOf:@"OPTIONAL"]).to(equal([SDLLockScreenStatus OPTIONAL])); + expect([SDLLockScreenStatus valueOf:@"REQUIRED"]).to(equal([SDLLockScreenStatus REQUIRED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLLockScreenStatus valueOf:nil]).to(beNil()); + expect([SDLLockScreenStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLLockScreenStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLLockScreenStatus OFF], + [SDLLockScreenStatus OPTIONAL], + [SDLLockScreenStatus REQUIRED]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLMaintenanceModeStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLMaintenanceModeStatusSpec.m new file mode 100644 index 000000000..349a073eb --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLMaintenanceModeStatusSpec.m @@ -0,0 +1,59 @@ +// +// SDLMaintenanceModeStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLMaintenanceModeStatus.h" + +QuickSpecBegin(SDLMaintenanceModeStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLMaintenanceModeStatus NORMAL].value).to(equal(@"NORMAL")); + expect([SDLMaintenanceModeStatus NEAR].value).to(equal(@"NEAR")); + expect([SDLMaintenanceModeStatus ACTIVE].value).to(equal(@"ACTIVE")); + expect([SDLMaintenanceModeStatus FEATURE_NOT_PRESENT].value).to(equal(@"FEATURE_NOT_PRESENT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLMaintenanceModeStatus valueOf:@"NORMAL"]).to(equal([SDLMaintenanceModeStatus NORMAL])); + expect([SDLMaintenanceModeStatus valueOf:@"NEAR"]).to(equal([SDLMaintenanceModeStatus NEAR])); + expect([SDLMaintenanceModeStatus valueOf:@"ACTIVE"]).to(equal([SDLMaintenanceModeStatus ACTIVE])); + expect([SDLMaintenanceModeStatus valueOf:@"FEATURE_NOT_PRESENT"]).to(equal([SDLMaintenanceModeStatus FEATURE_NOT_PRESENT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLMaintenanceModeStatus valueOf:nil]).to(beNil()); + expect([SDLMaintenanceModeStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLMaintenanceModeStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLMaintenanceModeStatus NORMAL], + [SDLMaintenanceModeStatus NEAR], + [SDLMaintenanceModeStatus ACTIVE], + [SDLMaintenanceModeStatus FEATURE_NOT_PRESENT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLMediaClockFormatSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLMediaClockFormatSpec.m new file mode 100644 index 000000000..80603a2b0 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLMediaClockFormatSpec.m @@ -0,0 +1,68 @@ +// +// SDLMediaClockFormatSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLMediaClockFormat.h" + +QuickSpecBegin(SDLMediaClockFormatSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLMediaClockFormat CLOCK1].value).to(equal(@"CLOCK1")); + expect([SDLMediaClockFormat CLOCK2].value).to(equal(@"CLOCK2")); + expect([SDLMediaClockFormat CLOCK3].value).to(equal(@"CLOCK3")); + expect([SDLMediaClockFormat CLOCKTEXT1].value).to(equal(@"CLOCKTEXT1")); + expect([SDLMediaClockFormat CLOCKTEXT2].value).to(equal(@"CLOCKTEXT2")); + expect([SDLMediaClockFormat CLOCKTEXT3].value).to(equal(@"CLOCKTEXT3")); + expect([SDLMediaClockFormat CLOCKTEXT4].value).to(equal(@"CLOCKTEXT4")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLMediaClockFormat valueOf:@"CLOCK1"]).to(equal([SDLMediaClockFormat CLOCK1])); + expect([SDLMediaClockFormat valueOf:@"CLOCK2"]).to(equal([SDLMediaClockFormat CLOCK2])); + expect([SDLMediaClockFormat valueOf:@"CLOCK3"]).to(equal([SDLMediaClockFormat CLOCK3])); + expect([SDLMediaClockFormat valueOf:@"CLOCKTEXT1"]).to(equal([SDLMediaClockFormat CLOCKTEXT1])); + expect([SDLMediaClockFormat valueOf:@"CLOCKTEXT2"]).to(equal([SDLMediaClockFormat CLOCKTEXT2])); + expect([SDLMediaClockFormat valueOf:@"CLOCKTEXT3"]).to(equal([SDLMediaClockFormat CLOCKTEXT3])); + expect([SDLMediaClockFormat valueOf:@"CLOCKTEXT4"]).to(equal([SDLMediaClockFormat CLOCKTEXT4])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLMediaClockFormat valueOf:nil]).to(beNil()); + expect([SDLMediaClockFormat valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLMediaClockFormat values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLMediaClockFormat CLOCK1], + [SDLMediaClockFormat CLOCK2], + [SDLMediaClockFormat CLOCK3], + [SDLMediaClockFormat CLOCKTEXT1], + [SDLMediaClockFormat CLOCKTEXT2], + [SDLMediaClockFormat CLOCKTEXT3], + [SDLMediaClockFormat CLOCKTEXT4]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPRNDLSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPRNDLSpec.m new file mode 100644 index 000000000..5310f3488 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPRNDLSpec.m @@ -0,0 +1,95 @@ +// +// SDLPRNDLSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPRNDL.h" + +QuickSpecBegin(SDLPRNDLSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPRNDL PARK].value).to(equal(@"PARK")); + expect([SDLPRNDL REVERSE].value).to(equal(@"REVERSE")); + expect([SDLPRNDL NEUTRAL].value).to(equal(@"NEUTRAL")); + expect([SDLPRNDL DRIVE].value).to(equal(@"DRIVE")); + expect([SDLPRNDL SPORT].value).to(equal(@"SPORT")); + expect([SDLPRNDL LOWGEAR].value).to(equal(@"LOWGEAR")); + expect([SDLPRNDL FIRST].value).to(equal(@"FIRST")); + expect([SDLPRNDL SECOND].value).to(equal(@"SECOND")); + expect([SDLPRNDL THIRD].value).to(equal(@"THIRD")); + expect([SDLPRNDL FOURTH].value).to(equal(@"FOURTH")); + expect([SDLPRNDL FIFTH].value).to(equal(@"FIFTH")); + expect([SDLPRNDL SIXTH].value).to(equal(@"SIXTH")); + expect([SDLPRNDL SEVENTH].value).to(equal(@"SEVENTH")); + expect([SDLPRNDL EIGHTH].value).to(equal(@"EIGHTH")); + expect([SDLPRNDL UNKNOWN].value).to(equal(@"UNKNOWN")); + expect([SDLPRNDL FAULT].value).to(equal(@"FAULT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPRNDL valueOf:@"PARK"]).to(equal([SDLPRNDL PARK])); + expect([SDLPRNDL valueOf:@"REVERSE"]).to(equal([SDLPRNDL REVERSE])); + expect([SDLPRNDL valueOf:@"NEUTRAL"]).to(equal([SDLPRNDL NEUTRAL])); + expect([SDLPRNDL valueOf:@"DRIVE"]).to(equal([SDLPRNDL DRIVE])); + expect([SDLPRNDL valueOf:@"SPORT"]).to(equal([SDLPRNDL SPORT])); + expect([SDLPRNDL valueOf:@"LOWGEAR"]).to(equal([SDLPRNDL LOWGEAR])); + expect([SDLPRNDL valueOf:@"FIRST"]).to(equal([SDLPRNDL FIRST])); + expect([SDLPRNDL valueOf:@"SECOND"]).to(equal([SDLPRNDL SECOND])); + expect([SDLPRNDL valueOf:@"THIRD"]).to(equal([SDLPRNDL THIRD])); + expect([SDLPRNDL valueOf:@"FOURTH"]).to(equal([SDLPRNDL FOURTH])); + expect([SDLPRNDL valueOf:@"FIFTH"]).to(equal([SDLPRNDL FIFTH])); + expect([SDLPRNDL valueOf:@"SIXTH"]).to(equal([SDLPRNDL SIXTH])); + expect([SDLPRNDL valueOf:@"SEVENTH"]).to(equal([SDLPRNDL SEVENTH])); + expect([SDLPRNDL valueOf:@"EIGHTH"]).to(equal([SDLPRNDL EIGHTH])); + expect([SDLPRNDL valueOf:@"UNKNOWN"]).to(equal([SDLPRNDL UNKNOWN])); + expect([SDLPRNDL valueOf:@"FAULT"]).to(equal([SDLPRNDL FAULT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPRNDL valueOf:nil]).to(beNil()); + expect([SDLPRNDL valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPRNDL values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPRNDL PARK], + [SDLPRNDL REVERSE], + [SDLPRNDL NEUTRAL], + [SDLPRNDL DRIVE], + [SDLPRNDL SPORT], + [SDLPRNDL LOWGEAR], + [SDLPRNDL FIRST], + [SDLPRNDL SECOND], + [SDLPRNDL THIRD], + [SDLPRNDL FOURTH], + [SDLPRNDL FIFTH], + [SDLPRNDL SIXTH], + [SDLPRNDL SEVENTH], + [SDLPRNDL EIGHTH], + [SDLPRNDL UNKNOWN], + [SDLPRNDL FAULT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPermissionStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPermissionStatusSpec.m new file mode 100644 index 000000000..3ca864595 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPermissionStatusSpec.m @@ -0,0 +1,59 @@ +// +// SDLPermissionStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPermissionStatus.h" + +QuickSpecBegin(SDLPermissionStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPermissionStatus ALLOWED].value).to(equal(@"ALLOWED")); + expect([SDLPermissionStatus DISALLOWED].value).to(equal(@"DISALLOWED")); + expect([SDLPermissionStatus USER_DISALLOWED].value).to(equal(@"USER_DISALLOWED")); + expect([SDLPermissionStatus USER_CONSENT_PENDING].value).to(equal(@"USER_CONSENT_PENDING")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPermissionStatus valueOf:@"ALLOWED"]).to(equal([SDLPermissionStatus ALLOWED])); + expect([SDLPermissionStatus valueOf:@"DISALLOWED"]).to(equal([SDLPermissionStatus DISALLOWED])); + expect([SDLPermissionStatus valueOf:@"USER_DISALLOWED"]).to(equal([SDLPermissionStatus USER_DISALLOWED])); + expect([SDLPermissionStatus valueOf:@"USER_CONSENT_PENDING"]).to(equal([SDLPermissionStatus USER_CONSENT_PENDING])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPermissionStatus valueOf:nil]).to(beNil()); + expect([SDLPermissionStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPermissionStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPermissionStatus ALLOWED], + [SDLPermissionStatus DISALLOWED], + [SDLPermissionStatus USER_DISALLOWED], + [SDLPermissionStatus USER_CONSENT_PENDING]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPowerModeQualificationStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPowerModeQualificationStatusSpec.m new file mode 100644 index 000000000..1a8c2dd55 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPowerModeQualificationStatusSpec.m @@ -0,0 +1,59 @@ +// +// SDLPowerModeQualificationStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPowerModeQualificationStatus.h" + +QuickSpecBegin(SDLPowerModeQualificationStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPowerModeQualificationStatus POWER_MODE_UNDEFINED].value).to(equal(@"POWER_MODE_UNDEFINED")); + expect([SDLPowerModeQualificationStatus POWER_MODE_EVALUATION_IN_PROGRESS].value).to(equal(@"POWER_MODE_EVALUATION_IN_PROGRESS")); + expect([SDLPowerModeQualificationStatus NOT_DEFINED].value).to(equal(@"NOT_DEFINED")); + expect([SDLPowerModeQualificationStatus POWER_MODE_OK].value).to(equal(@"POWER_MODE_OK")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPowerModeQualificationStatus valueOf:@"POWER_MODE_UNDEFINED"]).to(equal([SDLPowerModeQualificationStatus POWER_MODE_UNDEFINED])); + expect([SDLPowerModeQualificationStatus valueOf:@"POWER_MODE_EVALUATION_IN_PROGRESS"]).to(equal([SDLPowerModeQualificationStatus POWER_MODE_EVALUATION_IN_PROGRESS])); + expect([SDLPowerModeQualificationStatus valueOf:@"NOT_DEFINED"]).to(equal([SDLPowerModeQualificationStatus NOT_DEFINED])); + expect([SDLPowerModeQualificationStatus valueOf:@"POWER_MODE_OK"]).to(equal([SDLPowerModeQualificationStatus POWER_MODE_OK])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPowerModeQualificationStatus valueOf:nil]).to(beNil()); + expect([SDLPowerModeQualificationStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPowerModeQualificationStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPowerModeQualificationStatus POWER_MODE_UNDEFINED], + [SDLPowerModeQualificationStatus POWER_MODE_EVALUATION_IN_PROGRESS], + [SDLPowerModeQualificationStatus NOT_DEFINED], + [SDLPowerModeQualificationStatus POWER_MODE_OK]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPowerModeStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPowerModeStatusSpec.m new file mode 100644 index 000000000..4ffc91aba --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPowerModeStatusSpec.m @@ -0,0 +1,74 @@ +// +// SDLPowerModeStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPowerModeStatus.h" + +QuickSpecBegin(SDLPowerModeStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPowerModeStatus KEY_OUT].value).to(equal(@"KEY_OUT")); + expect([SDLPowerModeStatus KEY_RECENTLY_OUT].value).to(equal(@"KEY_RECENTLY_OUT")); + expect([SDLPowerModeStatus KEY_APPROVED_0].value).to(equal(@"KEY_APPROVED_0")); + expect([SDLPowerModeStatus POST_ACCESORY_0].value).to(equal(@"POST_ACCESORY_0")); + expect([SDLPowerModeStatus ACCESORY_1].value).to(equal(@"ACCESORY_1")); + expect([SDLPowerModeStatus POST_IGNITION_1].value).to(equal(@"POST_IGNITION_1")); + expect([SDLPowerModeStatus IGNITION_ON_2].value).to(equal(@"IGNITION_ON_2")); + expect([SDLPowerModeStatus RUNNING_2].value).to(equal(@"RUNNING_2")); + expect([SDLPowerModeStatus CRANK_3].value).to(equal(@"CRANK_3")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPowerModeStatus valueOf:@"KEY_OUT"]).to(equal([SDLPowerModeStatus KEY_OUT])); + expect([SDLPowerModeStatus valueOf:@"KEY_RECENTLY_OUT"]).to(equal([SDLPowerModeStatus KEY_RECENTLY_OUT])); + expect([SDLPowerModeStatus valueOf:@"KEY_APPROVED_0"]).to(equal([SDLPowerModeStatus KEY_APPROVED_0])); + expect([SDLPowerModeStatus valueOf:@"POST_ACCESORY_0"]).to(equal([SDLPowerModeStatus POST_ACCESORY_0])); + expect([SDLPowerModeStatus valueOf:@"ACCESORY_1"]).to(equal([SDLPowerModeStatus ACCESORY_1])); + expect([SDLPowerModeStatus valueOf:@"POST_IGNITION_1"]).to(equal([SDLPowerModeStatus POST_IGNITION_1])); + expect([SDLPowerModeStatus valueOf:@"IGNITION_ON_2"]).to(equal([SDLPowerModeStatus IGNITION_ON_2])); + expect([SDLPowerModeStatus valueOf:@"RUNNING_2"]).to(equal([SDLPowerModeStatus RUNNING_2])); + expect([SDLPowerModeStatus valueOf:@"CRANK_3"]).to(equal([SDLPowerModeStatus CRANK_3])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPowerModeStatus valueOf:nil]).to(beNil()); + expect([SDLPowerModeStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPowerModeStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPowerModeStatus KEY_OUT], + [SDLPowerModeStatus KEY_RECENTLY_OUT], + [SDLPowerModeStatus KEY_APPROVED_0], + [SDLPowerModeStatus POST_ACCESORY_0], + [SDLPowerModeStatus ACCESORY_1], + [SDLPowerModeStatus POST_IGNITION_1], + [SDLPowerModeStatus IGNITION_ON_2], + [SDLPowerModeStatus RUNNING_2], + [SDLPowerModeStatus CRANK_3]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPredefinedLayoutSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPredefinedLayoutSpec.m new file mode 100644 index 000000000..0f110d08c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPredefinedLayoutSpec.m @@ -0,0 +1,107 @@ +// +// SDLPredefinedLayoutSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPredefinedLayout.h" + +QuickSpecBegin(SDLPredefinedLayoutSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPredefinedLayout DEFAULT].value).to(equal(@"DEFAULT")); + expect([SDLPredefinedLayout MEDIA].value).to(equal(@"MEDIA")); + expect([SDLPredefinedLayout NON_MEDIA].value).to(equal(@"NON-MEDIA")); + expect([SDLPredefinedLayout ONSCREEN_PRESETS].value).to(equal(@"ONSCREEN_PRESETS")); + expect([SDLPredefinedLayout NAV_FULLSCREEN_MAP].value).to(equal(@"NAV_FULLSCREEN_MAP")); + expect([SDLPredefinedLayout NAV_LIST].value).to(equal(@"NAV_LIST")); + expect([SDLPredefinedLayout NAV_KEYBOARD].value).to(equal(@"NAV_KEYBOARD")); + expect([SDLPredefinedLayout GRAPHIC_WITH_TEXT].value).to(equal(@"GRAPHIC_WITH_TEXT")); + expect([SDLPredefinedLayout TEXT_WITH_GRAPHIC].value).to(equal(@"TEXT_WITH_GRAPHIC")); + expect([SDLPredefinedLayout TILES_ONLY].value).to(equal(@"TILES_ONLY")); + expect([SDLPredefinedLayout TEXTBUTTONS_ONLY].value).to(equal(@"TEXTBUTTONS_ONLY")); + expect([SDLPredefinedLayout GRAPHIC_WITH_TILES].value).to(equal(@"GRAPHIC_WITH_TILES")); + expect([SDLPredefinedLayout TILES_WITH_GRAPHIC].value).to(equal(@"TILES_WITH_GRAPHIC")); + expect([SDLPredefinedLayout GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS].value).to(equal(@"GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS")); + expect([SDLPredefinedLayout TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC].value).to(equal(@"TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC")); + expect([SDLPredefinedLayout GRAPHIC_WITH_TEXTBUTTONS].value).to(equal(@"GRAPHIC_WITH_TEXTBUTTONS")); + expect([SDLPredefinedLayout TEXTBUTTONS_WITH_GRAPHIC].value).to(equal(@"TEXTBUTTONS_WITH_GRAPHIC")); + expect([SDLPredefinedLayout LARGE_GRAPHIC_WITH_SOFTBUTTONS].value).to(equal(@"LARGE_GRAPHIC_WITH_SOFTBUTTONS")); + expect([SDLPredefinedLayout DOUBLE_GRAPHIC_WITH_SOFTBUTTONS].value).to(equal(@"DOUBLE_GRAPHIC_WITH_SOFTBUTTONS")); + expect([SDLPredefinedLayout LARGE_GRAPHIC_ONLY].value).to(equal(@"LARGE_GRAPHIC_ONLY")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPredefinedLayout valueOf:@"DEFAULT"]).to(equal([SDLPredefinedLayout DEFAULT])); + expect([SDLPredefinedLayout valueOf:@"MEDIA"]).to(equal([SDLPredefinedLayout MEDIA])); + expect([SDLPredefinedLayout valueOf:@"NON-MEDIA"]).to(equal([SDLPredefinedLayout NON_MEDIA])); + expect([SDLPredefinedLayout valueOf:@"ONSCREEN_PRESETS"]).to(equal([SDLPredefinedLayout ONSCREEN_PRESETS])); + expect([SDLPredefinedLayout valueOf:@"NAV_FULLSCREEN_MAP"]).to(equal([SDLPredefinedLayout NAV_FULLSCREEN_MAP])); + expect([SDLPredefinedLayout valueOf:@"NAV_LIST"]).to(equal([SDLPredefinedLayout NAV_LIST])); + expect([SDLPredefinedLayout valueOf:@"NAV_KEYBOARD"]).to(equal([SDLPredefinedLayout NAV_KEYBOARD])); + expect([SDLPredefinedLayout valueOf:@"GRAPHIC_WITH_TEXT"]).to(equal([SDLPredefinedLayout GRAPHIC_WITH_TEXT])); + expect([SDLPredefinedLayout valueOf:@"TEXT_WITH_GRAPHIC"]).to(equal([SDLPredefinedLayout TEXT_WITH_GRAPHIC])); + expect([SDLPredefinedLayout valueOf:@"TILES_ONLY"]).to(equal([SDLPredefinedLayout TILES_ONLY])); + expect([SDLPredefinedLayout valueOf:@"TEXTBUTTONS_ONLY"]).to(equal([SDLPredefinedLayout TEXTBUTTONS_ONLY])); + expect([SDLPredefinedLayout valueOf:@"GRAPHIC_WITH_TILES"]).to(equal([SDLPredefinedLayout GRAPHIC_WITH_TILES])); + expect([SDLPredefinedLayout valueOf:@"TILES_WITH_GRAPHIC"]).to(equal([SDLPredefinedLayout TILES_WITH_GRAPHIC])); + expect([SDLPredefinedLayout valueOf:@"GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS"]).to(equal([SDLPredefinedLayout GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS])); + expect([SDLPredefinedLayout valueOf:@"TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC"]).to(equal([SDLPredefinedLayout TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC])); + expect([SDLPredefinedLayout valueOf:@"GRAPHIC_WITH_TEXTBUTTONS"]).to(equal([SDLPredefinedLayout GRAPHIC_WITH_TEXTBUTTONS])); + expect([SDLPredefinedLayout valueOf:@"TEXTBUTTONS_WITH_GRAPHIC"]).to(equal([SDLPredefinedLayout TEXTBUTTONS_WITH_GRAPHIC])); + expect([SDLPredefinedLayout valueOf:@"LARGE_GRAPHIC_WITH_SOFTBUTTONS"]).to(equal([SDLPredefinedLayout LARGE_GRAPHIC_WITH_SOFTBUTTONS])); + expect([SDLPredefinedLayout valueOf:@"DOUBLE_GRAPHIC_WITH_SOFTBUTTONS"]).to(equal([SDLPredefinedLayout DOUBLE_GRAPHIC_WITH_SOFTBUTTONS])); + expect([SDLPredefinedLayout valueOf:@"LARGE_GRAPHIC_ONLY"]).to(equal([SDLPredefinedLayout LARGE_GRAPHIC_ONLY])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPredefinedLayout valueOf:nil]).to(beNil()); + expect([SDLPredefinedLayout valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPredefinedLayout values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPredefinedLayout DEFAULT], + [SDLPredefinedLayout MEDIA], + [SDLPredefinedLayout NON_MEDIA], + [SDLPredefinedLayout ONSCREEN_PRESETS], + [SDLPredefinedLayout NAV_FULLSCREEN_MAP], + [SDLPredefinedLayout NAV_LIST], + [SDLPredefinedLayout NAV_KEYBOARD], + [SDLPredefinedLayout GRAPHIC_WITH_TEXT], + [SDLPredefinedLayout TEXT_WITH_GRAPHIC], + [SDLPredefinedLayout TILES_ONLY], + [SDLPredefinedLayout TEXTBUTTONS_ONLY], + [SDLPredefinedLayout GRAPHIC_WITH_TILES], + [SDLPredefinedLayout TILES_WITH_GRAPHIC], + [SDLPredefinedLayout GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS], + [SDLPredefinedLayout TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC], + [SDLPredefinedLayout GRAPHIC_WITH_TEXTBUTTONS], + [SDLPredefinedLayout TEXTBUTTONS_WITH_GRAPHIC], + [SDLPredefinedLayout LARGE_GRAPHIC_WITH_SOFTBUTTONS], + [SDLPredefinedLayout DOUBLE_GRAPHIC_WITH_SOFTBUTTONS], + [SDLPredefinedLayout LARGE_GRAPHIC_ONLY]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPrerecordedSpeechSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPrerecordedSpeechSpec.m new file mode 100644 index 000000000..89c0bd218 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPrerecordedSpeechSpec.m @@ -0,0 +1,62 @@ +// +// SDLPrerecordedSpeechSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPrerecordedSpeech.h" + +QuickSpecBegin(SDLPrerecordedSpeechSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPrerecordedSpeech HELP_JINGLE].value).to(equal(@"HELP_JINGLE")); + expect([SDLPrerecordedSpeech INITIAL_JINGLE].value).to(equal(@"INITIAL_JINGLE")); + expect([SDLPrerecordedSpeech LISTEN_JINGLE].value).to(equal(@"LISTEN_JINGLE")); + expect([SDLPrerecordedSpeech POSITIVE_JINGLE].value).to(equal(@"POSITIVE_JINGLE")); + expect([SDLPrerecordedSpeech NEGATIVE_JINGLE].value).to(equal(@"NEGATIVE_JINGLE")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPrerecordedSpeech valueOf:@"HELP_JINGLE"]).to(equal([SDLPrerecordedSpeech HELP_JINGLE])); + expect([SDLPrerecordedSpeech valueOf:@"INITIAL_JINGLE"]).to(equal([SDLPrerecordedSpeech INITIAL_JINGLE])); + expect([SDLPrerecordedSpeech valueOf:@"LISTEN_JINGLE"]).to(equal([SDLPrerecordedSpeech LISTEN_JINGLE])); + expect([SDLPrerecordedSpeech valueOf:@"POSITIVE_JINGLE"]).to(equal([SDLPrerecordedSpeech POSITIVE_JINGLE])); + expect([SDLPrerecordedSpeech valueOf:@"NEGATIVE_JINGLE"]).to(equal([SDLPrerecordedSpeech NEGATIVE_JINGLE])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPrerecordedSpeech valueOf:nil]).to(beNil()); + expect([SDLPrerecordedSpeech valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPrerecordedSpeech values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPrerecordedSpeech HELP_JINGLE], + [SDLPrerecordedSpeech INITIAL_JINGLE], + [SDLPrerecordedSpeech LISTEN_JINGLE], + [SDLPrerecordedSpeech POSITIVE_JINGLE], + [SDLPrerecordedSpeech NEGATIVE_JINGLE]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPrimaryAudioSource.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPrimaryAudioSource.m new file mode 100644 index 000000000..0b273e0df --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLPrimaryAudioSource.m @@ -0,0 +1,68 @@ +// +// SDLPrimaryAudioSourceSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPrimaryAudioSource.h" + +QuickSpecBegin(SDLPrimaryAudioSourceSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLPrimaryAudioSource NO_SOURCE_SELECTED].value).to(equal(@"NO_SOURCE_SELECTED")); + expect([SDLPrimaryAudioSource USB].value).to(equal(@"USB")); + expect([SDLPrimaryAudioSource USB2].value).to(equal(@"USB2")); + expect([SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST].value).to(equal(@"BLUETOOTH_STEREO_BTST")); + expect([SDLPrimaryAudioSource LINE_IN].value).to(equal(@"LINE_IN")); + expect([SDLPrimaryAudioSource IPOD].value).to(equal(@"IPOD")); + expect([SDLPrimaryAudioSource MOBILE_APP].value).to(equal(@"MOBILE_APP")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLPrimaryAudioSource valueOf:@"NO_SOURCE_SELECTED"]).to(equal([SDLPrimaryAudioSource NO_SOURCE_SELECTED])); + expect([SDLPrimaryAudioSource valueOf:@"USB"]).to(equal([SDLPrimaryAudioSource USB])); + expect([SDLPrimaryAudioSource valueOf:@"USB2"]).to(equal([SDLPrimaryAudioSource USB2])); + expect([SDLPrimaryAudioSource valueOf:@"BLUETOOTH_STEREO_BTST"]).to(equal([SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST])); + expect([SDLPrimaryAudioSource valueOf:@"LINE_IN"]).to(equal([SDLPrimaryAudioSource LINE_IN])); + expect([SDLPrimaryAudioSource valueOf:@"IPOD"]).to(equal([SDLPrimaryAudioSource IPOD])); + expect([SDLPrimaryAudioSource valueOf:@"MOBILE_APP"]).to(equal([SDLPrimaryAudioSource MOBILE_APP])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLPrimaryAudioSource valueOf:nil]).to(beNil()); + expect([SDLPrimaryAudioSource valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLPrimaryAudioSource values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLPrimaryAudioSource NO_SOURCE_SELECTED], + [SDLPrimaryAudioSource USB], + [SDLPrimaryAudioSource USB2], + [SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST], + [SDLPrimaryAudioSource LINE_IN], + [SDLPrimaryAudioSource IPOD], + [SDLPrimaryAudioSource MOBILE_APP]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLRequestTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLRequestTypeSpec.m new file mode 100644 index 000000000..7a314e1a6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLRequestTypeSpec.m @@ -0,0 +1,108 @@ +// +// SDLRequestTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLRequestType.h" + +QuickSpecBegin(SDLRequestTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLRequestType HTTP].value).to(equal(@"HTTP")); + expect([SDLRequestType FILE_RESUME].value).to(equal(@"FILE_RESUME")); + expect([SDLRequestType AUTH_REQUEST].value).to(equal(@"AUTH_REQUEST")); + expect([SDLRequestType AUTH_CHALLENGE].value).to(equal(@"AUTH_CHALLENGE")); + expect([SDLRequestType AUTH_ACK].value).to(equal(@"AUTH_ACK")); + expect([SDLRequestType PROPRIETARY].value).to(equal(@"PROPRIETARY")); + expect([SDLRequestType QUERY_APPS].value).to(equal(@"QUERY_APPS")); + expect([SDLRequestType LAUNCH_APP].value).to(equal(@"LAUNCH_APP")); + expect([SDLRequestType LOCK_SCREEN_ICON_URL].value).to(equal(@"LOCK_SCREEN_ICON_URL")); + expect([SDLRequestType TRAFFIC_MESSAGE_CHANNEL].value).to(equal(@"TRAFFIC_MESSAGE_CHANNEL")); + expect([SDLRequestType DRIVER_PROFILE].value).to(equal(@"DRIVER_PROFILE")); + expect([SDLRequestType VOICE_SEARCH].value).to(equal(@"VOICE_SEARCH")); + expect([SDLRequestType NAVIGATION].value).to(equal(@"NAVIGATION")); + expect([SDLRequestType PHONE].value).to(equal(@"PHONE")); + expect([SDLRequestType CLIMATE].value).to(equal(@"CLIMATE")); + expect([SDLRequestType SETTINGS].value).to(equal(@"SETTINGS")); + expect([SDLRequestType VEHICLE_DIAGNOSTICS].value).to(equal(@"VEHICLE_DIAGNOSTICS")); + expect([SDLRequestType EMERGENCY].value).to(equal(@"EMERGENCY")); + expect([SDLRequestType MEDIA].value).to(equal(@"MEDIA")); + expect([SDLRequestType FOTA].value).to(equal(@"FOTA")); + }); +}); + +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLRequestType valueOf:@"HTTP"]).to(equal([SDLRequestType HTTP])); + expect([SDLRequestType valueOf:@"FILE_RESUME"]).to(equal([SDLRequestType FILE_RESUME])); + expect([SDLRequestType valueOf:@"AUTH_REQUEST"]).to(equal([SDLRequestType AUTH_REQUEST])); + expect([SDLRequestType valueOf:@"AUTH_CHALLENGE"]).to(equal([SDLRequestType AUTH_CHALLENGE])); + expect([SDLRequestType valueOf:@"AUTH_ACK"]).to(equal([SDLRequestType AUTH_ACK])); + expect([SDLRequestType valueOf:@"QUERY_APPS"]).to(equal([SDLRequestType QUERY_APPS])); + expect([SDLRequestType valueOf:@"LAUNCH_APP"]).to(equal([SDLRequestType LAUNCH_APP])); + expect([SDLRequestType valueOf:@"LOCK_SCREEN_ICON_URL"]).to(equal([SDLRequestType LOCK_SCREEN_ICON_URL])); + expect([SDLRequestType valueOf:@"TRAFFIC_MESSAGE_CHANNEL"]).to(equal([SDLRequestType TRAFFIC_MESSAGE_CHANNEL])); + expect([SDLRequestType valueOf:@"DRIVER_PROFILE"]).to(equal([SDLRequestType DRIVER_PROFILE])); + expect([SDLRequestType valueOf:@"VOICE_SEARCH"]).to(equal([SDLRequestType VOICE_SEARCH])); + expect([SDLRequestType valueOf:@"NAVIGATION"]).to(equal([SDLRequestType NAVIGATION])); + expect([SDLRequestType valueOf:@"PHONE"]).to(equal([SDLRequestType PHONE])); + expect([SDLRequestType valueOf:@"CLIMATE"]).to(equal([SDLRequestType CLIMATE])); + expect([SDLRequestType valueOf:@"SETTINGS"]).to(equal([SDLRequestType SETTINGS])); + expect([SDLRequestType valueOf:@"VEHICLE_DIAGNOSTICS"]).to(equal([SDLRequestType VEHICLE_DIAGNOSTICS])); + expect([SDLRequestType valueOf:@"EMERGENCY"]).to(equal([SDLRequestType EMERGENCY])); + expect([SDLRequestType valueOf:@"MEDIA"]).to(equal([SDLRequestType MEDIA])); + expect([SDLRequestType valueOf:@"FOTA"]).to(equal([SDLRequestType FOTA])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLRequestType valueOf:nil]).to(beNil()); + expect([SDLRequestType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); + +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLRequestType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLRequestType HTTP], + [SDLRequestType FILE_RESUME], + [SDLRequestType AUTH_REQUEST], + [SDLRequestType AUTH_CHALLENGE], + [SDLRequestType AUTH_ACK], + [SDLRequestType PROPRIETARY], + [SDLRequestType QUERY_APPS], + [SDLRequestType LAUNCH_APP], + [SDLRequestType LOCK_SCREEN_ICON_URL], + [SDLRequestType TRAFFIC_MESSAGE_CHANNEL], + [SDLRequestType DRIVER_PROFILE], + [SDLRequestType VOICE_SEARCH], + [SDLRequestType NAVIGATION], + [SDLRequestType PHONE], + [SDLRequestType CLIMATE], + [SDLRequestType SETTINGS], + [SDLRequestType VEHICLE_DIAGNOSTICS], + [SDLRequestType EMERGENCY], + [SDLRequestType MEDIA], + [SDLRequestType FOTA]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLResultSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLResultSpec.m new file mode 100644 index 000000000..916cb6155 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLResultSpec.m @@ -0,0 +1,145 @@ +// +// SDLResultSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLResult.h" + +QuickSpecBegin(SDLResultSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLResult SUCCESS].value).to(equal(@"SUCCESS")); + expect([SDLResult UNSUPPORTED_REQUEST].value).to(equal(@"UNSUPPORTED_REQUEST")); + expect([SDLResult UNSUPPORTED_RESOURCE].value).to(equal(@"UNSUPPORTED_RESOURCE")); + expect([SDLResult DISALLOWED].value).to(equal(@"DISALLOWED")); + expect([SDLResult REJECTED].value).to(equal(@"REJECTED")); + expect([SDLResult ABORTED].value).to(equal(@"ABORTED")); + expect([SDLResult IGNORED].value).to(equal(@"IGNORED")); + expect([SDLResult RETRY].value).to(equal(@"RETRY")); + expect([SDLResult IN_USE].value).to(equal(@"IN_USE")); + expect([SDLResult VEHICLE_DATA_NOT_AVAILABLE].value).to(equal(@"VEHICLE_DATA_NOT_AVAILABLE")); + expect([SDLResult TIMED_OUT].value).to(equal(@"TIMED_OUT")); + expect([SDLResult INVALID_DATA].value).to(equal(@"INVALID_DATA")); + expect([SDLResult CHAR_LIMIT_EXCEEDED].value).to(equal(@"CHAR_LIMIT_EXCEEDED")); + expect([SDLResult INVALID_ID].value).to(equal(@"INVALID_ID")); + expect([SDLResult DUPLICATE_NAME].value).to(equal(@"DUPLICATE_NAME")); + expect([SDLResult APPLICATION_NOT_REGISTERED].value).to(equal(@"APPLICATION_NOT_REGISTERED")); + expect([SDLResult WRONG_LANGUAGE].value).to(equal(@"WRONG_LANGUAGE")); + expect([SDLResult OUT_OF_MEMORY].value).to(equal(@"OUT_OF_MEMORY")); + expect([SDLResult TOO_MANY_PENDING_REQUESTS].value).to(equal(@"TOO_MANY_PENDING_REQUESTS")); + expect([SDLResult TOO_MANY_APPLICATIONS].value).to(equal(@"TOO_MANY_APPLICATIONS")); + expect([SDLResult APPLICATION_REGISTERED_ALREADY].value).to(equal(@"APPLICATION_REGISTERED_ALREADY")); + expect([SDLResult WARNINGS].value).to(equal(@"WARNINGS")); + expect([SDLResult GENERIC_ERROR].value).to(equal(@"GENERIC_ERROR")); + expect([SDLResult USER_DISALLOWED].value).to(equal(@"USER_DISALLOWED")); + expect([SDLResult UNSUPPORTED_VERSION].value).to(equal(@"UNSUPPORTED_VERSION")); + expect([SDLResult VEHICLE_DATA_NOT_ALLOWED].value).to(equal(@"VEHICLE_DATA_NOT_ALLOWED")); + expect([SDLResult FILE_NOT_FOUND].value).to(equal(@"FILE_NOT_FOUND")); + expect([SDLResult CANCEL_ROUTE].value).to(equal(@"CANCEL_ROUTE")); + expect([SDLResult TRUNCATED_DATA].value).to(equal(@"TRUNCATED_DATA")); + expect([SDLResult SAVED].value).to(equal(@"SAVED")); + expect([SDLResult INVALID_CERT].value).to(equal(@"INVALID_CERT")); + expect([SDLResult EXPIRED_CERT].value).to(equal(@"EXPIRED_CERT")); + expect([SDLResult RESUME_FAILED].value).to(equal(@"RESUME_FAILED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLResult valueOf:@"SUCCESS"]).to(equal([SDLResult SUCCESS])); + expect([SDLResult valueOf:@"UNSUPPORTED_REQUEST"]).to(equal([SDLResult UNSUPPORTED_REQUEST])); + expect([SDLResult valueOf:@"UNSUPPORTED_RESOURCE"]).to(equal([SDLResult UNSUPPORTED_RESOURCE])); + expect([SDLResult valueOf:@"DISALLOWED"]).to(equal([SDLResult DISALLOWED])); + expect([SDLResult valueOf:@"REJECTED"]).to(equal([SDLResult REJECTED])); + expect([SDLResult valueOf:@"IGNORED"]).to(equal([SDLResult IGNORED])); + expect([SDLResult valueOf:@"RETRY"]).to(equal([SDLResult RETRY])); + expect([SDLResult valueOf:@"IN_USE"]).to(equal([SDLResult IN_USE])); + expect([SDLResult valueOf:@"VEHICLE_DATA_NOT_AVAILABLE"]).to(equal([SDLResult VEHICLE_DATA_NOT_AVAILABLE])); + expect([SDLResult valueOf:@"TIMED_OUT"]).to(equal([SDLResult TIMED_OUT])); + expect([SDLResult valueOf:@"INVALID_DATA"]).to(equal([SDLResult INVALID_DATA])); + expect([SDLResult valueOf:@"CHAR_LIMIT_EXCEEDED"]).to(equal([SDLResult CHAR_LIMIT_EXCEEDED])); + expect([SDLResult valueOf:@"INVALID_ID"]).to(equal([SDLResult INVALID_ID])); + expect([SDLResult valueOf:@"DUPLICATE_NAME"]).to(equal([SDLResult DUPLICATE_NAME])); + expect([SDLResult valueOf:@"APPLICATION_NOT_REGISTERED"]).to(equal([SDLResult APPLICATION_NOT_REGISTERED])); + expect([SDLResult valueOf:@"WRONG_LANGUAGE"]).to(equal([SDLResult WRONG_LANGUAGE])); + expect([SDLResult valueOf:@"OUT_OF_MEMORY"]).to(equal([SDLResult OUT_OF_MEMORY])); + expect([SDLResult valueOf:@"TOO_MANY_PENDING_REQUESTS"]).to(equal([SDLResult TOO_MANY_PENDING_REQUESTS])); + expect([SDLResult valueOf:@"TOO_MANY_APPLICATIONS"]).to(equal([SDLResult TOO_MANY_APPLICATIONS])); + expect([SDLResult valueOf:@"APPLICATION_REGISTERED_ALREADY"]).to(equal([SDLResult APPLICATION_REGISTERED_ALREADY])); + expect([SDLResult valueOf:@"WARNINGS"]).to(equal([SDLResult WARNINGS])); + expect([SDLResult valueOf:@"GENERIC_ERROR"]).to(equal([SDLResult GENERIC_ERROR])); + expect([SDLResult valueOf:@"USER_DISALLOWED"]).to(equal([SDLResult USER_DISALLOWED])); + expect([SDLResult valueOf:@"UNSUPPORTED_VERSION"]).to(equal([SDLResult UNSUPPORTED_VERSION])); + expect([SDLResult valueOf:@"VEHICLE_DATA_NOT_ALLOWED"]).to(equal([SDLResult VEHICLE_DATA_NOT_ALLOWED])); + expect([SDLResult valueOf:@"FILE_NOT_FOUND"]).to(equal([SDLResult FILE_NOT_FOUND])); + expect([SDLResult valueOf:@"CANCEL_ROUTE"]).to(equal([SDLResult CANCEL_ROUTE])); + expect([SDLResult valueOf:@"TRUNCATED_DATA"]).to(equal([SDLResult TRUNCATED_DATA])); + expect([SDLResult valueOf:@"SAVED"]).to(equal([SDLResult SAVED])); + expect([SDLResult valueOf:@"INVALID_CERT"]).to(equal([SDLResult INVALID_CERT])); + expect([SDLResult valueOf:@"EXPIRED_CERT"]).to(equal([SDLResult EXPIRED_CERT])); + expect([SDLResult valueOf:@"RESUME_FAILED"]).to(equal([SDLResult RESUME_FAILED])); +}); + + it(@"Should return nil when invalid", ^ { + expect([SDLResult valueOf:nil]).to(beNil()); + expect([SDLResult valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLResult values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLResult SUCCESS], + [SDLResult UNSUPPORTED_REQUEST], + [SDLResult UNSUPPORTED_RESOURCE], + [SDLResult DISALLOWED], + [SDLResult REJECTED], + [SDLResult ABORTED], + [SDLResult IGNORED], + [SDLResult RETRY], + [SDLResult IN_USE], + [SDLResult VEHICLE_DATA_NOT_AVAILABLE], + [SDLResult TIMED_OUT], + [SDLResult INVALID_DATA], + [SDLResult CHAR_LIMIT_EXCEEDED], + [SDLResult INVALID_ID], + [SDLResult DUPLICATE_NAME], + [SDLResult APPLICATION_NOT_REGISTERED], + [SDLResult WRONG_LANGUAGE], + [SDLResult OUT_OF_MEMORY], + [SDLResult TOO_MANY_PENDING_REQUESTS], + [SDLResult TOO_MANY_APPLICATIONS], + [SDLResult APPLICATION_REGISTERED_ALREADY], + [SDLResult WARNINGS], + [SDLResult GENERIC_ERROR], + [SDLResult USER_DISALLOWED], + [SDLResult UNSUPPORTED_VERSION], + [SDLResult VEHICLE_DATA_NOT_ALLOWED], + [SDLResult FILE_NOT_FOUND], + [SDLResult CANCEL_ROUTE], + [SDLResult TRUNCATED_DATA], + [SDLResult SAVED], + [SDLResult INVALID_CERT], + [SDLResult EXPIRED_CERT], + [SDLResult RESUME_FAILED]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSamplingRateSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSamplingRateSpec.m new file mode 100644 index 000000000..1d4e56611 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSamplingRateSpec.m @@ -0,0 +1,59 @@ +// +// SDLSamplingRateSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSamplingRate.h" + +QuickSpecBegin(SDLSamplingRateSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLSamplingRate _8KHZ].value).to(equal(@"8KHZ")); + expect([SDLSamplingRate _16KHZ].value).to(equal(@"16KHZ")); + expect([SDLSamplingRate _22KHZ].value).to(equal(@"22KHZ")); + expect([SDLSamplingRate _44KHZ].value).to(equal(@"44KHZ")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLSamplingRate valueOf:@"8KHZ"]).to(equal([SDLSamplingRate _8KHZ])); + expect([SDLSamplingRate valueOf:@"16KHZ"]).to(equal([SDLSamplingRate _16KHZ])); + expect([SDLSamplingRate valueOf:@"22KHZ"]).to(equal([SDLSamplingRate _22KHZ])); + expect([SDLSamplingRate valueOf:@"44KHZ"]).to(equal([SDLSamplingRate _44KHZ])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLSamplingRate valueOf:nil]).to(beNil()); + expect([SDLSamplingRate valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLSamplingRate values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLSamplingRate _8KHZ], + [SDLSamplingRate _16KHZ], + [SDLSamplingRate _22KHZ], + [SDLSamplingRate _44KHZ]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSoftButtonTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSoftButtonTypeSpec.m new file mode 100644 index 000000000..6960fa1b1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSoftButtonTypeSpec.m @@ -0,0 +1,56 @@ +// +// SDLSoftButtonTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSoftButtonType.h" + +QuickSpecBegin(SDLSoftButtonTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLSoftButtonType TEXT].value).to(equal(@"TEXT")); + expect([SDLSoftButtonType IMAGE].value).to(equal(@"IMAGE")); + expect([SDLSoftButtonType BOTH].value).to(equal(@"BOTH")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLSoftButtonType valueOf:@"TEXT"]).to(equal([SDLSoftButtonType TEXT])); + expect([SDLSoftButtonType valueOf:@"IMAGE"]).to(equal([SDLSoftButtonType IMAGE])); + expect([SDLSoftButtonType valueOf:@"BOTH"]).to(equal([SDLSoftButtonType BOTH])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLSoftButtonType valueOf:nil]).to(beNil()); + expect([SDLSoftButtonType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLSoftButtonType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLSoftButtonType TEXT], + [SDLSoftButtonType IMAGE], + [SDLSoftButtonType BOTH]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSpeechCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSpeechCapabilitiesSpec.m new file mode 100644 index 000000000..c33de9c8c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSpeechCapabilitiesSpec.m @@ -0,0 +1,62 @@ +// +// SDLSpeechCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSpeechCapabilities.h" + +QuickSpecBegin(SDLSpeechCapabilitiesSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLSpeechCapabilities TEXT].value).to(equal(@"TEXT")); + expect([SDLSpeechCapabilities SAPI_PHONEMES].value).to(equal(@"SAPI_PHONEMES")); + expect([SDLSpeechCapabilities LHPLUS_PHONEMES].value).to(equal(@"LHPLUS_PHONEMES")); + expect([SDLSpeechCapabilities PRE_RECORDED].value).to(equal(@"PRE_RECORDED")); + expect([SDLSpeechCapabilities SILENCE].value).to(equal(@"SILENCE")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLSpeechCapabilities valueOf:@"TEXT"]).to(equal([SDLSpeechCapabilities TEXT])); + expect([SDLSpeechCapabilities valueOf:@"SAPI_PHONEMES"]).to(equal([SDLSpeechCapabilities SAPI_PHONEMES])); + expect([SDLSpeechCapabilities valueOf:@"LHPLUS_PHONEMES"]).to(equal([SDLSpeechCapabilities LHPLUS_PHONEMES])); + expect([SDLSpeechCapabilities valueOf:@"PRE_RECORDED"]).to(equal([SDLSpeechCapabilities PRE_RECORDED])); + expect([SDLSpeechCapabilities valueOf:@"SILENCE"]).to(equal([SDLSpeechCapabilities SILENCE])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLSpeechCapabilities valueOf:nil]).to(beNil()); + expect([SDLSpeechCapabilities valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLSpeechCapabilities values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLSpeechCapabilities TEXT], + [SDLSpeechCapabilities SAPI_PHONEMES], + [SDLSpeechCapabilities LHPLUS_PHONEMES], + [SDLSpeechCapabilities PRE_RECORDED], + [SDLSpeechCapabilities SILENCE]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSystemAction.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSystemAction.m new file mode 100644 index 000000000..917e1acb6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSystemAction.m @@ -0,0 +1,56 @@ +// +// SDLSystemActionSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSystemAction.h" + +QuickSpecBegin(SDLSystemActionSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLSystemAction DEFAULT_ACTION].value).to(equal(@"DEFAULT_ACTION")); + expect([SDLSystemAction STEAL_FOCUS].value).to(equal(@"STEAL_FOCUS")); + expect([SDLSystemAction KEEP_CONTEXT].value).to(equal(@"KEEP_CONTEXT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLSystemAction valueOf:@"DEFAULT_ACTION"]).to(equal([SDLSystemAction DEFAULT_ACTION])); + expect([SDLSystemAction valueOf:@"STEAL_FOCUS"]).to(equal([SDLSystemAction STEAL_FOCUS])); + expect([SDLSystemAction valueOf:@"KEEP_CONTEXT"]).to(equal([SDLSystemAction KEEP_CONTEXT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLSystemAction valueOf:nil]).to(beNil()); + expect([SDLSystemAction valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLSystemAction values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLSystemAction DEFAULT_ACTION], + [SDLSystemAction STEAL_FOCUS], + [SDLSystemAction KEEP_CONTEXT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSystemContextSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSystemContextSpec.m new file mode 100644 index 000000000..694247a1d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLSystemContextSpec.m @@ -0,0 +1,62 @@ +// +// SDLSystemContextSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSystemContext.h" + +QuickSpecBegin(SDLSystemContextSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLSystemContext MAIN].value).to(equal(@"MAIN")); + expect([SDLSystemContext VRSESSION].value).to(equal(@"VRSESSION")); + expect([SDLSystemContext MENU].value).to(equal(@"MENU")); + expect([SDLSystemContext HMI_OBSCURED].value).to(equal(@"HMI_OBSCURED")); + expect([SDLSystemContext ALERT].value).to(equal(@"ALERT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLSystemContext valueOf:@"MAIN"]).to(equal([SDLSystemContext MAIN])); + expect([SDLSystemContext valueOf:@"VRSESSION"]).to(equal([SDLSystemContext VRSESSION])); + expect([SDLSystemContext valueOf:@"MENU"]).to(equal([SDLSystemContext MENU])); + expect([SDLSystemContext valueOf:@"HMI_OBSCURED"]).to(equal([SDLSystemContext HMI_OBSCURED])); + expect([SDLSystemContext valueOf:@"ALERT"]).to(equal([SDLSystemContext ALERT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLSystemContext valueOf:nil]).to(beNil()); + expect([SDLSystemContext valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLSystemContext values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLSystemContext MAIN], + [SDLSystemContext VRSESSION], + [SDLSystemContext MENU], + [SDLSystemContext HMI_OBSCURED], + [SDLSystemContext ALERT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTBTStateSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTBTStateSpec.m new file mode 100644 index 000000000..070986389 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTBTStateSpec.m @@ -0,0 +1,77 @@ +// +// SDLTBTStateSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTBTState.h" + +QuickSpecBegin(SDLTBTStateSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLTBTState ROUTE_UPDATE_REQUEST].value).to(equal(@"ROUTE_UPDATE_REQUEST")); + expect([SDLTBTState ROUTE_ACCEPTED].value).to(equal(@"ROUTE_ACCEPTED")); + expect([SDLTBTState ROUTE_REFUSED].value).to(equal(@"ROUTE_REFUSED")); + expect([SDLTBTState ROUTE_CANCELLED].value).to(equal(@"ROUTE_CANCELLED")); + expect([SDLTBTState ETA_REQUEST].value).to(equal(@"ETA_REQUEST")); + expect([SDLTBTState NEXT_TURN_REQUEST].value).to(equal(@"NEXT_TURN_REQUEST")); + expect([SDLTBTState ROUTE_STATUS_REQUEST].value).to(equal(@"ROUTE_STATUS_REQUEST")); + expect([SDLTBTState ROUTE_SUMMARY_REQUEST].value).to(equal(@"ROUTE_SUMMARY_REQUEST")); + expect([SDLTBTState TRIP_STATUS_REQUEST].value).to(equal(@"TRIP_STATUS_REQUEST")); + expect([SDLTBTState ROUTE_UPDATE_REQUEST_TIMEOUT].value).to(equal(@"ROUTE_UPDATE_REQUEST_TIMEOUT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLTBTState valueOf:@"ROUTE_UPDATE_REQUEST"]).to(equal([SDLTBTState ROUTE_UPDATE_REQUEST])); + expect([SDLTBTState valueOf:@"ROUTE_ACCEPTED"]).to(equal([SDLTBTState ROUTE_ACCEPTED])); + expect([SDLTBTState valueOf:@"ROUTE_REFUSED"]).to(equal([SDLTBTState ROUTE_REFUSED])); + expect([SDLTBTState valueOf:@"ROUTE_CANCELLED"]).to(equal([SDLTBTState ROUTE_CANCELLED])); + expect([SDLTBTState valueOf:@"ETA_REQUEST"]).to(equal([SDLTBTState ETA_REQUEST])); + expect([SDLTBTState valueOf:@"NEXT_TURN_REQUEST"]).to(equal([SDLTBTState NEXT_TURN_REQUEST])); + expect([SDLTBTState valueOf:@"ROUTE_STATUS_REQUEST"]).to(equal([SDLTBTState ROUTE_STATUS_REQUEST])); + expect([SDLTBTState valueOf:@"ROUTE_SUMMARY_REQUEST"]).to(equal([SDLTBTState ROUTE_SUMMARY_REQUEST])); + expect([SDLTBTState valueOf:@"TRIP_STATUS_REQUEST"]).to(equal([SDLTBTState TRIP_STATUS_REQUEST])); + expect([SDLTBTState valueOf:@"ROUTE_UPDATE_REQUEST_TIMEOUT"]).to(equal([SDLTBTState ROUTE_UPDATE_REQUEST_TIMEOUT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLTBTState valueOf:nil]).to(beNil()); + expect([SDLTBTState valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLTBTState values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLTBTState ROUTE_UPDATE_REQUEST], + [SDLTBTState ROUTE_ACCEPTED], + [SDLTBTState ROUTE_REFUSED], + [SDLTBTState ROUTE_CANCELLED], + [SDLTBTState ETA_REQUEST], + [SDLTBTState NEXT_TURN_REQUEST], + [SDLTBTState ROUTE_STATUS_REQUEST], + [SDLTBTState ROUTE_SUMMARY_REQUEST], + [SDLTBTState TRIP_STATUS_REQUEST], + [SDLTBTState ROUTE_UPDATE_REQUEST_TIMEOUT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTextAlignmentSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTextAlignmentSpec.m new file mode 100644 index 000000000..06082c576 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTextAlignmentSpec.m @@ -0,0 +1,56 @@ +// +// SDLTextAlignmentSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTextAlignment.h" + +QuickSpecBegin(SDLTextAlignmentSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLTextAlignment LEFT_ALIGNED].value).to(equal(@"LEFT_ALIGNED")); + expect([SDLTextAlignment RIGHT_ALIGNED].value).to(equal(@"RIGHT_ALIGNED")); + expect([SDLTextAlignment CENTERED].value).to(equal(@"CENTERED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLTextAlignment valueOf:@"LEFT_ALIGNED"]).to(equal([SDLTextAlignment LEFT_ALIGNED])); + expect([SDLTextAlignment valueOf:@"RIGHT_ALIGNED"]).to(equal([SDLTextAlignment RIGHT_ALIGNED])); + expect([SDLTextAlignment valueOf:@"CENTERED"]).to(equal([SDLTextAlignment CENTERED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLTextAlignment valueOf:nil]).to(beNil()); + expect([SDLTextAlignment valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLTextAlignment values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLTextAlignment LEFT_ALIGNED], + [SDLTextAlignment RIGHT_ALIGNED], + [SDLTextAlignment CENTERED]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTextFieldNameSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTextFieldNameSpec.m new file mode 100644 index 000000000..40be02374 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTextFieldNameSpec.m @@ -0,0 +1,133 @@ +// +// SDLTextFieldNameSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTextFieldName.h" + +QuickSpecBegin(SDLTextFieldNameSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLTextFieldName mainField1].value).to(equal(@"mainField1")); + expect([SDLTextFieldName mainField2].value).to(equal(@"mainField2")); + expect([SDLTextFieldName mainField3].value).to(equal(@"mainField3")); + expect([SDLTextFieldName mainField4].value).to(equal(@"mainField4")); + expect([SDLTextFieldName statusBar].value).to(equal(@"statusBar")); + expect([SDLTextFieldName mediaClock].value).to(equal(@"mediaClock")); + expect([SDLTextFieldName mediaTrack].value).to(equal(@"mediaTrack")); + expect([SDLTextFieldName alertText1].value).to(equal(@"alertText1")); + expect([SDLTextFieldName alertText2].value).to(equal(@"alertText2")); + expect([SDLTextFieldName alertText3].value).to(equal(@"alertText3")); + expect([SDLTextFieldName scrollableMessageBody].value).to(equal(@"scrollableMessageBody")); + expect([SDLTextFieldName initialInteractionText].value).to(equal(@"initialInteractionText")); + expect([SDLTextFieldName navigationText1].value).to(equal(@"navigationText1")); + expect([SDLTextFieldName navigationText2].value).to(equal(@"navigationText2")); + expect([SDLTextFieldName ETA].value).to(equal(@"ETA")); + expect([SDLTextFieldName totalDistance].value).to(equal(@"totalDistance")); + expect([SDLTextFieldName audioPassThruDisplayText1].value).to(equal(@"audioPassThruDisplayText1")); + expect([SDLTextFieldName audioPassThruDisplayText2].value).to(equal(@"audioPassThruDisplayText2")); + expect([SDLTextFieldName sliderHeader].value).to(equal(@"sliderHeader")); + expect([SDLTextFieldName sliderFooter].value).to(equal(@"sliderFooter")); + expect([SDLTextFieldName menuName].value).to(equal(@"menuName")); + expect([SDLTextFieldName secondaryText].value).to(equal(@"secondaryText")); + expect([SDLTextFieldName tertiaryText].value).to(equal(@"tertiaryText")); + expect([SDLTextFieldName menuTitle].value).to(equal(@"menuTitle")); + expect([SDLTextFieldName locationName].value).to(equal(@"locationName")); + expect([SDLTextFieldName locationDescription].value).to(equal(@"locationDescription")); + expect([SDLTextFieldName addressLines].value).to(equal(@"addressLines")); + expect([SDLTextFieldName phoneNumber].value).to(equal(@"phoneNumber")); + }); +}); + +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLTextFieldName valueOf:@"mainField1"]).to(equal([SDLTextFieldName mainField1])); + expect([SDLTextFieldName valueOf:@"mainField2"]).to(equal([SDLTextFieldName mainField2])); + expect([SDLTextFieldName valueOf:@"mainField3"]).to(equal([SDLTextFieldName mainField3])); + expect([SDLTextFieldName valueOf:@"mainField4"]).to(equal([SDLTextFieldName mainField4])); + expect([SDLTextFieldName valueOf:@"statusBar"]).to(equal([SDLTextFieldName statusBar])); + expect([SDLTextFieldName valueOf:@"mediaClock"]).to(equal([SDLTextFieldName mediaClock])); + expect([SDLTextFieldName valueOf:@"mediaTrack"]).to(equal([SDLTextFieldName mediaTrack])); + expect([SDLTextFieldName valueOf:@"alertText1"]).to(equal([SDLTextFieldName alertText1])); + expect([SDLTextFieldName valueOf:@"alertText2"]).to(equal([SDLTextFieldName alertText2])); + expect([SDLTextFieldName valueOf:@"alertText3"]).to(equal([SDLTextFieldName alertText3])); + expect([SDLTextFieldName valueOf:@"scrollableMessageBody"]).to(equal([SDLTextFieldName scrollableMessageBody])); + expect([SDLTextFieldName valueOf:@"initialInteractionText"]).to(equal([SDLTextFieldName initialInteractionText])); + expect([SDLTextFieldName valueOf:@"navigationText1"]).to(equal([SDLTextFieldName navigationText1])); + expect([SDLTextFieldName valueOf:@"navigationText2"]).to(equal([SDLTextFieldName navigationText2])); + expect([SDLTextFieldName valueOf:@"ETA"]).to(equal([SDLTextFieldName ETA])); + expect([SDLTextFieldName valueOf:@"totalDistance"]).to(equal([SDLTextFieldName totalDistance])); + expect([SDLTextFieldName valueOf:@"audioPassThruDisplayText1"]).to(equal([SDLTextFieldName audioPassThruDisplayText1])); + expect([SDLTextFieldName valueOf:@"audioPassThruDisplayText2"]).to(equal([SDLTextFieldName audioPassThruDisplayText2])); + expect([SDLTextFieldName valueOf:@"sliderHeader"]).to(equal([SDLTextFieldName sliderHeader])); + expect([SDLTextFieldName valueOf:@"sliderFooter"]).to(equal([SDLTextFieldName sliderFooter])); + expect([SDLTextFieldName valueOf:@"menuName"]).to(equal([SDLTextFieldName menuName])); + expect([SDLTextFieldName valueOf:@"secondaryText"]).to(equal([SDLTextFieldName secondaryText])); + expect([SDLTextFieldName valueOf:@"tertiaryText"]).to(equal([SDLTextFieldName tertiaryText])); + expect([SDLTextFieldName valueOf:@"menuTitle"]).to(equal([SDLTextFieldName menuTitle])); + expect([SDLTextFieldName valueOf:@"locationName"]).to(equal([SDLTextFieldName locationName])); + expect([SDLTextFieldName valueOf:@"locationDescription"]).to(equal([SDLTextFieldName locationDescription])); + expect([SDLTextFieldName valueOf:@"addressLines"]).to(equal([SDLTextFieldName addressLines])); + expect([SDLTextFieldName valueOf:@"phoneNumber"]).to(equal([SDLTextFieldName phoneNumber])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLTextFieldName valueOf:nil]).to(beNil()); + expect([SDLTextFieldName valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); + +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLTextFieldName values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLTextFieldName mainField1], + [SDLTextFieldName mainField2], + [SDLTextFieldName mainField3], + [SDLTextFieldName mainField4], + [SDLTextFieldName statusBar], + [SDLTextFieldName mediaClock], + [SDLTextFieldName mediaTrack], + [SDLTextFieldName alertText1], + [SDLTextFieldName alertText2], + [SDLTextFieldName alertText3], + [SDLTextFieldName scrollableMessageBody], + [SDLTextFieldName initialInteractionText], + [SDLTextFieldName navigationText1], + [SDLTextFieldName navigationText2], + [SDLTextFieldName ETA], + [SDLTextFieldName totalDistance], + [SDLTextFieldName audioPassThruDisplayText1], + [SDLTextFieldName audioPassThruDisplayText2], + [SDLTextFieldName sliderHeader], + [SDLTextFieldName sliderFooter], + [SDLTextFieldName menuName], + [SDLTextFieldName secondaryText], + [SDLTextFieldName tertiaryText], + [SDLTextFieldName menuTitle], + [SDLTextFieldName locationName], + [SDLTextFieldName locationDescription], + [SDLTextFieldName addressLines], + [SDLTextFieldName phoneNumber]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTimerModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTimerModeSpec.m new file mode 100644 index 000000000..0bb0a7448 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTimerModeSpec.m @@ -0,0 +1,56 @@ +// +// SDLTimerModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTimerMode.h" + +QuickSpecBegin(SDLTimerModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLTimerMode UP].value).to(equal(@"UP")); + expect([SDLTimerMode DOWN].value).to(equal(@"DOWN")); + expect([SDLTimerMode NONE].value).to(equal(@"NONE")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLTimerMode valueOf:@"UP"]).to(equal([SDLTimerMode UP])); + expect([SDLTimerMode valueOf:@"DOWN"]).to(equal([SDLTimerMode DOWN])); + expect([SDLTimerMode valueOf:@"NONE"]).to(equal([SDLTimerMode NONE])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLTimerMode valueOf:nil]).to(beNil()); + expect([SDLTimerMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLTimerMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLTimerMode UP], + [SDLTimerMode DOWN], + [SDLTimerMode NONE]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTouchTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTouchTypeSpec.m new file mode 100644 index 000000000..dc72c74b2 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTouchTypeSpec.m @@ -0,0 +1,56 @@ +// +// SDLTouchTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTouchType.h" + +QuickSpecBegin(SDLTouchTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLTouchType BEGIN].value).to(equal(@"BEGIN")); + expect([SDLTouchType MOVE].value).to(equal(@"MOVE")); + expect([SDLTouchType END].value).to(equal(@"END")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLTouchType valueOf:@"BEGIN"]).to(equal([SDLTouchType BEGIN])); + expect([SDLTouchType valueOf:@"MOVE"]).to(equal([SDLTouchType MOVE])); + expect([SDLTouchType valueOf:@"END"]).to(equal([SDLTouchType END])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLTouchType valueOf:nil]).to(beNil()); + expect([SDLTouchType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLTouchType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLTouchType BEGIN], + [SDLTouchType MOVE], + [SDLTouchType END]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTriggerSource.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTriggerSource.m new file mode 100644 index 000000000..1a1413f54 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLTriggerSource.m @@ -0,0 +1,56 @@ +// +// SDLTriggerSourceSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTriggerSource.h" + +QuickSpecBegin(SDLTriggerSourceSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLTriggerSource MENU].value).to(equal(@"MENU")); + expect([SDLTriggerSource VR].value).to(equal(@"VR")); + expect([SDLTriggerSource KEYBOARD].value).to(equal(@"KEYBOARD")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLTriggerSource valueOf:@"MENU"]).to(equal([SDLTriggerSource MENU])); + expect([SDLTriggerSource valueOf:@"VR"]).to(equal([SDLTriggerSource VR])); + expect([SDLTriggerSource valueOf:@"KEYBOARD"]).to(equal([SDLTriggerSource KEYBOARD])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLTriggerSource valueOf:nil]).to(beNil()); + expect([SDLTriggerSource valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLTriggerSource values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLTriggerSource MENU], + [SDLTriggerSource VR], + [SDLTriggerSource KEYBOARD]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLUpdateModeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLUpdateModeSpec.m new file mode 100644 index 000000000..23c8bb5a5 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLUpdateModeSpec.m @@ -0,0 +1,62 @@ +// +// SDLUpdateModeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUpdateMode.h" + +QuickSpecBegin(SDLUpdateModeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLUpdateMode COUNTUP].value).to(equal(@"COUNTUP")); + expect([SDLUpdateMode COUNTDOWN].value).to(equal(@"COUNTDOWN")); + expect([SDLUpdateMode PAUSE].value).to(equal(@"PAUSE")); + expect([SDLUpdateMode RESUME].value).to(equal(@"RESUME")); + expect([SDLUpdateMode CLEAR].value).to(equal(@"CLEAR")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLUpdateMode valueOf:@"COUNTUP"]).to(equal([SDLUpdateMode COUNTUP])); + expect([SDLUpdateMode valueOf:@"COUNTDOWN"]).to(equal([SDLUpdateMode COUNTDOWN])); + expect([SDLUpdateMode valueOf:@"PAUSE"]).to(equal([SDLUpdateMode PAUSE])); + expect([SDLUpdateMode valueOf:@"RESUME"]).to(equal([SDLUpdateMode RESUME])); + expect([SDLUpdateMode valueOf:@"CLEAR"]).to(equal([SDLUpdateMode CLEAR])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLUpdateMode valueOf:nil]).to(beNil()); + expect([SDLUpdateMode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLUpdateMode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLUpdateMode COUNTUP], + [SDLUpdateMode COUNTDOWN], + [SDLUpdateMode PAUSE], + [SDLUpdateMode RESUME], + [SDLUpdateMode CLEAR]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataActiveStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataActiveStatusSpec.m new file mode 100644 index 000000000..46c2cd927 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataActiveStatusSpec.m @@ -0,0 +1,62 @@ +// +// SDLVehicleDataActiveStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataActiveStatus.h" + +QuickSpecBegin(SDLVehicleDataActiveStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVehicleDataActiveStatus INACTIVE_NOT_CONFIRMED].value).to(equal(@"INACTIVE_NOT_CONFIRMED")); + expect([SDLVehicleDataActiveStatus INACTIVE_CONFIRMED].value).to(equal(@"INACTIVE_CONFIRMED")); + expect([SDLVehicleDataActiveStatus ACTIVE_NOT_CONFIRMED].value).to(equal(@"ACTIVE_NOT_CONFIRMED")); + expect([SDLVehicleDataActiveStatus ACTIVE_CONFIRMED].value).to(equal(@"ACTIVE_CONFIRMED")); + expect([SDLVehicleDataActiveStatus FAULT].value).to(equal(@"FAULT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVehicleDataActiveStatus valueOf:@"INACTIVE_NOT_CONFIRMED"]).to(equal([SDLVehicleDataActiveStatus INACTIVE_NOT_CONFIRMED])); + expect([SDLVehicleDataActiveStatus valueOf:@"INACTIVE_CONFIRMED"]).to(equal([SDLVehicleDataActiveStatus INACTIVE_CONFIRMED])); + expect([SDLVehicleDataActiveStatus valueOf:@"ACTIVE_NOT_CONFIRMED"]).to(equal([SDLVehicleDataActiveStatus ACTIVE_NOT_CONFIRMED])); + expect([SDLVehicleDataActiveStatus valueOf:@"ACTIVE_CONFIRMED"]).to(equal([SDLVehicleDataActiveStatus ACTIVE_CONFIRMED])); + expect([SDLVehicleDataActiveStatus valueOf:@"FAULT"]).to(equal([SDLVehicleDataActiveStatus FAULT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVehicleDataActiveStatus valueOf:nil]).to(beNil()); + expect([SDLVehicleDataActiveStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVehicleDataActiveStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVehicleDataActiveStatus INACTIVE_NOT_CONFIRMED], + [SDLVehicleDataActiveStatus INACTIVE_CONFIRMED], + [SDLVehicleDataActiveStatus ACTIVE_NOT_CONFIRMED], + [SDLVehicleDataActiveStatus ACTIVE_CONFIRMED], + [SDLVehicleDataActiveStatus FAULT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataEventStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataEventStatusSpec.m new file mode 100644 index 000000000..452404231 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataEventStatusSpec.m @@ -0,0 +1,62 @@ +// +// SDLVehicleDataEventStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataEventStatus.h" + +QuickSpecBegin(SDLVehicleDataEventStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVehicleDataEventStatus NO_EVENT].value).to(equal(@"NO_EVENT")); + expect([SDLVehicleDataEventStatus _NO].value).to(equal(@"NO")); + expect([SDLVehicleDataEventStatus _YES].value).to(equal(@"YES")); + expect([SDLVehicleDataEventStatus NOT_SUPPORTED].value).to(equal(@"NOT_SUPPORTED")); + expect([SDLVehicleDataEventStatus FAULT].value).to(equal(@"FAULT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVehicleDataEventStatus valueOf:@"NO_EVENT"]).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect([SDLVehicleDataEventStatus valueOf:@"NO"]).to(equal([SDLVehicleDataEventStatus _NO])); + expect([SDLVehicleDataEventStatus valueOf:@"YES"]).to(equal([SDLVehicleDataEventStatus _YES])); + expect([SDLVehicleDataEventStatus valueOf:@"NOT_SUPPORTED"]).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect([SDLVehicleDataEventStatus valueOf:@"FAULT"]).to(equal([SDLVehicleDataEventStatus FAULT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVehicleDataEventStatus valueOf:nil]).to(beNil()); + expect([SDLVehicleDataEventStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVehicleDataEventStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVehicleDataEventStatus NO_EVENT], + [SDLVehicleDataEventStatus _NO], + [SDLVehicleDataEventStatus _YES], + [SDLVehicleDataEventStatus NOT_SUPPORTED], + [SDLVehicleDataEventStatus FAULT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataNotificationStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataNotificationStatusSpec.m new file mode 100644 index 000000000..6edf13783 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataNotificationStatusSpec.m @@ -0,0 +1,60 @@ +// +// SDLVehicleDataNotificationStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataNotificationStatus.h" + +QuickSpecBegin(SDLVehicleDataNotificationStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVehicleDataNotificationStatus NOT_SUPPORTED].value).to(equal(@"NOT_SUPPORTED")); + expect([SDLVehicleDataNotificationStatus NORMAL].value).to(equal(@"NORMAL")); + expect([SDLVehicleDataNotificationStatus ACTIVE].value).to(equal(@"ACTIVE")); + expect([SDLVehicleDataNotificationStatus NOT_USED].value).to(equal(@"NOT_USED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVehicleDataNotificationStatus valueOf:@"NOT_SUPPORTED"]).to(equal([SDLVehicleDataNotificationStatus NOT_SUPPORTED])); + expect([SDLVehicleDataNotificationStatus valueOf:@"NORMAL"]).to(equal([SDLVehicleDataNotificationStatus NORMAL])); + expect([SDLVehicleDataNotificationStatus valueOf:@"ACTIVE"]).to(equal([SDLVehicleDataNotificationStatus ACTIVE])); + expect([SDLVehicleDataNotificationStatus valueOf:@"NOT_USED"]).to(equal([SDLVehicleDataNotificationStatus NOT_USED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVehicleDataNotificationStatus valueOf:nil]).to(beNil()); + expect([SDLVehicleDataNotificationStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVehicleDataNotificationStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVehicleDataNotificationStatus NOT_SUPPORTED], + [SDLVehicleDataNotificationStatus NORMAL], + [SDLVehicleDataNotificationStatus ACTIVE], + [SDLVehicleDataNotificationStatus NOT_USED]] copy]; + + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataResultCodeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataResultCodeSpec.m new file mode 100644 index 000000000..be09e2495 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataResultCodeSpec.m @@ -0,0 +1,74 @@ +// +// SDLVehicleDataResultCodeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataResultCode.h" + +QuickSpecBegin(SDLVehicleDataResultCodeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVehicleDataResultCode SUCCESS].value).to(equal(@"SUCCESS")); + expect([SDLVehicleDataResultCode TRUNCATED_DATA].value).to(equal(@"TRUNCATED_DATA")); + expect([SDLVehicleDataResultCode DISALLOWED].value).to(equal(@"DISALLOWED")); + expect([SDLVehicleDataResultCode USER_DISALLOWED].value).to(equal(@"USER_DISALLOWED")); + expect([SDLVehicleDataResultCode INVALID_ID].value).to(equal(@"INVALID_ID")); + expect([SDLVehicleDataResultCode VEHICLE_DATA_NOT_AVAILABLE].value).to(equal(@"VEHICLE_DATA_NOT_AVAILABLE")); + expect([SDLVehicleDataResultCode DATA_ALREADY_SUBSCRIBED].value).to(equal(@"DATA_ALREADY_SUBSCRIBED")); + expect([SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED].value).to(equal(@"DATA_NOT_SUBSCRIBED")); + expect([SDLVehicleDataResultCode IGNORED].value).to(equal(@"IGNORED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVehicleDataResultCode valueOf:@"SUCCESS"]).to(equal([SDLVehicleDataResultCode SUCCESS])); + expect([SDLVehicleDataResultCode valueOf:@"TRUNCATED_DATA"]).to(equal([SDLVehicleDataResultCode TRUNCATED_DATA])); + expect([SDLVehicleDataResultCode valueOf:@"DISALLOWED"]).to(equal([SDLVehicleDataResultCode DISALLOWED])); + expect([SDLVehicleDataResultCode valueOf:@"USER_DISALLOWED"]).to(equal([SDLVehicleDataResultCode USER_DISALLOWED])); + expect([SDLVehicleDataResultCode valueOf:@"INVALID_ID"]).to(equal([SDLVehicleDataResultCode INVALID_ID])); + expect([SDLVehicleDataResultCode valueOf:@"VEHICLE_DATA_NOT_AVAILABLE"]).to(equal([SDLVehicleDataResultCode VEHICLE_DATA_NOT_AVAILABLE])); + expect([SDLVehicleDataResultCode valueOf:@"DATA_ALREADY_SUBSCRIBED"]).to(equal([SDLVehicleDataResultCode DATA_ALREADY_SUBSCRIBED])); + expect([SDLVehicleDataResultCode valueOf:@"DATA_NOT_SUBSCRIBED"]).to(equal([SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED])); + expect([SDLVehicleDataResultCode valueOf:@"IGNORED"]).to(equal([SDLVehicleDataResultCode IGNORED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVehicleDataResultCode valueOf:nil]).to(beNil()); + expect([SDLVehicleDataResultCode valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVehicleDataResultCode values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVehicleDataResultCode SUCCESS], + [SDLVehicleDataResultCode TRUNCATED_DATA], + [SDLVehicleDataResultCode DISALLOWED], + [SDLVehicleDataResultCode USER_DISALLOWED], + [SDLVehicleDataResultCode INVALID_ID], + [SDLVehicleDataResultCode VEHICLE_DATA_NOT_AVAILABLE], + [SDLVehicleDataResultCode DATA_ALREADY_SUBSCRIBED], + [SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED], + [SDLVehicleDataResultCode IGNORED]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataStatusSpec.m new file mode 100644 index 000000000..997837562 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataStatusSpec.m @@ -0,0 +1,56 @@ +// +// SDLVehicleDataStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataStatus.h" + +QuickSpecBegin(SDLVehicleDataStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVehicleDataStatus NO_DATA_EXISTS].value).to(equal(@"NO_DATA_EXISTS")); + expect([SDLVehicleDataStatus OFF].value).to(equal(@"OFF")); + expect([SDLVehicleDataStatus ON].value).to(equal(@"ON")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVehicleDataStatus valueOf:@"NO_DATA_EXISTS"]).to(equal([SDLVehicleDataStatus NO_DATA_EXISTS])); + expect([SDLVehicleDataStatus valueOf:@"OFF"]).to(equal([SDLVehicleDataStatus OFF])); + expect([SDLVehicleDataStatus valueOf:@"ON"]).to(equal([SDLVehicleDataStatus ON])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVehicleDataStatus valueOf:nil]).to(beNil()); + expect([SDLVehicleDataStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVehicleDataStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVehicleDataStatus NO_DATA_EXISTS], + [SDLVehicleDataStatus OFF], + [SDLVehicleDataStatus ON]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataTypeSpec.m new file mode 100644 index 000000000..c11e93a7f --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVehicleDataTypeSpec.m @@ -0,0 +1,125 @@ +// +// SDLVehicleDataTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataType.h" + +QuickSpecBegin(SDLVehicleDataTypeSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVehicleDataType VEHICLEDATA_GPS].value).to(equal(@"VEHICLEDATA_GPS")); + expect([SDLVehicleDataType VEHICLEDATA_SPEED].value).to(equal(@"VEHICLEDATA_SPEED")); + expect([SDLVehicleDataType VEHICLEDATA_RPM].value).to(equal(@"VEHICLEDATA_RPM")); + expect([SDLVehicleDataType VEHICLEDATA_FUELLEVEL].value).to(equal(@"VEHICLEDATA_FUELLEVEL")); + expect([SDLVehicleDataType VEHICLEDATA_FUELLEVEL_STATE].value).to(equal(@"VEHICLEDATA_FUELLEVEL_STATE")); + expect([SDLVehicleDataType VEHICLEDATA_FUELCONSUMPTION].value).to(equal(@"VEHICLEDATA_FUELCONSUMPTION")); + expect([SDLVehicleDataType VEHICLEDATA_EXTERNTEMP].value).to(equal(@"VEHICLEDATA_EXTERNTEMP")); + expect([SDLVehicleDataType VEHICLEDATA_VIN].value).to(equal(@"VEHICLEDATA_VIN")); + expect([SDLVehicleDataType VEHICLEDATA_PRNDL].value).to(equal(@"VEHICLEDATA_PRNDL")); + expect([SDLVehicleDataType VEHICLEDATA_TIREPRESSURE].value).to(equal(@"VEHICLEDATA_TIREPRESSURE")); + expect([SDLVehicleDataType VEHICLEDATA_ODOMETER].value).to(equal(@"VEHICLEDATA_ODOMETER")); + expect([SDLVehicleDataType VEHICLEDATA_BELTSTATUS].value).to(equal(@"VEHICLEDATA_BELTSTATUS")); + expect([SDLVehicleDataType VEHICLEDATA_BODYINFO].value).to(equal(@"VEHICLEDATA_BODYINFO")); + expect([SDLVehicleDataType VEHICLEDATA_DEVICESTATUS].value).to(equal(@"VEHICLEDATA_DEVICESTATUS")); + expect([SDLVehicleDataType VEHICLEDATA_ECALLINFO].value).to(equal(@"VEHICLEDATA_ECALLINFO")); + expect([SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS].value).to(equal(@"VEHICLEDATA_AIRBAGSTATUS")); + expect([SDLVehicleDataType VEHICLEDATA_EMERGENCYEVENT].value).to(equal(@"VEHICLEDATA_EMERGENCYEVENT")); + expect([SDLVehicleDataType VEHICLEDATA_CLUSTERMODESTATUS].value).to(equal(@"VEHICLEDATA_CLUSTERMODESTATUS")); + expect([SDLVehicleDataType VEHICLEDATA_MYKEY].value).to(equal(@"VEHICLEDATA_MYKEY")); + expect([SDLVehicleDataType VEHICLEDATA_BRAKING].value).to(equal(@"VEHICLEDATA_BRAKING")); + expect([SDLVehicleDataType VEHICLEDATA_WIPERSTATUS].value).to(equal(@"VEHICLEDATA_WIPERSTATUS")); + expect([SDLVehicleDataType VEHICLEDATA_HEADLAMPSTATUS].value).to(equal(@"VEHICLEDATA_HEADLAMPSTATUS")); + expect([SDLVehicleDataType VEHICLEDATA_BATTVOLTAGE].value).to(equal(@"VEHICLEDATA_BATTVOLTAGE")); + expect([SDLVehicleDataType VEHICLEDATA_ENGINETORQUE].value).to(equal(@"VEHICLEDATA_ENGINETORQUE")); + expect([SDLVehicleDataType VEHICLEDATA_ACCPEDAL].value).to(equal(@"VEHICLEDATA_ACCPEDAL")); + expect([SDLVehicleDataType VEHICLEDATA_STEERINGWHEEL].value).to(equal(@"VEHICLEDATA_STEERINGWHEEL")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_GPS"]).to(equal([SDLVehicleDataType VEHICLEDATA_GPS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_SPEED"]).to(equal([SDLVehicleDataType VEHICLEDATA_SPEED])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_RPM"]).to(equal([SDLVehicleDataType VEHICLEDATA_RPM])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_FUELLEVEL"]).to(equal([SDLVehicleDataType VEHICLEDATA_FUELLEVEL])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_FUELLEVEL_STATE"]).to(equal([SDLVehicleDataType VEHICLEDATA_FUELLEVEL_STATE])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_FUELCONSUMPTION"]).to(equal([SDLVehicleDataType VEHICLEDATA_FUELCONSUMPTION])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_EXTERNTEMP"]).to(equal([SDLVehicleDataType VEHICLEDATA_EXTERNTEMP])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_VIN"]).to(equal([SDLVehicleDataType VEHICLEDATA_VIN])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_PRNDL"]).to(equal([SDLVehicleDataType VEHICLEDATA_PRNDL])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_TIREPRESSURE"]).to(equal([SDLVehicleDataType VEHICLEDATA_TIREPRESSURE])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_ODOMETER"]).to(equal([SDLVehicleDataType VEHICLEDATA_ODOMETER])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_BELTSTATUS"]).to(equal([SDLVehicleDataType VEHICLEDATA_BELTSTATUS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_BODYINFO"]).to(equal([SDLVehicleDataType VEHICLEDATA_BODYINFO])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_DEVICESTATUS"]).to(equal([SDLVehicleDataType VEHICLEDATA_DEVICESTATUS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_ECALLINFO"]).to(equal([SDLVehicleDataType VEHICLEDATA_ECALLINFO])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_AIRBAGSTATUS"]).to(equal([SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_EMERGENCYEVENT"]).to(equal([SDLVehicleDataType VEHICLEDATA_EMERGENCYEVENT])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_CLUSTERMODESTATUS"]).to(equal([SDLVehicleDataType VEHICLEDATA_CLUSTERMODESTATUS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_MYKEY"]).to(equal([SDLVehicleDataType VEHICLEDATA_MYKEY])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_BRAKING"]).to(equal([SDLVehicleDataType VEHICLEDATA_BRAKING])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_WIPERSTATUS"]).to(equal([SDLVehicleDataType VEHICLEDATA_WIPERSTATUS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_HEADLAMPSTATUS"]).to(equal([SDLVehicleDataType VEHICLEDATA_HEADLAMPSTATUS])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_BATTVOLTAGE"]).to(equal([SDLVehicleDataType VEHICLEDATA_BATTVOLTAGE])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_ENGINETORQUE"]).to(equal([SDLVehicleDataType VEHICLEDATA_ENGINETORQUE])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_ACCPEDAL"]).to(equal([SDLVehicleDataType VEHICLEDATA_ACCPEDAL])); + expect([SDLVehicleDataType valueOf:@"VEHICLEDATA_STEERINGWHEEL"]).to(equal([SDLVehicleDataType VEHICLEDATA_STEERINGWHEEL])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVehicleDataType valueOf:nil]).to(beNil()); + expect([SDLVehicleDataType valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVehicleDataType values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVehicleDataType VEHICLEDATA_GPS], + [SDLVehicleDataType VEHICLEDATA_SPEED], + [SDLVehicleDataType VEHICLEDATA_RPM], + [SDLVehicleDataType VEHICLEDATA_FUELLEVEL], + [SDLVehicleDataType VEHICLEDATA_FUELLEVEL_STATE], + [SDLVehicleDataType VEHICLEDATA_FUELCONSUMPTION], + [SDLVehicleDataType VEHICLEDATA_EXTERNTEMP], + [SDLVehicleDataType VEHICLEDATA_VIN], + [SDLVehicleDataType VEHICLEDATA_PRNDL], + [SDLVehicleDataType VEHICLEDATA_TIREPRESSURE], + [SDLVehicleDataType VEHICLEDATA_ODOMETER], + [SDLVehicleDataType VEHICLEDATA_BELTSTATUS], + [SDLVehicleDataType VEHICLEDATA_BODYINFO], + [SDLVehicleDataType VEHICLEDATA_DEVICESTATUS], + [SDLVehicleDataType VEHICLEDATA_ECALLINFO], + [SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS], + [SDLVehicleDataType VEHICLEDATA_EMERGENCYEVENT], + [SDLVehicleDataType VEHICLEDATA_CLUSTERMODESTATUS], + [SDLVehicleDataType VEHICLEDATA_MYKEY], + [SDLVehicleDataType VEHICLEDATA_BRAKING], + [SDLVehicleDataType VEHICLEDATA_WIPERSTATUS], + [SDLVehicleDataType VEHICLEDATA_HEADLAMPSTATUS], + [SDLVehicleDataType VEHICLEDATA_BATTVOLTAGE], + [SDLVehicleDataType VEHICLEDATA_ENGINETORQUE], + [SDLVehicleDataType VEHICLEDATA_ACCPEDAL], + [SDLVehicleDataType VEHICLEDATA_STEERINGWHEEL]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVrCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVrCapabilitiesSpec.m new file mode 100644 index 000000000..be62ee96a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLVrCapabilitiesSpec.m @@ -0,0 +1,50 @@ +// +// SDLVrCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVrCapabilities.h" + +QuickSpecBegin(SDLVrCapabilitiesSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLVRCapabilities TEXT].value).to(equal(@"TEXT")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLVRCapabilities valueOf:@"TEXT"]).to(equal([SDLVRCapabilities TEXT])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLVRCapabilities valueOf:nil]).to(beNil()); + expect([SDLVRCapabilities valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLVRCapabilities values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLVRCapabilities TEXT]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLWarningLightStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLWarningLightStatusSpec.m new file mode 100644 index 000000000..698116e50 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLWarningLightStatusSpec.m @@ -0,0 +1,60 @@ +// +// SDLWarningLightStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLWarningLightStatus.h" + +QuickSpecBegin(SDLWarningLightStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLWarningLightStatus OFF].value).to(equal(@"OFF")); + expect([SDLWarningLightStatus ON].value).to(equal(@"ON")); + expect([SDLWarningLightStatus FLASH].value).to(equal(@"FLASH")); + expect([SDLWarningLightStatus NOT_USED].value).to(equal(@"NOT_USED")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLWarningLightStatus valueOf:@"OFF"]).to(equal([SDLWarningLightStatus OFF])); + expect([SDLWarningLightStatus valueOf:@"ON"]).to(equal([SDLWarningLightStatus ON])); + expect([SDLWarningLightStatus valueOf:@"FLASH"]).to(equal([SDLWarningLightStatus FLASH])); + expect([SDLWarningLightStatus valueOf:@"NOT_USED"]).to(equal([SDLWarningLightStatus NOT_USED])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLWarningLightStatus valueOf:nil]).to(beNil()); + expect([SDLWarningLightStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLWarningLightStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLWarningLightStatus OFF], + [SDLWarningLightStatus ON], + [SDLWarningLightStatus FLASH], + [SDLWarningLightStatus NOT_USED]] copy]; + + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLWiperStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLWiperStatusSpec.m new file mode 100644 index 000000000..18fbce66c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/EnumSpecs/SDLWiperStatusSpec.m @@ -0,0 +1,92 @@ +// +// SDLWiperStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLWiperStatus.h" + +QuickSpecBegin(SDLWiperStatusSpec) + +describe(@"Individual Enum Value Tests", ^ { + it(@"Should match internal values", ^ { + expect([SDLWiperStatus OFF].value).to(equal(@"OFF")); + expect([SDLWiperStatus AUTO_OFF].value).to(equal(@"AUTO_OFF")); + expect([SDLWiperStatus OFF_MOVING].value).to(equal(@"OFF_MOVING")); + expect([SDLWiperStatus MAN_INT_OFF].value).to(equal(@"MAN_INT_OFF")); + expect([SDLWiperStatus MAN_INT_ON].value).to(equal(@"MAN_INT_ON")); + expect([SDLWiperStatus MAN_LOW].value).to(equal(@"MAN_LOW")); + expect([SDLWiperStatus MAN_HIGH].value).to(equal(@"MAN_HIGH")); + expect([SDLWiperStatus MAN_FLICK].value).to(equal(@"MAN_FLICK")); + expect([SDLWiperStatus WASH].value).to(equal(@"WASH")); + expect([SDLWiperStatus AUTO_LOW].value).to(equal(@"AUTO_LOW")); + expect([SDLWiperStatus AUTO_HIGH].value).to(equal(@"AUTO_HIGH")); + expect([SDLWiperStatus COURTESYWIPE].value).to(equal(@"COURTESYWIPE")); + expect([SDLWiperStatus AUTO_ADJUST].value).to(equal(@"AUTO_ADJUST")); + expect([SDLWiperStatus STALLED].value).to(equal(@"STALLED")); + expect([SDLWiperStatus NO_DATA_EXISTS].value).to(equal(@"NO_DATA_EXISTS")); + }); +}); +describe(@"ValueOf Tests", ^ { + it(@"Should return correct values when valid", ^ { + expect([SDLWiperStatus valueOf:@"OFF"]).to(equal([SDLWiperStatus OFF])); + expect([SDLWiperStatus valueOf:@"AUTO_OFF"]).to(equal([SDLWiperStatus AUTO_OFF])); + expect([SDLWiperStatus valueOf:@"OFF_MOVING"]).to(equal([SDLWiperStatus OFF_MOVING])); + expect([SDLWiperStatus valueOf:@"MAN_INT_OFF"]).to(equal([SDLWiperStatus MAN_INT_OFF])); + expect([SDLWiperStatus valueOf:@"MAN_INT_ON"]).to(equal([SDLWiperStatus MAN_INT_ON])); + expect([SDLWiperStatus valueOf:@"MAN_LOW"]).to(equal([SDLWiperStatus MAN_LOW])); + expect([SDLWiperStatus valueOf:@"MAN_HIGH"]).to(equal([SDLWiperStatus MAN_HIGH])); + expect([SDLWiperStatus valueOf:@"MAN_FLICK"]).to(equal([SDLWiperStatus MAN_FLICK])); + expect([SDLWiperStatus valueOf:@"WASH"]).to(equal([SDLWiperStatus WASH])); + expect([SDLWiperStatus valueOf:@"AUTO_LOW"]).to(equal([SDLWiperStatus AUTO_LOW])); + expect([SDLWiperStatus valueOf:@"AUTO_HIGH"]).to(equal([SDLWiperStatus AUTO_HIGH])); + expect([SDLWiperStatus valueOf:@"COURTESYWIPE"]).to(equal([SDLWiperStatus COURTESYWIPE])); + expect([SDLWiperStatus valueOf:@"AUTO_ADJUST"]).to(equal([SDLWiperStatus AUTO_ADJUST])); + expect([SDLWiperStatus valueOf:@"STALLED"]).to(equal([SDLWiperStatus STALLED])); + expect([SDLWiperStatus valueOf:@"NO_DATA_EXISTS"]).to(equal([SDLWiperStatus NO_DATA_EXISTS])); + }); + + it(@"Should return nil when invalid", ^ { + expect([SDLWiperStatus valueOf:nil]).to(beNil()); + expect([SDLWiperStatus valueOf:@"JKUYTFHYTHJGFRFGYTR"]).to(beNil()); + }); +}); +describe(@"Value List Tests", ^ { + NSArray* storedValues = [SDLWiperStatus values]; + __block NSArray* definedValues; + beforeSuite(^ { + definedValues = [@[[SDLWiperStatus OFF], + [SDLWiperStatus AUTO_OFF], + [SDLWiperStatus OFF_MOVING], + [SDLWiperStatus MAN_INT_OFF], + [SDLWiperStatus MAN_INT_ON], + [SDLWiperStatus MAN_LOW], + [SDLWiperStatus MAN_HIGH], + [SDLWiperStatus MAN_FLICK], + [SDLWiperStatus WASH], + [SDLWiperStatus AUTO_LOW], + [SDLWiperStatus AUTO_HIGH], + [SDLWiperStatus COURTESYWIPE], + [SDLWiperStatus AUTO_ADJUST], + [SDLWiperStatus STALLED], + [SDLWiperStatus NO_DATA_EXISTS]] copy]; + }); + + it(@"Should contain all defined enum values", ^ { + for (int i = 0; i < definedValues.count; i++) { + expect(storedValues).to(contain(definedValues[i])); + } + }); + + it(@"Should contain only defined enum values", ^ { + for (int i = 0; i < storedValues.count; i++) { + expect(definedValues).to(contain(storedValues[i])); + } + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m b/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m new file mode 100644 index 000000000..1f7da2226 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m @@ -0,0 +1,986 @@ +// +// SmartDeviceLinkTests.m +// SmartDeviceLinkTests + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SmartDeviceLink.h" + + +QuickSpecBegin(SDLRPCRequestFactorySpec) + +describe(@"BuildAddCommand Tests", ^ { + it(@"Should build correctly", ^ { + SDLAddCommand* message = [SDLRPCRequestFactory buildAddCommandWithID:@33 menuName:@"Menu" parentID:@4 position:@500 + vrCommands:nil iconValue:@"No" iconType:[SDLImageType STATIC] correlationID:@94]; + expect([message menuParams].position).to(equal(@500)); + expect([message menuParams].menuName).to(equal(@"Menu")); + expect([message menuParams].parentID).to(equal(@4)); + expect([message cmdIcon].value).to(equal(@"No")); + expect([message cmdIcon].imageType).to(equal([SDLImageType STATIC])); + expect(message.vrCommands).to(beNil()); + expect(message.cmdID).to(equal(@33)); + expect(message.correlationID).to(equal(@94)); + + NSArray* aliases = @[@"Joe1", @"Joe2", @"Joe3", + @"--------------------------------ASLONGOFASTRINGASICANPOSSIBLYMAKEINASINGLELINE---------------------------------"]; + message = [SDLRPCRequestFactory buildAddCommandWithID:@276 menuName:@"Arbitrary" vrCommands:aliases correlationID:@200]; + + expect([message menuParams].position).to(beNil()); + expect([message menuParams].menuName).to(equal(@"Arbitrary")); + expect([message menuParams].parentID).to(beNil()); + expect(message.vrCommands).to(equal(aliases)); + expect(message.cmdIcon).to(beNil()); + expect(message.cmdID).to(equal(@276)); + expect(message.correlationID).to(equal(@200)); + + message = [SDLRPCRequestFactory buildAddCommandWithID:@9001 vrCommands:@[@" ", @" ", @" ", @""] correlationID:@27]; + + expect(message.menuParams).to(beNil()); + expect(message.vrCommands).to(equal(@[@" ", @" ", @" ", @""])); + expect(message.cmdIcon).to(beNil()); + expect(message.cmdID).to(equal(@9001)); + expect(message.correlationID).to(equal(@27)); + }); +}); + +describe(@"BuildAddSubMenu Tests", ^ { + it(@"Should build correctly", ^ { + SDLAddSubMenu* message = [SDLRPCRequestFactory buildAddSubMenuWithID:@234234 menuName:@"QWERTY" position:@3 correlationID:@13]; + + expect(message.menuName).to(equal(@"QWERTY")); + expect(message.position).to(equal(@3)); + expect(message.menuID).to(equal(@234234)); + expect(message.correlationID).to(equal(@13)); + + message = [SDLRPCRequestFactory buildAddSubMenuWithID:@444 menuName:@"Words" correlationID:@423]; + + expect(message.menuName).to(equal(@"Words")); + expect(message.position).to(beNil()); + expect(message.menuID).to(equal(@444)); + expect(message.correlationID).to(equal(@423)); + }); +}); + +describe(@"BuildAlert Tests", ^ { + context(@"With Text", ^ { + it(@"Should build correctly", ^ { + NSArray* softButtons = @[[[SDLSoftButton alloc] init]]; + SDLAlert* message = [SDLRPCRequestFactory buildAlertWithAlertText1:@"String1" alertText2:@"String2" alertText3:@"String3" + duration:@9999 softButtons:softButtons correlationID:@41]; + + expect(message.alertText1).to(equal(@"String1")); + expect(message.alertText2).to(equal(@"String2")); + expect(message.alertText3).to(equal(@"String3")); + expect(message.ttsChunks).to(beNil()); + expect(message.duration).to(equal(@9999)); + expect(message.playTone).to(beNil()); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(equal(softButtons)); + expect(message.correlationID).to(equal(@41)); + + message = [SDLRPCRequestFactory buildAlertWithAlertText1:@"Alarming" alertText2:@"Astonishing" alertText3:@"Attention" + duration:@3000 correlationID:@11234]; + + expect(message.alertText1).to(equal(@"Alarming")); + expect(message.alertText2).to(equal(@"Astonishing")); + expect(message.alertText3).to(equal(@"Attention")); + expect(message.ttsChunks).to(beNil()); + expect(message.duration).to(equal(@3000)); + expect(message.playTone).to(beNil()); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.correlationID).to(equal(@11234)); + + message = [SDLRPCRequestFactory buildAlertWithAlertText1:@"1" alertText2:@"2" duration:@4153 correlationID:@1432143]; + + expect(message.alertText1).to(equal(@"1")); + expect(message.alertText2).to(equal(@"2")); + expect(message.alertText3).to(beNil()); + expect(message.ttsChunks).to(beNil()); + expect(message.duration).to(equal(@4153)); + expect(message.playTone).to(beNil()); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.correlationID).to(equal(@1432143)); + }); + }); + + context(@"With TTS", ^ { + it(@"Should build correctly", ^ { + SDLAlert* message = [SDLRPCRequestFactory buildAlertWithTTS:@"Wat" alertText1:@"11" alertText2:@"12" alertText3:@"13" + playTone:@NO duration:@3424 correlationID:@9999999]; + + expect(message.alertText1).to(equal(@"11")); + expect(message.alertText2).to(equal(@"12")); + expect(message.alertText3).to(equal(@"13")); + expect(((SDLTTSChunk*)[message ttsChunks][0]).text).to(equal(@"Wat")); + expect(message.duration).to(equal(@3424)); + expect(message.playTone).to(equal(@NO)); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.correlationID).to(equal(@9999999)); + + message = [SDLRPCRequestFactory buildAlertWithTTS:@"Say This" alertText1:@"hgkj" alertText2:@"bgydhgfc" + playTone:@YES duration:@6546 correlationID:@65436786]; + + expect(message.alertText1).to(equal(@"hgkj")); + expect(message.alertText2).to(equal(@"bgydhgfc")); + expect(message.alertText3).to(beNil()); + expect(((SDLTTSChunk*)[message ttsChunks][0]).text).to(equal(@"Say This")); + expect(message.duration).to(equal(@6546)); + expect(message.playTone).to(equal(@YES)); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.correlationID).to(equal(@65436786)); + + message = [SDLRPCRequestFactory buildAlertWithTTS:@"Surprise" playTone:@YES correlationID:@34]; + + expect(message.alertText1).to(beNil()); + expect(message.alertText2).to(beNil()); + expect(message.alertText3).to(beNil()); + expect(((SDLTTSChunk*)[message ttsChunks][0]).text).to(equal(@"Surprise")); + expect(message.duration).to(beNil()); + expect(message.playTone).to(equal(@YES)); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.correlationID).to(equal(@34)); + }); + }); + + context(@"With TTSChunks", ^ { + it(@"Should build correctly", ^ { + NSArray* softButtons = @[[[SDLSoftButton alloc] init]]; + NSArray* ttsChunks = @[[[SDLTTSChunk alloc] init]]; + SDLAlert* message = [SDLRPCRequestFactory buildAlertWithTTSChunks:ttsChunks alertText1:@"Astonish" alertText2:@"Hi" alertText3:@"Alert" + playTone:@NO duration:@4145 softButtons:softButtons correlationID:@19]; + + expect(message.alertText1).to(equal(@"Astonish")); + expect(message.alertText2).to(equal(@"Hi")); + expect(message.alertText3).to(equal(@"Alert")); + expect(message.ttsChunks).to(equal(ttsChunks)); + expect(message.duration).to(equal(@4145)); + expect(message.playTone).to(equal(@NO)); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(equal(softButtons)); + expect(message.correlationID).to(equal(@19)); + + message = [SDLRPCRequestFactory buildAlertWithTTSChunks:ttsChunks playTone:@YES correlationID:@1234321]; + + expect(message.alertText1).to(beNil()); + expect(message.alertText2).to(beNil()); + expect(message.alertText3).to(beNil()); + expect(message.ttsChunks).to(equal(ttsChunks)); + expect(message.duration).to(beNil()); + expect(message.playTone).to(equal(@YES)); + expect(message.progressIndicator).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.correlationID).to(equal(@1234321)); + }); + }); +}); + + +describe(@"SDLAlertManeuver Tests", ^ { + __block NSMutableArray *softButtons = nil; + __block NSMutableArray *ttsChunks = nil; + __block SDLAlertManeuver *message = nil; + + describe(@"Should build correctly", ^ { + beforeEach(^{ + softButtons = [@[[[SDLSoftButton alloc] init]] mutableCopy]; + ttsChunks = [@[[[SDLTTSChunk alloc] init]] mutableCopy]; + message = [SDLRPCRequestFactory buildAlertManeuverwithTTSchunks:ttsChunks softButtons:softButtons correlationID:@1234]; + }); + + it(@"Should properly set TTS Chunks", ^{ + expect(message.ttsChunks).to(equal(ttsChunks)); + }); + + it(@"Should properly set Soft Buttons", ^{ + expect(message.softButtons).to(equal(softButtons)); + }); + + it(@"Should properly set Correlation ID", ^{ + expect(message.correlationID).to(equal(@1234)); + }); + }); +}); + + +describe(@"BuildChangeRegistration Tests", ^ { + it(@"Should build correctly", ^ { + SDLChangeRegistration* message = [SDLRPCRequestFactory buildChangeRegistrationWithLanguage:[SDLLanguage EN_GB] hmiDisplayLanguage:[SDLLanguage DE_DE] correlationID:@22336644]; + + expect(message.language).to(equal([SDLLanguage EN_GB])); + expect(message.hmiDisplayLanguage).to(equal([SDLLanguage DE_DE])); + expect(message.correlationID).to(equal(@22336644)); + }); +}); + +describe(@"BuildCreateInteractionChoiceSet Tests", ^ { + it(@"Should build correctly", ^ { + NSArray* choices = @[[[SDLChoice alloc] init]]; + SDLCreateInteractionChoiceSet* message = [SDLRPCRequestFactory buildCreateInteractionChoiceSetWithID:@4567654 choiceSet:choices correlationID:@0]; + + expect(message.interactionChoiceSetID).to(equal(@4567654)); + expect(message.choiceSet).to(equal(choices)); + expect(message.correlationID).to(equal(@0)); + }); +}); + +describe(@"BuildDeleteCommand Tests", ^ { + it(@"Should build correctly", ^ { + SDLDeleteCommand* message = [SDLRPCRequestFactory buildDeleteCommandWithID:@2 correlationID:@234]; + + expect(message.cmdID).to(equal(@2)); + expect(message.correlationID).to(equal(@234)); + }); +}); + +describe(@"BuildDeleteFile Tests", ^ { + it(@"Should build correctly", ^ { + SDLDeleteFile* message = [SDLRPCRequestFactory buildDeleteFileWithName:@"CRITICAL_FILE" correlationID:@4930]; + + expect(message.syncFileName).to(equal(@"CRITICAL_FILE")); + expect(message.correlationID).to(equal(@4930)); + }); +}); + +describe(@"BuildListFiles Tests", ^ { + it(@"Should build correctly", ^ { + SDLListFiles* message = [SDLRPCRequestFactory buildListFilesWithCorrelationID:@13123]; + + expect(message.correlationID).to(equal(@13123)); + }); +}); + +describe(@"BuildDeleteInteractionChoiceSet Tests", ^ { + it(@"Should build correctly", ^ { + SDLDeleteInteractionChoiceSet* message = [SDLRPCRequestFactory buildDeleteInteractionChoiceSetWithID:@46765426 correlationID:@46765426]; + + expect(message.interactionChoiceSetID).to(equal(@46765426)); + expect(message.correlationID).to(equal(@46765426)); + }); +}); + +describe(@"BuildDeleteSubMenu Tests", ^ { + it(@"Should build correctly", ^ { + SDLDeleteSubMenu* message = [SDLRPCRequestFactory buildDeleteSubMenuWithID:@3515 correlationID:@5153]; + + expect(message.menuID).to(equal(@3515)); + expect(message.correlationID).to(equal(@5153)); + }); +}); + +describe(@"BuildDialNumber", ^{ + __block SDLDialNumber *message = nil; + __block NSString *someNumberString = nil; + + describe(@"when built correctly", ^{ + beforeEach(^{ + someNumberString = @"1234567890"; + message = [SDLRPCRequestFactory buildDialNumberWithNumber:someNumberString]; + }); + + it(@"should not be nil", ^{ + expect(message).toNot(beNil()); + }); + + it(@"should have number set properly", ^{ + expect(message.number).to(equal(someNumberString)); + }); + }); +}); + +describe(@"BuildEndAudioPassThru Tests", ^ { + it(@"Should build correctly", ^ { + SDLEndAudioPassThru* message = [SDLRPCRequestFactory buildEndAudioPassThruWithCorrelationID:@13123]; + + expect(message.correlationID).to(equal(@13123)); + }); +}); + +describe(@"BuildGetDTCs Tests", ^ { + it(@"Should build correctly", ^ { + SDLGetDTCs* message = [SDLRPCRequestFactory buildGetDTCsWithECUName:@255 correlationID:@60806050]; + + expect(message.ecuName).to(equal(@255)); + expect(message.dtcMask).to(beNil()); + expect(message.correlationID).to(equal(@60806050)); + }); +}); + +describe(@"BuildGetVehicleData Tests", ^ { + it(@"Should build correctly", ^ { + SDLGetVehicleData* message = [SDLRPCRequestFactory buildGetVehicleDataWithGPS:@YES speed:@NO rpm:@NO + fuelLevel:@YES fuelLevelState:@YES instantFuelConsumption:@NO + externalTemperature:@YES vin:@YES prndl:@YES + tirePressure:@NO odometer:@NO beltStatus:@NO + bodyInformation:@YES deviceStatus:@NO driverBraking:@NO + wiperStatus:@NO headLampStatus:@YES engineTorque:@YES + accPedalPosition:@NO steeringWheelAngle:@YES correlationID:@936]; + + expect(message.gps).to(equal(@YES)); + expect(message.speed).to(equal(@NO)); + expect(message.rpm).to(equal(@NO)); + expect(message.fuelLevel).to(equal(@YES)); + expect(message.fuelLevel_State).to(equal(@YES)); + expect(message.instantFuelConsumption).to(equal(@NO)); + expect(message.externalTemperature).to(equal(@YES)); + expect(message.vin).to(equal(@YES)); + expect(message.prndl).to(equal(@YES)); + expect(message.tirePressure).to(equal(@NO)); + expect(message.odometer).to(equal(@NO)); + expect(message.beltStatus).to(equal(@NO)); + expect(message.bodyInformation).to(equal(@YES)); + expect(message.deviceStatus).to(equal(@NO)); + expect(message.driverBraking).to(equal(@NO)); + expect(message.wiperStatus).to(equal(@NO)); + expect(message.headLampStatus).to(equal(@YES)); + expect(message.engineTorque).to(equal(@YES)); + expect(message.accPedalPosition).to(equal(@NO)); + expect(message.steeringWheelAngle).to(equal(@YES)); + expect(message.eCallInfo).to(beNil()); + expect(message.airbagStatus).to(beNil()); + expect(message.emergencyEvent).to(beNil()); + expect(message.clusterModeStatus).to(beNil()); + expect(message.myKey).to(beNil()); + expect(message.correlationID).to(equal(@936)); + }); +}); + +describe(@"BuildPerformAudioPassThru Tests", ^ { + it(@"Should build correctly", ^ { + SDLPerformAudioPassThru* message = [SDLRPCRequestFactory buildPerformAudioPassThruWithInitialPrompt:@"" audioPassThruDisplayText1:@"Display1" audioPassThruDisplayText2:@"Display2" + samplingRate:[SDLSamplingRate _44KHZ] maxDuration:@10 bitsPerSample:[SDLBitsPerSample _16_BIT] audioType:[SDLAudioType PCM] + muteAudio:@NO correlationID:@2500]; + + expect(((SDLTTSChunk*)[message initialPrompt][0]).text).to(equal(@"")); + expect(message.audioPassThruDisplayText1).to(equal(@"Display1")); + expect(message.audioPassThruDisplayText2).to(equal(@"Display2")); + expect(message.samplingRate).to(equal([SDLSamplingRate _44KHZ])); + expect(message.maxDuration).to(equal(@10)); + expect(message.bitsPerSample).to(equal([SDLBitsPerSample _16_BIT])); + expect(message.audioType).to(equal([SDLAudioType PCM])); + expect(message.muteAudio).to(equal(@NO)); + expect(message.correlationID).to(equal(@2500)); + }); +}); + +describe(@"BuildPerformInteraction Tests", ^ { + context(@"With Initial Chunks", ^ { + it(@"Should build correctly", ^ { + NSArray* initialChunks = @[[[SDLTTSChunk alloc] init]]; + NSArray* helpChunks = @[[[SDLTTSChunk alloc] init]]; + NSArray* timeoutChunks = @[[[SDLTTSChunk alloc] init]]; + NSArray* vrHelp = @[[[SDLVRHelpItem alloc] init]]; + SDLPerformInteraction* message = [SDLRPCRequestFactory buildPerformInteractionWithInitialChunks:initialChunks initialText:@"Start" interactionChoiceSetIDList:@[@878] + helpChunks:helpChunks timeoutChunks:timeoutChunks interactionMode:[SDLInteractionMode MANUAL_ONLY] timeout:@7500 + vrHelp:vrHelp correlationID:@272727]; + + expect(message.initialPrompt).to(equal(initialChunks)); + expect(message.initialText).to(equal(@"Start")); + expect(message.interactionChoiceSetIDList).to(equal(@[@878])); + expect(message.helpPrompt).to(equal(helpChunks)); + expect(message.timeoutPrompt).to(equal(timeoutChunks)); + expect(message.interactionMode).to(equal([SDLInteractionMode MANUAL_ONLY])); + expect(message.timeout).to(equal(@7500)); + expect(message.vrHelp).to(equal(vrHelp)); + expect(message.interactionLayout).to(beNil()); + expect(message.correlationID).to(equal(@272727)); + }); + }); + + context(@"With Initial Prompt", ^ { + it(@"Should build correctly", ^ { + NSArray* vrHelp = @[[[SDLVRHelpItem alloc] init]]; + SDLPerformInteraction* message = [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:@"Nothing" initialText:@"Still Nothing" interactionChoiceSetIDList:@[@4223, @1337] + helpPrompt:@"A Whole Lot of Nothing" timeoutPrompt:@"Time Remaining" interactionMode:[SDLInteractionMode VR_ONLY] + timeout:@5600 vrHelp:vrHelp correlationID:@31564]; + + expect(((SDLTTSChunk*)[message initialPrompt][0]).text).to(equal(@"Nothing")); + expect(message.initialText).to(equal(@"Still Nothing")); + expect(message.interactionChoiceSetIDList).to(equal(@[@4223, @1337])); + expect(((SDLTTSChunk*)[message helpPrompt][0]).text).to(equal(@"A Whole Lot of Nothing")); + expect(((SDLTTSChunk*)[message timeoutPrompt][0]).text).to(equal(@"Time Remaining")); + expect(message.interactionMode).to(equal([SDLInteractionMode VR_ONLY])); + expect(message.timeout).to(equal(@5600)); + expect(message.vrHelp).to(equal(vrHelp)); + expect(message.interactionLayout).to(beNil()); + expect(message.correlationID).to(equal(@31564)); + + message = [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:@"A" initialText:@"B" interactionChoiceSetIDList:@[@1, @2, @3, @4] helpPrompt:@"C" timeoutPrompt:@"D" + interactionMode:[SDLInteractionMode BOTH] timeout:@10000 correlationID:@7734]; + + expect(((SDLTTSChunk*)[message initialPrompt][0]).text).to(equal(@"A")); + expect(message.initialText).to(equal(@"B")); + expect(message.interactionChoiceSetIDList).to(equal(@[@1, @2, @3, @4])); + expect(((SDLTTSChunk*)[message helpPrompt][0]).text).to(equal(@"C")); + expect(((SDLTTSChunk*)[message timeoutPrompt][0]).text).to(equal(@"D")); + expect(message.interactionMode).to(equal([SDLInteractionMode BOTH])); + expect(message.timeout).to(equal(@10000)); + expect(message.vrHelp).to(beNil()); + expect(message.interactionLayout).to(beNil()); + expect(message.correlationID).to(equal(@7734)); + + message = [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:@"Initializing" initialText:@"Initialized" interactionChoiceSetID:@1456 vrHelp:vrHelp correlationID:@7056704]; + + expect(((SDLTTSChunk*)[message initialPrompt][0]).text).to(equal(@"Initializing")); + expect(message.initialText).to(equal(@"Initialized")); + expect(message.interactionChoiceSetIDList).to(equal(@[@1456])); + expect(message.helpPrompt).to(beNil()); + expect(message.timeoutPrompt).to(beNil()); + //Don't know whether the reason for this failure is a bug... + expect(message.interactionMode).to(equal([SDLInteractionMode BOTH])); + expect(message.timeout).to(beNil()); + expect(message.vrHelp).to(equal(vrHelp)); + expect(message.interactionLayout).to(beNil()); + expect(message.correlationID).to(equal(@7056704)); + + message = [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:@"#$%@" initialText:@"!%%&&^$" interactionChoiceSetID:@105503 correlationID:@1454156465]; + + expect(((SDLTTSChunk*)[message initialPrompt][0]).text).to(equal(@"#$%@")); + expect(message.initialText).to(equal(@"!%%&&^$")); + expect(message.interactionChoiceSetIDList).to(equal(@[@105503])); + expect(message.helpPrompt).to(beNil()); + expect(message.timeoutPrompt).to(beNil()); + expect(message.interactionMode).to(equal([SDLInteractionMode BOTH])); + expect(message.timeout).to(beNil()); + expect(message.vrHelp).to(beNil()); + expect(message.interactionLayout).to(beNil()); + expect(message.correlationID).to(equal(@1454156465)); + }); + }); +}); + +describe(@"BuildPutFile Tests", ^ { + it(@"Should build correctly", ^ { + SDLPutFile *message = [SDLRPCRequestFactory buildPutFileWithFileName:@"YES!?" fileType:[SDLFileType GRAPHIC_BMP] persistentFile:@165636 correlationId:@147986]; + + expect(message.syncFileName).to(equal(@"YES!?")); + expect(message.fileType).to(equal([SDLFileType GRAPHIC_BMP])); + expect(message.persistentFile).to(equal(@165636)); + expect(message.correlationID).to(equal(@147986)); + }); +}); + +describe(@"BuildReadDID Tests", ^ { + it(@"Should build correctly", ^ { + SDLReadDID* message = [SDLRPCRequestFactory buildReadDIDWithECUName:@12500 didLocation:@[@1, @5, @10, @10, @5, @1] correlationID:@6465678]; + + expect(message.ecuName).to(equal(@12500)); + expect(message.didLocation).to(equal(@[@1, @5, @10, @10, @5, @1])); + expect(message.correlationID).to(equal(@6465678)); + }); +}); + +describe(@"BuildRegisterAppInterface Tests", ^ { + it(@"Should build correctly", ^ { + NSMutableArray *ttsName = [NSMutableArray arrayWithArray:@[[[SDLTTSChunk alloc] init]]]; + NSMutableArray *synonyms = [NSMutableArray arrayWithArray:@[@"Q", @"W", @"E", @"R"]]; + SDLRegisterAppInterface* message = [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:@"Interface" ttsName:ttsName vrSynonyms:synonyms + isMediaApp:@YES languageDesired:[SDLLanguage EN_US] + hmiDisplayLanguageDesired:[SDLLanguage ES_MX] appID:@"6h43g"]; + + expect(message.syncMsgVersion).toNot(beNil()); + expect(message.syncMsgVersion.majorVersion).to(equal(@1)); + expect(message.syncMsgVersion.minorVersion).to(equal(@0)); + + expect(message.appName).to(equal(@"Interface")); + expect(message.ttsName).to(equal(ttsName)); + expect(message.ngnMediaScreenAppName).to(equal(@"Interface")); + expect(message.vrSynonyms).to(equal(@[@"Q", @"W", @"E", @"R"])); + expect(message.isMediaApplication).to(equal(@YES)); + expect(message.languageDesired).to(equal([SDLLanguage EN_US])); + expect(message.hmiDisplayLanguageDesired).to(equal([SDLLanguage ES_MX])); + expect(message.appHMIType).to(beNil()); + expect(message.hashID).to(beNil()); + expect(message.deviceInfo).toNot(beNil()); + expect(message.appID).to(equal(@"6h43g")); + expect(message.correlationID).to(equal(@1)); + + message = [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:@"Register App Interface" isMediaApp:@NO languageDesired:[SDLLanguage PT_BR] appID:@"36g6rsw4"]; + + expect(message.syncMsgVersion).toNot(beNil()); + expect(message.syncMsgVersion.majorVersion).to(equal(@1)); + expect(message.syncMsgVersion.minorVersion).to(equal(@0)); + + expect(message.appName).to(equal(@"Register App Interface")); + expect(message.ttsName).to(beNil()); + expect(message.ngnMediaScreenAppName).to(equal(@"Register App Interface")); + expect(message.vrSynonyms).to(equal(@[@"Register App Interface"])); + expect(message.isMediaApplication).to(equal(@NO)); + expect(message.languageDesired).to(equal([SDLLanguage PT_BR])); + expect(message.hmiDisplayLanguageDesired).to(equal([SDLLanguage PT_BR])); + expect(message.appHMIType).to(beNil()); + expect(message.hashID).to(beNil()); + expect(message.deviceInfo).toNot(beNil()); + expect(message.appID).to(equal(@"36g6rsw4")); + expect(message.correlationID).to(equal(@1)); + + message = [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:@"..." languageDesired:[SDLLanguage CS_CZ] appID:@"56ht5j"]; + + expect(message.syncMsgVersion).toNot(beNil()); + expect(message.syncMsgVersion.majorVersion).to(equal(@1)); + expect(message.syncMsgVersion.minorVersion).to(equal(@0)); + + expect(message.appName).to(equal(@"...")); + expect(message.ttsName).to(beNil()); + expect(message.ngnMediaScreenAppName).to(equal(@"...")); + expect(message.vrSynonyms).to(equal(@[@"..."])); + expect(message.isMediaApplication).to(equal(@NO)); + expect(message.languageDesired).to(equal([SDLLanguage CS_CZ])); + expect(message.hmiDisplayLanguageDesired).to(equal([SDLLanguage CS_CZ])); + expect(message.appHMIType).to(beNil()); + expect(message.hashID).to(beNil()); + expect(message.deviceInfo).toNot(beNil()); + expect(message.appID).to(equal(@"56ht5j")); + expect(message.correlationID).to(equal(@1)); + }); +}); + +describe(@"BuildResetGlobalProperties Tests", ^ { + it(@"Should build correctly", ^ { + SDLResetGlobalProperties* message = [SDLRPCRequestFactory buildResetGlobalPropertiesWithProperties:@[[SDLGlobalProperty MENUNAME], [SDLGlobalProperty TIMEOUTPROMPT]] + correlationID:@906842]; + + expect(message.properties).to(equal(@[[SDLGlobalProperty MENUNAME], [SDLGlobalProperty TIMEOUTPROMPT]])); + expect(message.correlationID).to(equal(@906842)); + }); +}); + +describe(@"BuildSendLocation", ^{ + __block SDLSendLocation *message = nil; + __block NSNumber *someLongitude = nil; + __block NSNumber *someLatitude = nil; + __block NSString *someLocation = nil; + __block NSString *someLocationDescription = nil; + __block NSArray *someAddressLines = nil; + __block NSString *somePhoneNumber = nil; + __block SDLImage *someImage = nil; + + describe(@"when built correctly", ^{ + beforeEach(^{ + someLongitude = @123.4567; + someLatitude = @65.4321; + someLocation = @"Livio"; + someLocationDescription = @"A great place to work"; + someAddressLines = @[@"3136 Hilton Rd", @"Ferndale, MI", @"48220"]; + somePhoneNumber = @"248-591-0333"; + someImage = [[SDLImage alloc] init]; + + message = [SDLRPCRequestFactory buildSendLocationWithLongitude:someLongitude latitude:someLatitude locationName:someLocation locationDescription:someLocationDescription address:someAddressLines phoneNumber:somePhoneNumber image:someImage]; + }); + + it(@"should not be nil", ^{ + expect(message).toNot(beNil()); + }); + + it(@"should properly set longitude", ^{ + expect(message.longitudeDegrees).to(equal(someLongitude)); + }); + + it(@"should properly set latitude", ^{ + expect(message.latitudeDegrees).to(equal(someLatitude)); + }); + + it(@"should properly set location", ^{ + expect(message.locationName).to(equal(someLocation)); + }); + + it(@"should properly set location description", ^{ + expect(message.locationDescription).to(equal(someLocationDescription)); + }); + + it(@"should properly set address lines", ^{ + expect(message.addressLines).to(equal(someAddressLines)); + }); + + it(@"should properly set phone number", ^{ + expect(message.phoneNumber).to(equal(somePhoneNumber)); + }); + + it(@"should properly set image", ^{ + expect(message.locationImage).to(equal(someImage)); + }); + }); +}); + +describe(@"BuildScrollableMessage Tests", ^ { + it(@"Should build correctly", ^ { + NSArray* softButtons = @[[[SDLSoftButton alloc] init]]; + SDLScrollableMessage* message = [SDLRPCRequestFactory buildScrollableMessage:@"Message Box" timeout:@37821 softButtons:softButtons correlationID:@9783356]; + + expect(message.scrollableMessageBody).to(equal(@"Message Box")); + expect(message.timeout).to(equal(@37821)); + expect(message.softButtons).to(equal(softButtons)); + expect(message.correlationID).to(equal(@9783356)); + }); +}); + +describe(@"BuildSetAppIcon Tests", ^ { + it(@"Should build correctly", ^ { + SDLSetAppIcon* message = [SDLRPCRequestFactory buildSetAppIconWithFileName:@"Iconic" correlationID:@465819]; + + expect(message.syncFileName).to(equal(@"Iconic")); + expect(message.correlationID).to(equal(@465819)); + }); +}); + +describe(@"BuildSetDisplayLayout Tests", ^ { + it(@"Should build correctly", ^ { + SDLSetDisplayLayout* message = [SDLRPCRequestFactory buildSetDisplayLayout:@"NONE" correlationID:@467926]; + + expect(message.displayLayout).to(equal(@"NONE")); + expect(message.correlationID).to(equal(@467926)); + }); +}); + +describe(@"BuildSetGlobalProperties Tests", ^ { + it(@"Should build correctly", ^ { + NSArray* help = @[[[SDLVRHelpItem alloc] init]]; + SDLSetGlobalProperties* message = [SDLRPCRequestFactory buildSetGlobalPropertiesWithHelpText:@"Beyond Help" timeoutText:@"You took too long" vrHelpTitle:@"Voice" + vrHelp:help correlationID:@5666666]; + + expect(((SDLTTSChunk*)[message helpPrompt][0]).text).to(equal(@"Beyond Help")); + expect(((SDLTTSChunk*)[message timeoutPrompt][0]).text).to(equal(@"You took too long")); + expect(message.vrHelpTitle).to(equal(@"Voice")); + expect(message.vrHelp).to(equal(help)); + expect(message.menuTitle).to(beNil()); + expect(message.menuIcon).to(beNil()); + expect(message.keyboardProperties).to(beNil()); + expect(message.correlationID).to(equal(@5666666)); + + message = [SDLRPCRequestFactory buildSetGlobalPropertiesWithHelpText:@"Helpful" timeoutText:@"Timed Out" correlationID:@10010100]; + + expect(((SDLTTSChunk*)[message helpPrompt][0]).text).to(equal(@"Helpful")); + expect(((SDLTTSChunk*)[message timeoutPrompt][0]).text).to(equal(@"Timed Out")); + expect(message.vrHelpTitle).to(beNil()); + expect(message.vrHelp).to(beNil()); + expect(message.menuTitle).to(beNil()); + expect(message.menuIcon).to(beNil()); + expect(message.keyboardProperties).to(beNil()); + expect(message.correlationID).to(equal(@10010100)); + }); +}); + +describe(@"BuildSetMediaClockTimer Tests", ^ { + it(@"Should build correctly", ^ { + SDLSetMediaClockTimer* message = [SDLRPCRequestFactory buildSetMediaClockTimerWithHours:@15 minutes:@36 seconds:@11 updateMode:[SDLUpdateMode COUNTDOWN] correlationID:@404]; + + expect([message startTime].hours).to(equal(@15)); + expect([message startTime].minutes).to(equal(@36)); + expect([message startTime].seconds).to(equal(@11)); + expect(message.endTime).to(beNil()); + expect(message.updateMode).to(equal([SDLUpdateMode COUNTDOWN])); + expect(message.correlationID).to(equal(@404)); + + message = [SDLRPCRequestFactory buildSetMediaClockTimerWithUpdateMode:[SDLUpdateMode RESUME] correlationID:@11213141]; + + expect(message.startTime).to(beNil()); + expect(message.endTime).to(beNil()); + expect(message.updateMode).to(equal([SDLUpdateMode RESUME])); + expect(message.correlationID).to(equal(@11213141)); + }); +}); + +describe(@"BuildShow Tests", ^ { + it(@"Should build correctly", ^ { + SDLImage* image = [[SDLImage alloc] init]; + NSArray* softButtons = @[[[SDLSoftButton alloc] init]]; + SDLShow* message = [SDLRPCRequestFactory buildShowWithMainField1:@"11" mainField2:@"22" mainField3:@"33" mainField4:@"44" statusBar:@"Bar" mediaClock:@"Time" mediaTrack:@"Crucial Line" + alignment:[SDLTextAlignment CENTERED] graphic:image softButtons:softButtons customPresets:@[@"w", @"x", @"y", @"z"] correlationID:@3432343]; + + expect(message.mainField1).to(equal(@"11")); + expect(message.mainField2).to(equal(@"22")); + expect(message.mainField3).to(equal(@"33")); + expect(message.mainField4).to(equal(@"44")); + expect(message.statusBar).to(equal(@"Bar")); + expect(message.mediaClock).to(equal(@"Time")); + expect(message.mediaTrack).to(equal(@"Crucial Line")); + expect(message.alignment).to(equal([SDLTextAlignment CENTERED])); + expect(message.graphic).to(equal(image)); + expect(message.secondaryGraphic).to(beNil()); + expect(message.softButtons).to(equal(softButtons)); + expect(message.customPresets).to(equal(@[@"w", @"x", @"y", @"z"])); + expect(message.correlationID).to(equal(@3432343)); + + message = [SDLRPCRequestFactory buildShowWithMainField1:@"A" mainField2:@"S" statusBar:@"D" mediaClock:@"F" mediaTrack:@"G" alignment:[SDLTextAlignment RIGHT_ALIGNED] correlationID:@999]; + + expect(message.mainField1).to(equal(@"A")); + expect(message.mainField2).to(equal(@"S")); + expect(message.mainField3).to(beNil()); + expect(message.mainField4).to(beNil()); + expect(message.statusBar).to(equal(@"D")); + expect(message.mediaClock).to(equal(@"F")); + expect(message.mediaTrack).to(equal(@"G")); + expect(message.alignment).to(equal([SDLTextAlignment RIGHT_ALIGNED])); + expect(message.graphic).to(beNil()); + expect(message.secondaryGraphic).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.customPresets).to(beNil()); + expect(message.correlationID).to(equal(@999)); + + message = [SDLRPCRequestFactory buildShowWithMainField1:@"Hello" mainField2:@"World" alignment:[SDLTextAlignment LEFT_ALIGNED] correlationID:@38792607]; + + expect(message.mainField1).to(equal(@"Hello")); + expect(message.mainField2).to(equal(@"World")); + expect(message.mainField3).to(beNil()); + expect(message.mainField4).to(beNil()); + expect(message.statusBar).to(beNil()); + expect(message.mediaClock).to(beNil()); + expect(message.mediaTrack).to(beNil()); + expect(message.alignment).to(equal([SDLTextAlignment LEFT_ALIGNED])); + expect(message.graphic).to(beNil()); + expect(message.secondaryGraphic).to(beNil()); + expect(message.softButtons).to(beNil()); + expect(message.customPresets).to(beNil()); + expect(message.correlationID).to(equal(@38792607)); + }); +}); + +describe(@"SDLShowConstantTBT Tests", ^ { + __block NSMutableArray *softButtons = nil; + __block SDLImage *image1 = nil; + __block SDLImage *image2 = nil; + __block SDLShowConstantTBT *message = nil; + + describe(@"Should build correctly", ^ { + beforeEach(^{ + softButtons = [@[[[SDLSoftButton alloc] init]] mutableCopy]; + image1 = [[SDLImage alloc]init]; + image2 = [[SDLImage alloc]init]; + message = [SDLRPCRequestFactory buildShowConstantTBTWithString:@"Navigation Text 1" navigationText2:@"Navigation Text 2" eta:@"ETA String" timeToDestination:@"10:31 PM" totalDistance:@"1000 Miles" turnIcon:image1 nextTurnIcon:image2 distanceToManeuver:@100.11 distanceToManeuverScale:@10.20 maneuverComplete:@23.2 softButtons:softButtons correlationID:@1234]; + }); + + it(@"Should properly set title navigation text", ^{ + expect(message.navigationText1).to(equal(@"Navigation Text 1")); + }); + + it(@"Should properly set secondary navigation text", ^{ + expect(message.navigationText2).to(equal(@"Navigation Text 2")); + }); + + it(@"Should properly set Estimated Time Of Arrival (ETA)", ^{ + expect(message.eta).to(equal(@"ETA String")); + }); + + it(@"Should properly set time to distance", ^{ + expect(message.timeToDestination).to(equal(@"10:31 PM")); + }); + + it(@"Should properly set total distance", ^{ + expect(message.totalDistance).to(equal(@"1000 Miles")); + }); + + it(@"Should properly set first turn icon", ^{ + expect(message.turnIcon).to(equal(image1)); + }); + + it(@"Should properly set second turn icon", ^{ + expect(message.nextTurnIcon).to(equal(image2)); + }); + + it(@"Should properly set distance to maneuver", ^{ + expect(message.distanceToManeuver).to(equal(@100.11)); + }); + + it(@"Should properly set scale for distance to maneuver", ^{ + expect(message.distanceToManeuverScale).to(equal(@10.20)); + }); + + it(@"Should properly set maneuver complete", ^{ + expect(message.maneuverComplete).to(equal(@23.2)); + }); + + it(@"Should properly set soft buttons", ^{ + expect(message.softButtons).to(equal(softButtons)); + }); + + it(@"Should properly set the correlation ID", ^{ + expect(message.correlationID).to(equal(@1234)); + }); + }); +}); + +describe(@"BuildSlider Tests", ^ { + it(@"Should build correctly", ^ { + SDLSlider* message = [SDLRPCRequestFactory buildSliderDynamicFooterWithNumTicks:@3 position:@2 sliderHeader:@"HEAD" sliderFooter:@[@"FOOT1", @"FOOT2", @"FOOT3"] timeout:@32321 + correlationID:@200]; + + expect(message.numTicks).to(equal(@3)); + expect(message.position).to(equal(@2)); + expect(message.sliderHeader).to(equal(@"HEAD")); + expect(message.sliderFooter).to(equal(@[@"FOOT1", @"FOOT2", @"FOOT3"])); + expect(message.timeout).to(equal(@32321)); + expect(message.correlationID).to(equal(@200)); + + message = [SDLRPCRequestFactory buildSliderStaticFooterWithNumTicks:@4 position:@2 sliderHeader:@"UP" sliderFooter:@"DOWN" timeout:@65535 correlationID:@1024]; + + expect(message.numTicks).to(equal(@4)); + expect(message.position).to(equal(@2)); + expect(message.sliderHeader).to(equal(@"UP")); + expect(message.sliderFooter).to(equal(@[@"DOWN", @"DOWN", @"DOWN", @"DOWN"])); + expect(message.timeout).to(equal(@65535)); + expect(message.correlationID).to(equal(@1024)); + }); +}); + +describe(@"BuildSpeak Tests", ^ { + it(@"Should build correctly", ^ { + NSArray* ttsChunks = @[[[SDLTTSChunk alloc] init]]; + SDLSpeak* message = [SDLRPCRequestFactory buildSpeakWithTTS:@"GREETINGS HUMAN" correlationID:@65]; + + expect(((SDLTTSChunk*)[message ttsChunks][0]).text).to(equal(@"GREETINGS HUMAN")); + expect(message.correlationID).to(equal(@65)); + + message = [SDLRPCRequestFactory buildSpeakWithTTSChunks:ttsChunks correlationID:@56]; + + expect(message.ttsChunks).to(equal(ttsChunks)); + expect(message.correlationID).to(equal(@56)); + }); +}); + +describe(@"BuildSubscribeButton Tests", ^ { + it(@"Should build correctly", ^ { + SDLSubscribeButton* message = [SDLRPCRequestFactory buildSubscribeButtonWithName:[SDLButtonName SEARCH] correlationID:@5555555]; + + expect(message.buttonName).to(equal([SDLButtonName SEARCH])); + expect(message.correlationID).to(equal(@5555555)); + }); +}); + +describe(@"BuildSubscribeVehicleData Tests", ^ { + it(@"Should build correctly", ^ { + SDLSubscribeVehicleData* message = [SDLRPCRequestFactory buildSubscribeVehicleDataWithGPS:@YES speed:@YES rpm:@YES + fuelLevel:@NO fuelLevelState:@NO instantFuelConsumption:@NO + externalTemperature:@YES prndl:@YES tirePressure:@YES + odometer:@NO beltStatus:@NO bodyInformation:@NO + deviceStatus:@YES driverBraking:@YES wiperStatus:@YES + headLampStatus:@NO engineTorque:@NO accPedalPosition:@NO + steeringWheelAngle:@YES correlationID:@3692581470]; + + expect(message.gps).to(equal(@YES)); + expect(message.speed).to(equal(@YES)); + expect(message.rpm).to(equal(@YES)); + expect(message.fuelLevel).to(equal(@NO)); + expect(message.fuelLevel_State).to(equal(@NO)); + expect(message.instantFuelConsumption).to(equal(@NO)); + expect(message.externalTemperature).to(equal(@YES)); + expect(message.prndl).to(equal(@YES)); + expect(message.tirePressure).to(equal(@YES)); + expect(message.odometer).to(equal(@NO)); + expect(message.beltStatus).to(equal(@NO)); + expect(message.bodyInformation).to(equal(@NO)); + expect(message.deviceStatus).to(equal(@YES)); + expect(message.driverBraking).to(equal(@YES)); + expect(message.wiperStatus).to(equal(@YES)); + expect(message.headLampStatus).to(equal(@NO)); + expect(message.engineTorque).to(equal(@NO)); + expect(message.accPedalPosition).to(equal(@NO)); + expect(message.steeringWheelAngle).to(equal(@YES)); + expect(message.eCallInfo).to(beNil()); + expect(message.airbagStatus).to(beNil()); + expect(message.emergencyEvent).to(beNil()); + expect(message.clusterModeStatus).to(beNil()); + expect(message.myKey).to(beNil()); + expect(message.correlationID).to(equal(@3692581470)); + }); +}); + +describe(@"BuildUnregisterAppInterface Tests", ^ { + it(@"Should build correctly", ^ { + SDLUnregisterAppInterface* message = [SDLRPCRequestFactory buildUnregisterAppInterfaceWithCorrelationID:@4200]; + + expect(message.correlationID).to(equal(@4200)); + }); +}); + +describe(@"BuildUnsubscribeButton Tests", ^ { + it(@"Should build correctly", ^ { + SDLUnsubscribeButton* message = [SDLRPCRequestFactory buildUnsubscribeButtonWithName:[SDLButtonName OK] correlationID:@88]; + + expect(message.buttonName).to(equal([SDLButtonName OK])); + expect(message.correlationID).to(equal(@88)); + }); +}); + +describe(@"BuildSubscribeVehicleData Tests", ^ { + it(@"Should build correctly", ^ { + SDLSubscribeVehicleData* message = [SDLRPCRequestFactory buildSubscribeVehicleDataWithGPS:@YES speed:@NO rpm:@YES + fuelLevel:@YES fuelLevelState:@NO instantFuelConsumption:@NO + externalTemperature:@YES prndl:@NO tirePressure:@YES + odometer:@YES beltStatus:@NO bodyInformation:@NO + deviceStatus:@YES driverBraking:@NO wiperStatus:@YES + headLampStatus:@YES engineTorque:@NO accPedalPosition:@NO + steeringWheelAngle:@YES correlationID:@1627384950]; + + expect(message.gps).to(equal(@YES)); + expect(message.speed).to(equal(@NO)); + expect(message.rpm).to(equal(@YES)); + expect(message.fuelLevel).to(equal(@YES)); + expect(message.fuelLevel_State).to(equal(@NO)); + expect(message.instantFuelConsumption).to(equal(@NO)); + expect(message.externalTemperature).to(equal(@YES)); + expect(message.prndl).to(equal(@NO)); + expect(message.tirePressure).to(equal(@YES)); + expect(message.odometer).to(equal(@YES)); + expect(message.beltStatus).to(equal(@NO)); + expect(message.bodyInformation).to(equal(@NO)); + expect(message.deviceStatus).to(equal(@YES)); + expect(message.driverBraking).to(equal(@NO)); + expect(message.wiperStatus).to(equal(@YES)); + expect(message.headLampStatus).to(equal(@YES)); + expect(message.engineTorque).to(equal(@NO)); + expect(message.accPedalPosition).to(equal(@NO)); + expect(message.steeringWheelAngle).to(equal(@YES)); + expect(message.eCallInfo).to(beNil()); + expect(message.airbagStatus).to(beNil()); + expect(message.emergencyEvent).to(beNil()); + expect(message.clusterModeStatus).to(beNil()); + expect(message.myKey).to(beNil()); + expect(message.correlationID).to(equal(@1627384950)); + }); +}); + +describe(@"SDLUpdateTurnList Tests", ^ { + __block NSMutableArray<SDLSoftButton *> *softButtons = nil; + __block NSMutableArray<SDLTurn *> *turns = nil; + __block SDLUpdateTurnList *message = nil; + + __block SDLTurn *turn1 = nil; + __block SDLTurn *turn2 = nil; + + describe(@"Should build correctly", ^ { + beforeEach(^{ + softButtons = [@[[[SDLSoftButton alloc] init]] mutableCopy]; + + turn1 = [[SDLTurn alloc] init]; + turn2 = [[SDLTurn alloc] init]; + turns = [@[turn1, turn2] mutableCopy]; + + message = [SDLRPCRequestFactory buildUpdateTurnListWithTurnList:turns softButtons:softButtons correlationID:@1234]; + }); + + it(@"Should properly set Turns", ^{ + expect(message.turnList).to(equal(turns)); + }); + + it(@"Should properly set Soft Buttons", ^{ + expect(message.softButtons).to(equal(softButtons)); + }); + + it(@"Should properly set Correlation Id", ^{ + expect(message.correlationID).to(equal(@1234)); + }); + }); +}); + +QuickSpecEnd + + diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnAppInterfaceUnregisteredSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnAppInterfaceUnregisteredSpec.m new file mode 100644 index 000000000..2ec566031 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnAppInterfaceUnregisteredSpec.m @@ -0,0 +1,43 @@ +// +// SDLOnAppInterfaceUnregisteredSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAppInterfaceUnregisteredReason.h" +#import "SDLOnAppInterfaceUnregistered.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnAppInterfaceUnregisteredSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnAppInterfaceUnregistered* testNotification = [[SDLOnAppInterfaceUnregistered alloc] init]; + + testNotification.reason = [SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED]; + + expect(testNotification.reason).to(equal([SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_reason:[SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED]}, + NAMES_operation_name:NAMES_OnAppInterfaceUnregistered}} mutableCopy]; + SDLOnAppInterfaceUnregistered* testNotification = [[SDLOnAppInterfaceUnregistered alloc] initWithDictionary:dict]; + + expect(testNotification.reason).to(equal([SDLAppInterfaceUnregisteredReason APP_UNAUTHORIZED])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnAppInterfaceUnregistered* testNotification = [[SDLOnAppInterfaceUnregistered alloc] init]; + + expect(testNotification.reason).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnAudioPassThruSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnAudioPassThruSpec.m new file mode 100644 index 000000000..213246b1c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnAudioPassThruSpec.m @@ -0,0 +1,16 @@ +// +// SDLOnAudioPassThruSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnAudioPassThru.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnAudioPassThruSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnButtonEventSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnButtonEventSpec.m new file mode 100644 index 000000000..becc5c251 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnButtonEventSpec.m @@ -0,0 +1,55 @@ +// +// SDLOnButtonEventSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonEventMode.h" +#import "SDLButtonName.h" +#import "SDLNames.h" +#import "SDLOnButtonEvent.h" + + +QuickSpecBegin(SDLOnButtonEventSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnButtonEvent* testNotification = [[SDLOnButtonEvent alloc] init]; + + testNotification.buttonName = [SDLButtonName CUSTOM_BUTTON]; + testNotification.buttonEventMode = [SDLButtonEventMode BUTTONDOWN]; + testNotification.customButtonID = @4252; + + expect(testNotification.buttonName).to(equal([SDLButtonName CUSTOM_BUTTON])); + expect(testNotification.buttonEventMode).to(equal([SDLButtonEventMode BUTTONDOWN])); + expect(testNotification.customButtonID).to(equal(@4252)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_buttonName:[SDLButtonName CUSTOM_BUTTON], + NAMES_buttonEventMode:[SDLButtonEventMode BUTTONDOWN], + NAMES_customButtonID:@4252}, + NAMES_operation_name:NAMES_OnButtonEvent}} mutableCopy]; + SDLOnButtonEvent* testNotification = [[SDLOnButtonEvent alloc] initWithDictionary:dict]; + + expect(testNotification.buttonName).to(equal([SDLButtonName CUSTOM_BUTTON])); + expect(testNotification.buttonEventMode).to(equal([SDLButtonEventMode BUTTONDOWN])); + expect(testNotification.customButtonID).to(equal(@4252)); + }); + + it(@"Should return nil if not set", ^ { + SDLOnButtonEvent* testNotification = [[SDLOnButtonEvent alloc] init]; + + expect(testNotification.buttonName).to(beNil()); + expect(testNotification.buttonEventMode).to(beNil()); + expect(testNotification.customButtonID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnButtonPressSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnButtonPressSpec.m new file mode 100644 index 000000000..4467f72a5 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnButtonPressSpec.m @@ -0,0 +1,55 @@ +// +// SDLOnButtonPressSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonName.h" +#import "SDLButtonPressMode.h" +#import "SDLOnButtonPress.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLOnButtonPressSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnButtonPress* testNotification = [[SDLOnButtonPress alloc] init]; + + testNotification.buttonName = [SDLButtonName CUSTOM_BUTTON]; + testNotification.buttonPressMode = [SDLButtonPressMode LONG]; + testNotification.customButtonID = @5642; + + expect(testNotification.buttonName).to(equal([SDLButtonName CUSTOM_BUTTON])); + expect(testNotification.buttonPressMode).to(equal([SDLButtonPressMode LONG])); + expect(testNotification.customButtonID).to(equal(@5642)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_buttonName:[SDLButtonName CUSTOM_BUTTON], + NAMES_buttonPressMode:[SDLButtonPressMode LONG], + NAMES_customButtonID:@5642}, + NAMES_operation_name:NAMES_OnButtonPress}} mutableCopy]; + SDLOnButtonPress* testNotification = [[SDLOnButtonPress alloc] initWithDictionary:dict]; + + expect(testNotification.buttonName).to(equal([SDLButtonName CUSTOM_BUTTON])); + expect(testNotification.buttonPressMode).to(equal([SDLButtonPressMode LONG])); + expect(testNotification.customButtonID).to(equal(@5642)); + }); + + it(@"Should return nil if not set", ^ { + SDLOnButtonPress* testNotification = [[SDLOnButtonPress alloc] init]; + + expect(testNotification.buttonName).to(beNil()); + expect(testNotification.buttonPressMode).to(beNil()); + expect(testNotification.customButtonID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnCommandSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnCommandSpec.m new file mode 100644 index 000000000..6b8afd10b --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnCommandSpec.m @@ -0,0 +1,48 @@ +// +// SDLOnCommandSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLOnCommand.h" +#import "SDLTriggerSource.h" + +QuickSpecBegin(SDLOnCommandSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnCommand* testNotification = [[SDLOnCommand alloc] init]; + + testNotification.cmdID = @5676544; + testNotification.triggerSource = [SDLTriggerSource KEYBOARD]; + + expect(testNotification.cmdID).to(equal(@5676544)); + expect(testNotification.triggerSource).to(equal([SDLTriggerSource KEYBOARD])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_cmdID:@5676544, + NAMES_triggerSource:[SDLTriggerSource KEYBOARD]}, + NAMES_operation_name:NAMES_OnCommand}} mutableCopy]; + SDLOnCommand* testNotification = [[SDLOnCommand alloc] initWithDictionary:dict]; + + expect(testNotification.cmdID).to(equal(@5676544)); + expect(testNotification.triggerSource).to(equal([SDLTriggerSource KEYBOARD])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnCommand* testNotification = [[SDLOnCommand alloc] init]; + + expect(testNotification.cmdID).to(beNil()); + expect(testNotification.triggerSource).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m new file mode 100644 index 000000000..79c90bdd7 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m @@ -0,0 +1,43 @@ +// +// SDLOnDriverDistractionSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDriverDistractionState.h" +#import "SDLOnDriverDistraction.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnDriverDistractionSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnDriverDistraction* testNotification = [[SDLOnDriverDistraction alloc] init]; + + testNotification.state = [SDLDriverDistractionState DD_ON]; + + expect(testNotification.state).to(equal([SDLDriverDistractionState DD_ON])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_state:[SDLDriverDistractionState DD_ON]}, + NAMES_operation_name:NAMES_OnDriverDistraction}} mutableCopy]; + SDLOnDriverDistraction* testNotification = [[SDLOnDriverDistraction alloc] initWithDictionary:dict]; + + expect(testNotification.state).to(equal([SDLDriverDistractionState DD_ON])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnDriverDistraction* testNotification = [[SDLOnDriverDistraction alloc] init]; + + expect(testNotification.state).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnEncodedSyncPDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnEncodedSyncPDataSpec.m new file mode 100644 index 000000000..a8844e22a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnEncodedSyncPDataSpec.m @@ -0,0 +1,52 @@ +// +// SDLOnEncodedSyncPDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnEncodedSyncPData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnEncodedSyncPDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnEncodedSyncPData* testNotification = [[SDLOnEncodedSyncPData alloc] init]; + + testNotification.data = [@[@0] mutableCopy]; + testNotification.URL = @"www.zombo.com"; + testNotification.Timeout = @564; + + expect(testNotification.data).to(equal([@[@0] mutableCopy])); + expect(testNotification.URL).to(equal(@"www.zombo.com")); + expect(testNotification.Timeout).to(equal(@564)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_data:[@[@0] mutableCopy], + NAMES_URL:@"www.zombo.com", + NAMES_Timeout:@564}, + NAMES_operation_name:NAMES_OnEncodedSyncPData}} mutableCopy]; + SDLOnEncodedSyncPData* testNotification = [[SDLOnEncodedSyncPData alloc] initWithDictionary:dict]; + + expect(testNotification.data).to(equal([@[@0] mutableCopy])); + expect(testNotification.URL).to(equal(@"www.zombo.com")); + expect(testNotification.Timeout).to(equal(@564)); + }); + + it(@"Should return nil if not set", ^ { + SDLOnEncodedSyncPData* testNotification = [[SDLOnEncodedSyncPData alloc] init]; + + expect(testNotification.data).to(beNil()); + expect(testNotification.URL).to(beNil()); + expect(testNotification.Timeout).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m new file mode 100644 index 000000000..c2d58a484 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHMIStatusSpec.m @@ -0,0 +1,56 @@ +// +// SDLOnHMIStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAudioStreamingState.h" +#import "SDLHMILevel.h" +#import "SDLOnHMIStatus.h" +#import "SDLNames.h" +#import "SDLSystemContext.h" + + +QuickSpecBegin(SDLOnHMIStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnHMIStatus* testNotification = [[SDLOnHMIStatus alloc] init]; + + testNotification.hmiLevel = [SDLHMILevel LIMITED]; + testNotification.audioStreamingState = [SDLAudioStreamingState ATTENUATED]; + testNotification.systemContext = [SDLSystemContext HMI_OBSCURED]; + + expect(testNotification.hmiLevel).to(equal([SDLHMILevel LIMITED])); + expect(testNotification.audioStreamingState).to(equal([SDLAudioStreamingState ATTENUATED])); + expect(testNotification.systemContext).to(equal([SDLSystemContext HMI_OBSCURED])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_hmiLevel:[SDLHMILevel LIMITED], + NAMES_audioStreamingState:[SDLAudioStreamingState ATTENUATED], + NAMES_systemContext:[SDLSystemContext HMI_OBSCURED]}, + NAMES_operation_name:NAMES_OnHMIStatus}} mutableCopy]; + SDLOnHMIStatus* testNotification = [[SDLOnHMIStatus alloc] initWithDictionary:dict]; + + expect(testNotification.hmiLevel).to(equal([SDLHMILevel LIMITED])); + expect(testNotification.audioStreamingState).to(equal([SDLAudioStreamingState ATTENUATED])); + expect(testNotification.systemContext).to(equal([SDLSystemContext HMI_OBSCURED])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnHMIStatus* testNotification = [[SDLOnHMIStatus alloc] init]; + + expect(testNotification.hmiLevel).to(beNil()); + expect(testNotification.audioStreamingState).to(beNil()); + expect(testNotification.systemContext).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHashChangeSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHashChangeSpec.m new file mode 100644 index 000000000..308347c61 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnHashChangeSpec.m @@ -0,0 +1,42 @@ +// +// SDLOnHashChangeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnHashChange.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnHashChangeSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnHashChange* testNotification = [[SDLOnHashChange alloc] init]; + + testNotification.hashID = @"hash"; + + expect(testNotification.hashID).to(equal(@"hash")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_hashID:@"hash"}, + NAMES_operation_name:NAMES_OnHashChange}} mutableCopy]; + SDLOnHashChange* testNotification = [[SDLOnHashChange alloc] initWithDictionary:dict]; + + expect(testNotification.hashID).to(equal(@"hash")); + }); + + it(@"Should return nil if not set", ^ { + SDLOnHashChange* testNotification = [[SDLOnHashChange alloc] init]; + + expect(testNotification.hashID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnKeyboardInputSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnKeyboardInputSpec.m new file mode 100644 index 000000000..cf87e853d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnKeyboardInputSpec.m @@ -0,0 +1,48 @@ +// +// SDLOnKeyboardInputSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLKeyboardEvent.h" +#import "SDLOnKeyboardInput.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnKeyboardInputSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnKeyboardInput* testNotification = [[SDLOnKeyboardInput alloc] init]; + + testNotification.event = [SDLKeyboardEvent ENTRY_SUBMITTED]; + testNotification.data = @"qwertyg"; + + expect(testNotification.event).to(equal([SDLKeyboardEvent ENTRY_SUBMITTED])); + expect(testNotification.data).to(equal(@"qwertyg")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_event:[SDLKeyboardEvent ENTRY_SUBMITTED], + NAMES_data:@"qwertyg"}, + NAMES_operation_name:NAMES_OnKeyboardInput}} mutableCopy]; + SDLOnKeyboardInput* testNotification = [[SDLOnKeyboardInput alloc] initWithDictionary:dict]; + + expect(testNotification.event).to(equal([SDLKeyboardEvent ENTRY_SUBMITTED])); + expect(testNotification.data).to(equal(@"qwertyg")); + }); + + it(@"Should return nil if not set", ^ { + SDLOnKeyboardInput* testNotification = [[SDLOnKeyboardInput alloc] init]; + + expect(testNotification.event).to(beNil()); + expect(testNotification.data).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLanguageChangeSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLanguageChangeSpec.m new file mode 100644 index 000000000..f9009f69c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLanguageChangeSpec.m @@ -0,0 +1,49 @@ +// +// SDLOnLanguageChangeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLLanguage.h" +#import "SDLOnLanguageChange.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLOnLanguageChangeSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnLanguageChange* testNotification = [[SDLOnLanguageChange alloc] init]; + + testNotification.language = [SDLLanguage ES_ES]; + testNotification.hmiDisplayLanguage = [SDLLanguage DE_DE]; + + expect(testNotification.language).to(equal([SDLLanguage ES_ES])); + expect(testNotification.hmiDisplayLanguage).to(equal([SDLLanguage DE_DE])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_language:[SDLLanguage ES_ES], + NAMES_hmiDisplayLanguage:[SDLLanguage DE_DE]}, + NAMES_operation_name:NAMES_OnLanguageChange}} mutableCopy]; + SDLOnLanguageChange* testNotification = [[SDLOnLanguageChange alloc] initWithDictionary:dict]; + + expect(testNotification.language).to(equal([SDLLanguage ES_ES])); + expect(testNotification.hmiDisplayLanguage).to(equal([SDLLanguage DE_DE])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnLanguageChange* testNotification = [[SDLOnLanguageChange alloc] init]; + + expect(testNotification.language).to(beNil()); + expect(testNotification.hmiDisplayLanguage).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m new file mode 100644 index 000000000..d438ec621 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m @@ -0,0 +1,59 @@ +// +// 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 "SDLNames.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 = [SDLLockScreenStatus REQUIRED]; + testNotification.hmiLevel = [SDLHMILevel NONE]; + + expect(testNotification.driverDistractionStatus).to(equal(@NO)); + expect(testNotification.userSelected).to(equal(@3)); + expect(testNotification.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + expect(testNotification.hmiLevel).to(equal([SDLHMILevel NONE])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{@"driverdistractionstatus":@NO, + @"userselected":@3, + @"OnLockScreenStatus":[SDLLockScreenStatus REQUIRED], + @"hmilevel":[SDLHMILevel NONE]}, + NAMES_operation_name:@"OnLockScreenStatus"}} mutableCopy]; + SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] initWithDictionary:dict]; + + expect(testNotification.driverDistractionStatus).to(equal(@NO)); + expect(testNotification.userSelected).to(equal(@3)); + expect(testNotification.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + expect(testNotification.hmiLevel).to(equal([SDLHMILevel NONE])); + }); + + 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
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnPermissionsChangeSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnPermissionsChangeSpec.m new file mode 100644 index 000000000..5a5d349cc --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnPermissionsChangeSpec.m @@ -0,0 +1,45 @@ +// +// SDLOnPermissionsChangeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnPermissionsChange.h" +#import "SDLPermissionItem.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnPermissionsChangeSpec) + +SDLPermissionItem* item = [[SDLPermissionItem alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnPermissionsChange* testNotification = [[SDLOnPermissionsChange alloc] init]; + + testNotification.permissionItem = [@[item] mutableCopy]; + + expect(testNotification.permissionItem).to(equal([@[item] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_permissionItem:[@[item] mutableCopy]}, + NAMES_operation_name:NAMES_OnPermissionsChange}} mutableCopy]; + SDLOnPermissionsChange* testNotification = [[SDLOnPermissionsChange alloc] initWithDictionary:dict]; + + expect(testNotification.permissionItem).to(equal([@[item] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnPermissionsChange* testNotification = [[SDLOnPermissionsChange alloc] init]; + + expect(testNotification.permissionItem).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSyncPDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSyncPDataSpec.m new file mode 100644 index 000000000..34ac9af9e --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSyncPDataSpec.m @@ -0,0 +1,47 @@ +// +// SDLOnSyncPDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnSyncPData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLOnSyncPDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnSyncPData* testNotification = [[SDLOnSyncPData alloc] init]; + + testNotification.URL = @"https://www.youtube.com/watch?v=ygr5AHufBN4"; + testNotification.Timeout = @8357; + + expect(testNotification.URL).to(equal(@"https://www.youtube.com/watch?v=ygr5AHufBN4")); + expect(testNotification.Timeout).to(equal(@8357)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_URL:@"https://www.youtube.com/watch?v=ygr5AHufBN4", + NAMES_Timeout:@8357}, + NAMES_operation_name:NAMES_OnSyncPData}} mutableCopy]; + SDLOnSyncPData* testNotification = [[SDLOnSyncPData alloc] initWithDictionary:dict]; + + expect(testNotification.URL).to(equal(@"https://www.youtube.com/watch?v=ygr5AHufBN4")); + expect(testNotification.Timeout).to(equal(@8357)); + }); + + it(@"Should return nil if not set", ^ { + SDLOnSyncPData* testNotification = [[SDLOnSyncPData alloc] init]; + + expect(testNotification.URL).to(beNil()); + expect(testNotification.Timeout).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m new file mode 100644 index 000000000..ed235871e --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnSystemRequestSpec.m @@ -0,0 +1,70 @@ +// +// SDLOnSystemRequestSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFileType.h" +#import "SDLNames.h" +#import "SDLOnSystemRequest.h" +#import "SDLRequestType.h" + + +QuickSpecBegin(SDLOnSystemRequestSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnSystemRequest* testNotification = [[SDLOnSystemRequest alloc] init]; + + testNotification.requestType = [SDLRequestType FILE_RESUME]; + testNotification.url = [@[@"www.google.com"] mutableCopy]; + testNotification.timeout = @52345; + testNotification.fileType = [SDLFileType GRAPHIC_PNG]; + testNotification.offset = @2532678684; + testNotification.length = @50000000000; + + expect(testNotification.requestType).to(equal([SDLRequestType FILE_RESUME])); + expect(testNotification.url).to(equal([@[@"www.google.com"] mutableCopy])); + expect(testNotification.timeout).to(equal(@52345)); + expect(testNotification.fileType).to(equal([SDLFileType GRAPHIC_PNG])); + expect(testNotification.offset).to(equal(@2532678684)); + expect(testNotification.length).to(equal(@50000000000)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_requestType:[SDLRequestType FILE_RESUME], + NAMES_url:[@[@"www.google.com"] mutableCopy], + NAMES_timeout:@52345, + NAMES_fileType:[SDLFileType GRAPHIC_PNG], + NAMES_offset:@2532678684, + NAMES_length:@50000000000}, + NAMES_operation_name:NAMES_OnSystemRequest}} mutableCopy]; + SDLOnSystemRequest* testNotification = [[SDLOnSystemRequest alloc] initWithDictionary:dict]; + + expect(testNotification.requestType).to(equal([SDLRequestType FILE_RESUME])); + expect(testNotification.url).to(equal([@[@"www.google.com"] mutableCopy])); + expect(testNotification.timeout).to(equal(@52345)); + expect(testNotification.fileType).to(equal([SDLFileType GRAPHIC_PNG])); + expect(testNotification.offset).to(equal(@2532678684)); + expect(testNotification.length).to(equal(@50000000000)); + }); + + it(@"Should return nil if not set", ^ { + SDLOnSystemRequest* testNotification = [[SDLOnSystemRequest alloc] init]; + + expect(testNotification.requestType).to(beNil()); + expect(testNotification.url).to(beNil()); + expect(testNotification.timeout).to(beNil()); + expect(testNotification.fileType).to(beNil()); + expect(testNotification.offset).to(beNil()); + expect(testNotification.length).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnTBTClientStateSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnTBTClientStateSpec.m new file mode 100644 index 000000000..b1391d033 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnTBTClientStateSpec.m @@ -0,0 +1,44 @@ +// +// SDLOnTBTClientStateSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnTBTClientState.h" +#import "SDLNames.h" +#import "SDLTBTState.h" + + +QuickSpecBegin(SDLOnTBTClientStateSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnTBTClientState* testNotification = [[SDLOnTBTClientState alloc] init]; + + testNotification.state = [SDLTBTState ETA_REQUEST]; + + expect(testNotification.state).to(equal([SDLTBTState ETA_REQUEST])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_state:[SDLTBTState ETA_REQUEST]}, + NAMES_operation_name:NAMES_OnTBTClientState}} mutableCopy]; + SDLOnTBTClientState* testNotification = [[SDLOnTBTClientState alloc] initWithDictionary:dict]; + + expect(testNotification.state).to(equal([SDLTBTState ETA_REQUEST])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnTBTClientState* testNotification = [[SDLOnTBTClientState alloc] init]; + + expect(testNotification.state).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnTouchEventSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnTouchEventSpec.m new file mode 100644 index 000000000..298ffef9f --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnTouchEventSpec.m @@ -0,0 +1,52 @@ +// +// SDLOnTouchEventSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLOnTouchEvent.h" +#import "SDLNames.h" +#import "SDLTouchEvent.h" +#import "SDLTouchType.h" + + +QuickSpecBegin(SDLOnTouchEventSpec) + +SDLTouchEvent* event = [[SDLTouchEvent alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnTouchEvent* testNotification = [[SDLOnTouchEvent alloc] init]; + + testNotification.type = [SDLTouchType BEGIN]; + testNotification.event = [@[event] mutableCopy]; + + expect(testNotification.type).to(equal([SDLTouchType BEGIN])); + expect(testNotification.event).to(equal([@[event] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_type:[SDLTouchType BEGIN], + NAMES_event:[@[event] mutableCopy]}, + NAMES_operation_name:NAMES_OnTouchEvent}} mutableCopy]; + SDLOnTouchEvent* testNotification = [[SDLOnTouchEvent alloc] initWithDictionary:dict]; + + expect(testNotification.type).to(equal([SDLTouchType BEGIN])); + expect(testNotification.event).to(equal([@[event] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLOnTouchEvent* testNotification = [[SDLOnTouchEvent alloc] init]; + + expect(testNotification.type).to(beNil()); + expect(testNotification.event).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnVehicleDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnVehicleDataSpec.m new file mode 100644 index 000000000..17704a304 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnVehicleDataSpec.m @@ -0,0 +1,175 @@ +// +// SDLOnVehicleDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SmartDeviceLink.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLOnVehicleDataSpec) + +SDLGPSData* gps = [[SDLGPSData alloc] init]; +SDLTireStatus* tires = [[SDLTireStatus alloc] init]; +SDLBeltStatus* belt = [[SDLBeltStatus alloc] init]; +SDLBodyInformation* body = [[SDLBodyInformation alloc] init]; +SDLDeviceStatus* device = [[SDLDeviceStatus alloc] init]; +SDLHeadLampStatus* headLamp = [[SDLHeadLampStatus alloc] init]; +SDLECallInfo* eCall = [[SDLECallInfo alloc] init]; +SDLAirbagStatus* airbag = [[SDLAirbagStatus alloc] init]; +SDLEmergencyEvent* event = [[SDLEmergencyEvent alloc] init]; +SDLClusterModeStatus* clusterMode = [[SDLClusterModeStatus alloc] init]; +SDLMyKey* myKey = [[SDLMyKey alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLOnVehicleData* testNotification = [[SDLOnVehicleData alloc] init]; + + testNotification.gps = gps; + testNotification.speed = @70.1; + testNotification.rpm = @4242; + testNotification.fuelLevel = @10.3; + testNotification.fuelLevel_State = [SDLComponentVolumeStatus ALERT]; + testNotification.instantFuelConsumption = @4000.63; + testNotification.externalTemperature = @-10; + testNotification.vin = @"222222222722"; + testNotification.prndl = [SDLPRNDL DRIVE]; + testNotification.tirePressure = tires; + testNotification.odometer = @100050; + testNotification.beltStatus = belt; + testNotification.bodyInformation = body; + testNotification.deviceStatus = device; + testNotification.driverBraking = [SDLVehicleDataEventStatus _YES]; + testNotification.wiperStatus = [SDLWiperStatus STALLED]; + testNotification.headLampStatus = headLamp; + testNotification.engineTorque = @-200.124; + testNotification.accPedalPosition = @99.99999999; + testNotification.steeringWheelAngle = @0.000000001; + testNotification.eCallInfo = eCall; + testNotification.airbagStatus = airbag; + testNotification.emergencyEvent = event; + testNotification.clusterModeStatus = clusterMode; + testNotification.myKey = myKey; + + expect(testNotification.gps).to(equal(gps)); + expect(testNotification.speed).to(equal(@70.1)); + expect(testNotification.rpm).to(equal(@4242)); + expect(testNotification.fuelLevel).to(equal(@10.3)); + expect(testNotification.fuelLevel_State).to(equal([SDLComponentVolumeStatus ALERT])); + expect(testNotification.instantFuelConsumption).to(equal(@4000.63)); + expect(testNotification.externalTemperature).to(equal(@-10)); + expect(testNotification.vin).to(equal(@"222222222722")); + expect(testNotification.prndl).to(equal([SDLPRNDL DRIVE])); + expect(testNotification.tirePressure).to(equal(tires)); + expect(testNotification.odometer).to(equal(@100050)); + expect(testNotification.beltStatus).to(equal(belt)); + expect(testNotification.bodyInformation).to(equal(body)); + expect(testNotification.deviceStatus).to(equal(device)); + expect(testNotification.driverBraking).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testNotification.wiperStatus).to(equal([SDLWiperStatus STALLED])); + expect(testNotification.headLampStatus).to(equal(headLamp)); + expect(testNotification.engineTorque).to(equal(@-200.124)); + expect(testNotification.accPedalPosition).to(equal(@99.99999999)); + expect(testNotification.steeringWheelAngle).to(equal(@0.000000001)); + expect(testNotification.eCallInfo).to(equal(eCall)); + expect(testNotification.airbagStatus).to(equal(airbag)); + expect(testNotification.emergencyEvent).to(equal(event)); + expect(testNotification.clusterModeStatus).to(equal(clusterMode)); + expect(testNotification.myKey).to(equal(myKey)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_gps:gps, + NAMES_speed:@70.1, + NAMES_rpm:@4242, + NAMES_fuelLevel:@10.3, + NAMES_fuelLevel_State:[SDLComponentVolumeStatus ALERT], + NAMES_instantFuelConsumption:@4000.63, + NAMES_externalTemperature:@-10, + NAMES_vin:@"222222222722", + NAMES_prndl:[SDLPRNDL DRIVE], + NAMES_tirePressure:tires, + NAMES_odometer:@100050, + NAMES_beltStatus:belt, + NAMES_bodyInformation:body, + NAMES_deviceStatus:device, + NAMES_driverBraking:[SDLVehicleDataEventStatus _YES], + NAMES_wiperStatus:[SDLWiperStatus STALLED], + NAMES_headLampStatus:headLamp, + NAMES_engineTorque:@-200.124, + NAMES_accPedalPosition:@99.99999999, + NAMES_steeringWheelAngle:@0.000000001, + NAMES_eCallInfo:eCall, + NAMES_airbagStatus:airbag, + NAMES_emergencyEvent:event, + NAMES_clusterModeStatus:clusterMode, + NAMES_myKey:myKey}, + NAMES_operation_name:NAMES_OnVehicleData}} mutableCopy]; + SDLOnVehicleData* testNotification = [[SDLOnVehicleData alloc] initWithDictionary:dict]; + + expect(testNotification.gps).to(equal(gps)); + expect(testNotification.speed).to(equal(@70.1)); + expect(testNotification.rpm).to(equal(@4242)); + expect(testNotification.fuelLevel).to(equal(@10.3)); + expect(testNotification.fuelLevel_State).to(equal([SDLComponentVolumeStatus ALERT])); + expect(testNotification.instantFuelConsumption).to(equal(@4000.63)); + expect(testNotification.externalTemperature).to(equal(@-10)); + expect(testNotification.vin).to(equal(@"222222222722")); + expect(testNotification.prndl).to(equal([SDLPRNDL DRIVE])); + expect(testNotification.tirePressure).to(equal(tires)); + expect(testNotification.odometer).to(equal(@100050)); + expect(testNotification.beltStatus).to(equal(belt)); + expect(testNotification.bodyInformation).to(equal(body)); + expect(testNotification.deviceStatus).to(equal(device)); + expect(testNotification.driverBraking).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testNotification.wiperStatus).to(equal([SDLWiperStatus STALLED])); + expect(testNotification.headLampStatus).to(equal(headLamp)); + expect(testNotification.engineTorque).to(equal(@-200.124)); + expect(testNotification.accPedalPosition).to(equal(@99.99999999)); + expect(testNotification.steeringWheelAngle).to(equal(@0.000000001)); + expect(testNotification.eCallInfo).to(equal(eCall)); + expect(testNotification.airbagStatus).to(equal(airbag)); + expect(testNotification.emergencyEvent).to(equal(event)); + expect(testNotification.clusterModeStatus).to(equal(clusterMode)); + expect(testNotification.myKey).to(equal(myKey)); + }); + + it(@"Should return nil if not set", ^ { + SDLOnVehicleData* testNotification = [[SDLOnVehicleData alloc] init]; + + expect(testNotification.gps).to(beNil()); + expect(testNotification.speed).to(beNil()); + expect(testNotification.rpm).to(beNil()); + expect(testNotification.fuelLevel).to(beNil()); + expect(testNotification.fuelLevel_State).to(beNil()); + expect(testNotification.instantFuelConsumption).to(beNil()); + expect(testNotification.externalTemperature).to(beNil()); + expect(testNotification.vin).to(beNil()); + expect(testNotification.prndl).to(beNil()); + expect(testNotification.tirePressure).to(beNil()); + expect(testNotification.odometer).to(beNil()); + expect(testNotification.beltStatus).to(beNil()); + expect(testNotification.bodyInformation).to(beNil()); + expect(testNotification.deviceStatus).to(beNil()); + expect(testNotification.driverBraking).to(beNil()); + expect(testNotification.wiperStatus).to(beNil()); + expect(testNotification.headLampStatus).to(beNil()); + expect(testNotification.engineTorque).to(beNil()); + expect(testNotification.accPedalPosition).to(beNil()); + expect(testNotification.steeringWheelAngle).to(beNil()); + expect(testNotification.eCallInfo).to(beNil()); + expect(testNotification.airbagStatus).to(beNil()); + expect(testNotification.emergencyEvent).to(beNil()); + expect(testNotification.clusterModeStatus).to(beNil()); + expect(testNotification.myKey).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/PayloadSpecs/SDLRPCPayloadSpec.m b/SmartDeviceLinkTests/RPCSpecs/PayloadSpecs/SDLRPCPayloadSpec.m new file mode 100644 index 000000000..441eca732 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/PayloadSpecs/SDLRPCPayloadSpec.m @@ -0,0 +1,75 @@ +// +// SDLRPCPayloadSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLRPCPayload.h" +#import "SDLRPCMessageType.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLRPCPayloadSpec) + +__block SDLRPCPayload* testPayload; +__block NSDictionary* dict = @{NAMES_response: + @{NAMES_parameters:@{}, + NAMES_operation_name:NAMES_DeleteCommand}}; + +NSData* (^testData)() = ^NSData* { + NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:0]; + NSData* binaryData = [NSData dataWithBytes:"PrimitiveString" length:strlen("PrimitiveString")]; + + UInt8 header[12] = {0x10, 0x00, 0x00, 0x06, 0x00, 0x00, 0x14, 0x43, 0x00, 0x00, 0x00, 0x00}; + *(UInt32 *)&header[8] = CFSwapInt32HostToBig((unsigned int)jsonData.length); + + NSMutableData *data = [NSMutableData dataWithCapacity:12 + jsonData.length]; + [data appendBytes:&header length:12]; + [data appendData:jsonData]; + [data appendData:binaryData]; + + return data; +}; + +beforeSuite(^ { + testPayload = [[SDLRPCPayload alloc] init]; + + testPayload.rpcType = 0x01; + testPayload.functionID = 0x06; + testPayload.correlationID = 0x1443; + testPayload.jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:0]; + testPayload.binaryData = [NSData dataWithBytes:"PrimitiveString" length:strlen("PrimitiveString")]; +}); + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + expect(@(testPayload.rpcType)).to(equal(@0x01)); + expect(@(testPayload.functionID)).to(equal(@0x06)); + expect(@(testPayload.correlationID)).to(equal(@0x1443)); + expect([NSJSONSerialization JSONObjectWithData:testPayload.jsonData options:0 error:0]).to(equal(dict)); + expect([NSString stringWithUTF8String:[testPayload binaryData].bytes]).to(equal(@"PrimitiveString")); + }); +}); + +describe(@"Data Tests", ^ { + it (@"Should convert to byte data correctly", ^ { + expect(testPayload.data).to(equal(testData())); + }); +}); + +describe(@"RPCPayloadWithData Test", ^ { + it (@"Should convert from byte data correctly", ^ { + SDLRPCPayload* constructedPayload = [SDLRPCPayload rpcPayloadWithData:testData()]; + + expect(@(constructedPayload.rpcType)).to(equal(@0x01)); + expect(@(constructedPayload.functionID)).to(equal(@0x06)); + expect(@(constructedPayload.correlationID)).to(equal(@0x1443)); + expect([NSJSONSerialization JSONObjectWithData:constructedPayload.jsonData options:0 error:0]).to(equal(dict)); + expect([NSString stringWithUTF8String:[constructedPayload binaryData].bytes]).to(equal(@"PrimitiveString")); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m new file mode 100644 index 000000000..455552bad --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddCommandSpec.m @@ -0,0 +1,62 @@ +// +// SDLAddCommandSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAddCommand.h" +#import "SDLImage.h" +#import "SDLMenuParams.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAddCommandSpec) + +SDLMenuParams* menu = [[SDLMenuParams alloc] init]; +SDLImage* image = [[SDLImage alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLAddCommand* testRequest = [[SDLAddCommand alloc] init]; + + testRequest.cmdID = @434577; + testRequest.menuParams = menu; + testRequest.vrCommands = [@[@"name", @"anotherName"] mutableCopy]; + testRequest.cmdIcon = image; + + expect(testRequest.cmdID).to(equal(@434577)); + expect(testRequest.menuParams).to(equal(menu)); + expect(testRequest.vrCommands).to(equal([@[@"name", @"anotherName"] mutableCopy])); + expect(testRequest.cmdIcon).to(equal(image)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_cmdID:@434577, + NAMES_menuParams:menu, + NAMES_vrCommands:[@[@"name", @"anotherName"] mutableCopy], + NAMES_cmdIcon:image}, + NAMES_operation_name:NAMES_AddCommand}} mutableCopy]; + SDLAddCommand* testRequest = [[SDLAddCommand alloc] initWithDictionary:dict]; + + expect(testRequest.cmdID).to(equal(@434577)); + expect(testRequest.menuParams).to(equal(menu)); + expect(testRequest.vrCommands).to(equal([@[@"name", @"anotherName"] mutableCopy])); + expect(testRequest.cmdIcon).to(equal(image)); + }); + + it(@"Should return nil if not set", ^ { + SDLAddCommand* testRequest = [[SDLAddCommand alloc] init]; + + expect(testRequest.cmdID).to(beNil()); + expect(testRequest.menuParams).to(beNil()); + expect(testRequest.vrCommands).to(beNil()); + expect(testRequest.cmdIcon).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddSubMenuSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddSubMenuSpec.m new file mode 100644 index 000000000..04a6526a8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAddSubMenuSpec.m @@ -0,0 +1,52 @@ +// +// SDLAddSubMenuSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAddSubMenu.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAddSubMenuSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLAddSubMenu* testRequest = [[SDLAddSubMenu alloc] init]; + + testRequest.menuID = @4345645; + testRequest.position = @27; + testRequest.menuName = @"Welcome to the menu"; + + expect(testRequest.menuID).to(equal(@4345645)); + expect(testRequest.position).to(equal(@27)); + expect(testRequest.menuName).to(equal(@"Welcome to the menu")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_menuID:@4345645, + NAMES_position:@27, + NAMES_menuName:@"Welcome to the menu"}, + NAMES_operation_name:NAMES_AddSubMenu}} mutableCopy]; + SDLAddSubMenu* testRequest = [[SDLAddSubMenu alloc] initWithDictionary:dict]; + + expect(testRequest.menuID).to(equal(@4345645)); + expect(testRequest.position).to(equal(@27)); + expect(testRequest.menuName).to(equal(@"Welcome to the menu")); + }); + + it(@"Should return nil if not set", ^ { + SDLAddSubMenu* testRequest = [[SDLAddSubMenu alloc] init]; + + expect(testRequest.menuID).to(beNil()); + expect(testRequest.position).to(beNil()); + expect(testRequest.menuName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertManeuverSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertManeuverSpec.m new file mode 100644 index 000000000..16d5aa0e6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertManeuverSpec.m @@ -0,0 +1,52 @@ +// +// SDLAlertManeuverSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAlertManeuver.h" +#import "SDLTTSChunk.h" +#import "SDLSoftButton.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAlertManeuverSpec) + +SDLTTSChunk* tts = [[SDLTTSChunk alloc] init]; +SDLSoftButton* button = [[SDLSoftButton alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLAlertManeuver* testRequest = [[SDLAlertManeuver alloc] init]; + + testRequest.ttsChunks = [@[tts] mutableCopy]; + testRequest.softButtons = [@[button] mutableCopy]; + + expect(testRequest.ttsChunks).to(equal([@[tts] mutableCopy])); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_ttsChunks:[@[tts] mutableCopy], + NAMES_softButtons:[@[button] mutableCopy]}, + NAMES_operation_name:NAMES_AlertManeuver}} mutableCopy]; + SDLAlertManeuver* testRequest = [[SDLAlertManeuver alloc] initWithDictionary:dict]; + + expect(testRequest.ttsChunks).to(equal([@[tts] mutableCopy])); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLAlertManeuver* testRequest = [[SDLAlertManeuver alloc] init]; + + expect(testRequest.ttsChunks).to(beNil()); + expect(testRequest.softButtons).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m new file mode 100644 index 000000000..b5725e168 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m @@ -0,0 +1,82 @@ +// +// SDLAlertSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAlert.h" +#import "SDLTTSChunk.h" +#import "SDLSoftButton.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAlertSpec) + +SDLTTSChunk* tts = [[SDLTTSChunk alloc] init]; +SDLSoftButton* button = [[SDLSoftButton alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLAlert* testRequest = [[SDLAlert alloc] init]; + + testRequest.alertText1 = @"alert#1"; + testRequest.alertText2 = @"alert#2"; + testRequest.alertText3 = @"alert#3"; + testRequest.ttsChunks = [@[tts] mutableCopy]; + testRequest.duration = @4357; + testRequest.playTone = @YES; + testRequest.progressIndicator = @NO; + testRequest.softButtons = [@[button] mutableCopy]; + + expect(testRequest.alertText1).to(equal(@"alert#1")); + expect(testRequest.alertText2).to(equal(@"alert#2")); + expect(testRequest.alertText3).to(equal(@"alert#3")); + expect(testRequest.ttsChunks).to(equal([@[tts] mutableCopy])); + expect(testRequest.duration).to(equal(@4357)); + expect(testRequest.playTone).to(equal(@YES)); + expect(testRequest.progressIndicator).to(equal(@NO)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_alertText1:@"alert#1", + NAMES_alertText2:@"alert#2", + NAMES_alertText3:@"alert#3", + NAMES_ttsChunks:[@[tts] mutableCopy], + NAMES_duration:@4357, + NAMES_playTone:@YES, + NAMES_progressIndicator:@NO, + NAMES_softButtons:[@[button] mutableCopy]}, + NAMES_operation_name:NAMES_Alert}} mutableCopy]; + SDLAlert* testRequest = [[SDLAlert alloc] initWithDictionary:dict]; + + expect(testRequest.alertText1).to(equal(@"alert#1")); + expect(testRequest.alertText2).to(equal(@"alert#2")); + expect(testRequest.alertText3).to(equal(@"alert#3")); + expect(testRequest.ttsChunks).to(equal([@[tts] mutableCopy])); + expect(testRequest.duration).to(equal(@4357)); + expect(testRequest.playTone).to(equal(@YES)); + expect(testRequest.progressIndicator).to(equal(@NO)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLAlert* testRequest = [[SDLAlert alloc] init]; + + expect(testRequest.alertText1).to(beNil()); + expect(testRequest.alertText2).to(beNil()); + expect(testRequest.alertText3).to(beNil()); + expect(testRequest.ttsChunks).to(beNil()); + expect(testRequest.duration).to(beNil()); + expect(testRequest.playTone).to(beNil()); + expect(testRequest.progressIndicator).to(beNil()); + expect(testRequest.softButtons).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLChangeRegistrationSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLChangeRegistrationSpec.m new file mode 100644 index 000000000..9bf496042 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLChangeRegistrationSpec.m @@ -0,0 +1,186 @@ +// +// SDLChangeRegistrationSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLChangeRegistration.h" +#import "SDLLanguage.h" +#import "SDLNames.h" +#import "SDLTTSChunk.h" + + +QuickSpecBegin(SDLChangeRegistrationSpec) + +describe(@"change registration", ^ { + __block SDLChangeRegistration *testRequest = nil; + __block SDLLanguage *someLanguage = nil; + __block SDLLanguage *someOtherLanguage = nil; + __block NSString *someAppName = nil; + __block NSArray *someTTSChunks = nil; + __block NSString *someNGNMediaAppName = nil; + __block NSArray *someVRSynonyms = nil; + + describe(@"when initializing with properites", ^{ + context(@"when parameters are set", ^{ + beforeEach(^{ + testRequest = [[SDLChangeRegistration alloc] init]; + + someLanguage = [SDLLanguage IT_IT]; + someOtherLanguage = [SDLLanguage KO_KR]; + someAppName = @"someAppName"; + someTTSChunks = @[[[SDLTTSChunk alloc] init]]; + someNGNMediaAppName = @"some media app name"; + someVRSynonyms = @[@"some1", @"some2"]; + + testRequest.language = someLanguage; + testRequest.hmiDisplayLanguage = someOtherLanguage; + testRequest.appName = someAppName; + testRequest.ttsName = someTTSChunks; + testRequest.ngnMediaScreenAppName = someNGNMediaAppName; + testRequest.vrSynonyms = someVRSynonyms; + }); + + // Since the properties are immutable, a copy should be executed as a retain, so they should be identical + it(@"should get language correctly", ^{ + expect(testRequest.language).to(beIdenticalTo(someLanguage)); + }); + + it(@"should get hmi display language correctly", ^{ + expect(testRequest.hmiDisplayLanguage).to(beIdenticalTo(someOtherLanguage)); + }); + + it(@"should get app name correctly", ^{ + expect(testRequest.appName).to(beIdenticalTo(someAppName)); + }); + + it(@"should get tts chuncks correctly", ^{ + expect(testRequest.ttsName).to(beIdenticalTo(someTTSChunks)); + }); + + it(@"should get ngn media app name correctly", ^{ + expect(testRequest.ngnMediaScreenAppName).to(beIdenticalTo(someNGNMediaAppName)); + }); + + it(@"should get vr synonyms correctly", ^{ + expect(testRequest.vrSynonyms).to(beIdenticalTo(someVRSynonyms)); + }); + }); + + context(@"when no parameters are set", ^{ + beforeEach(^{ + testRequest = [[SDLChangeRegistration alloc] init]; + }); + + it(@"Should return nil if for language", ^ { + expect(testRequest.language).to(beNil()); + }); + + it(@"should return nil for hmi display language", ^{ + expect(testRequest.hmiDisplayLanguage).to(beNil()); + }); + + it(@"should return nil for app name", ^{ + expect(testRequest.appName).to(beNil()); + }); + + it(@"should return nil for tts name", ^{ + expect(testRequest.ttsName).to(beNil()); + }); + + it(@"should return nil for ngn media screen app name", ^{ + expect(testRequest.ngnMediaScreenAppName).to(beNil()); + }); + + it(@"should return nil for vr synonyms", ^{ + expect(testRequest.vrSynonyms).to(beNil()); + }); + }); + }); + + describe(@"when initializing with a dictionary", ^{ + context(@"when parameters are set", ^{ + beforeEach(^{ + someLanguage = [SDLLanguage IT_IT]; + someOtherLanguage = [SDLLanguage KO_KR]; + someAppName = @"someAppName"; + someTTSChunks = @[[[SDLTTSChunk alloc] init]]; + someNGNMediaAppName = @"some media app name"; + someVRSynonyms = @[@"some1", @"some2"]; + + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_language:someLanguage, + NAMES_hmiDisplayLanguage:someOtherLanguage, + NAMES_appName:someAppName, + NAMES_ttsName:someTTSChunks, + NAMES_ngnMediaScreenAppName:someNGNMediaAppName, + NAMES_vrSynonyms:someVRSynonyms}, + NAMES_operation_name:NAMES_ChangeRegistration}} mutableCopy]; + + testRequest = [[SDLChangeRegistration alloc] initWithDictionary:dict]; + }); + + // Since the properties are immutable, a copy should be executed as a retain, so they should be identical + it(@"should get language correctly", ^{ + expect(testRequest.language).to(beIdenticalTo(someLanguage)); + }); + + it(@"should get hmi display language correctly", ^{ + expect(testRequest.hmiDisplayLanguage).to(beIdenticalTo(someOtherLanguage)); + }); + + it(@"should get app name correctly", ^{ + expect(testRequest.appName).to(beIdenticalTo(someAppName)); + }); + + it(@"should get tts chuncks correctly", ^{ + expect(testRequest.ttsName).to(beIdenticalTo(someTTSChunks)); + }); + + it(@"should get ngn media app name correctly", ^{ + expect(testRequest.ngnMediaScreenAppName).to(beIdenticalTo(someNGNMediaAppName)); + }); + + it(@"should get vr synonyms correctly", ^{ + expect(testRequest.vrSynonyms).to(beIdenticalTo(someVRSynonyms)); + }); + }); + + context(@"when no parameters are set", ^{ + beforeEach(^{ + testRequest = [[SDLChangeRegistration alloc] initWithDictionary:[NSMutableDictionary dictionary]]; + }); + + it(@"Should return nil if for language", ^ { + expect(testRequest.language).to(beNil()); + }); + + it(@"should return nil for hmi display language", ^{ + expect(testRequest.hmiDisplayLanguage).to(beNil()); + }); + + it(@"should return nil for app name", ^{ + expect(testRequest.appName).to(beNil()); + }); + + it(@"should return nil for tts name", ^{ + expect(testRequest.ttsName).to(beNil()); + }); + + it(@"should return nil for ngn media screen app name", ^{ + expect(testRequest.ngnMediaScreenAppName).to(beNil()); + }); + + it(@"should return nil for vr synonyms", ^{ + expect(testRequest.vrSynonyms).to(beNil()); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLCreateInteractionChoiceSetSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLCreateInteractionChoiceSetSpec.m new file mode 100644 index 000000000..39cadb2d6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLCreateInteractionChoiceSetSpec.m @@ -0,0 +1,50 @@ +// +// SDLCreateInteractionChoiceSetSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCreateInteractionChoiceSet.h" +#import "SDLChoice.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLCreateInteractionChoiceSetSpec) + +SDLChoice* choice = [[SDLChoice alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLCreateInteractionChoiceSet* testRequest = [[SDLCreateInteractionChoiceSet alloc] init]; + + testRequest.interactionChoiceSetID = @141414; + testRequest.choiceSet = [@[choice] mutableCopy]; + + expect(testRequest.interactionChoiceSetID).to(equal(@141414)); + expect(testRequest.choiceSet).to(equal([@[choice] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_interactionChoiceSetID:@141414, + NAMES_choiceSet:[@[choice] mutableCopy]}, + NAMES_operation_name:NAMES_CreateInteractionChoiceSet}} mutableCopy]; + SDLCreateInteractionChoiceSet* testRequest = [[SDLCreateInteractionChoiceSet alloc] initWithDictionary:dict]; + + expect(testRequest.interactionChoiceSetID).to(equal(@141414)); + expect(testRequest.choiceSet).to(equal([@[choice] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLCreateInteractionChoiceSet* testRequest = [[SDLCreateInteractionChoiceSet alloc] init]; + + expect(testRequest.interactionChoiceSetID).to(beNil()); + expect(testRequest.choiceSet).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteCommandSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteCommandSpec.m new file mode 100644 index 000000000..2d0be62d8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteCommandSpec.m @@ -0,0 +1,42 @@ +// +// SDLDeleteCommandSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteCommand.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteCommandSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeleteCommand* testRequest = [[SDLDeleteCommand alloc] init]; + + testRequest.cmdID = @11223344; + + expect(testRequest.cmdID).to(equal(@11223344)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_cmdID:@11223344}, + NAMES_operation_name:NAMES_DeleteCommand}} mutableCopy]; + SDLDeleteCommand* testRequest = [[SDLDeleteCommand alloc] initWithDictionary:dict]; + + expect(testRequest.cmdID).to(equal(@11223344)); + }); + + it(@"Should return nil if not set", ^ { + SDLDeleteCommand* testRequest = [[SDLDeleteCommand alloc] init]; + + expect(testRequest.cmdID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteFileSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteFileSpec.m new file mode 100755 index 000000000..c6e471fc4 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteFileSpec.m @@ -0,0 +1,42 @@ +// +// SDLDeleteFileSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteFile.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteFileSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeleteFile* testRequest = [[SDLDeleteFile alloc] init]; + + testRequest.syncFileName = @"synchro"; + + expect(testRequest.syncFileName).to(equal(@"synchro")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_syncFileName:@"synchro"}, + NAMES_operation_name:NAMES_DeleteFile}} mutableCopy]; + SDLDeleteFile* testRequest = [[SDLDeleteFile alloc] initWithDictionary:dict]; + + expect(testRequest.syncFileName).to(equal(@"synchro")); + }); + + it(@"Should return nil if not set", ^ { + SDLDeleteFile* testRequest = [[SDLDeleteFile alloc] init]; + + expect(testRequest.syncFileName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteInteractionChoiceSetSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteInteractionChoiceSetSpec.m new file mode 100755 index 000000000..6d42d114f --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteInteractionChoiceSetSpec.m @@ -0,0 +1,42 @@ +// +// SDLDeleteInteractionChoiceSetSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteInteractionChoiceSet.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteInteractionChoiceSetSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeleteInteractionChoiceSet* testRequest = [[SDLDeleteInteractionChoiceSet alloc] init]; + + testRequest.interactionChoiceSetID = @20314; + + expect(testRequest.interactionChoiceSetID).to(equal(@20314)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_interactionChoiceSetID:@20314}, + NAMES_operation_name:NAMES_DeleteInteractionChoiceSet}} mutableCopy]; + SDLDeleteInteractionChoiceSet* testRequest = [[SDLDeleteInteractionChoiceSet alloc] initWithDictionary:dict]; + + expect(testRequest.interactionChoiceSetID).to(equal(@20314)); + }); + + it(@"Should return nil if not set", ^ { + SDLDeleteInteractionChoiceSet* testRequest = [[SDLDeleteInteractionChoiceSet alloc] init]; + + expect(testRequest.interactionChoiceSetID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteSubMenuSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteSubMenuSpec.m new file mode 100755 index 000000000..9b2d6588d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDeleteSubMenuSpec.m @@ -0,0 +1,42 @@ +// +// SDLDeleteSubMenuSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteSubMenu.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteSubMenuSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeleteSubMenu* testRequest = [[SDLDeleteSubMenu alloc] init]; + + testRequest.menuID = @25614; + + expect(testRequest.menuID).to(equal(@25614)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_menuID:@25614}, + NAMES_operation_name:NAMES_DeleteSubMenu}} mutableCopy]; + SDLDeleteSubMenu* testRequest = [[SDLDeleteSubMenu alloc] initWithDictionary:dict]; + + expect(testRequest.menuID).to(equal(@25614)); + }); + + it(@"Should return nil if not set", ^ { + SDLDeleteSubMenu* testRequest = [[SDLDeleteSubMenu alloc] init]; + + expect(testRequest.menuID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDiagnosticMessageSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDiagnosticMessageSpec.m new file mode 100755 index 000000000..965920f39 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDiagnosticMessageSpec.m @@ -0,0 +1,52 @@ +// +// SDLDiagnosticMessageSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDiagnosticMessage.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDiagnosticMessageSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDiagnosticMessage* testRequest = [[SDLDiagnosticMessage alloc] init]; + + testRequest.targetID = @3562; + testRequest.messageLength = @55555; + testRequest.messageData = [@[@1, @4, @16, @64] mutableCopy]; + + expect(testRequest.targetID).to(equal(@3562)); + expect(testRequest.messageLength).to(equal(@55555)); + expect(testRequest.messageData).to(equal([@[@1, @4, @16, @64] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_targetID:@3562, + NAMES_messageLength:@55555, + NAMES_messageData:[@[@1, @4, @16, @64] mutableCopy]}, + NAMES_operation_name:NAMES_DiagnosticMessage}} mutableCopy]; + SDLDiagnosticMessage* testRequest = [[SDLDiagnosticMessage alloc] initWithDictionary:dict]; + + expect(testRequest.targetID).to(equal(@3562)); + expect(testRequest.messageLength).to(equal(@55555)); + expect(testRequest.messageData).to(equal([@[@1, @4, @16, @64] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLDiagnosticMessage* testRequest = [[SDLDiagnosticMessage alloc] init]; + + expect(testRequest.targetID).to(beNil()); + expect(testRequest.messageLength).to(beNil()); + expect(testRequest.messageData).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDialNumberSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDialNumberSpec.m new file mode 100644 index 000000000..7371fedf3 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLDialNumberSpec.m @@ -0,0 +1,80 @@ +// +// SDLDialNumberSpec.m +// SmartDeviceLink-iOS + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDialNumber.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLDialNumberSpec) + +describe(@"Dial Number RPC", ^{ + describe(@"when initialized with 'init'", ^{ + __block SDLDialNumber *testRequest = nil; + beforeEach(^{ + testRequest = [[SDLDialNumber alloc] init]; + }); + + context(@"when parameters are set correctly", ^{ + __block NSString *somePhoneNumber = nil; + beforeEach(^{ + somePhoneNumber = @"1234567890"; + testRequest.number = [somePhoneNumber copy]; + }); + + it(@"should get 'number' correctly", ^{ + expect(testRequest.number).to(equal(somePhoneNumber)); + }); + }); + + context(@"when parameters are not set correctly", ^{ + it(@"should return nil for number", ^{ + expect(testRequest.number).to(beNil()); + }); + }); + }); + + describe(@"when initialized with a dictionary and parameters are set correctly", ^{ + __block SDLDialNumber *testRequest = nil; + __block NSString *somePhoneNumber = nil; + beforeEach(^{ + somePhoneNumber = @"1234567890"; + NSDictionary *initDict = @{ + NAMES_request: @{ + NAMES_parameters: @{ + NAMES_number: [somePhoneNumber copy] + } + } + }; + + testRequest = [[SDLDialNumber alloc] initWithDictionary:[initDict mutableCopy]]; + }); + + it(@"should get 'number' correctly", ^{ + expect(testRequest.number).to(equal(somePhoneNumber)); + }); + }); + + describe(@"when initialized with a dictionary and parameters are not set correctly", ^{ + __block SDLDialNumber *testRequest = nil; + beforeEach(^{ + NSDictionary *initDict = @{ + NAMES_request: @{ + NAMES_parameters: @{ + } + } + }; + + testRequest = [[SDLDialNumber alloc] initWithDictionary:[initDict mutableCopy]]; + }); + + it(@"should return nil for number", ^{ + expect(testRequest.number).to(beNil()); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLEncodedSyncPDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLEncodedSyncPDataSpec.m new file mode 100755 index 000000000..753608940 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLEncodedSyncPDataSpec.m @@ -0,0 +1,42 @@ +// +// SDLEncodedSyncPDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEncodedSyncPData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLEncodedSyncPDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLEncodedSyncPData* testRequest = [[SDLEncodedSyncPData alloc] init]; + + testRequest.data = [@[@2, @2, @2] mutableCopy]; + + expect(testRequest.data).to(equal([@[@2, @2, @2] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_data:[@[@2, @2, @2] mutableCopy]}, + NAMES_operation_name:NAMES_EncodedSyncPData}} mutableCopy]; + SDLEncodedSyncPData* testRequest = [[SDLEncodedSyncPData alloc] initWithDictionary:dict]; + + expect(testRequest.data).to(equal([@[@2, @2, @2] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLEncodedSyncPData* testRequest = [[SDLEncodedSyncPData alloc] init]; + + expect(testRequest.data).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLEndAudioPassThruSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLEndAudioPassThruSpec.m new file mode 100644 index 000000000..843d917be --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLEndAudioPassThruSpec.m @@ -0,0 +1,16 @@ +// +// SDLEndAudioPassThruSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEndAudioPassThru.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLEndAudioPassThruSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLGetDTCsSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLGetDTCsSpec.m new file mode 100755 index 000000000..87f84fd4d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLGetDTCsSpec.m @@ -0,0 +1,47 @@ +// +// SDLGetDTCsSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLGetDTCs.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLGetDTCsSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLGetDTCs* testRequest = [[SDLGetDTCs alloc] init]; + + testRequest.ecuName = @4321; + testRequest.dtcMask = @22; + + expect(testRequest.ecuName).to(equal(@4321)); + expect(testRequest.dtcMask).to(equal(@22)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_ecuName:@4321, + NAMES_dtcMask:@22}, + NAMES_operation_name:NAMES_EndAudioPassThru}} mutableCopy]; + SDLGetDTCs* testRequest = [[SDLGetDTCs alloc] initWithDictionary:dict]; + + expect(testRequest.ecuName).to(equal(@4321)); + expect(testRequest.dtcMask).to(equal(@22)); + }); + + it(@"Should return nil if not set", ^ { + SDLGetDTCs* testRequest = [[SDLGetDTCs alloc] init]; + + expect(testRequest.ecuName).to(beNil()); + expect(testRequest.dtcMask).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLGetVehicleDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLGetVehicleDataSpec.m new file mode 100644 index 000000000..936550ce7 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLGetVehicleDataSpec.m @@ -0,0 +1,162 @@ +// +// SDLGetVehicleDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLGetVehicleData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLGetVehicleDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLGetVehicleData* testRequest = [[SDLGetVehicleData alloc] init]; + + testRequest.gps = @NO; + testRequest.speed = @YES; + testRequest.rpm = @NO; + testRequest.fuelLevel = @YES; + testRequest.fuelLevel_State = @NO; + testRequest.instantFuelConsumption = @YES; + testRequest.externalTemperature = @NO; + testRequest.vin = @YES; + testRequest.prndl = @NO; + testRequest.tirePressure = @YES; + testRequest.odometer = @NO; + testRequest.beltStatus = @YES; + testRequest.bodyInformation = @NO; + testRequest.deviceStatus = @YES; + testRequest.driverBraking = @NO; + testRequest.wiperStatus = @YES; + testRequest.headLampStatus = @NO; + testRequest.engineTorque = @YES; + testRequest.accPedalPosition = @NO; + testRequest.steeringWheelAngle = @YES; + testRequest.eCallInfo = @NO; + testRequest.airbagStatus = @YES; + testRequest.emergencyEvent = @NO; + testRequest.clusterModeStatus = @YES; + testRequest.myKey = @NO; + + expect(testRequest.gps).to(equal(@NO)); + expect(testRequest.speed).to(equal(@YES)); + expect(testRequest.rpm).to(equal(@NO)); + expect(testRequest.fuelLevel).to(equal(@YES)); + expect(testRequest.fuelLevel_State).to(equal(@NO)); + expect(testRequest.instantFuelConsumption).to(equal(@YES)); + expect(testRequest.externalTemperature).to(equal(@NO)); + expect(testRequest.vin).to(equal(@YES)); + expect(testRequest.prndl).to(equal(@NO)); + expect(testRequest.tirePressure).to(equal(@YES)); + expect(testRequest.odometer).to(equal(@NO)); + expect(testRequest.beltStatus).to(equal(@YES)); + expect(testRequest.bodyInformation).to(equal(@NO)); + expect(testRequest.deviceStatus).to(equal(@YES)); + expect(testRequest.driverBraking).to(equal(@NO)); + expect(testRequest.wiperStatus).to(equal(@YES)); + expect(testRequest.headLampStatus).to(equal(@NO)); + expect(testRequest.engineTorque).to(equal(@YES)); + expect(testRequest.accPedalPosition).to(equal(@NO)); + expect(testRequest.steeringWheelAngle).to(equal(@YES)); + expect(testRequest.eCallInfo).to(equal(@NO)); + expect(testRequest.airbagStatus).to(equal(@YES)); + expect(testRequest.emergencyEvent).to(equal(@NO)); + expect(testRequest.clusterModeStatus).to(equal(@YES)); + expect(testRequest.myKey).to(equal(@NO)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_gps:@NO, + NAMES_speed:@YES, + NAMES_rpm:@NO, + NAMES_fuelLevel:@YES, + NAMES_fuelLevel_State:@NO, + NAMES_instantFuelConsumption:@YES, + NAMES_externalTemperature:@NO, + NAMES_vin:@YES, + NAMES_prndl:@NO, + NAMES_tirePressure:@YES, + NAMES_odometer:@NO, + NAMES_beltStatus:@YES, + NAMES_bodyInformation:@NO, + NAMES_deviceStatus:@YES, + NAMES_driverBraking:@NO, + NAMES_wiperStatus:@YES, + NAMES_headLampStatus:@NO, + NAMES_engineTorque:@YES, + NAMES_accPedalPosition:@NO, + NAMES_steeringWheelAngle:@YES, + NAMES_eCallInfo:@NO, + NAMES_airbagStatus:@YES, + NAMES_emergencyEvent:@NO, + NAMES_clusterModeStatus:@YES, + NAMES_myKey:@NO}, + NAMES_operation_name:NAMES_GetVehicleData}} mutableCopy]; + SDLGetVehicleData* testRequest = [[SDLGetVehicleData alloc] initWithDictionary:dict]; + + expect(testRequest.gps).to(equal(@NO)); + expect(testRequest.speed).to(equal(@YES)); + expect(testRequest.rpm).to(equal(@NO)); + expect(testRequest.fuelLevel).to(equal(@YES)); + expect(testRequest.fuelLevel_State).to(equal(@NO)); + expect(testRequest.instantFuelConsumption).to(equal(@YES)); + expect(testRequest.externalTemperature).to(equal(@NO)); + expect(testRequest.vin).to(equal(@YES)); + expect(testRequest.prndl).to(equal(@NO)); + expect(testRequest.tirePressure).to(equal(@YES)); + expect(testRequest.odometer).to(equal(@NO)); + expect(testRequest.beltStatus).to(equal(@YES)); + expect(testRequest.bodyInformation).to(equal(@NO)); + expect(testRequest.deviceStatus).to(equal(@YES)); + expect(testRequest.driverBraking).to(equal(@NO)); + expect(testRequest.wiperStatus).to(equal(@YES)); + expect(testRequest.headLampStatus).to(equal(@NO)); + expect(testRequest.engineTorque).to(equal(@YES)); + expect(testRequest.accPedalPosition).to(equal(@NO)); + expect(testRequest.steeringWheelAngle).to(equal(@YES)); + expect(testRequest.eCallInfo).to(equal(@NO)); + expect(testRequest.airbagStatus).to(equal(@YES)); + expect(testRequest.emergencyEvent).to(equal(@NO)); + expect(testRequest.clusterModeStatus).to(equal(@YES)); + expect(testRequest.myKey).to(equal(@NO)); + }); + + it(@"Should return nil if not set", ^ { + SDLGetVehicleData* testRequest = [[SDLGetVehicleData alloc] init]; + + expect(testRequest.gps).to(beNil()); + expect(testRequest.speed).to(beNil()); + expect(testRequest.rpm).to(beNil()); + expect(testRequest.fuelLevel).to(beNil()); + expect(testRequest.fuelLevel_State).to(beNil()); + expect(testRequest.instantFuelConsumption).to(beNil()); + expect(testRequest.externalTemperature).to(beNil()); + expect(testRequest.vin).to(beNil()); + expect(testRequest.prndl).to(beNil()); + expect(testRequest.tirePressure).to(beNil()); + expect(testRequest.odometer).to(beNil()); + expect(testRequest.beltStatus).to(beNil()); + expect(testRequest.bodyInformation).to(beNil()); + expect(testRequest.deviceStatus).to(beNil()); + expect(testRequest.driverBraking).to(beNil()); + expect(testRequest.wiperStatus).to(beNil()); + expect(testRequest.headLampStatus).to(beNil()); + expect(testRequest.engineTorque).to(beNil()); + expect(testRequest.accPedalPosition).to(beNil()); + expect(testRequest.steeringWheelAngle).to(beNil()); + expect(testRequest.eCallInfo).to(beNil()); + expect(testRequest.airbagStatus).to(beNil()); + expect(testRequest.emergencyEvent).to(beNil()); + expect(testRequest.clusterModeStatus).to(beNil()); + expect(testRequest.myKey).to(beNil()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLListFilesSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLListFilesSpec.m new file mode 100644 index 000000000..0f0084f41 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLListFilesSpec.m @@ -0,0 +1,16 @@ +// +// SDLListFilesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLListFiles.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLListFilesSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformAudioPassThruSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformAudioPassThruSpec.m new file mode 100644 index 000000000..011a7adf5 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformAudioPassThruSpec.m @@ -0,0 +1,76 @@ +// +// SDLPerformAudioPassThruSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAudioType.h" +#import "SDLBitsPerSample.h" +#import "SDLNames.h" +#import "SDLPerformAudioPassThru.h" +#import "SDLSamplingRate.h" + + +QuickSpecBegin(SDLPerformAudioPassThruSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPerformAudioPassThru* testRequest = [[SDLPerformAudioPassThru alloc] init]; + + testRequest.audioPassThruDisplayText1 = @"passthru#1"; + testRequest.audioPassThruDisplayText2 = @"passthru#2"; + testRequest.samplingRate = [SDLSamplingRate _22KHZ]; + testRequest.maxDuration = @34563; + testRequest.bitsPerSample = [SDLBitsPerSample _16_BIT]; + testRequest.audioType = [SDLAudioType PCM]; + testRequest.muteAudio = @NO; + + expect(testRequest.audioPassThruDisplayText1).to(equal(@"passthru#1")); + expect(testRequest.audioPassThruDisplayText2).to(equal(@"passthru#2")); + expect(testRequest.samplingRate).to(equal([SDLSamplingRate _22KHZ])); + expect(testRequest.maxDuration).to(equal(@34563)); + expect(testRequest.bitsPerSample).to(equal([SDLBitsPerSample _16_BIT])); + expect(testRequest.audioType).to(equal([SDLAudioType PCM])); + expect(testRequest.muteAudio).to(equal(@NO)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_audioPassThruDisplayText1:@"passthru#1", + NAMES_audioPassThruDisplayText2:@"passthru#2", + NAMES_samplingRate:[SDLSamplingRate _22KHZ], + NAMES_maxDuration:@34563, + NAMES_bitsPerSample:[SDLBitsPerSample _16_BIT], + NAMES_audioType:[SDLAudioType PCM], + NAMES_muteAudio:@NO}, + NAMES_operation_name:NAMES_PerformAudioPassThru}} mutableCopy]; + SDLPerformAudioPassThru* testRequest = [[SDLPerformAudioPassThru alloc] initWithDictionary:dict]; + + expect(testRequest.audioPassThruDisplayText1).to(equal(@"passthru#1")); + expect(testRequest.audioPassThruDisplayText2).to(equal(@"passthru#2")); + expect(testRequest.samplingRate).to(equal([SDLSamplingRate _22KHZ])); + expect(testRequest.maxDuration).to(equal(@34563)); + expect(testRequest.bitsPerSample).to(equal([SDLBitsPerSample _16_BIT])); + expect(testRequest.audioType).to(equal([SDLAudioType PCM])); + expect(testRequest.muteAudio).to(equal(@NO)); + }); + + it(@"Should return nil if not set", ^ { + SDLPerformAudioPassThru* testRequest = [[SDLPerformAudioPassThru alloc] init]; + + expect(testRequest.audioPassThruDisplayText1).to(beNil()); + expect(testRequest.audioPassThruDisplayText2).to(beNil()); + expect(testRequest.samplingRate).to(beNil()); + expect(testRequest.maxDuration).to(beNil()); + expect(testRequest.bitsPerSample).to(beNil()); + expect(testRequest.audioType).to(beNil()); + expect(testRequest.muteAudio).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformInteractionSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformInteractionSpec.m new file mode 100644 index 000000000..c89c3d5bd --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformInteractionSpec.m @@ -0,0 +1,91 @@ +// +// SDLPerformInteractionSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLInteractionMode.h" +#import "SDLLayoutMode.h" +#import "SDLPerformInteraction.h" +#import "SDLTTSChunk.h" +#import "SDLVrHelpItem.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLPerformInteractionSpec) + +SDLTTSChunk* chunk1 = [[SDLTTSChunk alloc] init]; +SDLTTSChunk* chunk2 = [[SDLTTSChunk alloc] init]; +SDLTTSChunk* chunk3 = [[SDLTTSChunk alloc] init]; +SDLVRHelpItem* helpItem = [[SDLVRHelpItem alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPerformInteraction* testRequest = [[SDLPerformInteraction alloc] init]; + + testRequest.initialText = @"a"; + testRequest.initialPrompt = [@[chunk1] mutableCopy]; + testRequest.interactionMode = [SDLInteractionMode VR_ONLY]; + testRequest.interactionChoiceSetIDList = [@[@1, @2, @3] mutableCopy]; + testRequest.helpPrompt = [@[chunk2] mutableCopy]; + testRequest.timeoutPrompt = [@[chunk3] mutableCopy]; + testRequest.timeout = @42000; + testRequest.vrHelp = [@[helpItem] mutableCopy]; + testRequest.interactionLayout = [SDLLayoutMode ICON_WITH_SEARCH]; + + expect(testRequest.initialText).to(equal(@"a")); + expect(testRequest.initialPrompt).to(equal([@[chunk1] mutableCopy])); + expect(testRequest.interactionMode).to(equal([SDLInteractionMode VR_ONLY])); + expect(testRequest.interactionChoiceSetIDList).to(equal([@[@1, @2, @3] mutableCopy])); + expect(testRequest.helpPrompt).to(equal([@[chunk2] mutableCopy])); + expect(testRequest.timeoutPrompt).to(equal([@[chunk3] mutableCopy])); + expect(testRequest.timeout).to(equal(@42000)); + expect(testRequest.vrHelp).to(equal([@[helpItem] mutableCopy])); + expect(testRequest.interactionLayout).to(equal([SDLLayoutMode ICON_WITH_SEARCH])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_initialText:@"a", + NAMES_initialPrompt:[@[chunk1] mutableCopy], + NAMES_interactionMode:[SDLInteractionMode VR_ONLY], + NAMES_interactionChoiceSetIDList:[@[@1, @2, @3] mutableCopy], + NAMES_helpPrompt:[@[chunk2] mutableCopy], + NAMES_timeoutPrompt:[@[chunk3] mutableCopy], + NAMES_timeout:@42000, + NAMES_vrHelp:[@[helpItem] mutableCopy], + NAMES_interactionLayout:[SDLLayoutMode ICON_WITH_SEARCH]}, + NAMES_operation_name:NAMES_PerformInteraction}} mutableCopy]; + SDLPerformInteraction* testRequest = [[SDLPerformInteraction alloc] initWithDictionary:dict]; + + expect(testRequest.initialText).to(equal(@"a")); + expect(testRequest.initialPrompt).to(equal([@[chunk1] mutableCopy])); + expect(testRequest.interactionMode).to(equal([SDLInteractionMode VR_ONLY])); + expect(testRequest.interactionChoiceSetIDList).to(equal([@[@1, @2, @3] mutableCopy])); + expect(testRequest.helpPrompt).to(equal([@[chunk2] mutableCopy])); + expect(testRequest.timeoutPrompt).to(equal([@[chunk3] mutableCopy])); + expect(testRequest.timeout).to(equal(@42000)); + expect(testRequest.vrHelp).to(equal([@[helpItem] mutableCopy])); + expect(testRequest.interactionLayout).to(equal([SDLLayoutMode ICON_WITH_SEARCH])); + }); + + it(@"Should return nil if not set", ^ { + SDLPerformInteraction* testRequest = [[SDLPerformInteraction alloc] init]; + + expect(testRequest.initialText).to(beNil()); + expect(testRequest.initialPrompt).to(beNil()); + expect(testRequest.interactionMode).to(beNil()); + expect(testRequest.interactionChoiceSetIDList).to(beNil()); + expect(testRequest.helpPrompt).to(beNil()); + expect(testRequest.timeoutPrompt).to(beNil()); + expect(testRequest.timeout).to(beNil()); + expect(testRequest.vrHelp).to(beNil()); + expect(testRequest.interactionLayout).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPutFileSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPutFileSpec.m new file mode 100644 index 000000000..bfa24dc13 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPutFileSpec.m @@ -0,0 +1,69 @@ +// +// SDLPutFileSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFileType.h" +#import "SDLNames.h" +#import "SDLPutFile.h" + + +QuickSpecBegin(SDLPutFileSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPutFile* testRequest = [[SDLPutFile alloc] init]; + + testRequest.syncFileName = @"fileName"; + testRequest.fileType = [SDLFileType GRAPHIC_JPEG]; + testRequest.persistentFile = @YES; + testRequest.systemFile = @NO; + testRequest.offset = @987654321; + testRequest.length = @123456789; + + expect(testRequest.syncFileName).to(equal(@"fileName")); + expect(testRequest.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + expect(testRequest.persistentFile).to(equal(@YES)); + expect(testRequest.systemFile).to(equal(@NO)); + expect(testRequest.offset).to(equal(@987654321)); + expect(testRequest.length).to(equal(@123456789)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_syncFileName:@"fileName", + NAMES_fileType:[SDLFileType GRAPHIC_JPEG], + NAMES_persistentFile:@YES, + NAMES_systemFile:@NO, + NAMES_offset:@987654321, + NAMES_length:@123456789}, + NAMES_operation_name:NAMES_PutFile}} mutableCopy]; + SDLPutFile* testRequest = [[SDLPutFile alloc] initWithDictionary:dict]; + + expect(testRequest.syncFileName).to(equal(@"fileName")); + expect(testRequest.fileType).to(equal([SDLFileType GRAPHIC_JPEG])); + expect(testRequest.persistentFile).to(equal(@YES)); + expect(testRequest.systemFile).to(equal(@NO)); + expect(testRequest.offset).to(equal(@987654321)); + expect(testRequest.length).to(equal(@123456789)); + }); + + it(@"Should return nil if not set", ^ { + SDLPutFile* testRequest = [[SDLPutFile alloc] init]; + + expect(testRequest.syncFileName).to(beNil()); + expect(testRequest.fileType).to(beNil()); + expect(testRequest.persistentFile).to(beNil()); + expect(testRequest.systemFile).to(beNil()); + expect(testRequest.offset).to(beNil()); + expect(testRequest.length).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLReadDIDSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLReadDIDSpec.m new file mode 100644 index 000000000..7c5598bbb --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLReadDIDSpec.m @@ -0,0 +1,47 @@ +// +// SDLReadDIDSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLReadDID.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLReadDIDSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLReadDID* testRequest = [[SDLReadDID alloc] init]; + + testRequest.ecuName = @33112; + testRequest.didLocation = [@[@200, @201, @205] mutableCopy]; + + expect(testRequest.ecuName).to(equal(@33112)); + expect(testRequest.didLocation).to(equal([@[@200, @201, @205] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_ecuName:@33112, + NAMES_didLocation:[@[@200, @201, @205] mutableCopy]}, + NAMES_operation_name:NAMES_EndAudioPassThru}} mutableCopy]; + SDLReadDID* testRequest = [[SDLReadDID alloc] initWithDictionary:dict]; + + expect(testRequest.ecuName).to(equal(@33112)); + expect(testRequest.didLocation).to(equal([@[@200, @201, @205] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLReadDID* testRequest = [[SDLReadDID alloc] init]; + + expect(testRequest.ecuName).to(beNil()); + expect(testRequest.didLocation).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m new file mode 100644 index 000000000..6e8a4cc5d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m @@ -0,0 +1,107 @@ +// +// SDLRegisterAppInterfaceSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAppHMIType.h" +#import "SDLDeviceInfo.h" +#import "SDLLanguage.h" +#import "SDLNames.h" +#import "SDLRegisterAppInterface.h" +#import "SDLSyncMsgVersion.h" +#import "SDLTTSChunk.h" + + +QuickSpecBegin(SDLRegisterAppInterfaceSpec) + +SDLSyncMsgVersion* version = [[SDLSyncMsgVersion alloc] init]; +SDLTTSChunk* chunk = [[SDLTTSChunk alloc] init]; +SDLDeviceInfo* info = [[SDLDeviceInfo alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLRegisterAppInterface* testRequest = [[SDLRegisterAppInterface alloc] init]; + + testRequest.syncMsgVersion = version; + testRequest.appName = @"app56"; + testRequest.ttsName = [@[chunk] mutableCopy]; + testRequest.ngnMediaScreenAppName = @"whatisanngn"; + testRequest.vrSynonyms = [@[@"paraphrase of the original name"] mutableCopy]; + testRequest.isMediaApplication = @NO; + testRequest.languageDesired = [SDLLanguage NO_NO]; + testRequest.hmiDisplayLanguageDesired = [SDLLanguage PT_PT]; + testRequest.appHMIType = [@[[SDLAppHMIType MESSAGING], [SDLAppHMIType INFORMATION]] copy]; + testRequest.hashID = @"gercd35grw2"; + testRequest.deviceInfo = info; + testRequest.appID = @"123456789"; + + expect(testRequest.syncMsgVersion).to(equal(version)); + expect(testRequest.appName).to(equal(@"app56")); + expect(testRequest.ttsName).to(equal([@[chunk] mutableCopy])); + expect(testRequest.ngnMediaScreenAppName).to(equal(@"whatisanngn")); + expect(testRequest.vrSynonyms).to(equal([@[@"paraphrase of the original name"] mutableCopy])); + expect(testRequest.isMediaApplication).to(equal(@NO)); + expect(testRequest.languageDesired).to(equal([SDLLanguage NO_NO])); + expect(testRequest.hmiDisplayLanguageDesired).to(equal([SDLLanguage PT_PT])); + expect(testRequest.appHMIType).to(equal([@[[SDLAppHMIType MESSAGING], [SDLAppHMIType INFORMATION]] copy])); + expect(testRequest.hashID).to(equal(@"gercd35grw2")); + expect(testRequest.deviceInfo).to(equal(info)); + expect(testRequest.appID).to(equal(@"123456789")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_syncMsgVersion:version, + NAMES_appName:@"app56", + NAMES_ttsName:[@[chunk] mutableCopy], + NAMES_ngnMediaScreenAppName:@"whatisanngn", + NAMES_vrSynonyms:[@[@"paraphrase of the original name"] mutableCopy], + NAMES_isMediaApplication:@NO, + NAMES_languageDesired:[SDLLanguage NO_NO], + NAMES_hmiDisplayLanguageDesired:[SDLLanguage PT_PT], + NAMES_appHMIType:[@[[SDLAppHMIType MESSAGING], [SDLAppHMIType INFORMATION]] copy], + NAMES_hashID:@"gercd35grw2", + NAMES_deviceInfo:info, + NAMES_appID:@"123456789"}, + NAMES_operation_name:NAMES_RegisterAppInterface}} mutableCopy]; + SDLRegisterAppInterface* testRequest = [[SDLRegisterAppInterface alloc] initWithDictionary:dict]; + + expect(testRequest.syncMsgVersion).to(equal(version)); + expect(testRequest.appName).to(equal(@"app56")); + expect(testRequest.ttsName).to(equal([@[chunk] mutableCopy])); + expect(testRequest.ngnMediaScreenAppName).to(equal(@"whatisanngn")); + expect(testRequest.vrSynonyms).to(equal([@[@"paraphrase of the original name"] mutableCopy])); + expect(testRequest.isMediaApplication).to(equal(@NO)); + expect(testRequest.languageDesired).to(equal([SDLLanguage NO_NO])); + expect(testRequest.hmiDisplayLanguageDesired).to(equal([SDLLanguage PT_PT])); + expect(testRequest.appHMIType).to(equal([@[[SDLAppHMIType MESSAGING], [SDLAppHMIType INFORMATION]] copy])); + expect(testRequest.hashID).to(equal(@"gercd35grw2")); + expect(testRequest.deviceInfo).to(equal(info)); + expect(testRequest.appID).to(equal(@"123456789")); + }); + + it(@"Should return nil if not set", ^ { + SDLRegisterAppInterface* testRequest = [[SDLRegisterAppInterface alloc] init]; + + expect(testRequest.syncMsgVersion).to(beNil()); + expect(testRequest.appName).to(beNil()); + expect(testRequest.ttsName).to(beNil()); + expect(testRequest.ngnMediaScreenAppName).to(beNil()); + expect(testRequest.vrSynonyms).to(beNil()); + expect(testRequest.isMediaApplication).to(beNil()); + expect(testRequest.languageDesired).to(beNil()); + expect(testRequest.hmiDisplayLanguageDesired).to(beNil()); + expect(testRequest.appHMIType).to(beNil()); + expect(testRequest.hashID).to(beNil()); + expect(testRequest.deviceInfo).to(beNil()); + expect(testRequest.appID).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLResetGlobalPropertiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLResetGlobalPropertiesSpec.m new file mode 100644 index 000000000..e99320f18 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLResetGlobalPropertiesSpec.m @@ -0,0 +1,43 @@ +// +// SDLResetGlobalPropertiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLResetGlobalProperties.h" +#import "SDLGlobalProperty.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLResetGlobalPropertiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLResetGlobalProperties* testRequest = [[SDLResetGlobalProperties alloc] init]; + + testRequest.properties = [@[[SDLGlobalProperty MENUNAME], [SDLGlobalProperty VRHELPTITLE]] copy]; + + expect(testRequest.properties).to(equal([@[[SDLGlobalProperty MENUNAME], [SDLGlobalProperty VRHELPTITLE]] copy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_properties:[@[[SDLGlobalProperty MENUNAME], [SDLGlobalProperty VRHELPTITLE]] copy]}, + NAMES_operation_name:NAMES_ResetGlobalProperties}} mutableCopy]; + SDLResetGlobalProperties* testRequest = [[SDLResetGlobalProperties alloc] initWithDictionary:dict]; + + expect(testRequest.properties).to(equal([@[[SDLGlobalProperty MENUNAME], [SDLGlobalProperty VRHELPTITLE]] copy])); + }); + + it(@"Should return nil if not set", ^ { + SDLResetGlobalProperties* testRequest = [[SDLResetGlobalProperties alloc] init]; + + expect(testRequest.properties).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLScrollableMessageSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLScrollableMessageSpec.m new file mode 100644 index 000000000..6b1142d6b --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLScrollableMessageSpec.m @@ -0,0 +1,55 @@ +// +// SDLScrollableMessageSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLScrollableMessage.h" +#import "SDLSoftButton.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLScrollableMessageSpec) + +SDLSoftButton* button = [[SDLSoftButton alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLScrollableMessage* testRequest = [[SDLScrollableMessage alloc] init]; + + testRequest.scrollableMessageBody = @"thatmessagebody"; + testRequest.timeout = @9182; + testRequest.softButtons = [@[button] mutableCopy]; + + expect(testRequest.scrollableMessageBody).to(equal(@"thatmessagebody")); + expect(testRequest.timeout).to(equal(@9182)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_scrollableMessageBody:@"thatmessagebody", + NAMES_timeout:@9182, + NAMES_softButtons:[@[button] mutableCopy]}, + NAMES_operation_name:NAMES_ScrollableMessage}} mutableCopy]; + SDLScrollableMessage* testRequest = [[SDLScrollableMessage alloc] initWithDictionary:dict]; + + expect(testRequest.scrollableMessageBody).to(equal(@"thatmessagebody")); + expect(testRequest.timeout).to(equal(@9182)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLScrollableMessage* testRequest = [[SDLScrollableMessage alloc] init]; + + expect(testRequest.scrollableMessageBody).to(beNil()); + expect(testRequest.timeout).to(beNil()); + expect(testRequest.softButtons).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSendLocationSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSendLocationSpec.m new file mode 100644 index 000000000..ccd4bafdb --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSendLocationSpec.m @@ -0,0 +1,222 @@ +// +// SDLSendLocationSpec.m +// SmartDeviceLink-iOS + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLSendLocation.h" + + +QuickSpecBegin(SDLSendLocationSpec) + +describe(@"Send Location RPC", ^{ + __block SDLSendLocation *testRequest = nil; + __block NSNumber *someLongitude = nil; + __block NSNumber *someLatitude = nil; + __block NSString *someLocation = nil; + __block NSString *someLocationDescription = nil; + __block NSArray *someAddressLines = nil; + __block NSString *somePhoneNumber = nil; + __block SDLImage *someImage = nil; + + describe(@"when initialized with init", ^{ + beforeEach(^{ + testRequest = [[SDLSendLocation alloc] init]; + }); + + context(@"when parameters are set correctly", ^{ + beforeEach(^{ + someLongitude = @123.4567; + someLatitude = @65.4321; + someLocation = @"Livio"; + someLocationDescription = @"A great place to work"; + someAddressLines = @[@"3136 Hilton Rd", @"Ferndale, MI", @"48220"]; + somePhoneNumber = @"248-591-0333"; + someImage = [[SDLImage alloc] init]; + + testRequest.longitudeDegrees = someLongitude; + testRequest.latitudeDegrees = someLatitude; + testRequest.locationName = someLocation; + testRequest.locationDescription = someLocationDescription; + testRequest.addressLines = someAddressLines; + testRequest.phoneNumber = somePhoneNumber; + testRequest.locationImage = someImage; + }); + + // Since all the properties are immutable, a copy should be executed as a retain, which means they should be identical + it(@"should get longitude correctly", ^{ + expect(testRequest.longitudeDegrees).to(equal(someLongitude)); + expect(testRequest.longitudeDegrees).to(beIdenticalTo(someLongitude)); + }); + + it(@"should get latitude correctly", ^{ + expect(testRequest.latitudeDegrees).to(equal(someLatitude)); + expect(testRequest.latitudeDegrees).to(beIdenticalTo(someLatitude)); + }); + + it(@"should get location correctly", ^{ + expect(testRequest.locationName).to(equal(someLocation)); + expect(testRequest.locationName).to(beIdenticalTo(someLocation)); + }); + + it(@"should get location description correctly", ^{ + expect(testRequest.locationDescription).to(equal(someLocationDescription)); + expect(testRequest.locationDescription).to(beIdenticalTo(someLocationDescription)); + }); + + it(@"should get address lines correctly", ^{ + expect(testRequest.addressLines).to(equal(someAddressLines)); + expect(testRequest.addressLines).to(beIdenticalTo(someAddressLines)); + }); + + it(@"should get phone number correctly", ^{ + expect(testRequest.phoneNumber).to(equal(somePhoneNumber)); + expect(testRequest.phoneNumber).to(beIdenticalTo(somePhoneNumber)); + }); + + it(@"should get image correctly", ^{ + expect(testRequest.locationImage).to(equal(someImage)); + expect(testRequest.locationImage).to(beIdenticalTo(someImage)); + }); + }); + + context(@"when parameters are not set", ^{ + it(@"should return nil for longitude", ^{ + expect(testRequest.longitudeDegrees).to(beNil()); + }); + + it(@"should return nil for latitude", ^{ + expect(testRequest.latitudeDegrees).to(beNil()); + }); + + it(@"should return nil for location", ^{ + expect(testRequest.locationName).to(beNil()); + }); + + it(@"should return nil for location description", ^{ + expect(testRequest.locationDescription).to(beNil()); + }); + + it(@"should return nil for address lines", ^{ + expect(testRequest.addressLines).to(beNil()); + }); + + it(@"should return nil for phone number", ^{ + expect(testRequest.phoneNumber).to(beNil()); + }); + + it(@"should return nil for image", ^{ + expect(testRequest.locationImage).to(beNil()); + }); + }); + }); + + describe(@"when initialized with a dictionary", ^{ + context(@"when parameters are set correctly", ^{ + beforeEach(^{ + someLongitude = @123.4567; + someLatitude = @65.4321; + someLocation = @"Livio"; + someLocationDescription = @"A great place to work"; + someAddressLines = @[@"3136 Hilton Rd", @"Ferndale, MI", @"48220"]; + somePhoneNumber = @"248-591-0333"; + someImage = [[SDLImage alloc] init]; + NSDictionary *initDict = @{ + NAMES_request: @{ + NAMES_parameters: @{ + NAMES_longitudeDegrees: someLongitude, + NAMES_latitudeDegrees: someLatitude, + NAMES_locationName: someLocation, + NAMES_locationDescription: someLocationDescription, + NAMES_addressLines: someAddressLines, + NAMES_phoneNumber: somePhoneNumber, + NAMES_locationImage: someImage + } + } + }; + + testRequest = [[SDLSendLocation alloc] initWithDictionary:[NSMutableDictionary dictionaryWithDictionary:initDict]]; + }); + + // Since all the properties are immutable, a copy should be executed as a retain, which means they should be identical + it(@"should get longitude correctly", ^{ + expect(testRequest.longitudeDegrees).to(equal(someLongitude)); + expect(testRequest.longitudeDegrees).to(beIdenticalTo(someLongitude)); + }); + + it(@"should get latitude correctly", ^{ + expect(testRequest.latitudeDegrees).to(equal(someLatitude)); + expect(testRequest.latitudeDegrees).to(beIdenticalTo(someLatitude)); + }); + + it(@"should get location correctly", ^{ + expect(testRequest.locationName).to(equal(someLocation)); + expect(testRequest.locationName).to(beIdenticalTo(someLocation)); + }); + + it(@"should get location description correctly", ^{ + expect(testRequest.locationDescription).to(equal(someLocationDescription)); + expect(testRequest.locationDescription).to(beIdenticalTo(someLocationDescription)); + }); + + it(@"should get address lines correctly", ^{ + expect(testRequest.addressLines).to(equal(someAddressLines)); + expect(testRequest.addressLines).to(beIdenticalTo(someAddressLines)); + }); + + it(@"should get phone number correctly", ^{ + expect(testRequest.phoneNumber).to(equal(somePhoneNumber)); + expect(testRequest.phoneNumber).to(beIdenticalTo(somePhoneNumber)); + }); + + it(@"should get image correctly", ^{ + expect(testRequest.locationImage).to(equal(someImage)); + expect(testRequest.locationImage).to(beIdenticalTo(someImage)); + }); + }); + + context(@"when parameters are not set", ^{ + beforeEach(^{ + NSDictionary *initDict = @{ + NAMES_request: @{ + NAMES_parameters: @{} + } + }; + + testRequest = [[SDLSendLocation alloc] initWithDictionary:[NSMutableDictionary dictionaryWithDictionary:initDict]]; + }); + + it(@"should return nil for longitude", ^{ + expect(testRequest.longitudeDegrees).to(beNil()); + }); + + it(@"should return nil for latitude", ^{ + expect(testRequest.latitudeDegrees).to(beNil()); + }); + + it(@"should return nil for location", ^{ + expect(testRequest.locationName).to(beNil()); + }); + + it(@"should return nil for location description", ^{ + expect(testRequest.locationDescription).to(beNil()); + }); + + it(@"should return nil for address lines", ^{ + expect(testRequest.addressLines).to(beNil()); + }); + + it(@"should return nil for phone number", ^{ + expect(testRequest.phoneNumber).to(beNil()); + }); + + it(@"should return nil for image", ^{ + expect(testRequest.locationImage).to(beNil()); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetAppIconSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetAppIconSpec.m new file mode 100644 index 000000000..9c24c9e91 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetAppIconSpec.m @@ -0,0 +1,42 @@ +// +// SDLSetAppIconSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSetAppIcon.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSetAppIconSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSetAppIcon* testRequest = [[SDLSetAppIcon alloc] init]; + + testRequest.syncFileName = @"A/File/Name"; + + expect(testRequest.syncFileName).to(equal(@"A/File/Name")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_syncFileName:@"A/File/Name"}, + NAMES_operation_name:NAMES_SetAppIcon}} mutableCopy]; + SDLSetAppIcon* testRequest = [[SDLSetAppIcon alloc] initWithDictionary:dict]; + + expect(testRequest.syncFileName).to(equal(@"A/File/Name")); + }); + + it(@"Should return nil if not set", ^ { + SDLSetAppIcon* testRequest = [[SDLSetAppIcon alloc] init]; + + expect(testRequest.syncFileName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetDisplayLayoutSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetDisplayLayoutSpec.m new file mode 100644 index 000000000..41e63323a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetDisplayLayoutSpec.m @@ -0,0 +1,42 @@ +// +// SDLSetDisplayLayoutSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSetDisplayLayout.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSetDisplayLayoutSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSetDisplayLayout* testRequest = [[SDLSetDisplayLayout alloc] init]; + + testRequest.displayLayout = @"wat"; + + expect(testRequest.displayLayout).to(equal(@"wat")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_displayLayout:@"wat"}, + NAMES_operation_name:NAMES_SetDisplayLayout}} mutableCopy]; + SDLSetDisplayLayout* testRequest = [[SDLSetDisplayLayout alloc] initWithDictionary:dict]; + + expect(testRequest.displayLayout).to(equal(@"wat")); + }); + + it(@"Should return nil if not set", ^ { + SDLSetDisplayLayout* testRequest = [[SDLSetDisplayLayout alloc] init]; + + expect(testRequest.displayLayout).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetGlobalPropertiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetGlobalPropertiesSpec.m new file mode 100644 index 000000000..437218896 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetGlobalPropertiesSpec.m @@ -0,0 +1,83 @@ +// +// SDLSetGlobalPropertiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImage.h" +#import "SDLKeyboardProperties.h" +#import "SDLNames.h" +#import "SDLSetGlobalProperties.h" +#import "SDLTTSChunk.h" +#import "SDLVrHelpItem.h" + + +QuickSpecBegin(SDLSetGlobalPropertiesSpec) + +SDLTTSChunk* chunk1 = [[SDLTTSChunk alloc] init]; +SDLTTSChunk* chunk2 = [[SDLTTSChunk alloc] init]; +SDLVRHelpItem* help = [[SDLVRHelpItem alloc] init]; +SDLImage* image = [[SDLImage alloc] init]; +SDLKeyboardProperties* keyboard = [[SDLKeyboardProperties alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSetGlobalProperties* testRequest = [[SDLSetGlobalProperties alloc] init]; + + testRequest.helpPrompt = [@[chunk1] mutableCopy]; + testRequest.timeoutPrompt = [@[chunk2] mutableCopy]; + testRequest.vrHelpTitle = @"vr"; + testRequest.vrHelp = [@[help] mutableCopy]; + testRequest.menuTitle = @"TheNewMenu"; + testRequest.menuIcon = image; + testRequest.keyboardProperties = keyboard; + + expect(testRequest.helpPrompt).to(equal([@[chunk1] mutableCopy])); + expect(testRequest.timeoutPrompt).to(equal([@[chunk2] mutableCopy])); + expect(testRequest.vrHelpTitle).to(equal(@"vr")); + expect(testRequest.vrHelp).to(equal([@[help] mutableCopy])); + expect(testRequest.menuTitle).to(equal(@"TheNewMenu")); + expect(testRequest.menuIcon).to(equal(image)); + expect(testRequest.keyboardProperties).to(equal(keyboard)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_helpPrompt:[@[chunk1] mutableCopy], + NAMES_timeoutPrompt:[@[chunk2] mutableCopy], + NAMES_vrHelpTitle:@"vr", + NAMES_vrHelp:[@[help] mutableCopy], + NAMES_menuTitle:@"TheNewMenu", + NAMES_menuIcon:image, + NAMES_keyboardProperties:keyboard}, + NAMES_operation_name:NAMES_SetGlobalProperties}} mutableCopy]; + SDLSetGlobalProperties* testRequest = [[SDLSetGlobalProperties alloc] initWithDictionary:dict]; + + expect(testRequest.helpPrompt).to(equal([@[chunk1] mutableCopy])); + expect(testRequest.timeoutPrompt).to(equal([@[chunk2] mutableCopy])); + expect(testRequest.vrHelpTitle).to(equal(@"vr")); + expect(testRequest.vrHelp).to(equal([@[help] mutableCopy])); + expect(testRequest.menuTitle).to(equal(@"TheNewMenu")); + expect(testRequest.menuIcon).to(equal(image)); + expect(testRequest.keyboardProperties).to(equal(keyboard)); + }); + + it(@"Should return nil if not set", ^ { + SDLSetGlobalProperties* testRequest = [[SDLSetGlobalProperties alloc] init]; + + expect(testRequest.helpPrompt).to(beNil()); + expect(testRequest.timeoutPrompt).to(beNil()); + expect(testRequest.vrHelpTitle).to(beNil()); + expect(testRequest.vrHelp).to(beNil()); + expect(testRequest.menuTitle).to(beNil()); + expect(testRequest.menuIcon).to(beNil()); + expect(testRequest.keyboardProperties).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetMediaClockTimerSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetMediaClockTimerSpec.m new file mode 100644 index 000000000..8d2a9a36e --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSetMediaClockTimerSpec.m @@ -0,0 +1,58 @@ +// +// SDLSetMediaClockTimerSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLSetMediaClockTimer.h" +#import "SDLStartTime.h" +#import "SDLUpdateMode.h" + + +QuickSpecBegin(SDLSetMediaClockTimerSpec) + +SDLStartTime* time1 = [[SDLStartTime alloc] init]; +SDLStartTime* time2 = [[SDLStartTime alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSetMediaClockTimer* testRequest = [[SDLSetMediaClockTimer alloc] init]; + + testRequest.startTime = time1; + testRequest.endTime = time2; + testRequest.updateMode = [SDLUpdateMode COUNTUP]; + + expect(testRequest.startTime).to(equal(time1)); + expect(testRequest.endTime).to(equal(time2)); + expect(testRequest.updateMode).to(equal([SDLUpdateMode COUNTUP])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_startTime:time1, + NAMES_endTime:time2, + NAMES_updateMode:[SDLUpdateMode COUNTUP]}, + NAMES_operation_name:NAMES_SetMediaClockTimer}} mutableCopy]; + SDLSetMediaClockTimer* testRequest = [[SDLSetMediaClockTimer alloc] initWithDictionary:dict]; + + expect(testRequest.startTime).to(equal(time1)); + expect(testRequest.endTime).to(equal(time2)); + expect(testRequest.updateMode).to(equal([SDLUpdateMode COUNTUP])); + }); + + it(@"Should return nil if not set", ^ { + SDLSetMediaClockTimer* testRequest = [[SDLSetMediaClockTimer alloc] init]; + + expect(testRequest.startTime).to(beNil()); + expect(testRequest.endTime).to(beNil()); + expect(testRequest.updateMode).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLShowConstantTBTSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLShowConstantTBTSpec.m new file mode 100644 index 000000000..3af100462 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLShowConstantTBTSpec.m @@ -0,0 +1,99 @@ +// +// SDLShowConstantTBTSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLShowConstantTBT.h" +#import "SDLSoftButton.h" + + +QuickSpecBegin(SDLShowConstantTBTSpec) + +SDLImage* image1 = [[SDLImage alloc] init]; +SDLImage* image2 = [[SDLImage alloc] init]; +SDLSoftButton* button = [[SDLSoftButton alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLShowConstantTBT* testRequest = [[SDLShowConstantTBT alloc] init]; + + testRequest.navigationText1 = @"nav1"; + testRequest.navigationText2 = @"nav2"; + testRequest.eta = @"4/1/7015"; + testRequest.timeToDestination = @"5000 Years"; + testRequest.totalDistance = @"1 parsec"; + testRequest.turnIcon = image1; + testRequest.nextTurnIcon = image2; + testRequest.distanceToManeuver = @2; + testRequest.distanceToManeuverScale = @4; + testRequest.maneuverComplete = @NO; + testRequest.softButtons = [@[button] mutableCopy]; + + expect(testRequest.navigationText1).to(equal(@"nav1")); + expect(testRequest.navigationText2).to(equal(@"nav2")); + expect(testRequest.eta).to(equal(@"4/1/7015")); + expect(testRequest.timeToDestination).to(equal(@"5000 Years")); + expect(testRequest.totalDistance).to(equal(@"1 parsec")); + expect(testRequest.turnIcon).to(equal(image1)); + expect(testRequest.nextTurnIcon).to(equal(image2)); + expect(testRequest.distanceToManeuver).to(equal(@2)); + expect(testRequest.distanceToManeuverScale).to(equal(@4)); + expect(testRequest.maneuverComplete).to(equal(@NO)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_navigationText1:@"nav1", + NAMES_navigationText2:@"nav2", + NAMES_eta:@"4/1/7015", + NAMES_timeToDestination:@"5000 Years", + NAMES_totalDistance:@"1 parsec", + NAMES_turnIcon:image1, + NAMES_nextTurnIcon:image2, + NAMES_distanceToManeuver:@2, + NAMES_distanceToManeuverScale:@4, + NAMES_maneuverComplete:@NO, + NAMES_softButtons:[@[button] mutableCopy]}, + NAMES_operation_name:NAMES_ShowConstantTBT}} mutableCopy]; + SDLShowConstantTBT* testRequest = [[SDLShowConstantTBT alloc] initWithDictionary:dict]; + + expect(testRequest.navigationText1).to(equal(@"nav1")); + expect(testRequest.navigationText2).to(equal(@"nav2")); + expect(testRequest.eta).to(equal(@"4/1/7015")); + expect(testRequest.timeToDestination).to(equal(@"5000 Years")); + expect(testRequest.totalDistance).to(equal(@"1 parsec")); + expect(testRequest.turnIcon).to(equal(image1)); + expect(testRequest.nextTurnIcon).to(equal(image2)); + expect(testRequest.distanceToManeuver).to(equal(@2)); + expect(testRequest.distanceToManeuverScale).to(equal(@4)); + expect(testRequest.maneuverComplete).to(equal(@NO)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLShowConstantTBT* testRequest = [[SDLShowConstantTBT alloc] init]; + + expect(testRequest.navigationText1).to(beNil()); + expect(testRequest.navigationText2).to(beNil()); + expect(testRequest.eta).to(beNil()); + expect(testRequest.timeToDestination).to(beNil()); + expect(testRequest.totalDistance).to(beNil()); + expect(testRequest.turnIcon).to(beNil()); + expect(testRequest.nextTurnIcon).to(beNil()); + expect(testRequest.distanceToManeuver).to(beNil()); + expect(testRequest.distanceToManeuverScale).to(beNil()); + expect(testRequest.maneuverComplete).to(beNil()); + expect(testRequest.softButtons).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLShowSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLShowSpec.m new file mode 100644 index 000000000..3058872e6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLShowSpec.m @@ -0,0 +1,105 @@ +// +// SDLShowSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLShow.h" +#import "SDLSoftButton.h" +#import "SDLTextAlignment.h" + + +QuickSpecBegin(SDLShowSpec) + +SDLImage* image1 = [[SDLImage alloc] init]; +SDLImage* image2 = [[SDLImage alloc] init]; +SDLSoftButton* button = [[SDLSoftButton alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLShow* testRequest = [[SDLShow alloc] init]; + + testRequest.mainField1 = @"field1"; + testRequest.mainField2 = @"field2"; + testRequest.mainField3 = @"field3"; + testRequest.mainField4 = @"field4"; + testRequest.alignment = [SDLTextAlignment LEFT_ALIGNED]; + testRequest.statusBar = @"status"; + testRequest.mediaClock = @"TheTime"; + testRequest.mediaTrack = @"In The Clear"; + testRequest.graphic = image1; + testRequest.secondaryGraphic = image2; + testRequest.softButtons = [@[button] mutableCopy]; + testRequest.customPresets = [@[@"preset1", @"preset2"] mutableCopy]; + + expect(testRequest.mainField1).to(equal(@"field1")); + expect(testRequest.mainField2).to(equal(@"field2")); + expect(testRequest.mainField3).to(equal(@"field3")); + expect(testRequest.mainField4).to(equal(@"field4")); + expect(testRequest.alignment).to(equal([SDLTextAlignment LEFT_ALIGNED])); + expect(testRequest.statusBar).to(equal(@"status")); + expect(testRequest.mediaClock).to(equal(@"TheTime")); + expect(testRequest.mediaTrack).to(equal(@"In The Clear")); + expect(testRequest.graphic).to(equal(image1)); + expect(testRequest.secondaryGraphic).to(equal(image2)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + expect(testRequest.customPresets).to(equal([@[@"preset1", @"preset2"] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_mainField1:@"field1", + NAMES_mainField2:@"field2", + NAMES_mainField3:@"field3", + NAMES_mainField4:@"field4", + NAMES_alignment:[SDLTextAlignment LEFT_ALIGNED], + NAMES_statusBar:@"status", + NAMES_mediaClock:@"TheTime", + NAMES_mediaTrack:@"In The Clear", + NAMES_graphic:image1, + NAMES_secondaryGraphic:image2, + NAMES_softButtons:[@[button] mutableCopy], + NAMES_customPresets:[@[@"preset1", @"preset2"] mutableCopy]}, + NAMES_operation_name:NAMES_Show}} mutableCopy]; + SDLShow* testRequest = [[SDLShow alloc] initWithDictionary:dict]; + + expect(testRequest.mainField1).to(equal(@"field1")); + expect(testRequest.mainField2).to(equal(@"field2")); + expect(testRequest.mainField3).to(equal(@"field3")); + expect(testRequest.mainField4).to(equal(@"field4")); + expect(testRequest.alignment).to(equal([SDLTextAlignment LEFT_ALIGNED])); + expect(testRequest.statusBar).to(equal(@"status")); + expect(testRequest.mediaClock).to(equal(@"TheTime")); + expect(testRequest.mediaTrack).to(equal(@"In The Clear")); + expect(testRequest.graphic).to(equal(image1)); + expect(testRequest.secondaryGraphic).to(equal(image2)); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + expect(testRequest.customPresets).to(equal([@[@"preset1", @"preset2"] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLShow* testRequest = [[SDLShow alloc] init]; + + expect(testRequest.mainField1).to(beNil()); + expect(testRequest.mainField2).to(beNil()); + expect(testRequest.mainField3).to(beNil()); + expect(testRequest.mainField4).to(beNil()); + expect(testRequest.alignment).to(beNil()); + expect(testRequest.statusBar).to(beNil()); + expect(testRequest.mediaClock).to(beNil()); + expect(testRequest.mediaTrack).to(beNil()); + expect(testRequest.graphic).to(beNil()); + expect(testRequest.secondaryGraphic).to(beNil()); + expect(testRequest.softButtons).to(beNil()); + expect(testRequest.customPresets).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSliderSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSliderSpec.m new file mode 100644 index 000000000..7455bcf51 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSliderSpec.m @@ -0,0 +1,62 @@ +// +// SDLSliderSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSlider.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSliderSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSlider* testRequest = [[SDLSlider alloc] init]; + + testRequest.numTicks = @2; + testRequest.position = @1; + testRequest.sliderHeader = @"Head"; + testRequest.sliderFooter = [@[@"LeftFoot", @"RightFoot"] mutableCopy]; + testRequest.timeout = @2000; + + expect(testRequest.numTicks).to(equal(@2)); + expect(testRequest.position).to(equal(@1)); + expect(testRequest.sliderHeader).to(equal(@"Head")); + expect(testRequest.sliderFooter).to(equal([@[@"LeftFoot", @"RightFoot"] mutableCopy])); + expect(testRequest.timeout).to(equal(@2000)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_numTicks:@2, + NAMES_position:@1, + NAMES_sliderHeader:@"Head", + NAMES_sliderFooter:[@[@"LeftFoot", @"RightFoot"] mutableCopy], + NAMES_timeout:@2000}, + NAMES_operation_name:NAMES_Slider}} mutableCopy]; + SDLSlider* testRequest = [[SDLSlider alloc] initWithDictionary:dict]; + + expect(testRequest.numTicks).to(equal(@2)); + expect(testRequest.position).to(equal(@1)); + expect(testRequest.sliderHeader).to(equal(@"Head")); + expect(testRequest.sliderFooter).to(equal([@[@"LeftFoot", @"RightFoot"] mutableCopy])); + expect(testRequest.timeout).to(equal(@2000)); + }); + + it(@"Should return nil if not set", ^ { + SDLSlider* testRequest = [[SDLSlider alloc] init]; + + expect(testRequest.numTicks).to(beNil()); + expect(testRequest.position).to(beNil()); + expect(testRequest.sliderHeader).to(beNil()); + expect(testRequest.sliderFooter).to(beNil()); + expect(testRequest.timeout).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSpeakSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSpeakSpec.m new file mode 100644 index 000000000..dd6b6a400 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSpeakSpec.m @@ -0,0 +1,45 @@ +// +// SDLSpeakSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSpeak.h" +#import "SDLTTSChunk.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSpeakSpec) + +SDLTTSChunk* chunk = [[SDLTTSChunk alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSpeak* testRequest = [[SDLSpeak alloc] init]; + + testRequest.ttsChunks = [@[chunk] mutableCopy]; + + expect(testRequest.ttsChunks).to(equal([@[chunk] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_ttsChunks:[@[chunk] mutableCopy]}, + NAMES_operation_name:NAMES_Speak}} mutableCopy]; + SDLSpeak* testRequest = [[SDLSpeak alloc] initWithDictionary:dict]; + + expect(testRequest.ttsChunks).to(equal([@[chunk] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLSpeak* testRequest = [[SDLSpeak alloc] init]; + + expect(testRequest.ttsChunks).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSubscribeButtonSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSubscribeButtonSpec.m new file mode 100644 index 000000000..d51ae33a6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSubscribeButtonSpec.m @@ -0,0 +1,44 @@ +// +// SDLSubscribeButtonSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonName.h" +#import "SDLNames.h" +#import "SDLSubscribeButton.h" + + +QuickSpecBegin(SDLSubscribeButtonSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSubscribeButton* testRequest = [[SDLSubscribeButton alloc] init]; + + testRequest.buttonName = [SDLButtonName PRESET_5]; + + expect(testRequest.buttonName).to(equal([SDLButtonName PRESET_5])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_buttonName:[SDLButtonName PRESET_5]}, + NAMES_operation_name:NAMES_SubscribeButton}} mutableCopy]; + SDLSubscribeButton* testRequest = [[SDLSubscribeButton alloc] initWithDictionary:dict]; + + expect(testRequest.buttonName).to(equal([SDLButtonName PRESET_5])); + }); + + it(@"Should return nil if not set", ^ { + SDLSubscribeButton* testRequest = [[SDLSubscribeButton alloc] init]; + + expect(testRequest.buttonName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSubscribeVehicleDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSubscribeVehicleDataSpec.m new file mode 100644 index 000000000..c35d45db3 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSubscribeVehicleDataSpec.m @@ -0,0 +1,157 @@ +// +// SDLSubscribeVehicleDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSubscribeVehicleData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSubscribeVehicleDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSubscribeVehicleData* testRequest = [[SDLSubscribeVehicleData alloc] init]; + + testRequest.gps = @YES; + testRequest.speed = @NO; + testRequest.rpm = @YES; + testRequest.fuelLevel = @NO; + testRequest.fuelLevel_State = @YES; + testRequest.instantFuelConsumption = @NO; + testRequest.externalTemperature = @YES; + testRequest.prndl = @YES; + testRequest.tirePressure = @NO; + testRequest.odometer = @YES; + testRequest.beltStatus = @NO; + testRequest.bodyInformation = @YES; + testRequest.deviceStatus = @NO; + testRequest.driverBraking = @YES; + testRequest.wiperStatus = @NO; + testRequest.headLampStatus = @YES; + testRequest.engineTorque = @NO; + testRequest.accPedalPosition = @YES; + testRequest.steeringWheelAngle = @NO; + testRequest.eCallInfo = @YES; + testRequest.airbagStatus = @NO; + testRequest.emergencyEvent = @YES; + testRequest.clusterModeStatus = @NO; + testRequest.myKey = @YES; + + expect(testRequest.gps).to(equal(@YES)); + expect(testRequest.speed).to(equal(@NO)); + expect(testRequest.rpm).to(equal(@YES)); + expect(testRequest.fuelLevel).to(equal(@NO)); + expect(testRequest.fuelLevel_State).to(equal(@YES)); + expect(testRequest.instantFuelConsumption).to(equal(@NO)); + expect(testRequest.externalTemperature).to(equal(@YES)); + expect(testRequest.prndl).to(equal(@YES)); + expect(testRequest.tirePressure).to(equal(@NO)); + expect(testRequest.odometer).to(equal(@YES)); + expect(testRequest.beltStatus).to(equal(@NO)); + expect(testRequest.bodyInformation).to(equal(@YES)); + expect(testRequest.deviceStatus).to(equal(@NO)); + expect(testRequest.driverBraking).to(equal(@YES)); + expect(testRequest.wiperStatus).to(equal(@NO)); + expect(testRequest.headLampStatus).to(equal(@YES)); + expect(testRequest.engineTorque).to(equal(@NO)); + expect(testRequest.accPedalPosition).to(equal(@YES)); + expect(testRequest.steeringWheelAngle).to(equal(@NO)); + expect(testRequest.eCallInfo).to(equal(@YES)); + expect(testRequest.airbagStatus).to(equal(@NO)); + expect(testRequest.emergencyEvent).to(equal(@YES)); + expect(testRequest.clusterModeStatus).to(equal(@NO)); + expect(testRequest.myKey).to(equal(@YES)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_gps:@YES, + NAMES_speed:@NO, + NAMES_rpm:@YES, + NAMES_fuelLevel:@NO, + NAMES_fuelLevel_State:@YES, + NAMES_instantFuelConsumption:@NO, + NAMES_externalTemperature:@YES, + NAMES_prndl:@YES, + NAMES_tirePressure:@NO, + NAMES_odometer:@YES, + NAMES_beltStatus:@NO, + NAMES_bodyInformation:@YES, + NAMES_deviceStatus:@NO, + NAMES_driverBraking:@YES, + NAMES_wiperStatus:@NO, + NAMES_headLampStatus:@YES, + NAMES_engineTorque:@NO, + NAMES_accPedalPosition:@YES, + NAMES_steeringWheelAngle:@NO, + NAMES_eCallInfo:@YES, + NAMES_airbagStatus:@NO, + NAMES_emergencyEvent:@YES, + NAMES_clusterModeStatus:@NO, + NAMES_myKey:@YES}, + NAMES_operation_name:NAMES_SubscribeVehicleData}} mutableCopy]; + SDLSubscribeVehicleData* testRequest = [[SDLSubscribeVehicleData alloc] initWithDictionary:dict]; + + expect(testRequest.gps).to(equal(@YES)); + expect(testRequest.speed).to(equal(@NO)); + expect(testRequest.rpm).to(equal(@YES)); + expect(testRequest.fuelLevel).to(equal(@NO)); + expect(testRequest.fuelLevel_State).to(equal(@YES)); + expect(testRequest.instantFuelConsumption).to(equal(@NO)); + expect(testRequest.externalTemperature).to(equal(@YES)); + expect(testRequest.prndl).to(equal(@YES)); + expect(testRequest.tirePressure).to(equal(@NO)); + expect(testRequest.odometer).to(equal(@YES)); + expect(testRequest.beltStatus).to(equal(@NO)); + expect(testRequest.bodyInformation).to(equal(@YES)); + expect(testRequest.deviceStatus).to(equal(@NO)); + expect(testRequest.driverBraking).to(equal(@YES)); + expect(testRequest.wiperStatus).to(equal(@NO)); + expect(testRequest.headLampStatus).to(equal(@YES)); + expect(testRequest.engineTorque).to(equal(@NO)); + expect(testRequest.accPedalPosition).to(equal(@YES)); + expect(testRequest.steeringWheelAngle).to(equal(@NO)); + expect(testRequest.eCallInfo).to(equal(@YES)); + expect(testRequest.airbagStatus).to(equal(@NO)); + expect(testRequest.emergencyEvent).to(equal(@YES)); + expect(testRequest.clusterModeStatus).to(equal(@NO)); + expect(testRequest.myKey).to(equal(@YES)); + }); + + it(@"Should return nil if not set", ^ { + SDLSubscribeVehicleData* testRequest = [[SDLSubscribeVehicleData alloc] init]; + + expect(testRequest.gps).to(beNil()); + expect(testRequest.speed).to(beNil()); + expect(testRequest.rpm).to(beNil()); + expect(testRequest.fuelLevel).to(beNil()); + expect(testRequest.fuelLevel_State).to(beNil()); + expect(testRequest.instantFuelConsumption).to(beNil()); + expect(testRequest.externalTemperature).to(beNil()); + expect(testRequest.prndl).to(beNil()); + expect(testRequest.tirePressure).to(beNil()); + expect(testRequest.odometer).to(beNil()); + expect(testRequest.beltStatus).to(beNil()); + expect(testRequest.bodyInformation).to(beNil()); + expect(testRequest.deviceStatus).to(beNil()); + expect(testRequest.driverBraking).to(beNil()); + expect(testRequest.wiperStatus).to(beNil()); + expect(testRequest.headLampStatus).to(beNil()); + expect(testRequest.engineTorque).to(beNil()); + expect(testRequest.accPedalPosition).to(beNil()); + expect(testRequest.steeringWheelAngle).to(beNil()); + expect(testRequest.eCallInfo).to(beNil()); + expect(testRequest.airbagStatus).to(beNil()); + expect(testRequest.emergencyEvent).to(beNil()); + expect(testRequest.clusterModeStatus).to(beNil()); + expect(testRequest.myKey).to(beNil()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSyncPDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSyncPDataSpec.m new file mode 100644 index 000000000..300583447 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSyncPDataSpec.m @@ -0,0 +1,16 @@ +// +// SDLSyncPDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSyncPData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSyncPDataSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSystemRequestSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSystemRequestSpec.m new file mode 100644 index 000000000..ade3fb762 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLSystemRequestSpec.m @@ -0,0 +1,48 @@ +// +// SDLSystemRequestSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSystemRequest.h" +#import "SDLRequestType.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSystemRequestSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSystemRequest* testRequest = [[SDLSystemRequest alloc] init]; + + testRequest.requestType = [SDLRequestType AUTH_REQUEST]; + testRequest.fileName = @"AnotherFile"; + + expect(testRequest.requestType).to(equal([SDLRequestType AUTH_REQUEST])); + expect(testRequest.fileName).to(equal(@"AnotherFile")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_requestType:[SDLRequestType AUTH_REQUEST], + NAMES_fileName:@"AnotherFile"}, + NAMES_operation_name:NAMES_SystemRequest}} mutableCopy]; + SDLSystemRequest* testRequest = [[SDLSystemRequest alloc] initWithDictionary:dict]; + + expect(testRequest.requestType).to(equal([SDLRequestType AUTH_REQUEST])); + expect(testRequest.fileName).to(equal(@"AnotherFile")); + }); + + it(@"Should return nil if not set", ^ { + SDLSystemRequest* testRequest = [[SDLSystemRequest alloc] init]; + + expect(testRequest.requestType).to(beNil()); + expect(testRequest.fileName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnregisterAppInterfaceSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnregisterAppInterfaceSpec.m new file mode 100644 index 000000000..746c07d2b --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnregisterAppInterfaceSpec.m @@ -0,0 +1,16 @@ +// +// SDLUnregisterAppInterfaceSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUnregisterAppInterface.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLUnregisterAppInterfaceSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnsubscribeButtonSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnsubscribeButtonSpec.m new file mode 100644 index 000000000..4c0bfc3f1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnsubscribeButtonSpec.m @@ -0,0 +1,44 @@ +// +// SDLUnsubscribeButtonSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonName.h" +#import "SDLNames.h" +#import "SDLUnsubscribeButton.h" + + +QuickSpecBegin(SDLUnsubscribeButtonSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLUnsubscribeButton* testRequest = [[SDLUnsubscribeButton alloc] init]; + + testRequest.buttonName = [SDLButtonName PRESET_0]; + + expect(testRequest.buttonName).to(equal([SDLButtonName PRESET_0])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_buttonName:[SDLButtonName PRESET_0]}, + NAMES_operation_name:NAMES_UnsubscribeButton}} mutableCopy]; + SDLUnsubscribeButton* testRequest = [[SDLUnsubscribeButton alloc] initWithDictionary:dict]; + + expect(testRequest.buttonName).to(equal([SDLButtonName PRESET_0])); + }); + + it(@"Should return nil if not set", ^ { + SDLUnsubscribeButton* testRequest = [[SDLUnsubscribeButton alloc] init]; + + expect(testRequest.buttonName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnsubscribeVehicleDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnsubscribeVehicleDataSpec.m new file mode 100644 index 000000000..1bb2cb125 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUnsubscribeVehicleDataSpec.m @@ -0,0 +1,157 @@ +// +// SDLUnsubscribeVehicleDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUnsubscribeVehicleData.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLUnsubscribeVehicleDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLUnsubscribeVehicleData* testRequest = [[SDLUnsubscribeVehicleData alloc] init]; + + testRequest.gps = @YES; + testRequest.speed = @YES; + testRequest.rpm = @YES; + testRequest.fuelLevel = @YES; + testRequest.fuelLevel_State = @YES; + testRequest.instantFuelConsumption = @YES; + testRequest.externalTemperature = @YES; + testRequest.prndl = @YES; + testRequest.tirePressure = @YES; + testRequest.odometer = @YES; + testRequest.beltStatus = @YES; + testRequest.bodyInformation = @YES; + testRequest.deviceStatus = @YES; + testRequest.driverBraking = @YES; + testRequest.wiperStatus = @YES; + testRequest.headLampStatus = @YES; + testRequest.engineTorque = @YES; + testRequest.accPedalPosition = @YES; + testRequest.steeringWheelAngle = @YES; + testRequest.eCallInfo = @YES; + testRequest.airbagStatus = @YES; + testRequest.emergencyEvent = @YES; + testRequest.clusterModeStatus = @YES; + testRequest.myKey = @YES; + + expect(testRequest.gps).to(equal(@YES)); + expect(testRequest.speed).to(equal(@YES)); + expect(testRequest.rpm).to(equal(@YES)); + expect(testRequest.fuelLevel).to(equal(@YES)); + expect(testRequest.fuelLevel_State).to(equal(@YES)); + expect(testRequest.instantFuelConsumption).to(equal(@YES)); + expect(testRequest.externalTemperature).to(equal(@YES)); + expect(testRequest.prndl).to(equal(@YES)); + expect(testRequest.tirePressure).to(equal(@YES)); + expect(testRequest.odometer).to(equal(@YES)); + expect(testRequest.beltStatus).to(equal(@YES)); + expect(testRequest.bodyInformation).to(equal(@YES)); + expect(testRequest.deviceStatus).to(equal(@YES)); + expect(testRequest.driverBraking).to(equal(@YES)); + expect(testRequest.wiperStatus).to(equal(@YES)); + expect(testRequest.headLampStatus).to(equal(@YES)); + expect(testRequest.engineTorque).to(equal(@YES)); + expect(testRequest.accPedalPosition).to(equal(@YES)); + expect(testRequest.steeringWheelAngle).to(equal(@YES)); + expect(testRequest.eCallInfo).to(equal(@YES)); + expect(testRequest.airbagStatus).to(equal(@YES)); + expect(testRequest.emergencyEvent).to(equal(@YES)); + expect(testRequest.clusterModeStatus).to(equal(@YES)); + expect(testRequest.myKey).to(equal(@YES)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_gps:@YES, + NAMES_speed:@YES, + NAMES_rpm:@YES, + NAMES_fuelLevel:@YES, + NAMES_fuelLevel_State:@YES, + NAMES_instantFuelConsumption:@YES, + NAMES_externalTemperature:@YES, + NAMES_prndl:@YES, + NAMES_tirePressure:@YES, + NAMES_odometer:@YES, + NAMES_beltStatus:@YES, + NAMES_bodyInformation:@YES, + NAMES_deviceStatus:@YES, + NAMES_driverBraking:@YES, + NAMES_wiperStatus:@YES, + NAMES_headLampStatus:@YES, + NAMES_engineTorque:@YES, + NAMES_accPedalPosition:@YES, + NAMES_steeringWheelAngle:@YES, + NAMES_eCallInfo:@YES, + NAMES_airbagStatus:@YES, + NAMES_emergencyEvent:@YES, + NAMES_clusterModeStatus:@YES, + NAMES_myKey:@YES}, + NAMES_operation_name:NAMES_UnsubscribeVehicleData}} mutableCopy]; + SDLUnsubscribeVehicleData* testRequest = [[SDLUnsubscribeVehicleData alloc] initWithDictionary:dict]; + + expect(testRequest.gps).to(equal(@YES)); + expect(testRequest.speed).to(equal(@YES)); + expect(testRequest.rpm).to(equal(@YES)); + expect(testRequest.fuelLevel).to(equal(@YES)); + expect(testRequest.fuelLevel_State).to(equal(@YES)); + expect(testRequest.instantFuelConsumption).to(equal(@YES)); + expect(testRequest.externalTemperature).to(equal(@YES)); + expect(testRequest.prndl).to(equal(@YES)); + expect(testRequest.tirePressure).to(equal(@YES)); + expect(testRequest.odometer).to(equal(@YES)); + expect(testRequest.beltStatus).to(equal(@YES)); + expect(testRequest.bodyInformation).to(equal(@YES)); + expect(testRequest.deviceStatus).to(equal(@YES)); + expect(testRequest.driverBraking).to(equal(@YES)); + expect(testRequest.wiperStatus).to(equal(@YES)); + expect(testRequest.headLampStatus).to(equal(@YES)); + expect(testRequest.engineTorque).to(equal(@YES)); + expect(testRequest.accPedalPosition).to(equal(@YES)); + expect(testRequest.steeringWheelAngle).to(equal(@YES)); + expect(testRequest.eCallInfo).to(equal(@YES)); + expect(testRequest.airbagStatus).to(equal(@YES)); + expect(testRequest.emergencyEvent).to(equal(@YES)); + expect(testRequest.clusterModeStatus).to(equal(@YES)); + expect(testRequest.myKey).to(equal(@YES)); + }); + + it(@"Should return nil if not set", ^ { + SDLUnsubscribeVehicleData* testRequest = [[SDLUnsubscribeVehicleData alloc] init]; + + expect(testRequest.gps).to(beNil()); + expect(testRequest.speed).to(beNil()); + expect(testRequest.rpm).to(beNil()); + expect(testRequest.fuelLevel).to(beNil()); + expect(testRequest.fuelLevel_State).to(beNil()); + expect(testRequest.instantFuelConsumption).to(beNil()); + expect(testRequest.externalTemperature).to(beNil()); + expect(testRequest.prndl).to(beNil()); + expect(testRequest.tirePressure).to(beNil()); + expect(testRequest.odometer).to(beNil()); + expect(testRequest.beltStatus).to(beNil()); + expect(testRequest.bodyInformation).to(beNil()); + expect(testRequest.deviceStatus).to(beNil()); + expect(testRequest.driverBraking).to(beNil()); + expect(testRequest.wiperStatus).to(beNil()); + expect(testRequest.headLampStatus).to(beNil()); + expect(testRequest.engineTorque).to(beNil()); + expect(testRequest.accPedalPosition).to(beNil()); + expect(testRequest.steeringWheelAngle).to(beNil()); + expect(testRequest.eCallInfo).to(beNil()); + expect(testRequest.airbagStatus).to(beNil()); + expect(testRequest.emergencyEvent).to(beNil()); + expect(testRequest.clusterModeStatus).to(beNil()); + expect(testRequest.myKey).to(beNil()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUpdateTurnListSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUpdateTurnListSpec.m new file mode 100644 index 000000000..ae1d55823 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLUpdateTurnListSpec.m @@ -0,0 +1,52 @@ +// +// SDLUpdateTurnListSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUpdateTurnList.h" +#import "SDLTurn.h" +#import "SDLSoftButton.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLUpdateTurnListSpec) + +SDLTurn* turn = [[SDLTurn alloc] init]; +SDLSoftButton* button = [[SDLSoftButton alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLUpdateTurnList* testRequest = [[SDLUpdateTurnList alloc] init]; + + testRequest.turnList = [@[turn] mutableCopy]; + testRequest.softButtons = [@[button] mutableCopy]; + + expect(testRequest.turnList).to(equal([@[turn] mutableCopy])); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_turnList:[@[turn] mutableCopy], + NAMES_softButtons:[@[button] mutableCopy]}, + NAMES_operation_name:NAMES_UpdateTurnList}} mutableCopy]; + SDLUpdateTurnList* testRequest = [[SDLUpdateTurnList alloc] initWithDictionary:dict]; + + expect(testRequest.turnList).to(equal([@[turn] mutableCopy])); + expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLUpdateTurnList* testRequest = [[SDLUpdateTurnList alloc] init]; + + expect(testRequest.turnList).to(beNil()); + expect(testRequest.softButtons).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAddCommandResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAddCommandResponseSpec.m new file mode 100644 index 000000000..ff1f36682 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAddCommandResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLAddCommandResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAddCommandResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAddCommandResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAddSubMenuResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAddSubMenuResponseSpec.m new file mode 100644 index 000000000..a351d0ee2 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAddSubMenuResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLAddSubMenuResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAddSubMenuResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAddSubMenuResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAlertManeuverResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAlertManeuverResponseSpec.m new file mode 100644 index 000000000..5b4860134 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAlertManeuverResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLAlertManeuverResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAlertManeuverResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAlertManeuverResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAlertResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAlertResponseSpec.m new file mode 100644 index 000000000..e29e23ed3 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLAlertResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLAlertResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAlertResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLAlertResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLChangeRegistrationResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLChangeRegistrationResponseSpec.m new file mode 100644 index 000000000..c6e0b27d9 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLChangeRegistrationResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLChangeRegistrationResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLChangeRegistrationResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLChangeRegistrationResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLCreateInteractionChoiceSetResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLCreateInteractionChoiceSetResponseSpec.m new file mode 100644 index 000000000..3b3d27e90 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLCreateInteractionChoiceSetResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLCreateInteractionChoiceSetResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCreateInteractionChoiceSetResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLCreateInteractionChoiceSetResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteCommandResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteCommandResponseSpec.m new file mode 100644 index 000000000..013702513 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteCommandResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLDeleteCommandResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteCommandResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteCommandResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteFileResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteFileResponseSpec.m new file mode 100644 index 000000000..64e8522c9 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteFileResponseSpec.m @@ -0,0 +1,42 @@ +// +// SDLDeleteFileResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteFileResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteFileResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeleteFileResponse* testResponse = [[SDLDeleteFileResponse alloc] init]; + + testResponse.spaceAvailable = @0; + + expect(testResponse.spaceAvailable).to(equal(@0)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_spaceAvailable:@0}, + NAMES_operation_name:NAMES_DeleteFile}} mutableCopy]; + SDLDeleteFileResponse* testResponse = [[SDLDeleteFileResponse alloc] initWithDictionary:dict]; + + expect(testResponse.spaceAvailable).to(equal(@0)); + }); + + it(@"Should return nil if not set", ^ { + SDLDeleteFileResponse* testResponse = [[SDLDeleteFileResponse alloc] init]; + + expect(testResponse.spaceAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteInteractionChoiceSetResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteInteractionChoiceSetResponseSpec.m new file mode 100644 index 000000000..4f3f0c4c1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteInteractionChoiceSetResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLDeleteInteractionChoiceSetResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteInteractionChoiceSetResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteInteractionChoiceSetResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteSubMenuResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteSubMenuResponseSpec.m new file mode 100644 index 000000000..c17b91d1c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDeleteSubMenuResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLDeleteSubMenuResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeleteSubMenuResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeleteSubMenuResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDiagnosticMessageResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDiagnosticMessageResponseSpec.m new file mode 100644 index 000000000..7507bbe5a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDiagnosticMessageResponseSpec.m @@ -0,0 +1,42 @@ +// +// SDLDiagnosticMessageResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDiagnosticMessageResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDiagnosticMessageResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDiagnosticMessageResponse* testResponse = [[SDLDiagnosticMessageResponse alloc] init]; + + testResponse.messageDataResult = [@[@3, @9, @27, @81] mutableCopy]; + + expect(testResponse.messageDataResult).to(equal([@[@3, @9, @27, @81] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_messageDataResult:[@[@3, @9, @27, @81] mutableCopy]}, + NAMES_operation_name:NAMES_DiagnosticMessage}} mutableCopy]; + SDLDiagnosticMessageResponse* testResponse = [[SDLDiagnosticMessageResponse alloc] initWithDictionary:dict]; + + expect(testResponse.messageDataResult).to(equal([@[@3, @9, @27, @81] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLDiagnosticMessageResponse* testResponse = [[SDLDiagnosticMessageResponse alloc] init]; + + expect(testResponse.messageDataResult).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDialNumberResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDialNumberResponseSpec.m new file mode 100644 index 000000000..2adf33aeb --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLDialNumberResponseSpec.m @@ -0,0 +1,10 @@ +// +// SDLDialNumberResponseSpec.m +// SmartDeviceLink-iOS + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +QuickSpecBegin(SDLDialNumberResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLEncodedSyncPDataResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLEncodedSyncPDataResponseSpec.m new file mode 100644 index 000000000..4324f0bb8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLEncodedSyncPDataResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLEncodedSyncPDataResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEncodedSyncPDataResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLEncodedSyncPDataResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLEndAudioPassThruResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLEndAudioPassThruResponseSpec.m new file mode 100644 index 000000000..5fcc7d6d8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLEndAudioPassThruResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLEndAudioPassThruResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEndAudioPassThruResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLEndAudioPassThruResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGenericResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGenericResponseSpec.m new file mode 100644 index 000000000..227aea92d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGenericResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLGenericResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLGenericResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLGenericResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetDTCsResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetDTCsResponseSpec.m new file mode 100644 index 000000000..150f9bd73 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetDTCsResponseSpec.m @@ -0,0 +1,47 @@ +// +// SDLGetDTCsResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLGetDTCsResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLGetDTCsResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLGetDTCsResponse* testResponse = [[SDLGetDTCsResponse alloc] init]; + + testResponse.ecuHeader = @404; + testResponse.dtc = [@[@"FFFF", @"FFFE", @"FFFD"] mutableCopy]; + + expect(testResponse.ecuHeader).to(equal(@404)); + expect(testResponse.dtc).to(equal([@[@"FFFF", @"FFFE", @"FFFD"] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_ecuHeader:@404, + NAMES_dtc:[@[@"FFFF", @"FFFE", @"FFFD"] mutableCopy]}, + NAMES_operation_name:NAMES_GetDTCs}} mutableCopy]; + SDLGetDTCsResponse* testResponse = [[SDLGetDTCsResponse alloc] initWithDictionary:dict]; + + expect(testResponse.ecuHeader).to(equal(@404)); + expect(testResponse.dtc).to(equal([@[@"FFFF", @"FFFE", @"FFFD"] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLGetDTCsResponse* testResponse = [[SDLGetDTCsResponse alloc] init]; + + expect(testResponse.ecuHeader).to(beNil()); + expect(testResponse.dtc).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetVehicleDataResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetVehicleDataResponseSpec.m new file mode 100644 index 000000000..d70e8f12b --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLGetVehicleDataResponseSpec.m @@ -0,0 +1,175 @@ +// +// SDLGetVehicleDataResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SmartDeviceLink.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLGetVehicleDataResponseSpec) + +SDLGPSData* gps = [[SDLGPSData alloc] init]; +SDLTireStatus* tires = [[SDLTireStatus alloc] init]; +SDLBeltStatus* belt = [[SDLBeltStatus alloc] init]; +SDLBodyInformation* body = [[SDLBodyInformation alloc] init]; +SDLDeviceStatus* device = [[SDLDeviceStatus alloc] init]; +SDLHeadLampStatus* headLamp = [[SDLHeadLampStatus alloc] init]; +SDLECallInfo* eCall = [[SDLECallInfo alloc] init]; +SDLAirbagStatus* airbag = [[SDLAirbagStatus alloc] init]; +SDLEmergencyEvent* event = [[SDLEmergencyEvent alloc] init]; +SDLClusterModeStatus* clusterMode = [[SDLClusterModeStatus alloc] init]; +SDLMyKey* myKey = [[SDLMyKey alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLGetVehicleDataResponse* testResponse = [[SDLGetVehicleDataResponse alloc] init]; + + testResponse.gps = gps; + testResponse.speed = @100; + testResponse.rpm = @3; + testResponse.fuelLevel = @99.9999; + testResponse.fuelLevel_State = [SDLComponentVolumeStatus FAULT]; + testResponse.instantFuelConsumption = @40.7; + testResponse.externalTemperature = @0; + testResponse.vin = @"6574839201"; + testResponse.prndl = [SDLPRNDL PARK]; + testResponse.tirePressure = tires; + testResponse.odometer = @70000; + testResponse.beltStatus = belt; + testResponse.bodyInformation = body; + testResponse.deviceStatus = device; + testResponse.driverBraking = [SDLVehicleDataEventStatus NO_EVENT]; + testResponse.wiperStatus = [SDLWiperStatus AUTO_HIGH]; + testResponse.headLampStatus = headLamp; + testResponse.engineTorque = @630.4; + testResponse.accPedalPosition = @0; + testResponse.steeringWheelAngle = @-1500; + testResponse.eCallInfo = eCall; + testResponse.airbagStatus = airbag; + testResponse.emergencyEvent = event; + testResponse.clusterModeStatus = clusterMode; + testResponse.myKey = myKey; + + expect(testResponse.gps).to(equal(gps)); + expect(testResponse.speed).to(equal(@100)); + expect(testResponse.rpm).to(equal(@3)); + expect(testResponse.fuelLevel).to(equal(@99.9999)); + expect(testResponse.fuelLevel_State).to(equal([SDLComponentVolumeStatus FAULT])); + expect(testResponse.instantFuelConsumption).to(equal(@40.7)); + expect(testResponse.externalTemperature).to(equal(@0)); + expect(testResponse.vin).to(equal(@"6574839201")); + expect(testResponse.prndl).to(equal([SDLPRNDL PARK])); + expect(testResponse.tirePressure).to(equal(tires)); + expect(testResponse.odometer).to(equal(@70000)); + expect(testResponse.beltStatus).to(equal(belt)); + expect(testResponse.bodyInformation).to(equal(body)); + expect(testResponse.deviceStatus).to(equal(device)); + expect(testResponse.driverBraking).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testResponse.wiperStatus).to(equal([SDLWiperStatus AUTO_HIGH])); + expect(testResponse.headLampStatus).to(equal(headLamp)); + expect(testResponse.engineTorque).to(equal(@630.4)); + expect(testResponse.accPedalPosition).to(equal(@0)); + expect(testResponse.steeringWheelAngle).to(equal(@-1500)); + expect(testResponse.eCallInfo).to(equal(eCall)); + expect(testResponse.airbagStatus).to(equal(airbag)); + expect(testResponse.emergencyEvent).to(equal(event)); + expect(testResponse.clusterModeStatus).to(equal(clusterMode)); + expect(testResponse.myKey).to(equal(myKey)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_notification: + @{NAMES_parameters: + @{NAMES_gps:gps, + NAMES_speed:@100, + NAMES_rpm:@3, + NAMES_fuelLevel:@99.9999, + NAMES_fuelLevel_State:[SDLComponentVolumeStatus FAULT], + NAMES_instantFuelConsumption:@40.7, + NAMES_externalTemperature:@0, + NAMES_vin:@"6574839201", + NAMES_prndl:[SDLPRNDL PARK], + NAMES_tirePressure:tires, + NAMES_odometer:@70000, + NAMES_beltStatus:belt, + NAMES_bodyInformation:body, + NAMES_deviceStatus:device, + NAMES_driverBraking:[SDLVehicleDataEventStatus NO_EVENT], + NAMES_wiperStatus:[SDLWiperStatus AUTO_HIGH], + NAMES_headLampStatus:headLamp, + NAMES_engineTorque:@630.4, + NAMES_accPedalPosition:@0, + NAMES_steeringWheelAngle:@-1500, + NAMES_eCallInfo:eCall, + NAMES_airbagStatus:airbag, + NAMES_emergencyEvent:event, + NAMES_clusterModeStatus:clusterMode, + NAMES_myKey:myKey}, + NAMES_operation_name:NAMES_GetVehicleData}} mutableCopy]; + SDLGetVehicleDataResponse* testResponse = [[SDLGetVehicleDataResponse alloc] initWithDictionary:dict]; + + expect(testResponse.gps).to(equal(gps)); + expect(testResponse.speed).to(equal(@100)); + expect(testResponse.rpm).to(equal(@3)); + expect(testResponse.fuelLevel).to(equal(@99.9999)); + expect(testResponse.fuelLevel_State).to(equal([SDLComponentVolumeStatus FAULT])); + expect(testResponse.instantFuelConsumption).to(equal(@40.7)); + expect(testResponse.externalTemperature).to(equal(@0)); + expect(testResponse.vin).to(equal(@"6574839201")); + expect(testResponse.prndl).to(equal([SDLPRNDL PARK])); + expect(testResponse.tirePressure).to(equal(tires)); + expect(testResponse.odometer).to(equal(@70000)); + expect(testResponse.beltStatus).to(equal(belt)); + expect(testResponse.bodyInformation).to(equal(body)); + expect(testResponse.deviceStatus).to(equal(device)); + expect(testResponse.driverBraking).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testResponse.wiperStatus).to(equal([SDLWiperStatus AUTO_HIGH])); + expect(testResponse.headLampStatus).to(equal(headLamp)); + expect(testResponse.engineTorque).to(equal(@630.4)); + expect(testResponse.accPedalPosition).to(equal(@0)); + expect(testResponse.steeringWheelAngle).to(equal(@-1500)); + expect(testResponse.eCallInfo).to(equal(eCall)); + expect(testResponse.airbagStatus).to(equal(airbag)); + expect(testResponse.emergencyEvent).to(equal(event)); + expect(testResponse.clusterModeStatus).to(equal(clusterMode)); + expect(testResponse.myKey).to(equal(myKey)); + }); + + it(@"Should return nil if not set", ^ { + SDLGetVehicleDataResponse* testResponse = [[SDLGetVehicleDataResponse alloc] init]; + + expect(testResponse.gps).to(beNil()); + expect(testResponse.speed).to(beNil()); + expect(testResponse.rpm).to(beNil()); + expect(testResponse.fuelLevel).to(beNil()); + expect(testResponse.fuelLevel_State).to(beNil()); + expect(testResponse.instantFuelConsumption).to(beNil()); + expect(testResponse.externalTemperature).to(beNil()); + expect(testResponse.vin).to(beNil()); + expect(testResponse.prndl).to(beNil()); + expect(testResponse.tirePressure).to(beNil()); + expect(testResponse.odometer).to(beNil()); + expect(testResponse.beltStatus).to(beNil()); + expect(testResponse.bodyInformation).to(beNil()); + expect(testResponse.deviceStatus).to(beNil()); + expect(testResponse.driverBraking).to(beNil()); + expect(testResponse.wiperStatus).to(beNil()); + expect(testResponse.headLampStatus).to(beNil()); + expect(testResponse.engineTorque).to(beNil()); + expect(testResponse.accPedalPosition).to(beNil()); + expect(testResponse.steeringWheelAngle).to(beNil()); + expect(testResponse.eCallInfo).to(beNil()); + expect(testResponse.airbagStatus).to(beNil()); + expect(testResponse.emergencyEvent).to(beNil()); + expect(testResponse.clusterModeStatus).to(beNil()); + expect(testResponse.myKey).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLListFilesResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLListFilesResponseSpec.m new file mode 100644 index 000000000..824bc7517 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLListFilesResponseSpec.m @@ -0,0 +1,47 @@ +// +// SDLListFilesResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLListFilesResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLListFilesResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLListFilesResponse* testResponse = [[SDLListFilesResponse alloc] init]; + + testResponse.filenames = [@[@"Music/music.mp3", @"Documents/document.txt", @"Downloads/format.exe"] mutableCopy]; + testResponse.spaceAvailable = @500000000; + + expect(testResponse.filenames).to(equal([@[@"Music/music.mp3", @"Documents/document.txt", @"Downloads/format.exe"] mutableCopy])); + expect(testResponse.spaceAvailable).to(equal(@500000000)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_filenames:[@[@"Music/music.mp3", @"Documents/document.txt", @"Downloads/format.exe"] mutableCopy], + NAMES_spaceAvailable:@500000000}, + NAMES_operation_name:NAMES_ListFiles}} mutableCopy]; + SDLListFilesResponse* testResponse = [[SDLListFilesResponse alloc] initWithDictionary:dict]; + + expect(testResponse.filenames).to(equal([@[@"Music/music.mp3", @"Documents/document.txt", @"Downloads/format.exe"] mutableCopy])); + expect(testResponse.spaceAvailable).to(equal(@500000000)); + }); + + it(@"Should return nil if not set", ^ { + SDLListFilesResponse* testResponse = [[SDLListFilesResponse alloc] init]; + + expect(testResponse.filenames).to(beNil()); + expect(testResponse.spaceAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPerformAudioPassThruResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPerformAudioPassThruResponseSpec.m new file mode 100644 index 000000000..eb661c3f2 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPerformAudioPassThruResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLPerformAudioPassThruResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPerformAudioPassThruResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLPerformAudioPassThruResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPerformInteractionResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPerformInteractionResponseSpec.m new file mode 100644 index 000000000..b32b44cd6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPerformInteractionResponseSpec.m @@ -0,0 +1,54 @@ +// +// SDLPerformInteractionResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPerformInteractionResponse.h" +#import "SDLNames.h" +#import "SDLTriggerSource.h" + + +QuickSpecBegin(SDLPerformInteractionResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPerformInteractionResponse* testResponse = [[SDLPerformInteractionResponse alloc] init]; + + testResponse.choiceID = @25; + testResponse.manualTextEntry = @"entry"; + testResponse.triggerSource = [SDLTriggerSource KEYBOARD]; + + expect(testResponse.choiceID).to(equal(@25)); + expect(testResponse.manualTextEntry).to(equal(@"entry")); + expect(testResponse.triggerSource).to(equal([SDLTriggerSource KEYBOARD])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_choiceID:@25, + NAMES_manualTextEntry:@"entry", + NAMES_triggerSource:[SDLTriggerSource KEYBOARD]}, + NAMES_operation_name:NAMES_PerformInteraction}} mutableCopy]; + SDLPerformInteractionResponse* testResponse = [[SDLPerformInteractionResponse alloc] initWithDictionary:dict]; + + expect(testResponse.choiceID).to(equal(@25)); + expect(testResponse.manualTextEntry).to(equal(@"entry")); + expect(testResponse.triggerSource).to(equal([SDLTriggerSource KEYBOARD])); + }); + + it(@"Should return nil if not set", ^ { + SDLPerformInteractionResponse* testResponse = [[SDLPerformInteractionResponse alloc] init]; + + expect(testResponse.choiceID).to(beNil()); + expect(testResponse.manualTextEntry).to(beNil()); + expect(testResponse.triggerSource).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPutFileResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPutFileResponseSpec.m new file mode 100644 index 000000000..565f97a79 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLPutFileResponseSpec.m @@ -0,0 +1,42 @@ +// +// SDLPutFileResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPutFileResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLPutFileResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPutFileResponse* testResponse = [[SDLPutFileResponse alloc] init]; + + testResponse.spaceAvailable = @1248; + + expect(testResponse.spaceAvailable).to(equal(@1248)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_spaceAvailable:@1248}, + NAMES_operation_name:NAMES_PutFile}} mutableCopy]; + SDLPutFileResponse* testResponse = [[SDLPutFileResponse alloc] initWithDictionary:dict]; + + expect(testResponse.spaceAvailable).to(equal(@1248)); + }); + + it(@"Should return nil if not set", ^ { + SDLPutFileResponse* testResponse = [[SDLPutFileResponse alloc] init]; + + expect(testResponse.spaceAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLReadDIDResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLReadDIDResponseSpec.m new file mode 100644 index 000000000..0ae2c5b9d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLReadDIDResponseSpec.m @@ -0,0 +1,45 @@ +// +// SDLReadDIDResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLReadDIDResponse.h" +#import "SDLDIDResult.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLReadDIDResponseSpec) + +SDLDIDResult* result = [[SDLDIDResult alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLReadDIDResponse* testResponse = [[SDLReadDIDResponse alloc] init]; + + testResponse.didResult = [@[result] mutableCopy]; + + expect(testResponse.didResult).to(equal([@[result] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_didResult:[@[result] mutableCopy]}, + NAMES_operation_name:NAMES_ReadDID}} mutableCopy]; + SDLReadDIDResponse* testResponse = [[SDLReadDIDResponse alloc] initWithDictionary:dict]; + + expect(testResponse.didResult).to(equal([@[result] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLReadDIDResponse* testResponse = [[SDLReadDIDResponse alloc] init]; + + expect(testResponse.didResult).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLRegisterAppInterfaceResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLRegisterAppInterfaceResponseSpec.m new file mode 100644 index 000000000..62eb9b152 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLRegisterAppInterfaceResponseSpec.m @@ -0,0 +1,133 @@ +// +// SDLRegisterAppInterfaceResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SmartDeviceLink.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLRegisterAppInterfaceResponseSpec) + +SDLSyncMsgVersion* version = [[SDLSyncMsgVersion alloc] init]; +SDLDisplayCapabilities* info = [[SDLDisplayCapabilities alloc] init]; +SDLButtonCapabilities* button = [[SDLButtonCapabilities alloc] init]; +SDLSoftButtonCapabilities* softButton = [[SDLSoftButtonCapabilities alloc] init]; +SDLPresetBankCapabilities* presetBank = [[SDLPresetBankCapabilities alloc] init]; +SDLAudioPassThruCapabilities* audioPassThru = [[SDLAudioPassThruCapabilities alloc] init]; +SDLVehicleType* vehicle = [[SDLVehicleType alloc] init]; +SDLHMICapabilities *hmiCapabilities = [[SDLHMICapabilities alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLRegisterAppInterfaceResponse* testResponse = [[SDLRegisterAppInterfaceResponse alloc] init]; + + testResponse.syncMsgVersion = version; + testResponse.language = [SDLLanguage ES_MX]; + testResponse.hmiDisplayLanguage = [SDLLanguage RU_RU]; + testResponse.displayCapabilities = info; + testResponse.buttonCapabilities = [@[button] mutableCopy]; + testResponse.softButtonCapabilities = [@[softButton] mutableCopy]; + testResponse.presetBankCapabilities = presetBank; + testResponse.hmiZoneCapabilities = [@[[SDLHMIZoneCapabilities BACK], [SDLHMIZoneCapabilities FRONT]] copy]; + testResponse.speechCapabilities = [@[[SDLSpeechCapabilities SAPI_PHONEMES], [SDLSpeechCapabilities SILENCE]] copy]; + testResponse.vrCapabilities = [@[[SDLVRCapabilities TEXT]] copy]; + testResponse.audioPassThruCapabilities = [@[audioPassThru] mutableCopy]; + testResponse.vehicleType = vehicle; + testResponse.prerecordedSpeech = [@[[SDLPrerecordedSpeech LISTEN_JINGLE], [SDLPrerecordedSpeech HELP_JINGLE]] copy]; + testResponse.supportedDiagModes = [@[@67, @99, @111] mutableCopy]; + testResponse.hmiCapabilities = hmiCapabilities; + testResponse.sdlVersion = @"sdlVersion"; + testResponse.systemSoftwareVersion = @"systemSoftwareVersion"; + + expect(testResponse.syncMsgVersion).to(equal(version)); + expect(testResponse.language).to(equal([SDLLanguage ES_MX])); + expect(testResponse.hmiDisplayLanguage).to(equal([SDLLanguage RU_RU])); + expect(testResponse.displayCapabilities).to(equal(info)); + expect(testResponse.buttonCapabilities).to(equal([@[button] mutableCopy])); + expect(testResponse.softButtonCapabilities).to(equal([@[softButton] mutableCopy])); + expect(testResponse.presetBankCapabilities).to(equal(presetBank)); + expect(testResponse.hmiZoneCapabilities).to(equal([@[[SDLHMIZoneCapabilities BACK], [SDLHMIZoneCapabilities FRONT]] copy])); + expect(testResponse.speechCapabilities).to(equal([@[[SDLSpeechCapabilities SAPI_PHONEMES], [SDLSpeechCapabilities SILENCE]] copy])); + expect(testResponse.vrCapabilities).to(equal([@[[SDLVRCapabilities TEXT]] copy])); + expect(testResponse.audioPassThruCapabilities).to(equal([@[audioPassThru] mutableCopy])); + expect(testResponse.vehicleType).to(equal(vehicle)); + expect(testResponse.prerecordedSpeech).to(equal([@[[SDLPrerecordedSpeech LISTEN_JINGLE], [SDLPrerecordedSpeech HELP_JINGLE]] copy])); + expect(testResponse.supportedDiagModes).to(equal([@[@67, @99, @111] mutableCopy])); + expect(testResponse.hmiCapabilities).to(equal(hmiCapabilities)); + expect(testResponse.sdlVersion).to(equal(@"sdlVersion")); + expect(testResponse.systemSoftwareVersion).to(equal(@"systemSoftwareVersion")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_syncMsgVersion:version, + NAMES_language:[SDLLanguage ES_MX], + NAMES_hmiDisplayLanguage:[SDLLanguage RU_RU], + NAMES_displayCapabilities:info, + NAMES_buttonCapabilities:[@[button] mutableCopy], + NAMES_softButtonCapabilities:[@[softButton] mutableCopy], + NAMES_presetBankCapabilities:presetBank, + NAMES_hmiZoneCapabilities:[@[[SDLHMIZoneCapabilities BACK], [SDLHMIZoneCapabilities FRONT]] copy], + NAMES_speechCapabilities:[@[[SDLSpeechCapabilities SAPI_PHONEMES], [SDLSpeechCapabilities SILENCE]] copy], + NAMES_vrCapabilities:[@[[SDLVRCapabilities TEXT]] copy], + NAMES_audioPassThruCapabilities:[@[audioPassThru] mutableCopy], + NAMES_vehicleType:vehicle, + NAMES_prerecordedSpeech:[@[[SDLPrerecordedSpeech LISTEN_JINGLE], [SDLPrerecordedSpeech HELP_JINGLE]] mutableCopy], + NAMES_supportedDiagModes:[@[@67, @99, @111] mutableCopy], + NAMES_hmiCapabilities: hmiCapabilities, + NAMES_sdlVersion: @"sdlVersion", + NAMES_systemSoftwareVersion: @"systemSoftwareVersion" + }, + NAMES_operation_name:NAMES_RegisterAppInterface}} mutableCopy]; + SDLRegisterAppInterfaceResponse* testResponse = [[SDLRegisterAppInterfaceResponse alloc] initWithDictionary:dict]; + + expect(testResponse.syncMsgVersion).to(equal(version)); + expect(testResponse.language).to(equal([SDLLanguage ES_MX])); + expect(testResponse.hmiDisplayLanguage).to(equal([SDLLanguage RU_RU])); + expect(testResponse.displayCapabilities).to(equal(info)); + expect(testResponse.buttonCapabilities).to(equal([@[button] mutableCopy])); + expect(testResponse.softButtonCapabilities).to(equal([@[softButton] mutableCopy])); + expect(testResponse.presetBankCapabilities).to(equal(presetBank)); + expect(testResponse.hmiZoneCapabilities).to(equal([@[[SDLHMIZoneCapabilities BACK], [SDLHMIZoneCapabilities FRONT]] copy])); + expect(testResponse.speechCapabilities).to(equal([@[[SDLSpeechCapabilities SAPI_PHONEMES], [SDLSpeechCapabilities SILENCE]] copy])); + expect(testResponse.vrCapabilities).to(equal([@[[SDLVRCapabilities TEXT]] copy])); + expect(testResponse.audioPassThruCapabilities).to(equal([@[audioPassThru] mutableCopy])); + expect(testResponse.vehicleType).to(equal(vehicle)); + expect(testResponse.prerecordedSpeech).to(equal([@[[SDLPrerecordedSpeech LISTEN_JINGLE], [SDLPrerecordedSpeech HELP_JINGLE]] copy])); + expect(testResponse.supportedDiagModes).to(equal([@[@67, @99, @111] mutableCopy])); + expect(testResponse.hmiCapabilities).to(equal(hmiCapabilities)); + expect(testResponse.sdlVersion).to(equal(@"sdlVersion")); + expect(testResponse.systemSoftwareVersion).to(equal(@"systemSoftwareVersion")); + }); + + it(@"Should return nil if not set", ^ { + SDLRegisterAppInterfaceResponse* testResponse = [[SDLRegisterAppInterfaceResponse alloc] init]; + + expect(testResponse.syncMsgVersion).to(beNil()); + expect(testResponse.language).to(beNil()); + expect(testResponse.hmiDisplayLanguage).to(beNil()); + expect(testResponse.displayCapabilities).to(beNil()); + expect(testResponse.buttonCapabilities).to(beNil()); + expect(testResponse.softButtonCapabilities).to(beNil()); + expect(testResponse.presetBankCapabilities).to(beNil()); + expect(testResponse.hmiZoneCapabilities).to(beNil()); + expect(testResponse.speechCapabilities).to(beNil()); + expect(testResponse.vrCapabilities).to(beNil()); + expect(testResponse.audioPassThruCapabilities).to(beNil()); + expect(testResponse.vehicleType).to(beNil()); + expect(testResponse.prerecordedSpeech).to(beNil()); + expect(testResponse.supportedDiagModes).to(beNil()); + expect(testResponse.hmiCapabilities).to(beNil()); + expect(testResponse.sdlVersion).to(beNil()); + expect(testResponse.systemSoftwareVersion).to(beNil()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLResetGlobalPropertiesResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLResetGlobalPropertiesResponseSpec.m new file mode 100644 index 000000000..fb9b4a2ed --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLResetGlobalPropertiesResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLResetGlobalPropertiesResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLResetGlobalPropertiesResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLResetGlobalPropertiesResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLScrollableMessageResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLScrollableMessageResponseSpec.m new file mode 100644 index 000000000..5cebb0229 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLScrollableMessageResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLScrollableMessageResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLScrollableMessageResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLScrollableMessageResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSendLocationResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSendLocationResponseSpec.m new file mode 100644 index 000000000..83d1ee55a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSendLocationResponseSpec.m @@ -0,0 +1,12 @@ +// +// SDLSendLocationResponseSpec.m +// SmartDeviceLink-iOS + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +QuickSpecBegin(SDLSendLocationResponseSpec) + + + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetAppIconResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetAppIconResponseSpec.m new file mode 100644 index 000000000..44593a080 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetAppIconResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSetAppIconResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSetAppIconResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSetAppIconResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetDisplayLayoutResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetDisplayLayoutResponseSpec.m new file mode 100644 index 000000000..3eeab76a1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetDisplayLayoutResponseSpec.m @@ -0,0 +1,67 @@ +// +// SDLSetDisplayLayoutResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonCapabilities.h" +#import "SDLDisplayCapabilities.h" +#import "SDLNames.h" +#import "SDLPresetBankCapabilities.h" +#import "SDLSetDisplayLayoutResponse.h" +#import "SDLSoftButtonCapabilities.h" + + +QuickSpecBegin(SDLSetDisplayLayoutResponseSpec) + +SDLDisplayCapabilities* info = [[SDLDisplayCapabilities alloc] init]; +SDLButtonCapabilities* button = [[SDLButtonCapabilities alloc] init]; +SDLSoftButtonCapabilities* softButton = [[SDLSoftButtonCapabilities alloc] init]; +SDLPresetBankCapabilities* presetBank = [[SDLPresetBankCapabilities alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSetDisplayLayoutResponse* testResponse = [[SDLSetDisplayLayoutResponse alloc] init]; + + testResponse.displayCapabilities = info; + testResponse.buttonCapabilities = [@[button] mutableCopy]; + testResponse.softButtonCapabilities = [@[softButton] mutableCopy]; + testResponse.presetBankCapabilities = presetBank; + + expect(testResponse.displayCapabilities).to(equal(info)); + expect(testResponse.buttonCapabilities).to(equal([@[button] mutableCopy])); + expect(testResponse.softButtonCapabilities).to(equal([@[softButton] mutableCopy])); + expect(testResponse.presetBankCapabilities).to(equal(presetBank)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_request: + @{NAMES_parameters: + @{NAMES_displayCapabilities:info, + NAMES_buttonCapabilities:[@[button] mutableCopy], + NAMES_softButtonCapabilities:[@[softButton] mutableCopy], + NAMES_presetBankCapabilities:presetBank}, + NAMES_operation_name:NAMES_SetDisplayLayout}} mutableCopy]; + SDLSetDisplayLayoutResponse* testResponse = [[SDLSetDisplayLayoutResponse alloc] initWithDictionary:dict]; + + expect(testResponse.displayCapabilities).to(equal(info)); + expect(testResponse.buttonCapabilities).to(equal([@[button] mutableCopy])); + expect(testResponse.softButtonCapabilities).to(equal([@[softButton] mutableCopy])); + expect(testResponse.presetBankCapabilities).to(equal(presetBank)); + }); + + it(@"Should return nil if not set", ^ { + SDLSetDisplayLayoutResponse* testResponse = [[SDLSetDisplayLayoutResponse alloc] init]; + + expect(testResponse.displayCapabilities).to(beNil()); + expect(testResponse.buttonCapabilities).to(beNil()); + expect(testResponse.softButtonCapabilities).to(beNil()); + expect(testResponse.presetBankCapabilities).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetGlobalPropertiesResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetGlobalPropertiesResponseSpec.m new file mode 100644 index 000000000..80a5f47ec --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetGlobalPropertiesResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSetGlobalPropertiesResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSetGlobalPropertiesResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSetGlobalPropertiesResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetMediaClockTimerResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetMediaClockTimerResponseSpec.m new file mode 100644 index 000000000..e840213d6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSetMediaClockTimerResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSetMediaClockTimerResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSetMediaClockTimerResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSetMediaClockTimerResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLShowConstantTBTResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLShowConstantTBTResponseSpec.m new file mode 100644 index 000000000..1bd2c57cd --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLShowConstantTBTResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLShowConstantTBTResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLShowConstantTBTResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLShowConstantTBTResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLShowResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLShowResponseSpec.m new file mode 100644 index 000000000..bbfa524c0 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLShowResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLShowResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLShowResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLShowResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSliderResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSliderResponseSpec.m new file mode 100644 index 000000000..6f92c1e48 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSliderResponseSpec.m @@ -0,0 +1,43 @@ +// +// SDLSliderResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSliderResponse.h" +#import "SDLDIDResult.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSliderResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSliderResponse* testResponse = [[SDLSliderResponse alloc] init]; + + testResponse.sliderPosition = @13; + + expect(testResponse.sliderPosition).to(equal(@13)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_sliderPosition:@13}, + NAMES_operation_name:NAMES_Slider}} mutableCopy]; + SDLSliderResponse* testResponse = [[SDLSliderResponse alloc] initWithDictionary:dict]; + + expect(testResponse.sliderPosition).to(equal(@13)); + }); + + it(@"Should return nil if not set", ^ { + SDLSliderResponse* testResponse = [[SDLSliderResponse alloc] init]; + + expect(testResponse.sliderPosition).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSpeakResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSpeakResponseSpec.m new file mode 100644 index 000000000..688e8f34c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSpeakResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSpeakResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSpeakResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSpeakResponseSpec) + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSubscribeButtonResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSubscribeButtonResponseSpec.m new file mode 100644 index 000000000..5e78d95ed --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSubscribeButtonResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSubscribeButtonResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSubscribeButtonResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSubscribeButtonResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSubscribeVehicleDataResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSubscribeVehicleDataResponseSpec.m new file mode 100644 index 000000000..d6c0dc6ac --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSubscribeVehicleDataResponseSpec.m @@ -0,0 +1,161 @@ +// +// SDLSubscribeVehicleDataResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLSubscribeVehicleDataResponse.h" +#import "SDLVehicleDataResult.h" + + +QuickSpecBegin(SDLSubscribeVehicleDataResponseSpec) + +SDLVehicleDataResult* vehicleDataResult = [[SDLVehicleDataResult alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSubscribeVehicleDataResponse* testResponse = [[SDLSubscribeVehicleDataResponse alloc] init]; + + testResponse.gps = vehicleDataResult; + testResponse.speed = vehicleDataResult; + testResponse.rpm = vehicleDataResult; + testResponse.fuelLevel = vehicleDataResult; + testResponse.fuelLevel_State = vehicleDataResult; + testResponse.instantFuelConsumption = vehicleDataResult; + testResponse.externalTemperature = vehicleDataResult; + testResponse.prndl = vehicleDataResult; + testResponse.tirePressure = vehicleDataResult; + testResponse.odometer = vehicleDataResult; + testResponse.beltStatus = vehicleDataResult; + testResponse.bodyInformation = vehicleDataResult; + testResponse.deviceStatus = vehicleDataResult; + testResponse.driverBraking = vehicleDataResult; + testResponse.wiperStatus = vehicleDataResult; + testResponse.headLampStatus = vehicleDataResult; + testResponse.engineTorque = vehicleDataResult; + testResponse.accPedalPosition = vehicleDataResult; + testResponse.steeringWheelAngle = vehicleDataResult; + testResponse.eCallInfo = vehicleDataResult; + testResponse.airbagStatus = vehicleDataResult; + testResponse.emergencyEvent = vehicleDataResult; + testResponse.clusterModes = vehicleDataResult; + testResponse.myKey = vehicleDataResult; + + expect(testResponse.gps).to(equal(vehicleDataResult)); + expect(testResponse.speed).to(equal(vehicleDataResult)); + expect(testResponse.rpm).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel_State).to(equal(vehicleDataResult)); + expect(testResponse.instantFuelConsumption).to(equal(vehicleDataResult)); + expect(testResponse.externalTemperature).to(equal(vehicleDataResult)); + expect(testResponse.prndl).to(equal(vehicleDataResult)); + expect(testResponse.tirePressure).to(equal(vehicleDataResult)); + expect(testResponse.odometer).to(equal(vehicleDataResult)); + expect(testResponse.beltStatus).to(equal(vehicleDataResult)); + expect(testResponse.bodyInformation).to(equal(vehicleDataResult)); + expect(testResponse.deviceStatus).to(equal(vehicleDataResult)); + expect(testResponse.driverBraking).to(equal(vehicleDataResult)); + expect(testResponse.wiperStatus).to(equal(vehicleDataResult)); + expect(testResponse.headLampStatus).to(equal(vehicleDataResult)); + expect(testResponse.engineTorque).to(equal(vehicleDataResult)); + expect(testResponse.accPedalPosition).to(equal(vehicleDataResult)); + expect(testResponse.steeringWheelAngle).to(equal(vehicleDataResult)); + expect(testResponse.eCallInfo).to(equal(vehicleDataResult)); + expect(testResponse.airbagStatus).to(equal(vehicleDataResult)); + expect(testResponse.emergencyEvent).to(equal(vehicleDataResult)); + expect(testResponse.clusterModes).to(equal(vehicleDataResult)); + expect(testResponse.myKey).to(equal(vehicleDataResult)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_gps:vehicleDataResult, + NAMES_speed:vehicleDataResult, + NAMES_rpm:vehicleDataResult, + NAMES_fuelLevel:vehicleDataResult, + NAMES_fuelLevel_State:vehicleDataResult, + NAMES_instantFuelConsumption:vehicleDataResult, + NAMES_externalTemperature:vehicleDataResult, + NAMES_prndl:vehicleDataResult, + NAMES_tirePressure:vehicleDataResult, + NAMES_odometer:vehicleDataResult, + NAMES_beltStatus:vehicleDataResult, + NAMES_bodyInformation:vehicleDataResult, + NAMES_deviceStatus:vehicleDataResult, + NAMES_driverBraking:vehicleDataResult, + NAMES_wiperStatus:vehicleDataResult, + NAMES_headLampStatus:vehicleDataResult, + NAMES_engineTorque:vehicleDataResult, + NAMES_accPedalPosition:vehicleDataResult, + NAMES_steeringWheelAngle:vehicleDataResult, + NAMES_eCallInfo:vehicleDataResult, + NAMES_airbagStatus:vehicleDataResult, + NAMES_emergencyEvent:vehicleDataResult, + NAMES_clusterModes:vehicleDataResult, + NAMES_myKey:vehicleDataResult}, + NAMES_operation_name:NAMES_SubscribeVehicleData}} mutableCopy]; + SDLSubscribeVehicleDataResponse* testResponse = [[SDLSubscribeVehicleDataResponse alloc] initWithDictionary:dict]; + + expect(testResponse.gps).to(equal(vehicleDataResult)); + expect(testResponse.speed).to(equal(vehicleDataResult)); + expect(testResponse.rpm).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel_State).to(equal(vehicleDataResult)); + expect(testResponse.instantFuelConsumption).to(equal(vehicleDataResult)); + expect(testResponse.externalTemperature).to(equal(vehicleDataResult)); + expect(testResponse.prndl).to(equal(vehicleDataResult)); + expect(testResponse.tirePressure).to(equal(vehicleDataResult)); + expect(testResponse.odometer).to(equal(vehicleDataResult)); + expect(testResponse.beltStatus).to(equal(vehicleDataResult)); + expect(testResponse.bodyInformation).to(equal(vehicleDataResult)); + expect(testResponse.deviceStatus).to(equal(vehicleDataResult)); + expect(testResponse.driverBraking).to(equal(vehicleDataResult)); + expect(testResponse.wiperStatus).to(equal(vehicleDataResult)); + expect(testResponse.headLampStatus).to(equal(vehicleDataResult)); + expect(testResponse.engineTorque).to(equal(vehicleDataResult)); + expect(testResponse.accPedalPosition).to(equal(vehicleDataResult)); + expect(testResponse.steeringWheelAngle).to(equal(vehicleDataResult)); + expect(testResponse.eCallInfo).to(equal(vehicleDataResult)); + expect(testResponse.airbagStatus).to(equal(vehicleDataResult)); + expect(testResponse.emergencyEvent).to(equal(vehicleDataResult)); + expect(testResponse.clusterModes).to(equal(vehicleDataResult)); + expect(testResponse.myKey).to(equal(vehicleDataResult)); + }); + + it(@"Should return nil if not set", ^ { + SDLSubscribeVehicleDataResponse* testResponse = [[SDLSubscribeVehicleDataResponse alloc] init]; + + expect(testResponse.gps).to(beNil()); + expect(testResponse.speed).to(beNil()); + expect(testResponse.rpm).to(beNil()); + expect(testResponse.fuelLevel).to(beNil()); + expect(testResponse.fuelLevel_State).to(beNil()); + expect(testResponse.instantFuelConsumption).to(beNil()); + expect(testResponse.externalTemperature).to(beNil()); + expect(testResponse.prndl).to(beNil()); + expect(testResponse.tirePressure).to(beNil()); + expect(testResponse.odometer).to(beNil()); + expect(testResponse.beltStatus).to(beNil()); + expect(testResponse.bodyInformation).to(beNil()); + expect(testResponse.deviceStatus).to(beNil()); + expect(testResponse.driverBraking).to(beNil()); + expect(testResponse.wiperStatus).to(beNil()); + expect(testResponse.headLampStatus).to(beNil()); + expect(testResponse.engineTorque).to(beNil()); + expect(testResponse.accPedalPosition).to(beNil()); + expect(testResponse.steeringWheelAngle).to(beNil()); + expect(testResponse.eCallInfo).to(beNil()); + expect(testResponse.airbagStatus).to(beNil()); + expect(testResponse.emergencyEvent).to(beNil()); + expect(testResponse.clusterModes).to(beNil()); + expect(testResponse.myKey).to(beNil()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSyncPDataResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSyncPDataResponseSpec.m new file mode 100644 index 000000000..6a287f226 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSyncPDataResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSyncPDataResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSyncPDataResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSyncPDataResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSystemRequestResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSystemRequestResponseSpec.m new file mode 100644 index 000000000..2571379c8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLSystemRequestResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLSystemRequestResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSystemRequestResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSystemRequestResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnregisterAppInterfaceResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnregisterAppInterfaceResponseSpec.m new file mode 100644 index 000000000..f10eb6048 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnregisterAppInterfaceResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLUnregisterAppInterfaceResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUnregisterAppInterfaceResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLUnregisterAppInterfaceResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnsubscribeButtonResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnsubscribeButtonResponseSpec.m new file mode 100644 index 000000000..ca76ef4e7 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnsubscribeButtonResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLUnsubscribeButtonResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUnsubscribeButtonResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLUnsubscribeButtonResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnsubscribeVehicleDataResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnsubscribeVehicleDataResponseSpec.m new file mode 100644 index 000000000..29cb4e08c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUnsubscribeVehicleDataResponseSpec.m @@ -0,0 +1,161 @@ +// +// SDLUnsubscribeVehicleDataResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUnsubscribeVehicleDataResponse.h" +#import "SDLNames.h" +#import "SDLVehicleDataResult.h" + + +QuickSpecBegin(SDLUnsubscribeVehicleDataResponseSpec) + +SDLVehicleDataResult* vehicleDataResult = [[SDLVehicleDataResult alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLUnsubscribeVehicleDataResponse* testResponse = [[SDLUnsubscribeVehicleDataResponse alloc] init]; + + testResponse.gps = vehicleDataResult; + testResponse.speed = vehicleDataResult; + testResponse.rpm = vehicleDataResult; + testResponse.fuelLevel = vehicleDataResult; + testResponse.fuelLevel_State = vehicleDataResult; + testResponse.instantFuelConsumption = vehicleDataResult; + testResponse.externalTemperature = vehicleDataResult; + testResponse.prndl = vehicleDataResult; + testResponse.tirePressure = vehicleDataResult; + testResponse.odometer = vehicleDataResult; + testResponse.beltStatus = vehicleDataResult; + testResponse.bodyInformation = vehicleDataResult; + testResponse.deviceStatus = vehicleDataResult; + testResponse.driverBraking = vehicleDataResult; + testResponse.wiperStatus = vehicleDataResult; + testResponse.headLampStatus = vehicleDataResult; + testResponse.engineTorque = vehicleDataResult; + testResponse.accPedalPosition = vehicleDataResult; + testResponse.steeringWheelAngle = vehicleDataResult; + testResponse.eCallInfo = vehicleDataResult; + testResponse.airbagStatus = vehicleDataResult; + testResponse.emergencyEvent = vehicleDataResult; + testResponse.clusterModes = vehicleDataResult; + testResponse.myKey = vehicleDataResult; + + expect(testResponse.gps).to(equal(vehicleDataResult)); + expect(testResponse.speed).to(equal(vehicleDataResult)); + expect(testResponse.rpm).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel_State).to(equal(vehicleDataResult)); + expect(testResponse.instantFuelConsumption).to(equal(vehicleDataResult)); + expect(testResponse.externalTemperature).to(equal(vehicleDataResult)); + expect(testResponse.prndl).to(equal(vehicleDataResult)); + expect(testResponse.tirePressure).to(equal(vehicleDataResult)); + expect(testResponse.odometer).to(equal(vehicleDataResult)); + expect(testResponse.beltStatus).to(equal(vehicleDataResult)); + expect(testResponse.bodyInformation).to(equal(vehicleDataResult)); + expect(testResponse.deviceStatus).to(equal(vehicleDataResult)); + expect(testResponse.driverBraking).to(equal(vehicleDataResult)); + expect(testResponse.wiperStatus).to(equal(vehicleDataResult)); + expect(testResponse.headLampStatus).to(equal(vehicleDataResult)); + expect(testResponse.engineTorque).to(equal(vehicleDataResult)); + expect(testResponse.accPedalPosition).to(equal(vehicleDataResult)); + expect(testResponse.steeringWheelAngle).to(equal(vehicleDataResult)); + expect(testResponse.eCallInfo).to(equal(vehicleDataResult)); + expect(testResponse.airbagStatus).to(equal(vehicleDataResult)); + expect(testResponse.emergencyEvent).to(equal(vehicleDataResult)); + expect(testResponse.clusterModes).to(equal(vehicleDataResult)); + expect(testResponse.myKey).to(equal(vehicleDataResult)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_response: + @{NAMES_parameters: + @{NAMES_gps:vehicleDataResult, + NAMES_speed:vehicleDataResult, + NAMES_rpm:vehicleDataResult, + NAMES_fuelLevel:vehicleDataResult, + NAMES_fuelLevel_State:vehicleDataResult, + NAMES_instantFuelConsumption:vehicleDataResult, + NAMES_externalTemperature:vehicleDataResult, + NAMES_prndl:vehicleDataResult, + NAMES_tirePressure:vehicleDataResult, + NAMES_odometer:vehicleDataResult, + NAMES_beltStatus:vehicleDataResult, + NAMES_bodyInformation:vehicleDataResult, + NAMES_deviceStatus:vehicleDataResult, + NAMES_driverBraking:vehicleDataResult, + NAMES_wiperStatus:vehicleDataResult, + NAMES_headLampStatus:vehicleDataResult, + NAMES_engineTorque:vehicleDataResult, + NAMES_accPedalPosition:vehicleDataResult, + NAMES_steeringWheelAngle:vehicleDataResult, + NAMES_eCallInfo:vehicleDataResult, + NAMES_airbagStatus:vehicleDataResult, + NAMES_emergencyEvent:vehicleDataResult, + NAMES_clusterModes:vehicleDataResult, + NAMES_myKey:vehicleDataResult}, + NAMES_operation_name:NAMES_UnsubscribeVehicleData}} mutableCopy]; + SDLUnsubscribeVehicleDataResponse* testResponse = [[SDLUnsubscribeVehicleDataResponse alloc] initWithDictionary:dict]; + + expect(testResponse.gps).to(equal(vehicleDataResult)); + expect(testResponse.speed).to(equal(vehicleDataResult)); + expect(testResponse.rpm).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel).to(equal(vehicleDataResult)); + expect(testResponse.fuelLevel_State).to(equal(vehicleDataResult)); + expect(testResponse.instantFuelConsumption).to(equal(vehicleDataResult)); + expect(testResponse.externalTemperature).to(equal(vehicleDataResult)); + expect(testResponse.prndl).to(equal(vehicleDataResult)); + expect(testResponse.tirePressure).to(equal(vehicleDataResult)); + expect(testResponse.odometer).to(equal(vehicleDataResult)); + expect(testResponse.beltStatus).to(equal(vehicleDataResult)); + expect(testResponse.bodyInformation).to(equal(vehicleDataResult)); + expect(testResponse.deviceStatus).to(equal(vehicleDataResult)); + expect(testResponse.driverBraking).to(equal(vehicleDataResult)); + expect(testResponse.wiperStatus).to(equal(vehicleDataResult)); + expect(testResponse.headLampStatus).to(equal(vehicleDataResult)); + expect(testResponse.engineTorque).to(equal(vehicleDataResult)); + expect(testResponse.accPedalPosition).to(equal(vehicleDataResult)); + expect(testResponse.steeringWheelAngle).to(equal(vehicleDataResult)); + expect(testResponse.eCallInfo).to(equal(vehicleDataResult)); + expect(testResponse.airbagStatus).to(equal(vehicleDataResult)); + expect(testResponse.emergencyEvent).to(equal(vehicleDataResult)); + expect(testResponse.clusterModes).to(equal(vehicleDataResult)); + expect(testResponse.myKey).to(equal(vehicleDataResult)); + }); + + it(@"Should return nil if not set", ^ { + SDLUnsubscribeVehicleDataResponse* testResponse = [[SDLUnsubscribeVehicleDataResponse alloc] init]; + + expect(testResponse.gps).to(beNil()); + expect(testResponse.speed).to(beNil()); + expect(testResponse.rpm).to(beNil()); + expect(testResponse.fuelLevel).to(beNil()); + expect(testResponse.fuelLevel_State).to(beNil()); + expect(testResponse.instantFuelConsumption).to(beNil()); + expect(testResponse.externalTemperature).to(beNil()); + expect(testResponse.prndl).to(beNil()); + expect(testResponse.tirePressure).to(beNil()); + expect(testResponse.odometer).to(beNil()); + expect(testResponse.beltStatus).to(beNil()); + expect(testResponse.bodyInformation).to(beNil()); + expect(testResponse.deviceStatus).to(beNil()); + expect(testResponse.driverBraking).to(beNil()); + expect(testResponse.wiperStatus).to(beNil()); + expect(testResponse.headLampStatus).to(beNil()); + expect(testResponse.engineTorque).to(beNil()); + expect(testResponse.accPedalPosition).to(beNil()); + expect(testResponse.steeringWheelAngle).to(beNil()); + expect(testResponse.eCallInfo).to(beNil()); + expect(testResponse.airbagStatus).to(beNil()); + expect(testResponse.emergencyEvent).to(beNil()); + expect(testResponse.clusterModes).to(beNil()); + expect(testResponse.myKey).to(beNil()); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUpdateTurnListResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUpdateTurnListResponseSpec.m new file mode 100644 index 000000000..d455dea46 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/ResponseSpecs/SDLUpdateTurnListResponseSpec.m @@ -0,0 +1,16 @@ +// +// SDLUpdateTurnListResponseSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLUpdateTurnListResponse.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLUpdateTurnListResponseSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLAirbagStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLAirbagStatusSpec.m new file mode 100644 index 000000000..ea88855c5 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLAirbagStatusSpec.m @@ -0,0 +1,76 @@ +// +// SDLAirbagStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAirbagStatus.h" +#import "SDLNames.h" +#import "SDLVehicleDataEventStatus.h" + + +QuickSpecBegin(SDLAirbagStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLAirbagStatus* testStruct = [[SDLAirbagStatus alloc] init]; + + testStruct.driverAirbagDeployed = [SDLVehicleDataEventStatus _YES]; + testStruct.driverSideAirbagDeployed = [SDLVehicleDataEventStatus NO_EVENT]; + testStruct.driverCurtainAirbagDeployed = [SDLVehicleDataEventStatus _NO]; + testStruct.passengerAirbagDeployed = [SDLVehicleDataEventStatus NOT_SUPPORTED]; + testStruct.passengerCurtainAirbagDeployed = [SDLVehicleDataEventStatus FAULT]; + testStruct.driverKneeAirbagDeployed = [SDLVehicleDataEventStatus _NO]; + testStruct.passengerSideAirbagDeployed = [SDLVehicleDataEventStatus _YES]; + testStruct.passengerKneeAirbagDeployed = [SDLVehicleDataEventStatus NO_EVENT]; + + expect(testStruct.driverAirbagDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.driverSideAirbagDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.driverCurtainAirbagDeployed).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.passengerAirbagDeployed).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.passengerCurtainAirbagDeployed).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.driverKneeAirbagDeployed).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.passengerSideAirbagDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.passengerKneeAirbagDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_driverAirbagDeployed:[SDLVehicleDataEventStatus _YES], + NAMES_driverSideAirbagDeployed:[SDLVehicleDataEventStatus NO_EVENT], + NAMES_driverCurtainAirbagDeployed:[SDLVehicleDataEventStatus _NO], + NAMES_passengerAirbagDeployed:[SDLVehicleDataEventStatus NOT_SUPPORTED], + NAMES_passengerCurtainAirbagDeployed:[SDLVehicleDataEventStatus FAULT], + NAMES_driverKneeAirbagDeployed:[SDLVehicleDataEventStatus _NO], + NAMES_passengerSideAirbagDeployed:[SDLVehicleDataEventStatus _YES], + NAMES_passengerKneeAirbagDeployed:[SDLVehicleDataEventStatus NO_EVENT]} mutableCopy]; + SDLAirbagStatus* testStruct = [[SDLAirbagStatus alloc] initWithDictionary:dict]; + + expect(testStruct.driverAirbagDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.driverSideAirbagDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.driverCurtainAirbagDeployed).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.passengerAirbagDeployed).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.passengerCurtainAirbagDeployed).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.driverKneeAirbagDeployed).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.passengerSideAirbagDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.passengerKneeAirbagDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + }); + + it(@"Should return nil if not set", ^ { + SDLAirbagStatus* testStruct = [[SDLAirbagStatus alloc] init]; + + expect(testStruct.driverAirbagDeployed).to(beNil()); + expect(testStruct.driverSideAirbagDeployed).to(beNil()); + expect(testStruct.driverCurtainAirbagDeployed).to(beNil()); + expect(testStruct.passengerAirbagDeployed).to(beNil()); + expect(testStruct.passengerCurtainAirbagDeployed).to(beNil()); + expect(testStruct.driverKneeAirbagDeployed).to(beNil()); + expect(testStruct.passengerSideAirbagDeployed).to(beNil()); + expect(testStruct.passengerKneeAirbagDeployed).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLAudioPassThruCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLAudioPassThruCapabilitiesSpec.m new file mode 100644 index 000000000..8d66fc8af --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLAudioPassThruCapabilitiesSpec.m @@ -0,0 +1,53 @@ +// +// SDLAudioPassThruCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAudioPassThruCapabilities.h" +#import "SDLAudioType.h" +#import "SDLBitsPerSample.h" +#import "SDLNames.h" +#import "SDLSamplingRate.h" + + +QuickSpecBegin(SDLAudioPassThruCapabilitiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLAudioPassThruCapabilities* testStruct = [[SDLAudioPassThruCapabilities alloc] init]; + + testStruct.samplingRate = [SDLSamplingRate _22KHZ]; + testStruct.bitsPerSample = [SDLBitsPerSample _8_BIT]; + testStruct.audioType = [SDLAudioType PCM]; + + expect(testStruct.samplingRate).to(equal([SDLSamplingRate _22KHZ])); + expect(testStruct.bitsPerSample).to(equal([SDLBitsPerSample _8_BIT])); + expect(testStruct.audioType).to(equal([SDLAudioType PCM])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_samplingRate:[SDLSamplingRate _22KHZ], + NAMES_bitsPerSample:[SDLBitsPerSample _8_BIT], + NAMES_audioType:[SDLAudioType PCM]} mutableCopy]; + SDLAudioPassThruCapabilities* testStruct = [[SDLAudioPassThruCapabilities alloc] initWithDictionary:dict]; + + expect(testStruct.samplingRate).to(equal([SDLSamplingRate _22KHZ])); + expect(testStruct.bitsPerSample).to(equal([SDLBitsPerSample _8_BIT])); + expect(testStruct.audioType).to(equal([SDLAudioType PCM])); + }); + + it(@"Should return nil if not set", ^ { + SDLAudioPassThruCapabilities* testStruct = [[SDLAudioPassThruCapabilities alloc] init]; + + expect(testStruct.samplingRate).to(beNil()); + expect(testStruct.bitsPerSample).to(beNil()); + expect(testStruct.audioType).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLBeltStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLBeltStatusSpec.m new file mode 100644 index 000000000..e0d8c4883 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLBeltStatusSpec.m @@ -0,0 +1,111 @@ +// +// SDLBeltStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLBeltStatus.h" +#import "SDLNames.h" +#import "SDLVehicleDataEventStatus.h" + + +QuickSpecBegin(SDLBeltStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLBeltStatus* testStruct = [[SDLBeltStatus alloc] init]; + + testStruct.driverBeltDeployed = [SDLVehicleDataEventStatus _YES]; + testStruct.passengerBeltDeployed = [SDLVehicleDataEventStatus NO_EVENT]; + testStruct.passengerBuckleBelted = [SDLVehicleDataEventStatus FAULT]; + testStruct.driverBuckleBelted = [SDLVehicleDataEventStatus _YES]; + testStruct.leftRow2BuckleBelted = [SDLVehicleDataEventStatus FAULT]; + testStruct.passengerChildDetected = [SDLVehicleDataEventStatus NOT_SUPPORTED]; + testStruct.rightRow2BuckleBelted = [SDLVehicleDataEventStatus _YES]; + testStruct.middleRow2BuckleBelted = [SDLVehicleDataEventStatus NO_EVENT]; + testStruct.middleRow3BuckleBelted = [SDLVehicleDataEventStatus NOT_SUPPORTED]; + testStruct.leftRow3BuckleBelted = [SDLVehicleDataEventStatus _YES]; + testStruct.rightRow3BuckleBelted = [SDLVehicleDataEventStatus _NO]; + testStruct.leftRearInflatableBelted = [SDLVehicleDataEventStatus NOT_SUPPORTED]; + testStruct.rightRearInflatableBelted = [SDLVehicleDataEventStatus FAULT]; + testStruct.middleRow1BeltDeployed = [SDLVehicleDataEventStatus _YES]; + testStruct.middleRow1BuckleBelted = [SDLVehicleDataEventStatus _NO]; + + expect(testStruct.driverBeltDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.passengerBeltDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.passengerBuckleBelted).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.driverBuckleBelted).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.leftRow2BuckleBelted).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.passengerChildDetected).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.rightRow2BuckleBelted).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.middleRow2BuckleBelted).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.middleRow3BuckleBelted).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.leftRow3BuckleBelted).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.rightRow3BuckleBelted).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.leftRearInflatableBelted).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.rightRearInflatableBelted).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.middleRow1BeltDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.middleRow1BuckleBelted).to(equal([SDLVehicleDataEventStatus _NO])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_driverBeltDeployed:[SDLVehicleDataEventStatus NO_EVENT], + NAMES_passengerBeltDeployed:[SDLVehicleDataEventStatus _YES], + NAMES_passengerBuckleBelted:[SDLVehicleDataEventStatus _NO], + NAMES_driverBuckleBelted:[SDLVehicleDataEventStatus FAULT], + NAMES_leftRow2BuckleBelted:[SDLVehicleDataEventStatus _YES], + NAMES_passengerChildDetected:[SDLVehicleDataEventStatus _NO], + NAMES_rightRow2BuckleBelted:[SDLVehicleDataEventStatus NOT_SUPPORTED], + NAMES_middleRow2BuckleBelted:[SDLVehicleDataEventStatus NO_EVENT], + NAMES_middleRow3BuckleBelted:[SDLVehicleDataEventStatus _YES], + NAMES_leftRow3BuckleBelted:[SDLVehicleDataEventStatus FAULT], + NAMES_rightRow3BuckleBelted:[SDLVehicleDataEventStatus _NO], + NAMES_leftRearInflatableBelted:[SDLVehicleDataEventStatus NOT_SUPPORTED], + NAMES_rightRearInflatableBelted:[SDLVehicleDataEventStatus FAULT], + NAMES_middleRow1BeltDeployed:[SDLVehicleDataEventStatus NO_EVENT], + NAMES_middleRow1BuckleBelted:[SDLVehicleDataEventStatus NOT_SUPPORTED]} mutableCopy]; + SDLBeltStatus* testStruct = [[SDLBeltStatus alloc] initWithDictionary:dict]; + + expect(testStruct.driverBeltDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.passengerBeltDeployed).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.passengerBuckleBelted).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.driverBuckleBelted).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.leftRow2BuckleBelted).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.passengerChildDetected).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.rightRow2BuckleBelted).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.middleRow2BuckleBelted).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.middleRow3BuckleBelted).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.leftRow3BuckleBelted).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.rightRow3BuckleBelted).to(equal([SDLVehicleDataEventStatus _NO])); + expect(testStruct.leftRearInflatableBelted).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + expect(testStruct.rightRearInflatableBelted).to(equal([SDLVehicleDataEventStatus FAULT])); + expect(testStruct.middleRow1BeltDeployed).to(equal([SDLVehicleDataEventStatus NO_EVENT])); + expect(testStruct.middleRow1BuckleBelted).to(equal([SDLVehicleDataEventStatus NOT_SUPPORTED])); + }); + + it(@"Should return nil if not set", ^ { + SDLBeltStatus* testStruct = [[SDLBeltStatus alloc] init]; + + expect(testStruct.driverBeltDeployed).to(beNil()); + expect(testStruct.passengerBeltDeployed).to(beNil()); + expect(testStruct.passengerBuckleBelted).to(beNil()); + expect(testStruct.driverBuckleBelted).to(beNil()); + expect(testStruct.leftRow2BuckleBelted).to(beNil()); + expect(testStruct.passengerChildDetected).to(beNil()); + expect(testStruct.rightRow2BuckleBelted).to(beNil()); + expect(testStruct.middleRow2BuckleBelted).to(beNil()); + expect(testStruct.middleRow3BuckleBelted).to(beNil()); + expect(testStruct.leftRow3BuckleBelted).to(beNil()); + expect(testStruct.rightRow3BuckleBelted).to(beNil()); + expect(testStruct.leftRearInflatableBelted).to(beNil()); + expect(testStruct.rightRearInflatableBelted).to(beNil()); + expect(testStruct.middleRow1BeltDeployed).to(beNil()); + expect(testStruct.middleRow1BuckleBelted).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLBodyInformationSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLBodyInformationSpec.m new file mode 100644 index 000000000..a13a7cc9c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLBodyInformationSpec.m @@ -0,0 +1,71 @@ +// +// SDLBodyInformationSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLBodyInformation.h" +#import "SDLIgnitionStableStatus.h" +#import "SDLIgnitionStatus.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLBodyInformationSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLBodyInformation* testStruct = [[SDLBodyInformation alloc] init]; + + testStruct.parkBrakeActive = @YES; + testStruct.ignitionStableStatus = [SDLIgnitionStableStatus IGNITION_SWITCH_STABLE]; + testStruct.ignitionStatus = [SDLIgnitionStatus START]; + testStruct.driverDoorAjar = @NO; + testStruct.passengerDoorAjar = @NO; + testStruct.rearLeftDoorAjar = @NO; + testStruct.rearRightDoorAjar = @YES; + + expect(testStruct.parkBrakeActive).to(equal(@YES)); + expect(testStruct.ignitionStableStatus).to(equal([SDLIgnitionStableStatus IGNITION_SWITCH_STABLE])); + expect(testStruct.ignitionStatus).to(equal([SDLIgnitionStatus START])); + expect(testStruct.driverDoorAjar).to(equal(@NO)); + expect(testStruct.passengerDoorAjar).to(equal(@NO)); + expect(testStruct.rearLeftDoorAjar).to(equal(@NO)); + expect(testStruct.rearRightDoorAjar).to(equal(@YES)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_parkBrakeActive:@YES, + NAMES_ignitionStableStatus:[SDLIgnitionStableStatus IGNITION_SWITCH_NOT_STABLE], + NAMES_ignitionStatus:[SDLIgnitionStatus START], + NAMES_driverDoorAjar:@NO, + NAMES_passengerDoorAjar:@NO, + NAMES_rearLeftDoorAjar:@NO, + NAMES_rearRightDoorAjar:@YES} mutableCopy]; + SDLBodyInformation* testStruct = [[SDLBodyInformation alloc] initWithDictionary:dict]; + + expect(testStruct.parkBrakeActive).to(equal(@YES)); + expect(testStruct.ignitionStableStatus).to(equal([SDLIgnitionStableStatus IGNITION_SWITCH_NOT_STABLE])); + expect(testStruct.ignitionStatus).to(equal([SDLIgnitionStatus START])); + expect(testStruct.driverDoorAjar).to(equal(@NO)); + expect(testStruct.passengerDoorAjar).to(equal(@NO)); + expect(testStruct.rearLeftDoorAjar).to(equal(@NO)); + expect(testStruct.rearRightDoorAjar).to(equal(@YES)); + }); + + it(@"Should return nil if not set", ^ { + SDLBodyInformation* testStruct = [[SDLBodyInformation alloc] init]; + + expect(testStruct.parkBrakeActive).to(beNil()); + expect(testStruct.ignitionStableStatus).to(beNil()); + expect(testStruct.ignitionStatus).to(beNil()); + expect(testStruct.driverDoorAjar).to(beNil()); + expect(testStruct.passengerDoorAjar).to(beNil()); + expect(testStruct.rearLeftDoorAjar).to(beNil()); + expect(testStruct.rearRightDoorAjar).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLButtonCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLButtonCapabilitiesSpec.m new file mode 100644 index 000000000..a5f753629 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLButtonCapabilitiesSpec.m @@ -0,0 +1,56 @@ +// +// SDLButtonCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLButtonCapabilities.h" +#import "SDLButtonName.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLButtonCapabilitiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLButtonCapabilities* testStruct = [[SDLButtonCapabilities alloc] init]; + + testStruct.name = [SDLButtonName TUNEUP]; + testStruct.shortPressAvailable = @YES; + testStruct.longPressAvailable = @YES; + testStruct.upDownAvailable = @NO; + + expect(testStruct.name).to(equal([SDLButtonName TUNEUP])); + expect(testStruct.shortPressAvailable).to(equal(@YES)); + expect(testStruct.longPressAvailable).to(equal(@YES)); + expect(testStruct.upDownAvailable).to(equal(@NO)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_name:[SDLButtonName CUSTOM_BUTTON], + NAMES_shortPressAvailable:@YES, + NAMES_longPressAvailable:@YES, + NAMES_upDownAvailable:@NO} mutableCopy]; + SDLButtonCapabilities* testStruct = [[SDLButtonCapabilities alloc] initWithDictionary:dict]; + + expect(testStruct.name).to(equal([SDLButtonName CUSTOM_BUTTON])); + expect(testStruct.shortPressAvailable).to(equal(@YES)); + expect(testStruct.longPressAvailable).to(equal(@YES)); + expect(testStruct.upDownAvailable).to(equal(@NO)); + }); + + it(@"Should return nil if not set", ^ { + SDLButtonCapabilities* testStruct = [[SDLButtonCapabilities alloc] init]; + + expect(testStruct.name).to(beNil()); + expect(testStruct.shortPressAvailable).to(beNil()); + expect(testStruct.longPressAvailable).to(beNil()); + expect(testStruct.upDownAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLChoiceSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLChoiceSpec.m new file mode 100644 index 000000000..63116976a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLChoiceSpec.m @@ -0,0 +1,74 @@ +// +// SDLChoiceSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLChoice.h" +#import "SDLImage.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLChoiceSpec) + +__block SDLImage* image = [[SDLImage alloc] init]; +__block SDLImage* secondaryImage = [[SDLImage alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLChoice* testStruct = [[SDLChoice alloc] init]; + + testStruct.choiceID = @3; + testStruct.menuName = @"Hello"; + testStruct.vrCommands = [@[@"1", @"2"] mutableCopy]; + testStruct.image = image; + testStruct.secondaryText = @"Arbitrary"; + testStruct.tertiaryText = @"qwerty"; + testStruct.secondaryImage = secondaryImage; + + expect(testStruct.choiceID).to(equal(@3)); + expect(testStruct.menuName).to(equal(@"Hello")); + expect(testStruct.vrCommands).to(equal([@[@"1", @"2"] mutableCopy])); + expect(testStruct.image).to(equal(image)); + expect(testStruct.secondaryText).to(equal(@"Arbitrary")); + expect(testStruct.tertiaryText).to(equal(@"qwerty")); + expect(testStruct.secondaryImage).to(equal(secondaryImage)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_choiceID:@3, + NAMES_menuName:@"Hello", + NAMES_vrCommands:[@[@"1", @"2"] mutableCopy], + NAMES_image:image, + NAMES_secondaryText:@"Arbitrary", + NAMES_tertiaryText:@"qwerty", + NAMES_secondaryImage:secondaryImage} mutableCopy]; + SDLChoice* testStruct = [[SDLChoice alloc] initWithDictionary:dict]; + + expect(testStruct.choiceID).to(equal(@3)); + expect(testStruct.menuName).to(equal(@"Hello")); + expect(testStruct.vrCommands).to(equal([@[@"1", @"2"] mutableCopy])); + expect(testStruct.image).to(equal(image)); + expect(testStruct.secondaryText).to(equal(@"Arbitrary")); + expect(testStruct.tertiaryText).to(equal(@"qwerty")); + expect(testStruct.secondaryImage).to(equal(secondaryImage)); + }); + + it(@"Should return nil if not set", ^ { + SDLChoice* testStruct = [[SDLChoice alloc] init]; + + expect(testStruct.choiceID).to(beNil()); + expect(testStruct.menuName).to(beNil()); + expect(testStruct.vrCommands).to(beNil()); + expect(testStruct.image).to(beNil()); + expect(testStruct.secondaryText).to(beNil()); + expect(testStruct.tertiaryText).to(beNil()); + expect(testStruct.secondaryImage).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLClusterModeStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLClusterModeStatusSpec.m new file mode 100644 index 000000000..8e74324cf --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLClusterModeStatusSpec.m @@ -0,0 +1,57 @@ +// +// SDLClusterModeStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCarModeStatus.h" +#import "SDLClusterModeStatus.h" +#import "SDLPowerModeQualificationStatus.h" +#import "SDLPowerModeStatus.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLClusterModeStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLClusterModeStatus* testStruct = [[SDLClusterModeStatus alloc] init]; + + testStruct.powerModeActive = @YES; + testStruct.powerModeQualificationStatus = [SDLPowerModeQualificationStatus POWER_MODE_EVALUATION_IN_PROGRESS]; + testStruct.carModeStatus = [SDLCarModeStatus CRASH]; + testStruct.powerModeStatus = [SDLPowerModeStatus IGNITION_ON_2]; + + expect(testStruct.powerModeActive).to(equal(@YES)); + expect(testStruct.powerModeQualificationStatus).to(equal([SDLPowerModeQualificationStatus POWER_MODE_EVALUATION_IN_PROGRESS])); + expect(testStruct.carModeStatus).to(equal([SDLCarModeStatus CRASH])); + expect(testStruct.powerModeStatus).to(equal([SDLPowerModeStatus IGNITION_ON_2])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_powerModeActive:@NO, + NAMES_powerModeQualificationStatus:[SDLPowerModeQualificationStatus POWER_MODE_OK], + NAMES_carModeStatus:[SDLCarModeStatus CRASH], + NAMES_powerModeStatus:[SDLPowerModeStatus KEY_OUT]} mutableCopy]; + SDLClusterModeStatus* testStruct = [[SDLClusterModeStatus alloc] initWithDictionary:dict]; + + expect(testStruct.powerModeActive).to(equal(@NO)); + expect(testStruct.powerModeQualificationStatus).to(equal([SDLPowerModeQualificationStatus POWER_MODE_OK])); + expect(testStruct.carModeStatus).to(equal([SDLCarModeStatus CRASH])); + expect(testStruct.powerModeStatus).to(equal([SDLPowerModeStatus KEY_OUT])); + }); + + it(@"Should return nil if not set", ^ { + SDLClusterModeStatus* testStruct = [[SDLClusterModeStatus alloc] init]; + + expect(testStruct.powerModeActive).to(beNil()); + expect(testStruct.powerModeQualificationStatus).to(beNil()); + expect(testStruct.carModeStatus).to(beNil()); + expect(testStruct.powerModeStatus).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDIDResult.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDIDResult.m new file mode 100644 index 000000000..db626f959 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDIDResult.m @@ -0,0 +1,51 @@ +// +// SDLDIDResultSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDIDResult.h" +#import "SDLNames.h" +#import "SDLVehicleDataResultCode.h" + + +QuickSpecBegin(SDLDIDResultSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDIDResult* testStruct = [[SDLDIDResult alloc] init]; + + testStruct.resultCode = [SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED]; + testStruct.didLocation = @300; + testStruct.data = @"gertwydhty4235tdhedt4tue"; + + expect(testStruct.resultCode).to(equal([SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED])); + expect(testStruct.didLocation).to(equal(@300)); + expect(testStruct.data).to(equal(@"gertwydhty4235tdhedt4tue")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_resultCode:[SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED], + NAMES_didLocation:@300, + NAMES_data:@"gertwydhty4235tdhedt4tue"} mutableCopy]; + SDLDIDResult* testStruct = [[SDLDIDResult alloc] initWithDictionary:dict]; + + expect(testStruct.resultCode).to(equal([SDLVehicleDataResultCode DATA_NOT_SUBSCRIBED])); + expect(testStruct.didLocation).to(equal(@300)); + expect(testStruct.data).to(equal(@"gertwydhty4235tdhedt4tue")); + }); + + it(@"Should return nil if not set", ^ { + SDLDIDResult* testStruct = [[SDLDIDResult alloc] init]; + + expect(testStruct.resultCode).to(beNil()); + expect(testStruct.didLocation).to(beNil()); + expect(testStruct.data).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDeviceInfoSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDeviceInfoSpec.m new file mode 100644 index 000000000..beb3b2d80 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDeviceInfoSpec.m @@ -0,0 +1,64 @@ +// +// SDLDeviceInfoSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeviceInfo.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLDeviceInfoSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeviceInfo* testStruct = [[SDLDeviceInfo alloc] init]; + + testStruct.hardware = @"GDFR34F"; + testStruct.firmwareRev = @"4.2a"; + testStruct.os = @"Robot"; + testStruct.osVersion = @"9.9"; + testStruct.carrier = @"ThatOneWirelessCompany"; + testStruct.maxNumberRFCOMMPorts = @20; + + expect(testStruct.hardware).to(equal(@"GDFR34F")); + expect(testStruct.firmwareRev).to(equal(@"4.2a")); + expect(testStruct.os).to(equal(@"Robot")); + expect(testStruct.osVersion).to(equal(@"9.9")); + expect(testStruct.carrier).to(equal(@"ThatOneWirelessCompany")); + expect(testStruct.maxNumberRFCOMMPorts).to(equal(@20)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_hardware:@"GDFR34F", + NAMES_firmwareRev:@"4.2a", + NAMES_os:@"Robot", + NAMES_osVersion:@"9.9", + NAMES_carrier:@"ThatOneWirelessCompany", + NAMES_maxNumberRFCOMMPorts:@20} mutableCopy]; + SDLDeviceInfo* testStruct = [[SDLDeviceInfo alloc] initWithDictionary:dict]; + + expect(testStruct.hardware).to(equal(@"GDFR34F")); + expect(testStruct.firmwareRev).to(equal(@"4.2a")); + expect(testStruct.os).to(equal(@"Robot")); + expect(testStruct.osVersion).to(equal(@"9.9")); + expect(testStruct.carrier).to(equal(@"ThatOneWirelessCompany")); + expect(testStruct.maxNumberRFCOMMPorts).to(equal(@20)); + }); + + it(@"Should return nil if not set", ^ { + SDLDeviceInfo* testStruct = [[SDLDeviceInfo alloc] init]; + + expect(testStruct.hardware).to(beNil()); + expect(testStruct.firmwareRev).to(beNil()); + expect(testStruct.os).to(beNil()); + expect(testStruct.osVersion).to(beNil()); + expect(testStruct.carrier).to(beNil()); + expect(testStruct.maxNumberRFCOMMPorts).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDeviceStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDeviceStatusSpec.m new file mode 100644 index 000000000..1996e45a8 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDeviceStatusSpec.m @@ -0,0 +1,92 @@ +// +// SDLDeviceStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDeviceLevelStatus.h" +#import "SDLDeviceStatus.h" +#import "SDLNames.h" +#import "SDLPrimaryAudioSource.h" + + +QuickSpecBegin(SDLDeviceStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDeviceStatus* testStruct = [[SDLDeviceStatus alloc] init]; + + testStruct.voiceRecOn = @NO; + testStruct.btIconOn = @NO; + testStruct.callActive = @YES; + testStruct.phoneRoaming = @NO; + testStruct.textMsgAvailable = @YES; + testStruct.battLevelStatus = [SDLDeviceLevelStatus FOUR_LEVEL_BARS]; + testStruct.stereoAudioOutputMuted = @YES; + testStruct.monoAudioOutputMuted = @YES; + testStruct.signalLevelStatus = [SDLDeviceLevelStatus TWO_LEVEL_BARS]; + testStruct.primaryAudioSource = [SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST]; + testStruct.eCallEventActive = @NO; + + expect(testStruct.voiceRecOn).to(equal(@NO)); + expect(testStruct.btIconOn).to(equal(@NO)); + expect(testStruct.callActive).to(equal(@YES)); + expect(testStruct.phoneRoaming).to(equal(@NO)); + expect(testStruct.textMsgAvailable).to(equal(@YES)); + expect(testStruct.battLevelStatus).to(equal([SDLDeviceLevelStatus FOUR_LEVEL_BARS])); + expect(testStruct.stereoAudioOutputMuted).to(equal(@YES)); + expect(testStruct.monoAudioOutputMuted).to(equal(@YES)); + expect(testStruct.signalLevelStatus).to(equal([SDLDeviceLevelStatus TWO_LEVEL_BARS])); + expect(testStruct.primaryAudioSource).to(equal([SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST])); + expect(testStruct.eCallEventActive).to(equal(@NO)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_voiceRecOn:@NO, + NAMES_btIconOn:@NO, + NAMES_callActive:@YES, + NAMES_phoneRoaming:@NO, + NAMES_textMsgAvailable:@YES, + NAMES_battLevelStatus:[SDLDeviceLevelStatus FOUR_LEVEL_BARS], + NAMES_stereoAudioOutputMuted:@YES, + NAMES_monoAudioOutputMuted:@YES, + NAMES_signalLevelStatus:[SDLDeviceLevelStatus TWO_LEVEL_BARS], + NAMES_primaryAudioSource:[SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST], + NAMES_eCallEventActive:@NO} mutableCopy]; + SDLDeviceStatus* testStruct = [[SDLDeviceStatus alloc] initWithDictionary:dict]; + + expect(testStruct.voiceRecOn).to(equal(@NO)); + expect(testStruct.btIconOn).to(equal(@NO)); + expect(testStruct.callActive).to(equal(@YES)); + expect(testStruct.phoneRoaming).to(equal(@NO)); + expect(testStruct.textMsgAvailable).to(equal(@YES)); + expect(testStruct.battLevelStatus).to(equal([SDLDeviceLevelStatus FOUR_LEVEL_BARS])); + expect(testStruct.stereoAudioOutputMuted).to(equal(@YES)); + expect(testStruct.monoAudioOutputMuted).to(equal(@YES)); + expect(testStruct.signalLevelStatus).to(equal([SDLDeviceLevelStatus TWO_LEVEL_BARS])); + expect(testStruct.primaryAudioSource).to(equal([SDLPrimaryAudioSource BLUETOOTH_STEREO_BTST])); + expect(testStruct.eCallEventActive).to(equal(@NO)); + }); + + it(@"Should return nil if not set", ^ { + SDLDeviceStatus* testStruct = [[SDLDeviceStatus alloc] init]; + + expect(testStruct.voiceRecOn).to(beNil()); + expect(testStruct.btIconOn).to(beNil()); + expect(testStruct.callActive).to(beNil()); + expect(testStruct.phoneRoaming).to(beNil()); + expect(testStruct.textMsgAvailable).to(beNil()); + expect(testStruct.battLevelStatus).to(beNil()); + expect(testStruct.stereoAudioOutputMuted).to(beNil()); + expect(testStruct.monoAudioOutputMuted).to(beNil()); + expect(testStruct.signalLevelStatus).to(beNil()); + expect(testStruct.primaryAudioSource).to(beNil()); + expect(testStruct.eCallEventActive).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDisplayCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDisplayCapabilitiesSpec.m new file mode 100644 index 000000000..02cac7f54 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDisplayCapabilitiesSpec.m @@ -0,0 +1,84 @@ +// +// SDLDisplayCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLDisplayCapabilities.h" +#import "SDLDisplayType.h" +#import "SDLImageField.h" +#import "SDLMediaClockFormat.h" +#import "SDLNames.h" +#import "SDLScreenParams.h" +#import "SDLTextField.h" + + +QuickSpecBegin(SDLDisplayCapabilitiesSpec) + +SDLScreenParams* screenParams = [[SDLScreenParams alloc] init]; +SDLTextField* textField = [[SDLTextField alloc] init]; +SDLImageField* imageField = [[SDLImageField alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLDisplayCapabilities* testStruct = [[SDLDisplayCapabilities alloc] init]; + + testStruct.displayType = [SDLDisplayType GEN2_6_DMA]; + testStruct.textFields = [@[textField] mutableCopy]; + testStruct.imageFields = [@[imageField] mutableCopy]; + testStruct.mediaClockFormats = [@[[SDLMediaClockFormat CLOCKTEXT1], [SDLMediaClockFormat CLOCK3], [SDLMediaClockFormat CLOCKTEXT3]] copy]; + testStruct.graphicSupported = @YES; + testStruct.templatesAvailable = [@[@"String", @"String", @"String"] mutableCopy]; + testStruct.screenParams = screenParams; + testStruct.numCustomPresetsAvailable = @43; + + expect(testStruct.displayType).to(equal([SDLDisplayType GEN2_6_DMA])); + expect(testStruct.textFields).to(equal([@[textField] mutableCopy])); + expect(testStruct.imageFields).to(equal([@[imageField] mutableCopy])); + expect(testStruct.mediaClockFormats).to(equal([@[[SDLMediaClockFormat CLOCKTEXT1], [SDLMediaClockFormat CLOCK3], [SDLMediaClockFormat CLOCKTEXT3]] copy])); + expect(testStruct.graphicSupported).to(equal(@YES)); + expect(testStruct.templatesAvailable).to(equal([@[@"String", @"String", @"String"] mutableCopy])); + expect(testStruct.screenParams).to(equal(screenParams)); + expect(testStruct.numCustomPresetsAvailable).to(equal(@43)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_displayType:[SDLDisplayType GEN2_6_DMA], + NAMES_textFields:[@[textField] mutableCopy], + NAMES_imageFields:[@[imageField] mutableCopy], + NAMES_mediaClockFormats:[@[[SDLMediaClockFormat CLOCKTEXT1], [SDLMediaClockFormat CLOCK3], [SDLMediaClockFormat CLOCKTEXT3]] copy], + NAMES_graphicSupported:@YES, + NAMES_templatesAvailable:[@[@"String", @"String", @"String"] mutableCopy], + NAMES_screenParams:screenParams, + NAMES_numCustomPresetsAvailable:@43} mutableCopy]; + SDLDisplayCapabilities* testStruct = [[SDLDisplayCapabilities alloc] initWithDictionary:dict]; + + expect(testStruct.displayType).to(equal([SDLDisplayType GEN2_6_DMA])); + expect(testStruct.textFields).to(equal([@[textField] mutableCopy])); + expect(testStruct.imageFields).to(equal([@[imageField] mutableCopy])); + expect(testStruct.mediaClockFormats).to(equal([@[[SDLMediaClockFormat CLOCKTEXT1], [SDLMediaClockFormat CLOCK3], [SDLMediaClockFormat CLOCKTEXT3]] copy])); + expect(testStruct.graphicSupported).to(equal(@YES)); + expect(testStruct.templatesAvailable).to(equal([@[@"String", @"String", @"String"] mutableCopy])); + expect(testStruct.screenParams).to(equal(screenParams)); + expect(testStruct.numCustomPresetsAvailable).to(equal(@43)); + }); + + it(@"Should return nil if not set", ^ { + SDLDisplayCapabilities* testStruct = [[SDLDisplayCapabilities alloc] init]; + + expect(testStruct.displayType).to(beNil()); + expect(testStruct.textFields).to(beNil()); + expect(testStruct.imageFields).to(beNil()); + expect(testStruct.mediaClockFormats).to(beNil()); + expect(testStruct.graphicSupported).to(beNil()); + expect(testStruct.templatesAvailable).to(beNil()); + expect(testStruct.screenParams).to(beNil()); + expect(testStruct.numCustomPresetsAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLECallInfoSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLECallInfoSpec.m new file mode 100644 index 000000000..28e226187 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLECallInfoSpec.m @@ -0,0 +1,52 @@ +// +// SDLECallInfoSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataNotificationStatus.h" +#import "SDLECallConfirmationStatus.h" +#import "SDLECallInfo.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLECallInfoSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLECallInfo* testStruct = [[SDLECallInfo alloc] init]; + + testStruct.eCallNotificationStatus = [SDLVehicleDataNotificationStatus NORMAL]; + testStruct.auxECallNotificationStatus = [SDLVehicleDataNotificationStatus ACTIVE]; + testStruct.eCallConfirmationStatus = [SDLECallConfirmationStatus CALL_IN_PROGRESS]; + + expect(testStruct.eCallNotificationStatus).to(equal([SDLVehicleDataNotificationStatus NORMAL])); + expect(testStruct.auxECallNotificationStatus).to(equal([SDLVehicleDataNotificationStatus ACTIVE])); + expect(testStruct.eCallConfirmationStatus).to(equal([SDLECallConfirmationStatus CALL_IN_PROGRESS])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_eCallNotificationStatus:[SDLVehicleDataNotificationStatus NORMAL], + NAMES_auxECallNotificationStatus:[SDLVehicleDataNotificationStatus ACTIVE], + NAMES_eCallConfirmationStatus:[SDLECallConfirmationStatus CALL_IN_PROGRESS]} mutableCopy]; + SDLECallInfo* testStruct = [[SDLECallInfo alloc] initWithDictionary:dict]; + + expect(testStruct.eCallNotificationStatus).to(equal([SDLVehicleDataNotificationStatus NORMAL])); + expect(testStruct.auxECallNotificationStatus).to(equal([SDLVehicleDataNotificationStatus ACTIVE])); + expect(testStruct.eCallConfirmationStatus).to(equal([SDLECallConfirmationStatus CALL_IN_PROGRESS])); + }); + + it(@"Should return nil if not set", ^ { + SDLECallInfo* testStruct = [[SDLECallInfo alloc] init]; + + expect(testStruct.eCallNotificationStatus).to(beNil()); + expect(testStruct.auxECallNotificationStatus).to(beNil()); + expect(testStruct.eCallConfirmationStatus).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLEmergencyEventSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLEmergencyEventSpec.m new file mode 100644 index 000000000..c67f45d45 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLEmergencyEventSpec.m @@ -0,0 +1,63 @@ +// +// SDLEmergencyEventSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEmergencyEvent.h" +#import "SDLEmergencyEventType.h" +#import "SDLFuelCutoffStatus.h" +#import "SDLNames.h" +#import "SDLVehicleDataEventStatus.h" + + +QuickSpecBegin(SDLEmergencyEventSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLEmergencyEvent* testStruct = [[SDLEmergencyEvent alloc] init]; + + testStruct.emergencyEventType = [SDLEmergencyEventType FRONTAL]; + testStruct.fuelCutoffStatus = [SDLFuelCutoffStatus NORMAL_OPERATION]; + testStruct.rolloverEvent = [SDLVehicleDataEventStatus _YES]; + testStruct.maximumChangeVelocity = @33; + testStruct.multipleEvents = [SDLVehicleDataEventStatus _NO]; + + expect(testStruct.emergencyEventType).to(equal([SDLEmergencyEventType FRONTAL])); + expect(testStruct.fuelCutoffStatus).to(equal([SDLFuelCutoffStatus NORMAL_OPERATION])); + expect(testStruct.rolloverEvent).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.maximumChangeVelocity).to(equal(@33)); + expect(testStruct.multipleEvents).to(equal([SDLVehicleDataEventStatus _NO])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_emergencyEventType:[SDLEmergencyEventType FRONTAL], + NAMES_fuelCutoffStatus:[SDLFuelCutoffStatus NORMAL_OPERATION], + NAMES_rolloverEvent:[SDLVehicleDataEventStatus _YES], + NAMES_maximumChangeVelocity:@33, + NAMES_multipleEvents:[SDLVehicleDataEventStatus _NO]} mutableCopy]; + SDLEmergencyEvent* testStruct = [[SDLEmergencyEvent alloc] initWithDictionary:dict]; + + expect(testStruct.emergencyEventType).to(equal([SDLEmergencyEventType FRONTAL])); + expect(testStruct.fuelCutoffStatus).to(equal([SDLFuelCutoffStatus NORMAL_OPERATION])); + expect(testStruct.rolloverEvent).to(equal([SDLVehicleDataEventStatus _YES])); + expect(testStruct.maximumChangeVelocity).to(equal(@33)); + expect(testStruct.multipleEvents).to(equal([SDLVehicleDataEventStatus _NO])); + }); + + it(@"Should return nil if not set", ^ { + SDLEmergencyEvent* testStruct = [[SDLEmergencyEvent alloc] init]; + + expect(testStruct.emergencyEventType).to(beNil()); + expect(testStruct.fuelCutoffStatus).to(beNil()); + expect(testStruct.rolloverEvent).to(beNil()); + expect(testStruct.maximumChangeVelocity).to(beNil()); + expect(testStruct.multipleEvents).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLGPSDataSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLGPSDataSpec.m new file mode 100644 index 000000000..6d19dbf77 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLGPSDataSpec.m @@ -0,0 +1,127 @@ +// +// SDLGPSDataSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCompassDirection.h" +#import "SDLDimension.h" +#import "SDLGPSData.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLGPSDataSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLGPSData* testStruct = [[SDLGPSData alloc] init]; + + testStruct.longitudeDegrees = @31.41592653589793; + testStruct.latitudeDegrees = @45; + testStruct.utcYear = @2015; + testStruct.utcMonth = @1; + testStruct.utcDay = @26; + testStruct.utcHours = @23; + testStruct.utcMinutes = @59; + testStruct.utcSeconds = @59; + testStruct.compassDirection = [SDLCompassDirection SOUTHEAST]; + testStruct.pdop = @3.4; + testStruct.hdop = @9.9; + testStruct.vdop = @0; + testStruct.actual = @NO; + testStruct.satellites = @12; + testStruct.dimension = [SDLDimension _3D]; + testStruct.altitude = @3000; + testStruct.heading = @96; + testStruct.speed = @64; + + expect(testStruct.longitudeDegrees).to(equal(@31.41592653589793)); + expect(testStruct.latitudeDegrees).to(equal(@45)); + expect(testStruct.utcYear).to(equal(@2015)); + expect(testStruct.utcMonth).to(equal(@1)); + expect(testStruct.utcDay).to(equal(@26)); + expect(testStruct.utcHours).to(equal(@23)); + expect(testStruct.utcMinutes).to(equal(@59)); + expect(testStruct.utcSeconds).to(equal(@59)); + expect(testStruct.compassDirection).to(equal([SDLCompassDirection SOUTHEAST])); + expect(testStruct.pdop).to(equal(@3.4)); + expect(testStruct.hdop).to(equal(@9.9)); + expect(testStruct.vdop).to(equal(@0)); + expect(testStruct.actual).to(equal(@NO)); + expect(testStruct.satellites).to(equal(@12)); + expect(testStruct.dimension).to(equal([SDLDimension _3D])); + expect(testStruct.altitude).to(equal(@3000)); + expect(testStruct.heading).to(equal(@96)); + expect(testStruct.speed).to(equal(@64)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_longitudeDegrees:@31.41592653589793, + NAMES_latitudeDegrees:@45, + NAMES_utcYear:@2015, + NAMES_utcMonth:@1, + NAMES_utcDay:@26, + NAMES_utcHours:@23, + NAMES_utcMinutes:@59, + NAMES_utcSeconds:@59, + NAMES_compassDirection:[SDLCompassDirection SOUTHEAST], + NAMES_pdop:@3.4, + NAMES_hdop:@9.9, + NAMES_vdop:@0, + NAMES_actual:@NO, + NAMES_satellites:@12, + NAMES_dimension:[SDLDimension _3D], + NAMES_altitude:@3000, + NAMES_heading:@96, + NAMES_speed:@64} mutableCopy]; + SDLGPSData* testStruct = [[SDLGPSData alloc] initWithDictionary:dict]; + + expect(testStruct.longitudeDegrees).to(equal(@31.41592653589793)); + expect(testStruct.latitudeDegrees).to(equal(@45)); + expect(testStruct.utcYear).to(equal(@2015)); + expect(testStruct.utcMonth).to(equal(@1)); + expect(testStruct.utcDay).to(equal(@26)); + expect(testStruct.utcHours).to(equal(@23)); + expect(testStruct.utcMinutes).to(equal(@59)); + expect(testStruct.utcSeconds).to(equal(@59)); + expect(testStruct.compassDirection).to(equal([SDLCompassDirection SOUTHEAST])); + expect(testStruct.pdop).to(equal(@3.4)); + expect(testStruct.hdop).to(equal(@9.9)); + expect(testStruct.vdop).to(equal(@0)); + expect(testStruct.actual).to(equal(@NO)); + expect(testStruct.satellites).to(equal(@12)); + expect(testStruct.dimension).to(equal([SDLDimension _3D])); + expect(testStruct.altitude).to(equal(@3000)); + expect(testStruct.heading).to(equal(@96)); + expect(testStruct.speed).to(equal(@64)); + }); + + it(@"Should return nil if not set", ^ { + SDLGPSData* testStruct = [[SDLGPSData alloc] init]; + + expect(testStruct.longitudeDegrees).to(beNil()); + expect(testStruct.latitudeDegrees).to(beNil()); + expect(testStruct.utcYear).to(beNil()); + expect(testStruct.utcMonth).to(beNil()); + expect(testStruct.utcDay).to(beNil()); + expect(testStruct.utcHours).to(beNil()); + expect(testStruct.utcMinutes).to(beNil()); + expect(testStruct.utcSeconds).to(beNil()); + expect(testStruct.compassDirection).to(beNil()); + expect(testStruct.pdop).to(beNil()); + expect(testStruct.hdop).to(beNil()); + expect(testStruct.vdop).to(beNil()); + expect(testStruct.actual).to(beNil()); + expect(testStruct.satellites).to(beNil()); + expect(testStruct.dimension).to(beNil()); + expect(testStruct.altitude).to(beNil()); + expect(testStruct.heading).to(beNil()); + expect(testStruct.speed).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m new file mode 100644 index 000000000..e9935bedf --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m @@ -0,0 +1,69 @@ +// +// SDLHMICapabilitiesSpec.m +// SmartDeviceLink-iOS +// + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMICapabilities.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLHMICapabilitiesSpec) + +describe(@"SDLHMICapabilities struct", ^{ + __block SDLHMICapabilities *testStruct = nil; + __block NSNumber *somePhoneCallState = @NO; + __block NSNumber *someNavigationState = @YES; + + context(@"When initialized with properties", ^{ + beforeEach(^{ + testStruct = [[SDLHMICapabilities alloc] init]; + testStruct.phoneCall = somePhoneCallState; + testStruct.navigation = someNavigationState; + }); + + it(@"should properly set phone call", ^{ + expect(testStruct.phoneCall).to(equal(somePhoneCallState)); + }); + + it(@"should properly set navigation", ^{ + expect(testStruct.navigation).to(equal(someNavigationState)); + }); + }); + + context(@"When initialized with a dictionary", ^{ + beforeEach(^{ + NSDictionary *structInitDict = @{ + NAMES_navigation: someNavigationState, + NAMES_phoneCall: somePhoneCallState + }; + testStruct = [[SDLHMICapabilities alloc] initWithDictionary:[structInitDict mutableCopy]]; + }); + + it(@"should properly set phone call", ^{ + expect(testStruct.phoneCall).to(equal(somePhoneCallState)); + }); + + it(@"should properly set navigation", ^{ + expect(testStruct.navigation).to(equal(someNavigationState)); + }); + }); + + context(@"When not initialized", ^{ + beforeEach(^{ + testStruct = nil; + }); + + it(@"phoneCall should be nil", ^{ + expect(testStruct.phoneCall).to(beNil()); + }); + + it(@"navigation should be nil", ^{ + expect(testStruct.navigation).to(beNil()); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMIPermissionsSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMIPermissionsSpec.m new file mode 100644 index 000000000..63df146cb --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMIPermissionsSpec.m @@ -0,0 +1,45 @@ +// +// SDLHMIPermissionsSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMIPermissions.h" +#import "SDLHMILevel.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLHMIPermissionsSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLHMIPermissions* testStruct = [[SDLHMIPermissions alloc] init]; + + testStruct.allowed = [@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy]; + testStruct.userDisallowed = [@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy]; + + expect(testStruct.allowed).to(equal([@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy])); + expect(testStruct.userDisallowed).to(equal([@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_allowed:[@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy], + NAMES_userDisallowed:[@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy]} mutableCopy]; + SDLHMIPermissions* testStruct = [[SDLHMIPermissions alloc] initWithDictionary:dict]; + + expect(testStruct.allowed).to(equal([@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy])); + expect(testStruct.userDisallowed).to(equal([@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy])); + }); + + it(@"Should return nil if not set", ^ { + SDLHMIPermissions* testStruct = [[SDLHMIPermissions alloc] init]; + + expect(testStruct.allowed).to(beNil()); + expect(testStruct.userDisallowed).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHeadLampStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHeadLampStatusSpec.m new file mode 100644 index 000000000..b418b962b --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHeadLampStatusSpec.m @@ -0,0 +1,51 @@ +// +// SDLHeadLampStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLAmbientLightStatus.h" +#import "SDLHeadLampStatus.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLHeadLampStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLHeadLampStatus* testStruct = [[SDLHeadLampStatus alloc] init]; + + testStruct.lowBeamsOn = @YES; + testStruct.highBeamsOn = @NO; + testStruct.ambientLightSensorStatus = [SDLAmbientLightStatus TWILIGHT_3]; + + expect(testStruct.lowBeamsOn).to(equal(@YES)); + expect(testStruct.highBeamsOn).to(equal(@NO)); + expect(testStruct.ambientLightSensorStatus).to(equal([SDLAmbientLightStatus TWILIGHT_3])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_lowBeamsOn:@YES, + NAMES_highBeamsOn:@NO, + NAMES_ambientLightSensorStatus:[SDLAmbientLightStatus TWILIGHT_3]} mutableCopy]; + SDLHeadLampStatus* testStruct = [[SDLHeadLampStatus alloc] initWithDictionary:dict]; + + expect(testStruct.lowBeamsOn).to(equal(@YES)); + expect(testStruct.highBeamsOn).to(equal(@NO)); + expect(testStruct.ambientLightSensorStatus).to(equal([SDLAmbientLightStatus TWILIGHT_3])); + }); + + it(@"Should return nil if not set", ^ { + SDLHeadLampStatus* testStruct = [[SDLHeadLampStatus alloc] init]; + + expect(testStruct.lowBeamsOn).to(beNil()); + expect(testStruct.highBeamsOn).to(beNil()); + expect(testStruct.ambientLightSensorStatus).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m new file mode 100644 index 000000000..2bcef11f1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageFieldSpec.m @@ -0,0 +1,55 @@ +// +// SDLImageFieldSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLFileType.h" +#import "SDLImageField.h" +#import "SDLImageFieldName.h" +#import "SDLImageResolution.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLImageFieldSpec) + +SDLImageResolution* resolution = [[SDLImageResolution alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLImageField* testStruct = [[SDLImageField alloc] init]; + + testStruct.name = [SDLImageFieldName turnIcon]; + testStruct.imageTypeSupported = [@[[SDLFileType GRAPHIC_PNG], [SDLFileType GRAPHIC_JPEG]] copy]; + testStruct.imageResolution = resolution; + + expect(testStruct.name).to(equal([SDLImageFieldName turnIcon])); + expect(testStruct.imageTypeSupported).to(equal([@[[SDLFileType GRAPHIC_PNG], [SDLFileType GRAPHIC_JPEG]] copy])); + expect(testStruct.imageResolution).to(equal(resolution)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_name:[SDLImageFieldName turnIcon], + NAMES_imageTypeSupported:[@[[SDLFileType GRAPHIC_PNG], [SDLFileType GRAPHIC_JPEG]] copy], + NAMES_imageResolution:resolution} mutableCopy]; + SDLImageField* testStruct = [[SDLImageField alloc] initWithDictionary:dict]; + + expect(testStruct.name).to(equal([SDLImageFieldName turnIcon])); + expect(testStruct.imageTypeSupported).to(equal([@[[SDLFileType GRAPHIC_PNG], [SDLFileType GRAPHIC_JPEG]] copy])); + expect(testStruct.imageResolution).to(equal(resolution)); + }); + + it(@"Should return nil if not set", ^ { + SDLImageField* testStruct = [[SDLImageField alloc] init]; + + expect(testStruct.name).to(beNil()); + expect(testStruct.imageTypeSupported).to(beNil()); + expect(testStruct.imageResolution).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageSpec.m new file mode 100644 index 000000000..dba2d630e --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLImageSpec.m @@ -0,0 +1,46 @@ +// +// SDLImageSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImage.h" +#import "SDLImageType.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLImageSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLImage* testStruct = [[SDLImage alloc] init]; + + testStruct.value = @"value"; + testStruct.imageType = [SDLImageType STATIC]; + + expect(testStruct.value).to(equal(@"value")); + expect(testStruct.imageType).to(equal([SDLImageType STATIC])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_value:@"value", + NAMES_imageType:[SDLImageType STATIC]} mutableCopy]; + SDLImage* testStruct = [[SDLImage alloc] initWithDictionary:dict]; + + expect(testStruct.value).to(equal(@"value")); + expect(testStruct.imageType).to(equal([SDLImageType STATIC])); + }); + + it(@"Should return nil if not set", ^ { + SDLImage* testStruct = [[SDLImage alloc] init]; + + expect(testStruct.value).to(beNil()); + expect(testStruct.imageType).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m new file mode 100644 index 000000000..3e6793b62 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m @@ -0,0 +1,63 @@ +// +// SDLKeyboardPropertiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLKeyboardLayout.h" +#import "SDLKeypressMode.h" +#import "SDLKeyboardProperties.h" +#import "SDLLanguage.h" +#import "SDLNames.h" + + +QuickSpecBegin(SDLKeyboardPropertiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] init]; + + testStruct.language = [SDLLanguage DA_DK]; + testStruct.keyboardLayout = [SDLKeyboardLayout QWERTZ]; + testStruct.keypressMode = [SDLKeypressMode RESEND_CURRENT_ENTRY]; + testStruct.limitedCharacterList = [@[@"s", @"r", @"f", @"q"] mutableCopy]; + testStruct.autoCompleteText = @"Auto Carrot"; + + expect(testStruct.language).to(equal([SDLLanguage DA_DK])); + expect(testStruct.keyboardLayout).to(equal([SDLKeyboardLayout QWERTZ])); + expect(testStruct.keypressMode).to(equal([SDLKeypressMode RESEND_CURRENT_ENTRY])); + expect(testStruct.limitedCharacterList).to(equal([@[@"s", @"r", @"f", @"q"] mutableCopy])); + expect(testStruct.autoCompleteText).to(equal(@"Auto Carrot")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_language:[SDLLanguage DA_DK], + NAMES_keyboardLayout:[SDLKeyboardLayout QWERTZ], + NAMES_keypressMode:[SDLKeypressMode RESEND_CURRENT_ENTRY], + NAMES_limitedCharacterList:[@[@"s", @"r", @"f", @"q"] mutableCopy], + NAMES_autoCompleteText:@"Auto Carrot"} mutableCopy]; + SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] initWithDictionary:dict]; + + expect(testStruct.language).to(equal([SDLLanguage DA_DK])); + expect(testStruct.keyboardLayout).to(equal([SDLKeyboardLayout QWERTZ])); + expect(testStruct.keypressMode).to(equal([SDLKeypressMode RESEND_CURRENT_ENTRY])); + expect(testStruct.limitedCharacterList).to(equal([@[@"s", @"r", @"f", @"q"] mutableCopy])); + expect(testStruct.autoCompleteText).to(equal(@"Auto Carrot")); + }); + + it(@"Should return nil if not set", ^ { + SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] init]; + + expect(testStruct.language).to(beNil()); + expect(testStruct.keyboardLayout).to(beNil()); + expect(testStruct.keypressMode).to(beNil()); + expect(testStruct.limitedCharacterList).to(beNil()); + expect(testStruct.autoCompleteText).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMenuParamsSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMenuParamsSpec.m new file mode 100644 index 000000000..3d6bc6462 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMenuParamsSpec.m @@ -0,0 +1,49 @@ +// +// SDLMenuParamsSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLMenuParams.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLMenuParamsSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLMenuParams* testStruct = [[SDLMenuParams alloc] init]; + + testStruct.parentID = @504320489; + testStruct.position = @256; + testStruct.menuName = @"Menu"; + + expect(testStruct.parentID).to(equal(@504320489)); + expect(testStruct.position).to(equal(@256)); + expect(testStruct.menuName).to(equal(@"Menu")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_parentID:@504320489, + NAMES_position:@256, + NAMES_menuName:@"Menu"} mutableCopy]; + SDLMenuParams* testStruct = [[SDLMenuParams alloc] initWithDictionary:dict]; + + expect(testStruct.parentID).to(equal(@504320489)); + expect(testStruct.position).to(equal(@256)); + expect(testStruct.menuName).to(equal(@"Menu")); + }); + + it(@"Should return nil if not set", ^ { + SDLMenuParams* testStruct = [[SDLMenuParams alloc] init]; + + expect(testStruct.parentID).to(beNil()); + expect(testStruct.position).to(beNil()); + expect(testStruct.menuName).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMyKeySpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMyKeySpec.m new file mode 100644 index 000000000..c442e2cfc --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLMyKeySpec.m @@ -0,0 +1,41 @@ +// +// SDLMyKeySpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLMyKey.h" +#import "SDLNames.h" +#import "SDLVehicleDataStatus.h" + + +QuickSpecBegin(SDLMyKeySpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLMyKey* testStruct = [[SDLMyKey alloc] init]; + + testStruct.e911Override = [SDLVehicleDataStatus OFF]; + + expect(testStruct.e911Override).to(equal([SDLVehicleDataStatus OFF])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_e911Override:[SDLVehicleDataStatus ON]} mutableCopy]; + SDLMyKey* testStruct = [[SDLMyKey alloc] initWithDictionary:dict]; + + expect(testStruct.e911Override).to(equal([SDLVehicleDataStatus ON])); + }); + + it(@"Should return nil if not set", ^ { + SDLMyKey* testStruct = [[SDLMyKey alloc] init]; + + expect(testStruct.e911Override).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLParameterPermissionsSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLParameterPermissionsSpec.m new file mode 100644 index 000000000..08e375e9f --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLParameterPermissionsSpec.m @@ -0,0 +1,45 @@ +// +// SDLParameterPermissionsSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLParameterPermissions.h" +#import "SDLHMILevel.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLParameterPermissionsSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLParameterPermissions* testStruct = [[SDLParameterPermissions alloc] init]; + + testStruct.allowed = [@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy]; + testStruct.userDisallowed = [@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy]; + + expect(testStruct.allowed).to(equal([@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy])); + expect(testStruct.userDisallowed).to(equal([@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_allowed:[@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy], + NAMES_userDisallowed:[@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy]} mutableCopy]; + SDLParameterPermissions* testStruct = [[SDLParameterPermissions alloc] initWithDictionary:dict]; + + expect(testStruct.allowed).to(equal([@[[SDLHMILevel BACKGROUND], [SDLHMILevel FULL]] copy])); + expect(testStruct.userDisallowed).to(equal([@[[SDLHMILevel NONE], [SDLHMILevel LIMITED]] copy])); + }); + + it(@"Should return nil if not set", ^ { + SDLParameterPermissions* testStruct = [[SDLParameterPermissions alloc] init]; + + expect(testStruct.allowed).to(beNil()); + expect(testStruct.userDisallowed).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLPermissionItemSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLPermissionItemSpec.m new file mode 100644 index 000000000..0e5b367d1 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLPermissionItemSpec.m @@ -0,0 +1,54 @@ +// +// SDLPermissionItemSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHMIPermissions.h" +#import "SDLParameterPermissions.h" +#import "SDLPermissionItem.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLPermissionItemSpec) + +SDLHMIPermissions* hmiPermissions = [[SDLHMIPermissions alloc] init]; +SDLParameterPermissions* parameterPermissions = [[SDLParameterPermissions alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPermissionItem* testStruct = [[SDLPermissionItem alloc] init]; + + testStruct.rpcName = @"RPCNameThing"; + testStruct.hmiPermissions = hmiPermissions; + testStruct.parameterPermissions = parameterPermissions; + + expect(testStruct.rpcName).to(equal(@"RPCNameThing")); + expect(testStruct.hmiPermissions).to(equal(hmiPermissions)); + expect(testStruct.parameterPermissions).to(equal(parameterPermissions)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_rpcName:@"RPCNameThing", + NAMES_hmiPermissions:hmiPermissions, + NAMES_parameterPermissions:parameterPermissions} mutableCopy]; + SDLPermissionItem* testStruct = [[SDLPermissionItem alloc] initWithDictionary:dict]; + + expect(testStruct.rpcName).to(equal(@"RPCNameThing")); + expect(testStruct.hmiPermissions).to(equal(hmiPermissions)); + expect(testStruct.parameterPermissions).to(equal(parameterPermissions)); + }); + + it(@"Should return nil if not set", ^ { + SDLPermissionItem* testStruct = [[SDLPermissionItem alloc] init]; + + expect(testStruct.rpcName).to(beNil()); + expect(testStruct.hmiPermissions).to(beNil()); + expect(testStruct.parameterPermissions).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLPresetBankCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLPresetBankCapabilitiesSpec.m new file mode 100644 index 000000000..f473c60b6 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLPresetBankCapabilitiesSpec.m @@ -0,0 +1,39 @@ +// +// SDLPresetBankCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPresetBankCapabilities.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLPresetBankCapabilitiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLPresetBankCapabilities* testStruct = [[SDLPresetBankCapabilities alloc] init]; + + testStruct.onScreenPresetsAvailable = @NO; + + expect(testStruct.onScreenPresetsAvailable).to(equal(@NO)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_onScreenPresetsAvailable:@YES} mutableCopy]; + SDLPresetBankCapabilities* testStruct = [[SDLPresetBankCapabilities alloc] initWithDictionary:dict]; + + expect(testStruct.onScreenPresetsAvailable).to(equal(@YES)); + }); + + it(@"Should return nil if not set", ^ { + SDLPresetBankCapabilities* testStruct = [[SDLPresetBankCapabilities alloc] init]; + + expect(testStruct.onScreenPresetsAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLScreenParamsSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLScreenParamsSpec.m new file mode 100644 index 000000000..0438b8a21 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLScreenParamsSpec.m @@ -0,0 +1,50 @@ +// +// SDLScreenParamsSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImageResolution.h" +#import "SDLNames.h" +#import "SDLScreenParams.h" +#import "SDLTouchEventCapabilities.h" + + +QuickSpecBegin(SDLScreenParamsSpec) + +SDLImageResolution* resolution = [[SDLImageResolution alloc] init]; +SDLTouchEventCapabilities* capabilities = [[SDLTouchEventCapabilities alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLScreenParams* testStruct = [[SDLScreenParams alloc] init]; + + testStruct.resolution = resolution; + testStruct.touchEventAvailable = capabilities; + + expect(testStruct.resolution).to(equal(resolution)); + expect(testStruct.touchEventAvailable).to(equal(capabilities)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_resolution:resolution, + NAMES_touchEventAvailable:capabilities} mutableCopy]; + SDLScreenParams* testStruct = [[SDLScreenParams alloc] initWithDictionary:dict]; + + expect(testStruct.resolution).to(equal(resolution)); + expect(testStruct.touchEventAvailable).to(equal(capabilities)); + }); + + it(@"Should return nil if not set", ^ { + SDLScreenParams* testStruct = [[SDLScreenParams alloc] init]; + + expect(testStruct.resolution).to(beNil()); + expect(testStruct.touchEventAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSingleTireStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSingleTireStatusSpec.m new file mode 100644 index 000000000..6482a4f75 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSingleTireStatusSpec.m @@ -0,0 +1,40 @@ +// +// SDLSingleTireStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSingleTireStatus.h" +#import "SDLComponentVolumeStatus.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSingleTireStatusSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSingleTireStatus* testStruct = [[SDLSingleTireStatus alloc] init]; + + testStruct.status = [SDLComponentVolumeStatus NORMAL]; + + expect(testStruct.status).to(equal([SDLComponentVolumeStatus NORMAL])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_status:[SDLComponentVolumeStatus LOW]} mutableCopy]; + SDLSingleTireStatus* testStruct = [[SDLSingleTireStatus alloc] initWithDictionary:dict]; + + expect(testStruct.status).to(equal([SDLComponentVolumeStatus LOW])); + }); + + it(@"Should return nil if not set", ^ { + SDLSingleTireStatus* testStruct = [[SDLSingleTireStatus alloc] init]; + + expect(testStruct.status).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSoftButtonCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSoftButtonCapabilitiesSpec.m new file mode 100644 index 000000000..0cb200414 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSoftButtonCapabilitiesSpec.m @@ -0,0 +1,54 @@ +// +// SDLSoftButtonCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSoftButtonCapabilities.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSoftButtonCapabilitiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSoftButtonCapabilities* testStruct = [[SDLSoftButtonCapabilities alloc] init]; + + testStruct.shortPressAvailable = @NO; + testStruct.longPressAvailable = @YES; + testStruct.upDownAvailable = @NO; + testStruct.imageSupported = @NO; + + expect(testStruct.shortPressAvailable).to(equal(@NO)); + expect(testStruct.longPressAvailable).to(equal(@YES)); + expect(testStruct.upDownAvailable).to(equal(@NO)); + expect(testStruct.imageSupported).to(equal(@NO)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_shortPressAvailable:@NO, + NAMES_longPressAvailable:@YES, + NAMES_upDownAvailable:@NO, + NAMES_imageSupported:@NO} mutableCopy]; + SDLSoftButtonCapabilities* testStruct = [[SDLSoftButtonCapabilities alloc] initWithDictionary:dict]; + + expect(testStruct.shortPressAvailable).to(equal(@NO)); + expect(testStruct.longPressAvailable).to(equal(@YES)); + expect(testStruct.upDownAvailable).to(equal(@NO)); + expect(testStruct.imageSupported).to(equal(@NO)); + }); + + it(@"Should return nil if not set", ^ { + SDLSoftButtonCapabilities* testStruct = [[SDLSoftButtonCapabilities alloc] init]; + + expect(testStruct.shortPressAvailable).to(beNil()); + expect(testStruct.longPressAvailable).to(beNil()); + expect(testStruct.upDownAvailable).to(beNil()); + expect(testStruct.imageSupported).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSoftButtonSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSoftButtonSpec.m new file mode 100644 index 000000000..c9e766a65 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSoftButtonSpec.m @@ -0,0 +1,70 @@ +// +// SDLSoftButtonSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLSoftButton.h" +#import "SDLSoftButtonType.h" +#import "SDLSystemAction.h" + + +QuickSpecBegin(SDLSoftButtonSpec) + +SDLImage* image = [[SDLImage alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSoftButton* testStruct = [[SDLSoftButton alloc] init]; + + testStruct.type = [SDLSoftButtonType IMAGE]; + testStruct.text = @"Button"; + testStruct.image = image; + testStruct.isHighlighted = @YES; + testStruct.softButtonID = @5423; + testStruct.systemAction = [SDLSystemAction KEEP_CONTEXT]; + + expect(testStruct.type).to(equal([SDLSoftButtonType IMAGE])); + expect(testStruct.text).to(equal(@"Button")); + expect(testStruct.image).to(equal(image)); + expect(testStruct.isHighlighted).to(equal(@YES)); + expect(testStruct.softButtonID).to(equal(@5423)); + expect(testStruct.systemAction).to(equal([SDLSystemAction KEEP_CONTEXT])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_type:[SDLSoftButtonType IMAGE], + NAMES_text:@"Button", + NAMES_image:image, + NAMES_isHighlighted:@YES, + NAMES_softButtonID:@5423, + NAMES_systemAction:[SDLSystemAction KEEP_CONTEXT]} mutableCopy]; + SDLSoftButton* testStruct = [[SDLSoftButton alloc] initWithDictionary:dict]; + + expect(testStruct.type).to(equal([SDLSoftButtonType IMAGE])); + expect(testStruct.text).to(equal(@"Button")); + expect(testStruct.image).to(equal(image)); + expect(testStruct.isHighlighted).to(equal(@YES)); + expect(testStruct.softButtonID).to(equal(@5423)); + expect(testStruct.systemAction).to(equal([SDLSystemAction KEEP_CONTEXT])); + }); + + it(@"Should return nil if not set", ^ { + SDLSoftButton* testStruct = [[SDLSoftButton alloc] init]; + + expect(testStruct.type).to(beNil()); + expect(testStruct.text).to(beNil()); + expect(testStruct.image).to(beNil()); + expect(testStruct.isHighlighted).to(beNil()); + expect(testStruct.softButtonID).to(beNil()); + expect(testStruct.systemAction).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLStartTimeSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLStartTimeSpec.m new file mode 100644 index 000000000..476fc6500 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLStartTimeSpec.m @@ -0,0 +1,49 @@ +// +// SDLStartTimeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLStartTime.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLStartTimeSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLStartTime* testStruct = [[SDLStartTime alloc] init]; + + testStruct.hours = @22; + testStruct.minutes = @39; + testStruct.seconds = @11; + + expect(testStruct.hours).to(equal(@22)); + expect(testStruct.minutes).to(equal(@39)); + expect(testStruct.seconds).to(equal(@11)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_hours:@22, + NAMES_minutes:@39, + NAMES_seconds:@11} mutableCopy]; + SDLStartTime* testStruct = [[SDLStartTime alloc] initWithDictionary:dict]; + + expect(testStruct.hours).to(equal(@22)); + expect(testStruct.minutes).to(equal(@39)); + expect(testStruct.seconds).to(equal(@11)); + }); + + it(@"Should return nil if not set", ^ { + SDLStartTime* testStruct = [[SDLStartTime alloc] init]; + + expect(testStruct.hours).to(beNil()); + expect(testStruct.minutes).to(beNil()); + expect(testStruct.seconds).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSyncMsgVersionSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSyncMsgVersionSpec.m new file mode 100644 index 000000000..56c74cd18 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSyncMsgVersionSpec.m @@ -0,0 +1,44 @@ +// +// SDLSyncMsgVersionSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLSyncMsgVersion.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLSyncMsgVersionSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLSyncMsgVersion* testStruct = [[SDLSyncMsgVersion alloc] init]; + + testStruct.majorVersion = @4; + testStruct.minorVersion = @532; + + expect(testStruct.majorVersion).to(equal(@4)); + expect(testStruct.minorVersion).to(equal(@532)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_majorVersion:@4, + NAMES_minorVersion:@532} mutableCopy]; + SDLSyncMsgVersion* testStruct = [[SDLSyncMsgVersion alloc] initWithDictionary:dict]; + + expect(testStruct.majorVersion).to(equal(@4)); + expect(testStruct.minorVersion).to(equal(@532)); + }); + + it(@"Should return nil if not set", ^ { + SDLSyncMsgVersion* testStruct = [[SDLSyncMsgVersion alloc] init]; + + expect(testStruct.majorVersion).to(beNil()); + expect(testStruct.minorVersion).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTTSChunkSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTTSChunkSpec.m new file mode 100644 index 000000000..78ca915c9 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTTSChunkSpec.m @@ -0,0 +1,46 @@ +// +// SDLTTSChunkSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLSpeechCapabilities.h" +#import "SDLTTSChunk.h" + + +QuickSpecBegin(SDLTTSChunkSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTTSChunk* testStruct = [[SDLTTSChunk alloc] init]; + + testStruct.text = @"TEXT"; + testStruct.type = [SDLSpeechCapabilities PRE_RECORDED]; + + expect(testStruct.text).to(equal(@"TEXT")); + expect(testStruct.type).to(equal([SDLSpeechCapabilities PRE_RECORDED])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_text:@"TEXT", + NAMES_type:[SDLSpeechCapabilities PRE_RECORDED]} mutableCopy]; + SDLTTSChunk* testStruct = [[SDLTTSChunk alloc] initWithDictionary:dict]; + + expect(testStruct.text).to(equal(@"TEXT")); + expect(testStruct.type).to(equal([SDLSpeechCapabilities PRE_RECORDED])); + }); + + it(@"Should return nil if not set", ^ { + SDLTTSChunk* testStruct = [[SDLTTSChunk alloc] init]; + + expect(testStruct.text).to(beNil()); + expect(testStruct.type).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m new file mode 100644 index 000000000..a07331a59 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTextFieldSpec.m @@ -0,0 +1,57 @@ +// +// SDLTextFieldSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLCharacterSet.h" +#import "SDLNames.h" +#import "SDLTextField.h" +#import "SDLTextFieldName.h" + + +QuickSpecBegin(SDLTextFieldSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTextField* testStruct = [[SDLTextField alloc] init]; + + testStruct.name = [SDLTextFieldName tertiaryText]; + testStruct.characterSet = [SDLCharacterSet TYPE5SET]; + testStruct.width = @111; + testStruct.rows = @4; + + expect(testStruct.name).to(equal([SDLTextFieldName tertiaryText])); + expect(testStruct.characterSet).to(equal([SDLCharacterSet TYPE5SET])); + expect(testStruct.width).to(equal(@111)); + expect(testStruct.rows).to(equal(@4)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_name:[SDLTextFieldName tertiaryText], + NAMES_characterSet:[SDLCharacterSet TYPE5SET], + NAMES_width:@111, + NAMES_rows:@4} mutableCopy]; + SDLTextField* testStruct = [[SDLTextField alloc] initWithDictionary:dict]; + + expect(testStruct.name).to(equal([SDLTextFieldName tertiaryText])); + expect(testStruct.characterSet).to(equal([SDLCharacterSet TYPE5SET])); + expect(testStruct.width).to(equal(@111)); + expect(testStruct.rows).to(equal(@4)); + }); + + it(@"Should return nil if not set", ^ { + SDLTextField* testStruct = [[SDLTextField alloc] init]; + + expect(testStruct.name).to(beNil()); + expect(testStruct.characterSet).to(beNil()); + expect(testStruct.width).to(beNil()); + expect(testStruct.rows).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTireStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTireStatusSpec.m new file mode 100644 index 000000000..dcad4943d --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTireStatusSpec.m @@ -0,0 +1,78 @@ +// +// SDLTireStatusSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTireStatus.h" +#import "SDLSingleTireStatus.h" +#import "SDLWarningLightStatus.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLTireStatusSpec) + +SDLSingleTireStatus* tire1 = [[SDLSingleTireStatus alloc] init]; +SDLSingleTireStatus* tire2 = [[SDLSingleTireStatus alloc] init]; +SDLSingleTireStatus* tire3 = [[SDLSingleTireStatus alloc] init]; +SDLSingleTireStatus* tire4 = [[SDLSingleTireStatus alloc] init]; +SDLSingleTireStatus* tire5 = [[SDLSingleTireStatus alloc] init]; +SDLSingleTireStatus* tire6 = [[SDLSingleTireStatus alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTireStatus* testStruct = [[SDLTireStatus alloc] init]; + + testStruct.pressureTelltale = [SDLWarningLightStatus OFF]; + testStruct.leftFront = tire1; + testStruct.rightFront = tire2; + testStruct.leftRear = tire3; + testStruct.rightRear = tire4; + testStruct.innerLeftRear = tire5; + testStruct.innerRightRear = tire6; + + expect(testStruct.pressureTelltale).to(equal([SDLWarningLightStatus OFF])); + expect(testStruct.leftFront).to(equal(tire1)); + expect(testStruct.rightFront).to(equal(tire2)); + expect(testStruct.leftRear).to(equal(tire3)); + expect(testStruct.rightRear).to(equal(tire4)); + expect(testStruct.innerLeftRear).to(equal(tire5)); + expect(testStruct.innerRightRear).to(equal(tire6)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_pressureTelltale:[SDLWarningLightStatus OFF], + NAMES_leftFront:tire1, + NAMES_rightFront:tire2, + NAMES_leftRear:tire3, + NAMES_rightRear:tire4, + NAMES_innerLeftRear:tire5, + NAMES_innerRightRear:tire6} mutableCopy]; + SDLTireStatus* testStruct = [[SDLTireStatus alloc] initWithDictionary:dict]; + + expect(testStruct.pressureTelltale).to(equal([SDLWarningLightStatus OFF])); + expect(testStruct.leftFront).to(equal(tire1)); + expect(testStruct.rightFront).to(equal(tire2)); + expect(testStruct.leftRear).to(equal(tire3)); + expect(testStruct.rightRear).to(equal(tire4)); + expect(testStruct.innerLeftRear).to(equal(tire5)); + expect(testStruct.innerRightRear).to(equal(tire6)); + }); + + it(@"Should return nil if not set", ^ { + SDLTireStatus* testStruct = [[SDLTireStatus alloc] init]; + + expect(testStruct.pressureTelltale).to(beNil()); + expect(testStruct.leftFront).to(beNil()); + expect(testStruct.rightFront).to(beNil()); + expect(testStruct.leftRear).to(beNil()); + expect(testStruct.rightRear).to(beNil()); + expect(testStruct.innerLeftRear).to(beNil()); + expect(testStruct.innerRightRear).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchCoordSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchCoordSpec.m new file mode 100644 index 000000000..eedca3a9b --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchCoordSpec.m @@ -0,0 +1,44 @@ +// +// SDLTouchCoordSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTouchCoord.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLTouchCoordSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTouchCoord* testStruct = [[SDLTouchCoord alloc] init]; + + testStruct.x = @67; + testStruct.y = @362; + + expect(testStruct.x).to(equal(@67)); + expect(testStruct.y).to(equal(@362)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_x:@67, + NAMES_y:@362} mutableCopy]; + SDLTouchCoord* testStruct = [[SDLTouchCoord alloc] initWithDictionary:dict]; + + expect(testStruct.x).to(equal(@67)); + expect(testStruct.y).to(equal(@362)); + }); + + it(@"Should return nil if not set", ^ { + SDLTouchCoord* testStruct = [[SDLTouchCoord alloc] init]; + + expect(testStruct.x).to(beNil()); + expect(testStruct.y).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchEventCapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchEventCapabilitiesSpec.m new file mode 100644 index 000000000..a8b8c73e0 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchEventCapabilitiesSpec.m @@ -0,0 +1,49 @@ +// +// SDLTouchEventCapabilitiesSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTouchEventCapabilities.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLTouchEventCapabilitiesSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTouchEventCapabilities* testStruct = [[SDLTouchEventCapabilities alloc] init]; + + testStruct.pressAvailable = @YES; + testStruct.multiTouchAvailable = @NO; + testStruct.doublePressAvailable = @YES; + + expect(testStruct.pressAvailable).to(equal(@YES)); + expect(testStruct.multiTouchAvailable).to(equal(@NO)); + expect(testStruct.doublePressAvailable).to(equal(@YES)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_pressAvailable:@YES, + NAMES_multiTouchAvailable:@NO, + NAMES_doublePressAvailable:@NO} mutableCopy]; + SDLTouchEventCapabilities* testStruct = [[SDLTouchEventCapabilities alloc] initWithDictionary:dict]; + + expect(testStruct.pressAvailable).to(equal(@YES)); + expect(testStruct.multiTouchAvailable).to(equal(@NO)); + expect(testStruct.doublePressAvailable).to(equal(@NO)); + }); + + it(@"Should return nil if not set", ^ { + SDLTouchEventCapabilities* testStruct = [[SDLTouchEventCapabilities alloc] init]; + + expect(testStruct.pressAvailable).to(beNil()); + expect(testStruct.multiTouchAvailable).to(beNil()); + expect(testStruct.doublePressAvailable).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchEventSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchEventSpec.m new file mode 100644 index 000000000..c95cfb525 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTouchEventSpec.m @@ -0,0 +1,52 @@ +// +// SDLTouchEventSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTouchEvent.h" +#import "SDLTouchCoord.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLTouchEventSpec) + +SDLTouchCoord* coord = [[SDLTouchCoord alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTouchEvent* testStruct = [[SDLTouchEvent alloc] init]; + + testStruct.touchEventId = @3; + testStruct.timeStamp = [@[@23, @52, @41345234] mutableCopy]; + testStruct.coord = [@[coord] mutableCopy]; + + expect(testStruct.touchEventId).to(equal(@3)); + expect(testStruct.timeStamp).to(equal([@[@23, @52, @41345234] mutableCopy])); + expect(testStruct.coord).to(equal([@[coord] mutableCopy])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_id:@3, + NAMES_ts:[@[@23, @52, @41345234] mutableCopy], + NAMES_c:[@[coord] mutableCopy]} mutableCopy]; + SDLTouchEvent* testStruct = [[SDLTouchEvent alloc] initWithDictionary:dict]; + + expect(testStruct.touchEventId).to(equal(@3)); + expect(testStruct.timeStamp).to(equal([@[@23, @52, @41345234] mutableCopy])); + expect(testStruct.coord).to(equal([@[coord] mutableCopy])); + }); + + it(@"Should return nil if not set", ^ { + SDLTouchEvent* testStruct = [[SDLTouchEvent alloc] init]; + + expect(testStruct.touchEventId).to(beNil()); + expect(testStruct.timeStamp).to(beNil()); + expect(testStruct.coord).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTurnSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTurnSpec.m new file mode 100644 index 000000000..07152ad92 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTurnSpec.m @@ -0,0 +1,47 @@ +// +// SDLTurnSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLTurn.h" +#import "SDLNames.h" +#import "SDLImage.h" + +QuickSpecBegin(SDLTurnSpec) + +SDLImage* image = [[SDLImage alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLTurn* testStruct = [[SDLTurn alloc] init]; + + testStruct.navigationText = @"NAVTEXT"; + testStruct.turnIcon = image; + + expect(testStruct.navigationText).to(equal(@"NAVTEXT")); + expect(testStruct.turnIcon).to(equal(image)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_navigationText:@"NAVTEXT", + NAMES_turnIcon:image} mutableCopy]; + SDLTurn* testStruct = [[SDLTurn alloc] initWithDictionary:dict]; + + expect(testStruct.navigationText).to(equal(@"NAVTEXT")); + expect(testStruct.turnIcon).to(equal(image)); + }); + + it(@"Should return nil if not set", ^ { + SDLTurn* testStruct = [[SDLTurn alloc] init]; + + expect(testStruct.navigationText).to(beNil()); + expect(testStruct.turnIcon).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVehicleDataResultSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVehicleDataResultSpec.m new file mode 100644 index 000000000..ee3c4774a --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVehicleDataResultSpec.m @@ -0,0 +1,46 @@ +// +// SDLVehicleDataResultSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleDataResult.h" +#import "SDLVehicleDataResultCode.h" +#import "SDLVehicleDataType.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLVehicleDataResultSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLVehicleDataResult* testStruct = [[SDLVehicleDataResult alloc] init]; + + testStruct.dataType = [SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS]; + testStruct.resultCode = [SDLVehicleDataResultCode DISALLOWED]; + + expect(testStruct.dataType).to(equal([SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS])); + expect(testStruct.resultCode).to(equal([SDLVehicleDataResultCode DISALLOWED])); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_dataType:[SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS], + NAMES_resultCode:[SDLVehicleDataResultCode DISALLOWED]} mutableCopy]; + SDLVehicleDataResult* testStruct = [[SDLVehicleDataResult alloc] initWithDictionary:dict]; + + expect(testStruct.dataType).to(equal([SDLVehicleDataType VEHICLEDATA_AIRBAGSTATUS])); + expect(testStruct.resultCode).to(equal([SDLVehicleDataResultCode DISALLOWED])); + }); + + it(@"Should return nil if not set", ^ { + SDLVehicleDataResult* testStruct = [[SDLVehicleDataResult alloc] init]; + + expect(testStruct.dataType).to(beNil()); + expect(testStruct.resultCode).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVehicleTypeSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVehicleTypeSpec.m new file mode 100644 index 000000000..9a282b72e --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVehicleTypeSpec.m @@ -0,0 +1,54 @@ +// +// SDLVehicleTypeSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLVehicleType.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLVehicleTypeSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLVehicleType* testStruct = [[SDLVehicleType alloc] init]; + + testStruct.make = @"Make"; + testStruct.model = @"Model"; + testStruct.modelYear = @"3.141*10^36"; + testStruct.trim = @"AE"; + + expect(testStruct.make).to(equal(@"Make")); + expect(testStruct.model).to(equal(@"Model")); + expect(testStruct.modelYear).to(equal(@"3.141*10^36")); + expect(testStruct.trim).to(equal(@"AE")); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_make:@"Make", + NAMES_model:@"Model", + NAMES_modelYear:@"3.141*10^36", + NAMES_trim:@"AE"} mutableCopy]; + SDLVehicleType* testStruct = [[SDLVehicleType alloc] initWithDictionary:dict]; + + expect(testStruct.make).to(equal(@"Make")); + expect(testStruct.model).to(equal(@"Model")); + expect(testStruct.modelYear).to(equal(@"3.141*10^36")); + expect(testStruct.trim).to(equal(@"AE")); + }); + + it(@"Should return nil if not set", ^ { + SDLVehicleType* testStruct = [[SDLVehicleType alloc] init]; + + expect(testStruct.make).to(beNil()); + expect(testStruct.model).to(beNil()); + expect(testStruct.modelYear).to(beNil()); + expect(testStruct.trim).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVrHelpItemSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVrHelpItemSpec.m new file mode 100644 index 000000000..e76be2558 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVrHelpItemSpec.m @@ -0,0 +1,53 @@ +// +// SDLVrHelpItemSpec.m +// SmartDeviceLink + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLVrHelpItem.h" + + +QuickSpecBegin(SDLVrHelpItemSpec) + +SDLImage* image = [[SDLImage alloc] init]; + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLVRHelpItem* testStruct = [[SDLVRHelpItem alloc] init]; + + testStruct.text = @"DON'T PANIC"; + testStruct.image = image; + testStruct.position = @42; + + expect(testStruct.text).to(equal(@"DON'T PANIC")); + expect(testStruct.image).to(equal(image)); + expect(testStruct.position).to(equal(@42)); + }); + + it(@"Should get correctly when initialized", ^ { + NSMutableDictionary* dict = [@{NAMES_text:@"DON'T PANIC", + NAMES_image:image, + NAMES_position:@42} mutableCopy]; + SDLVRHelpItem* testStruct = [[SDLVRHelpItem alloc] initWithDictionary:dict]; + + expect(testStruct.text).to(equal(@"DON'T PANIC")); + expect(testStruct.image).to(equal(image)); + expect(testStruct.position).to(equal(@42)); + }); + + it(@"Should return nil if not set", ^ { + SDLVRHelpItem* testStruct = [[SDLVRHelpItem alloc] init]; + + expect(testStruct.text).to(beNil()); + expect(testStruct.image).to(beNil()); + expect(testStruct.position).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m new file mode 100644 index 000000000..e4d330a3c --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m @@ -0,0 +1,25 @@ +// +// SDLEnumSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLEnum.h" + +QuickSpecBegin(SDLEnumSpec) + +describe(@"Value Tests", ^ { + it(@"Should get value correctly when initialized", ^ { + SDLEnum* enumValue = [[SDLEnum alloc] initWithValue:@"Enum"]; + + expect(enumValue).toNot(beNil()); + + expect(enumValue.value).to(equal(@"Enum")); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCMessageSpec.m b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCMessageSpec.m new file mode 100644 index 000000000..39a9ebc74 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCMessageSpec.m @@ -0,0 +1,115 @@ +// +// SDLRPCMessage.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLRPCMessage.h" +#import "SDLNames.h" + +QuickSpecBegin(SDLRPCMessageSpec) + +describe(@"Readonly Property Tests", ^ { + it(@"Should get name correctly when initialized with name", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithName:@"Poorly Named"]; + + expect(testMessage.name).to(equal(@"Poorly Named")); + }); + + it(@"Should get correctly when initialized with dictionary", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithDictionary:[@{NAMES_notification: + @{NAMES_parameters: + @{@"name":@"George"}, + NAMES_operation_name:@"Poorly Named"}} mutableCopy]]; + + expect(testMessage.name).to(equal(@"Poorly Named")); + expect(testMessage.messageType).to(equal(NAMES_notification)); + }); +}); + +describe(@"Parameter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithName:@""]; + + [testMessage setParameters:@"ADogAPanicInAPagoda" value:@"adogaPAnIcinaPAgoDA"]; + + expect([testMessage getParameters:@"ADogAPanicInAPagoda"]).to(equal(@"adogaPAnIcinaPAgoDA")); + }); + + it(@"Should get correctly when initialized", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithDictionary:[@{NAMES_response: + @{NAMES_parameters: + @{@"age":@25}, + NAMES_operation_name:@"Nameless"}} mutableCopy]]; + + expect([testMessage getParameters:@"age"]).to(equal(@25)); + }); + + it(@"Should be nil if not set", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithName:@""]; + + expect([testMessage getParameters:@"ADogAPanicInAPagoda"]).to(beNil()); + }); +}); + +describe(@"FunctionName Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithName:@""]; + + [testMessage setFunctionName:@"Functioning"]; + + expect([testMessage getFunctionName]).to(equal(@"Functioning")); + }); + + it(@"Should get correctly when initialized", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithDictionary:[@{NAMES_request: + @{NAMES_parameters: + @{@"age":@25}, + NAMES_operation_name:@"DoNothing"}} mutableCopy]]; + + expect([testMessage getFunctionName]).to(equal(@"DoNothing")); + + testMessage = [[SDLRPCMessage alloc] initWithName:@"DoSomething"]; + + expect([testMessage getFunctionName]).to(equal(@"DoSomething")); + }); + + it(@"Should be nil if not set", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithDictionary:[@{NAMES_notification: + @{NAMES_parameters: + @{}}} mutableCopy]]; + expect([testMessage getFunctionName]).to(beNil()); + }); +}); + +describe(@"BulkDataTests", ^ { + it(@"Should set and get correctly", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithName:@""]; + + const char* testString = "ImportantData"; + testMessage.bulkData = [NSData dataWithBytes:testString length:strlen(testString)]; + + expect([NSString stringWithUTF8String:testMessage.bulkData.bytes]).to(equal(@"ImportantData")); + }); + + it(@"Should get correctly when initialized", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithDictionary:[@{NAMES_notification: + @{NAMES_parameters: + @{}}, + NAMES_bulkData:[NSData dataWithBytes:"ImageData" length:strlen("ImageData")]} mutableCopy]]; + + expect(testMessage.bulkData).to(equal([NSData dataWithBytes:"ImageData" length:strlen("ImageData")])); + }); + + it(@"Should be nil if not set", ^ { + SDLRPCMessage* testMessage = [[SDLRPCMessage alloc] initWithName:@""]; + + expect(testMessage.bulkData).to(beNil()); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCNotificationSpec.m b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCNotificationSpec.m new file mode 100644 index 000000000..d6dab74d5 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCNotificationSpec.m @@ -0,0 +1,15 @@ +// +// SDLRPCNotificationSpec.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLRPCNotification.h" + +QuickSpecBegin(SDLRPCNotificationSpec) + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCRequestSpec.m b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCRequestSpec.m new file mode 100644 index 000000000..1846e0700 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCRequestSpec.m @@ -0,0 +1,25 @@ +// +// SDLRPCRequest.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLRPCRequest.h" + +QuickSpecBegin(SDLRPCRequestSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLRPCRequest* testRequest = [[SDLRPCRequest alloc] initWithName:@"A Legitimate Request"]; + + testRequest.correlationID = @14641; + + expect(testRequest.correlationID).to(equal(@14641)); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCResponseSpec.m b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCResponseSpec.m new file mode 100644 index 000000000..0619dd3dc --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCResponseSpec.m @@ -0,0 +1,33 @@ +// +// SDLRPCResponse.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLResult.h" +#import "SDLRPCResponse.h" + + +QuickSpecBegin(SDLRPCResponseSpec) + +describe(@"Getter/Setter Tests", ^ { + it(@"Should set and get correctly", ^ { + SDLRPCResponse* response = [[SDLRPCResponse alloc] initWithName:@"A Legitimate Response"]; + + response.correlationID = @14641; + response.success = @YES; + response.resultCode = [SDLResult IGNORED]; + response.info = @"It has been done"; + + expect(response.correlationID).to(equal(@14641)); + expect(response.success).to(equal(@YES)); + expect(response.resultCode).to(equal([SDLResult IGNORED])); + expect(response.info).to(equal(@"It has been done")); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCStructSpec.m b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCStructSpec.m new file mode 100644 index 000000000..9352569ed --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLRPCStructSpec.m @@ -0,0 +1,24 @@ +// +// SDLRPCStruct.m +// SmartDeviceLink-iOS + + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLRPCStruct.h" + +QuickSpecBegin(SDLRPCStructSpec) + +describe(@"SerializeAsDictionary Tests", ^ { + it(@"Should serialize correctly", ^ { + NSMutableDictionary* dict = [@{@"Key":@"Value", @"Answer":@42, @"Struct":[[SDLRPCStruct alloc] initWithDictionary:[@{@"Array":@[@1, @1, @1, @1]} mutableCopy]]} mutableCopy]; + SDLRPCStruct* testStruct = [[SDLRPCStruct alloc] initWithDictionary:dict]; + + expect([testStruct serializeAsDictionary:2]).to(equal([@{@"Key":@"Value", @"Answer":@42, @"Struct":@{@"Array":@[@1, @1, @1, @1]}} mutableCopy])); + }); +}); + +QuickSpecEnd
\ No newline at end of file diff --git a/SmartDeviceLinkTests/SwiftSpec.swift b/SmartDeviceLinkTests/SwiftSpec.swift new file mode 100644 index 000000000..274da684d --- /dev/null +++ b/SmartDeviceLinkTests/SwiftSpec.swift @@ -0,0 +1,5 @@ +// +// SwiftSpec.swift +// SmartDeviceLink-iOS + +import Quick; diff --git a/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.h b/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.h new file mode 100644 index 000000000..04a5da98e --- /dev/null +++ b/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.h @@ -0,0 +1,51 @@ +// +// TestConnectionManager.h +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 11/6/15. +// Copyright © 2015 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#import "SDLConnectionManagerType.h" +#import "SDLNotificationConstants.h" + + +NS_ASSUME_NONNULL_BEGIN + +@interface TestConnectionManager : NSObject<SDLConnectionManagerType> + +/** + * All received requests. Chronological order. The 0th element will be the first request received; the nth request will be the n+1th request received. + */ +@property (copy, nonatomic, readonly) NSMutableArray<__kindof SDLRPCRequest *> *receivedRequests; + +/** + * The block passed for the last request send with sendRequest:withCompletionHandler: + */ +@property (copy, nonatomic, nullable) SDLRequestCompletionHandler lastRequestBlock; + +/** + * Call the last request's block with a specific response. + * + * @param response The RPC Response to pass into the last request's block. + */ +- (void)respondToLastRequestWithResponse:(__kindof SDLRPCResponse *)response; + +/** + * Call the last request's block with a specific response and error. + * + * @param response The response to pass into the last request's block. + * @param error The error to pass into the last request's block. + */ +- (void)respondToLastRequestWithResponse:(__kindof SDLRPCResponse *_Nullable)response error:( NSError *_Nullable)error; + +/** + * Remove all received requests. + */ +- (void)reset; + +@end + +NS_ASSUME_NONNULL_END
\ No newline at end of file diff --git a/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m b/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m new file mode 100644 index 000000000..a7c53d1f1 --- /dev/null +++ b/SmartDeviceLinkTests/TestUtilities/TestConnectionManager.m @@ -0,0 +1,64 @@ +// +// TestConnectionManager.m +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 11/6/15. +// Copyright © 2015 smartdevicelink. All rights reserved. +// + +#import "TestConnectionManager.h" + +#import "SDLRPCRequest.h" + + +NS_ASSUME_NONNULL_BEGIN + +@implementation TestConnectionManager + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + _receivedRequests = [NSMutableArray<__kindof SDLRPCRequest *> array]; + + return self; +} + +- (void)sendRequest:(__kindof SDLRPCRequest *)request withCompletionHandler:(nullable SDLRequestCompletionHandler)block { + self.lastRequestBlock = block; + request.correlationID = [self test_nextCorrelationID]; + + [self.receivedRequests addObject:request]; +} + +- (void)respondToLastRequestWithResponse:(__kindof SDLRPCResponse *)response { + [self respondToLastRequestWithResponse:response error:nil]; +} + +- (void)respondToLastRequestWithResponse:(__kindof SDLRPCResponse *_Nullable)response error:(NSError *_Nullable)error { + if (self.lastRequestBlock != nil) { + self.lastRequestBlock(self.receivedRequests.lastObject, response, error); + } else { + @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Attempted to respond to last request, but there was no last request block" userInfo:nil]; + } +} + +- (void)reset { + _receivedRequests = [NSMutableArray<__kindof SDLRPCRequest *> array]; + _lastRequestBlock = nil; +} + + +#pragma mark Private helpers + +- (NSNumber *)test_nextCorrelationID { + static NSUInteger correlationID = 0; + + return @(correlationID++); +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/HTTP Connection/SDLURLRequestTaskSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/HTTP Connection/SDLURLRequestTaskSpec.m new file mode 100644 index 000000000..d78ff0c7f --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/HTTP Connection/SDLURLRequestTaskSpec.m @@ -0,0 +1,140 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OHHTTPStubs/OHHTTPStubs.h> + +#import "SDLURLRequestTask.h" + + +QuickSpecBegin(SDLURLRequestTaskSpec) + +describe(@"a url request task", ^{ + __block SDLURLRequestTask *testTask = nil; + + describe(@"when the server returns correct data", ^{ + NSData *testData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + return [request.URL.host isEqualToString:@"www.faketest.com"]; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [[OHHTTPStubsResponse responseWithData:testData statusCode:200 headers:nil] requestTime:0.5 responseTime:0]; + }]; + + NSURLRequest *someURLRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.faketest.com"]]; + + testTask = [[SDLURLRequestTask alloc] initWithURLRequest:someURLRequest completionHandler:^void(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + }); + + afterEach(^{ + testTask = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should return data", ^{ + expect(testReturnData).toEventually(equal(testData)); + }); + + it(@"should return a response", ^{ + expect(testReturnResponse).toEventuallyNot(beNil()); + }); + + it(@"should not return an error", ^{ + expect(testReturnError).toEventually(beNil()); + }); + }); + + describe(@"when the connection fails because there is no internet", ^{ + NSError *someNetworkError = [NSError errorWithDomain:NSURLErrorDomain code:kCFURLErrorNotConnectedToInternet userInfo:nil]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + return [request.URL.host isEqualToString:@"www.faketest.com"]; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [OHHTTPStubsResponse responseWithError:someNetworkError]; + }]; + + NSURLRequest *someURLRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.faketest.com"]]; + + testTask = [[SDLURLRequestTask alloc] initWithURLRequest:someURLRequest completionHandler:^void(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + }); + + afterEach(^{ + testTask = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should return nil data", ^{ + expect(testReturnData).toEventually(beNil()); + }); + + it(@"should return a nil response", ^{ + expect(testReturnResponse).toEventually(beNil()); + }); + + it(@"should return an error", ^{ + expect(@(testReturnError.code)).toEventually(equal(@(someNetworkError.code))); + }); + }); + + describe(@"when the connection fails because it was cancelled", ^{ + NSData *testData = [@"testData" dataUsingEncoding:NSUTF8StringEncoding]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + return [request.URL.host isEqualToString:@"www.faketest.com"]; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [[OHHTTPStubsResponse responseWithData:testData statusCode:200 headers:nil] requestTime:0.25 responseTime:0.25]; + }]; + + NSURLRequest *someURLRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.faketest.com"]]; + + + testTask = [[SDLURLRequestTask alloc] initWithURLRequest:someURLRequest completionHandler:^void(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + + [testTask cancel]; + }); + + afterEach(^{ + testTask = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should return nil data", ^{ + expect(testReturnData).toEventually(beNil()); + }); + + it(@"should return a nil response", ^{ + expect(testReturnResponse).toEventually(beNil()); + }); + + it(@"should return an error", ^{ + expect(@(testReturnError.code)).toEventually(equal(@(kCFURLErrorCancelled))); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/HTTP Connection/SDLURLSessionSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/HTTP Connection/SDLURLSessionSpec.m new file mode 100644 index 000000000..d15bcc049 --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/HTTP Connection/SDLURLSessionSpec.m @@ -0,0 +1,191 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> +#import <OHHTTPStubs/OHHTTPStubs.h> + +#import "SDLURLSession.h" + +QuickSpecBegin(SDLURLSessionSpec) + +describe(@"the url session", ^{ + __block SDLURLSession *testSession = nil; + + describe(@"attempting to get good data", ^{ + context(@"uploading data", ^{ + NSData *testData = [@"testData" dataUsingEncoding:NSUTF8StringEncoding]; + NSArray *someJSONObject = @[@"one", @"two"]; + NSData *testJSONData = [NSJSONSerialization dataWithJSONObject:someJSONObject options:0 error:nil]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + __block NSArray *testReturnJSONObject = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + if ([request.URL.host isEqualToString:@"www.faketest.com"]) { + testReturnJSONObject = [NSJSONSerialization JSONObjectWithData:request.HTTPBody options:0 error:nil]; + return YES; + } + + return NO; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [[OHHTTPStubsResponse responseWithData:testData statusCode:200 headers:nil] requestTime:0.5 responseTime:0]; + }]; + + testSession = [[SDLURLSession alloc] init]; + NSURLRequest *someURLRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.faketest.com"]]; + + [testSession uploadWithURLRequest:someURLRequest data:testJSONData completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + }); + + afterEach(^{ + testSession = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should have the json object", ^{ + expect(testReturnJSONObject).toEventually(equal(someJSONObject)); + }); + + it(@"should not return any data", ^{ + expect(testReturnData).toEventually(equal(testData)); + }); + + it(@"should return a response", ^{ + expect(testReturnResponse).toEventuallyNot(beNil()); + }); + + it(@"should not return an error", ^{ + expect(testReturnError).toEventually(beNil()); + }); + }); + + context(@"downloading data", ^{ + NSData *testData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + return [request.URL.host isEqualToString:@"www.faketest.com"]; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [[OHHTTPStubsResponse responseWithData:testData statusCode:200 headers:nil] requestTime:0.5 responseTime:0]; + }]; + + testSession = [[SDLURLSession alloc] init]; + [testSession dataFromURL:[NSURL URLWithString:@"http://www.faketest.com"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + }); + + afterEach(^{ + testSession = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should not return any data", ^{ + expect(testReturnData).toEventually(equal(testData)); + }); + + it(@"should return a response", ^{ + expect(testReturnResponse).toEventuallyNot(beNil()); + }); + + it(@"should not return an error", ^{ + expect(testReturnError).toEventually(beNil()); + }); + }); + }); + + describe(@"when the connection fails because there is no internet", ^{ + NSError *someNetworkError = [NSError errorWithDomain:NSURLErrorDomain code:kCFURLErrorNotConnectedToInternet userInfo:nil]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + return [request.URL.host isEqualToString:@"www.faketest.com"]; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [OHHTTPStubsResponse responseWithError:someNetworkError]; + }]; + + testSession = [[SDLURLSession alloc] init]; + [testSession dataFromURL:[NSURL URLWithString:@"http://www.faketest.com"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + }); + + afterEach(^{ + testSession = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should return nil data", ^{ + expect(testReturnData).toEventually(beNil()); + }); + + it(@"should return a nil response", ^{ + expect(testReturnResponse).toEventually(beNil()); + }); + + it(@"should return an error", ^{ + expect(@(testReturnError.code)).toEventually(equal(@(someNetworkError.code))); + }); + }); + + describe(@"when the connection fails because it was cancelled", ^{ + NSData *testData = [@"testData" dataUsingEncoding:NSUTF8StringEncoding]; + + __block NSData *testReturnData = nil; + __block NSURLResponse *testReturnResponse = nil; + __block NSError *testReturnError = nil; + + beforeEach(^{ + [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) { + return [request.URL.host isEqualToString:@"www.faketest.com"]; + } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { + return [[OHHTTPStubsResponse responseWithData:testData statusCode:200 headers:nil] requestTime:0.25 responseTime:0.25]; + }]; + + testSession = [[SDLURLSession alloc] init]; + [testSession dataFromURL:[NSURL URLWithString:@"http://www.faketest.com"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + testReturnData = data; + testReturnResponse = response; + testReturnError = error; + }]; + + [testSession cancelAllTasks]; + }); + + afterEach(^{ + testSession = nil; + [OHHTTPStubs removeAllStubs]; + }); + + it(@"should return nil data", ^{ + expect(testReturnData).toEventually(beNil()); + }); + + it(@"should return a nil response", ^{ + expect(testReturnResponse).toEventually(beNil()); + }); + + it(@"should return an error", ^{ + expect(@(testReturnError.code)).toEventually(equal(@(kCFURLErrorCancelled))); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Prioritized Objects/SDLObjectWithPrioritySpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Prioritized Objects/SDLObjectWithPrioritySpec.m new file mode 100644 index 000000000..73ca3f7ea --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/Prioritized Objects/SDLObjectWithPrioritySpec.m @@ -0,0 +1,54 @@ +// +// SDLObjectWithPrioritySpec.m +// SmartDeviceLink-iOS + +#import <UIKit/UIKit.h> +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLObjectWithPriority.h" + + +QuickSpecBegin(SDLObjectWithPrioritySpec) + +describe(@"a prioritized object", ^{ + __block SDLObjectWithPriority *testObject = nil; + + beforeEach(^{ + testObject = [[SDLObjectWithPriority alloc] init]; + }); + + describe(@"should initialize properly", ^{ + it(@"should not be nil", ^{ + expect(testObject).toNot(beNil()); + }); + + it(@"should store a nil object", ^{ + expect(testObject.object).to(beNil()); + }); + + it(@"should have a priority of 0", ^{ + expect(@(testObject.priority)).to(equal(@(NSIntegerMax))); + }); + }); + + describe(@"should store an object properly", ^{ + __block NSString *testString = nil; + + beforeEach(^{ + testString = @"TestString"; + testObject.object = testString; + testObject.priority = 100; + }); + + it(@"should store the string as it's object", ^{ + expect(testObject.object).to(equal(testString)); + }); + + it(@"should set the priority as specified", ^{ + expect(@(testObject.priority)).to(equal(@100)); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Prioritized Objects/SDLPrioritizedObjectCollectionSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Prioritized Objects/SDLPrioritizedObjectCollectionSpec.m new file mode 100644 index 000000000..d417d6d1d --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/Prioritized Objects/SDLPrioritizedObjectCollectionSpec.m @@ -0,0 +1,89 @@ +// +// SDLPrioritizedObjectCollectionSpec.m +// SmartDeviceLink-iOS + +#import <UIKit/UIKit.h> +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLPrioritizedObjectCollection.h" + + +QuickSpecBegin(SDLPrioritizedObjectCollectionSpec) + +describe(@"a prioritized object collection", ^{ + __block SDLPrioritizedObjectCollection *collection = nil; + beforeEach(^{ + collection = [[SDLPrioritizedObjectCollection alloc] init]; + }); + + it(@"should be empty when first created", ^{ + id returnObj = [collection nextObject]; + + expect(returnObj).to(beNil()); + }); + + it(@"should ignore adding nil objects", ^{ + id obj = nil; + [collection addObject:obj withPriority:0]; + + id returnObj = [collection nextObject]; + expect(returnObj).to(beNil()); + }); + + it(@"should ignore adding NSNull objects", ^{ + [collection addObject:[NSNull null] withPriority:0]; + + id returnObj = [collection nextObject]; + expect(returnObj).to(beNil()); + }); + + it(@"should be able to add and retrieve a single item", ^{ + NSString *string = @"testString"; + [collection addObject:string withPriority:0]; + + id returnObj = [collection nextObject]; + + expect(returnObj).to(equal(string)); + }); + + describe(@"should retrieve higher priority objects first", ^{ + __block id firstObjectOut = nil; + __block id secondObjectOut = nil; + __block id thirdObjectOut = nil; + + __block NSString *highPriorityString = nil; + __block NSString *mediumPriorityString = nil; + __block NSString *lowPriorityString = nil; + + beforeEach(^{ + highPriorityString = @"highPriority"; + mediumPriorityString = @"mediumPriority"; + lowPriorityString = @"lowPriority"; + + // Add them in "incorrect" order to make sure sorting works correctly. + // Lower numbers indicate higher priority + [collection addObject:mediumPriorityString withPriority:100]; + [collection addObject:lowPriorityString withPriority:200]; + [collection addObject:highPriorityString withPriority:0]; + + firstObjectOut = [collection nextObject]; + secondObjectOut = [collection nextObject]; + thirdObjectOut = [collection nextObject]; + }); + + it(@"should retrieve the highest priority first", ^{ + expect(firstObjectOut).to(equal(highPriorityString)); + }); + + it(@"should retrieve the medium priority second", ^{ + expect(secondObjectOut).to(equal(mediumPriorityString)); + }); + + it(@"should retrieve the lowest priority last", ^{ + expect(thirdObjectOut).to(equal(lowPriorityString)); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m new file mode 100644 index 000000000..8acaaadcf --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m @@ -0,0 +1,85 @@ +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLGlobals.h" + +QuickSpecBegin(SDLGlobalsSpec) + +describe(@"The SDLGlobals class", ^{ + __block SDLGlobals *testGlobals = nil; + __block NSNumber *v1And2MTUSize = @1024; + __block NSNumber *v3And4MTUSize = @131084; + + beforeEach(^{ + testGlobals = [[SDLGlobals alloc] init]; + }); + + describe(@"when just initialized", ^{ + it(@"should properly set protocol version", ^{ + expect(@(testGlobals.protocolVersion)).to(equal(@1)); + }); + + it(@"should properly set max head unit version", ^{ + expect(@(testGlobals.maxHeadUnitVersion)).to(equal(@0)); + }); + + it(@"should throw an exception trying to get max MTU size", ^{ + expect(@(testGlobals.maxMTUSize)).to(equal(v1And2MTUSize)); + }); + }); + + describe(@"setting maxHeadUnitVersion should alter negotiated protocol version", ^{ + it(@"should use the max head unit version when lower than max proxy version", ^{ + NSUInteger someIntLowerThanMaxProxyVersion = 2; + testGlobals.maxHeadUnitVersion = someIntLowerThanMaxProxyVersion; + expect(@(testGlobals.protocolVersion)).to(equal(@(someIntLowerThanMaxProxyVersion))); + expect(@(testGlobals.maxHeadUnitVersion)).to(equal(@(someIntLowerThanMaxProxyVersion))); + }); + + it(@"should use the max proxy version when lower than max head unit version", ^{ + NSUInteger someIntHigherThanMaxProxyVersion = 1000; + testGlobals.maxHeadUnitVersion = someIntHigherThanMaxProxyVersion; + expect(@(testGlobals.protocolVersion)).to(beLessThan(@(someIntHigherThanMaxProxyVersion))); + expect(@(testGlobals.maxHeadUnitVersion)).to(equal(@(someIntHigherThanMaxProxyVersion))); + }); + }); + + describe(@"getting the max MTU version", ^{ + context(@"when protocol version is 1 - 2", ^{ + it(@"should return the correct value when protocol version is 1", ^{ + testGlobals.maxHeadUnitVersion = 1; + expect(@(testGlobals.maxMTUSize)).to(equal(v1And2MTUSize)); + }); + + it(@"should return the correct value when protocol version is 2", ^{ + testGlobals.maxHeadUnitVersion = 2; + expect(@(testGlobals.maxMTUSize)).to(equal(v1And2MTUSize)); + }); + }); + + context(@"when protocol version is 3 - 4", ^{ + it(@"should return the correct value when protocol version is 3", ^{ + testGlobals.maxHeadUnitVersion = 3; + expect(@(testGlobals.maxMTUSize)).to(equal(v3And4MTUSize)); + }); + + it(@"should return the correct value when protocol version is 4", ^{ + testGlobals.maxHeadUnitVersion = 4; + expect(@(testGlobals.maxMTUSize)).to(equal(v3And4MTUSize)); + }); + + describe(@"when the max proxy version is lower than max head unit version", ^{ + beforeEach(^{ + NSUInteger someIntHigherThanMaxProxyVersion = 1000; + testGlobals.maxHeadUnitVersion = someIntHigherThanMaxProxyVersion; + }); + + it(@"should return the v1 - 2 value", ^{ + expect(@(testGlobals.maxMTUSize)).to(equal(v1And2MTUSize)); + }); + }); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/SDLHexUtilitySpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/SDLHexUtilitySpec.m new file mode 100644 index 000000000..f9a539103 --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/SDLHexUtilitySpec.m @@ -0,0 +1,36 @@ +// +// SDLHexUtilitySpec.m +// SmartDeviceLink-iOS + +#import <UIKit/UIKit.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLHexUtility.h" + + +QuickSpecBegin(SDLHexUtilitySpec) + +describe(@"getting a hex string", ^{ + context(@"from a byte array", ^{ + it(@"correctly returns a hex string", ^{ + UInt8 byteArray[] = {0x00, 0x0F, 0xFF, 0x13}; + NSString *hexString = [SDLHexUtility getHexString:byteArray length:4]; + + expect(hexString).to(equal(@"000FFF13")); + }); + }); + + context(@"From a data object", ^{ + it(@"correctly returns a hex string", ^{ + UInt8 byteArray[] = {0x00, 0x0F, 0xFF, 0x13}; + NSData *byteData = [NSData dataWithBytes:byteArray length:4]; + NSString *hexString = [SDLHexUtility getHexString:byteData]; + + expect(hexString).to(equal(@"000FFF13")); + }); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/SDLJingleSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/SDLJingleSpec.m new file mode 100644 index 000000000..ed727abbb --- /dev/null +++ b/SmartDeviceLinkTests/UtilitiesSpecs/SDLJingleSpec.m @@ -0,0 +1,24 @@ +// +// SDLJingleSpec.m +// SmartDeviceLink-iOS + +#import <UIKit/UIKit.h> +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLJingle.h" + + +QuickSpecBegin(SDLJingleSpec) + +describe(@"retrieving jingle strings", ^{ + it(@"returns each jingle correctly", ^{ + expect([SDLJingle NEGATIVE_JINGLE]).to(equal(@"NEGATIVE_JINGLE")); + expect([SDLJingle POSITIVE_JINGLE]).to(equal(@"POSITIVE_JINGLE")); + expect([SDLJingle LISTEN_JINGLE]).to(equal(@"LISTEN_JINGLE")); + expect([SDLJingle INITIAL_JINGLE]).to(equal(@"INITIAL_JINGLE")); + expect([SDLJingle HELP_JINGLE]).to(equal(@"HELP_JINGLE")); + }); +}); + +QuickSpecEnd |