summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob <jacob.keeler@livioconnect.com>2015-03-03 13:25:45 -0500
committerJacob <jacob.keeler@livioconnect.com>2015-03-03 13:25:45 -0500
commitbe4d39025ac4cafd83c724bc6b6c050a812880b9 (patch)
tree0d5df2ead65d5736964288a826613563970bf3ee
parent49af40fe386c3679cfc2ecb6e612c62fc20b9441 (diff)
downloadsdl_ios-be4d39025ac4cafd83c724bc6b6c050a812880b9.tar.gz
Added tests for Protocol classes
-rw-r--r--.gitignore2
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj72
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m32
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m92
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m96
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m74
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m480
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m34
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m60
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m60
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m157
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m103
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m94
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m180
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m10
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m4
16 files changed, 1543 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index fa6ccefd9..d0c157b1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,3 +41,5 @@ profile
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
+
+SmartDeviceLink-iOS/Carthage/Checkouts/
diff --git a/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 6c62dedf2..d690950c7 100644
--- a/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -227,6 +227,18 @@
167ED92F1A9BB87900797BE5 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 167ED9241A9BB87900797BE5 /* libOCMock.a */; };
167ED93C1A9BCB8A00797BE5 /* SmartDeviceLink.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D61FA1C1A84237100846EE7 /* SmartDeviceLink.framework */; };
167ED9461A9BCE5D00797BE5 /* SwiftSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 167ED9451A9BCE5D00797BE5 /* SwiftSpec.swift */; };
+ 1680B1131A9CD7AD00DBD79E /* SDLProtocolHeaderSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1061A9CD7AD00DBD79E /* SDLProtocolHeaderSpec.m */; };
+ 1680B1141A9CD7AD00DBD79E /* SDLV1ProtocolHeaderSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1071A9CD7AD00DBD79E /* SDLV1ProtocolHeaderSpec.m */; };
+ 1680B1151A9CD7AD00DBD79E /* SDLV2ProtocolHeaderSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1081A9CD7AD00DBD79E /* SDLV2ProtocolHeaderSpec.m */; };
+ 1680B1161A9CD7AD00DBD79E /* SDLProtocolMessageSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B10A1A9CD7AD00DBD79E /* SDLProtocolMessageSpec.m */; };
+ 1680B1171A9CD7AD00DBD79E /* SDLProtocolSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B10B1A9CD7AD00DBD79E /* SDLProtocolSpec.m */; };
+ 1680B1181A9CD7AD00DBD79E /* SDLV1ProtocolMessageSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B10C1A9CD7AD00DBD79E /* SDLV1ProtocolMessageSpec.m */; };
+ 1680B1191A9CD7AD00DBD79E /* SDLV2ProtocolMessageSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B10D1A9CD7AD00DBD79E /* SDLV2ProtocolMessageSpec.m */; };
+ 1680B11A1A9CD7AD00DBD79E /* SDLAbstractProtocolSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B10E1A9CD7AD00DBD79E /* SDLAbstractProtocolSpec.m */; };
+ 1680B11B1A9CD7AD00DBD79E /* SDLFunctionIDSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B10F1A9CD7AD00DBD79E /* SDLFunctionIDSpec.m */; };
+ 1680B11C1A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1101A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m */; };
+ 1680B11D1A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1111A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m */; };
+ 1680B11E1A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1121A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m */; };
5D0218F61A8E79C400D1BF62 /* ConnectionTCPTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D0218F51A8E79C400D1BF62 /* ConnectionTCPTableViewController.m */; };
5D0218F91A8E7A7300D1BF62 /* ConnectionTCPTableViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5D0218F71A8E7A7300D1BF62 /* ConnectionTCPTableViewController.storyboard */; };
5D0218FC1A8E7E1700D1BF62 /* ConnectionContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D0218FB1A8E7E1700D1BF62 /* ConnectionContainerViewController.m */; };
@@ -1015,6 +1027,18 @@
167ED92D1A9BB87900797BE5 /* OCMRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMRecorder.h; sourceTree = "<group>"; };
167ED92E1A9BB87900797BE5 /* OCMStubRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMStubRecorder.h; sourceTree = "<group>"; };
167ED9451A9BCE5D00797BE5 /* SwiftSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSpec.swift; sourceTree = "<group>"; };
+ 1680B1061A9CD7AD00DBD79E /* SDLProtocolHeaderSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolHeaderSpec.m; sourceTree = "<group>"; };
+ 1680B1071A9CD7AD00DBD79E /* SDLV1ProtocolHeaderSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLV1ProtocolHeaderSpec.m; sourceTree = "<group>"; };
+ 1680B1081A9CD7AD00DBD79E /* SDLV2ProtocolHeaderSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLV2ProtocolHeaderSpec.m; sourceTree = "<group>"; };
+ 1680B10A1A9CD7AD00DBD79E /* SDLProtocolMessageSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolMessageSpec.m; sourceTree = "<group>"; };
+ 1680B10B1A9CD7AD00DBD79E /* SDLProtocolSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLProtocolSpec.m; path = MessageSpecs/SDLProtocolSpec.m; sourceTree = "<group>"; };
+ 1680B10C1A9CD7AD00DBD79E /* SDLV1ProtocolMessageSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLV1ProtocolMessageSpec.m; sourceTree = "<group>"; };
+ 1680B10D1A9CD7AD00DBD79E /* SDLV2ProtocolMessageSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLV2ProtocolMessageSpec.m; sourceTree = "<group>"; };
+ 1680B10E1A9CD7AD00DBD79E /* SDLAbstractProtocolSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAbstractProtocolSpec.m; sourceTree = "<group>"; };
+ 1680B10F1A9CD7AD00DBD79E /* SDLFunctionIDSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLFunctionIDSpec.m; sourceTree = "<group>"; };
+ 1680B1101A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolMessageAssemblerSpec.m; sourceTree = "<group>"; };
+ 1680B1111A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolMessageDisassemblerSpec.m; sourceTree = "<group>"; };
+ 1680B1121A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolReceivedMessageRouterSpec.m; sourceTree = "<group>"; };
5D0218F41A8E79C400D1BF62 /* ConnectionTCPTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConnectionTCPTableViewController.h; path = SmartDeviceLink_Example/Classes/ConnectionTCPTableViewController.h; sourceTree = SOURCE_ROOT; };
5D0218F51A8E79C400D1BF62 /* ConnectionTCPTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ConnectionTCPTableViewController.m; path = SmartDeviceLink_Example/Classes/ConnectionTCPTableViewController.m; sourceTree = SOURCE_ROOT; };
5D0218F81A8E7A7300D1BF62 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = SmartDeviceLink_Example/Base.lproj/ConnectionTCPTableViewController.storyboard; sourceTree = SOURCE_ROOT; };
@@ -1881,6 +1905,41 @@
path = Libraries/OCMock;
sourceTree = "<group>";
};
+ 1680B1041A9CD7AD00DBD79E /* ProtocolSpecs */ = {
+ isa = PBXGroup;
+ children = (
+ 1680B1051A9CD7AD00DBD79E /* HeaderSpecs */,
+ 1680B1091A9CD7AD00DBD79E /* MessageSpecs */,
+ 1680B10E1A9CD7AD00DBD79E /* SDLAbstractProtocolSpec.m */,
+ 1680B10F1A9CD7AD00DBD79E /* SDLFunctionIDSpec.m */,
+ 1680B10B1A9CD7AD00DBD79E /* SDLProtocolSpec.m */,
+ 1680B1101A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m */,
+ 1680B1111A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m */,
+ 1680B1121A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m */,
+ );
+ path = ProtocolSpecs;
+ sourceTree = "<group>";
+ };
+ 1680B1051A9CD7AD00DBD79E /* HeaderSpecs */ = {
+ isa = PBXGroup;
+ children = (
+ 1680B1061A9CD7AD00DBD79E /* SDLProtocolHeaderSpec.m */,
+ 1680B1071A9CD7AD00DBD79E /* SDLV1ProtocolHeaderSpec.m */,
+ 1680B1081A9CD7AD00DBD79E /* SDLV2ProtocolHeaderSpec.m */,
+ );
+ path = HeaderSpecs;
+ sourceTree = "<group>";
+ };
+ 1680B1091A9CD7AD00DBD79E /* MessageSpecs */ = {
+ isa = PBXGroup;
+ children = (
+ 1680B10A1A9CD7AD00DBD79E /* SDLProtocolMessageSpec.m */,
+ 1680B10C1A9CD7AD00DBD79E /* SDLV1ProtocolMessageSpec.m */,
+ 1680B10D1A9CD7AD00DBD79E /* SDLV2ProtocolMessageSpec.m */,
+ );
+ path = MessageSpecs;
+ sourceTree = "<group>";
+ };
5D0218E71A8D611600D1BF62 /* Frameworks */ = {
isa = PBXGroup;
children = (
@@ -2694,6 +2753,7 @@
5D61FA2C1A84237100846EE7 /* SmartDeviceLinkTests */ = {
isa = PBXGroup;
children = (
+ 1680B1041A9CD7AD00DBD79E /* ProtocolSpecs */,
162E81E01A9BDE8A00906325 /* RPCSpecs */,
5D61FA2D1A84237100846EE7 /* Supporting Files */,
167ED9451A9BCE5D00797BE5 /* SwiftSpec.swift */,
@@ -3381,6 +3441,7 @@
files = (
162E83951A9BDE8B00906325 /* SDLTurnSpec.m in Sources */,
162E83481A9BDE8B00906325 /* SDLUpdateTurnListSpec.m in Sources */,
+ 1680B11E1A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m in Sources */,
162E82FD1A9BDE8B00906325 /* SDLSystemContextSpec.m in Sources */,
162E82E21A9BDE8B00906325 /* SDLIgnitionStableStatusSpec.m in Sources */,
162E82EE1A9BDE8B00906325 /* SDLMediaClockFormatSpec.m in Sources */,
@@ -3397,6 +3458,8 @@
162E82D31A9BDE8A00906325 /* SDLCarModeStatusSpec.m in Sources */,
162E82EA1A9BDE8B00906325 /* SDLLanguageSpec.m in Sources */,
162E83331A9BDE8B00906325 /* SDLPerformInteractionSpec.m in Sources */,
+ 1680B11A1A9CD7AD00DBD79E /* SDLAbstractProtocolSpec.m in Sources */,
+ 1680B1151A9CD7AD00DBD79E /* SDLV2ProtocolHeaderSpec.m in Sources */,
162E83101A9BDE8B00906325 /* SDLOnAudioPassThruSpec.m in Sources */,
162E82D91A9BDE8A00906325 /* SDLDisplayTypeSpec.m in Sources */,
162E83871A9BDE8B00906325 /* SDLPermissionItemSpec.m in Sources */,
@@ -3406,6 +3469,7 @@
162E82E41A9BDE8B00906325 /* SDLImageFieldNameSpec.m in Sources */,
162E83991A9BDE8B00906325 /* SDLEnumSpec.m in Sources */,
162E82ED1A9BDE8B00906325 /* SDLMaintenanceModeStatusSpec.m in Sources */,
+ 1680B11C1A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m in Sources */,
162E83181A9BDE8B00906325 /* SDLOnKeyboardInputSpec.m in Sources */,
162E83701A9BDE8B00906325 /* SDLUpdateTurnListResponseSpec.m in Sources */,
162E833B1A9BDE8B00906325 /* SDLSetGlobalPropertiesSpec.m in Sources */,
@@ -3455,12 +3519,15 @@
162E837A1A9BDE8B00906325 /* SDLDIDResult.m in Sources */,
162E83171A9BDE8B00906325 /* SDLOnHMIStatusSpec.m in Sources */,
162E82F71A9BDE8B00906325 /* SDLResultSpec.m in Sources */,
+ 1680B1141A9CD7AD00DBD79E /* SDLV1ProtocolHeaderSpec.m in Sources */,
+ 1680B1161A9CD7AD00DBD79E /* SDLProtocolMessageSpec.m in Sources */,
162E83771A9BDE8B00906325 /* SDLClusterModeStatusSpec.m in Sources */,
162E83981A9BDE8B00906325 /* SDLVrHelpItemSpec.m in Sources */,
162E83831A9BDE8B00906325 /* SDLKeyboardPropertiesSpec.m in Sources */,
162E82D11A9BDE8A00906325 /* SDLButtonNameSpec.m in Sources */,
162E839E1A9BDE8B00906325 /* SDLRPCStructSpec.m in Sources */,
162E83291A9BDE8B00906325 /* SDLDeleteFileSpec.m in Sources */,
+ 1680B11D1A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m in Sources */,
162E838E1A9BDE8B00906325 /* SDLSyncMsgVersionSpec.m in Sources */,
162E82DA1A9BDE8B00906325 /* SDLDriverDistractionStateSpec.m in Sources */,
162E83631A9BDE8B00906325 /* SDLSetGlobalPropertiesResponseSpec.m in Sources */,
@@ -3506,6 +3573,7 @@
167ED9461A9BCE5D00797BE5 /* SwiftSpec.swift in Sources */,
162E838B1A9BDE8B00906325 /* SDLSoftButtonCapabilitiesSpec.m in Sources */,
162E834C1A9BDE8B00906325 /* SDLAlertResponseSpec.m in Sources */,
+ 1680B11B1A9CD7AD00DBD79E /* SDLFunctionIDSpec.m in Sources */,
162E83131A9BDE8B00906325 /* SDLOnCommandSpec.m in Sources */,
162E833A1A9BDE8B00906325 /* SDLSetDisplayLayoutSpec.m in Sources */,
162E838F1A9BDE8B00906325 /* SDLTextFieldSpec.m in Sources */,
@@ -3553,6 +3621,7 @@
162E82D41A9BDE8A00906325 /* SDLCharacterSetSpec.m in Sources */,
162E830F1A9BDE8B00906325 /* SDLOnAppInterfaceUnregisteredSpec.m in Sources */,
162E83971A9BDE8B00906325 /* SDLVehicleTypeSpec.m in Sources */,
+ 1680B1131A9CD7AD00DBD79E /* SDLProtocolHeaderSpec.m in Sources */,
162E82D01A9BDE8A00906325 /* SDLButtonEventModeSpec.m in Sources */,
162E83781A9BDE8B00906325 /* SDLDeviceInfoSpec.m in Sources */,
162E83391A9BDE8B00906325 /* SDLSetAppIconSpec.m in Sources */,
@@ -3567,9 +3636,11 @@
162E83081A9BDE8B00906325 /* SDLVehicleDataResultCodeSpec.m in Sources */,
162E83621A9BDE8B00906325 /* SDLSetDisplayLayoutResponseSpec.m in Sources */,
162E832E1A9BDE8B00906325 /* SDLEndAudioPassThruSpec.m in Sources */,
+ 1680B1191A9CD7AD00DBD79E /* SDLV2ProtocolMessageSpec.m in Sources */,
162E83961A9BDE8B00906325 /* SDLVehicleDataResultSpec.m in Sources */,
162E83491A9BDE8B00906325 /* SDLAddCommandResponseSpec.m in Sources */,
162E82F51A9BDE8B00906325 /* SDLPRNDLSpec.m in Sources */,
+ 1680B1171A9CD7AD00DBD79E /* SDLProtocolSpec.m in Sources */,
162E836D1A9BDE8B00906325 /* SDLUnregisterAppInterfaceResponseSpec.m in Sources */,
162E837C1A9BDE8B00906325 /* SDLECallInfoSpec.m in Sources */,
162E83401A9BDE8B00906325 /* SDLSpeakSpec.m in Sources */,
@@ -3591,6 +3662,7 @@
162E82F41A9BDE8B00906325 /* SDLPrimaryAudioSource.m in Sources */,
162E83461A9BDE8B00906325 /* SDLUnsubscribeButtonSpec.m in Sources */,
162E82EB1A9BDE8B00906325 /* SDLLayoutModeSpec.m in Sources */,
+ 1680B1181A9CD7AD00DBD79E /* SDLV1ProtocolMessageSpec.m in Sources */,
162E82EC1A9BDE8B00906325 /* SDLLockScreenStatusSpec.m in Sources */,
162E832F1A9BDE8B00906325 /* SDLGetDTCsSpec.m in Sources */,
);
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m
new file mode 100644
index 000000000..bc7652098
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m
@@ -0,0 +1,32 @@
+//
+// SDLProtocolHeaderSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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(beAKindOf(SDLV2ProtocolHeader.class));
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m
new file mode 100644
index 000000000..7265ae8c1
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV1ProtocolHeaderSpec.m
@@ -0,0 +1,92 @@
+//
+// SDLV1ProtocolHeaderSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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([NSNumber numberWithInteger:testHeader.version]).to(equal(@1));
+ expect([NSNumber numberWithInteger:testHeader.size]).to(equal(@8));
+ });
+
+ it(@"Should set and get correctly", ^ {
+ expect([NSNumber numberWithBool:testHeader.compressed]).to(equal([NSNumber numberWithBool:YES]));
+ expect([NSNumber numberWithInteger:testHeader.frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Control]));
+ expect([NSNumber numberWithInteger:testHeader.serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:testHeader.frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_StartSession]));
+ expect([NSNumber numberWithInteger:testHeader.sessionID]).to(equal(@0x53));
+ expect([NSNumber numberWithInteger:testHeader.bytesInPayload]).to(equal(@0x1234));
+ });
+});
+
+describe(@"Copy Tests", ^ {
+ it(@"Should copy correctly", ^ {
+ SDLV1ProtocolHeader* headerCopy = [testHeader copy];
+
+ expect([NSNumber numberWithInteger:headerCopy.version]).to(equal(@1));
+ expect([NSNumber numberWithInteger:headerCopy.size]).to(equal(@8));
+
+ expect([NSNumber numberWithBool:headerCopy.compressed]).to(equal([NSNumber numberWithBool:YES]));
+ expect([NSNumber numberWithInteger:headerCopy.frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Control]));
+ expect([NSNumber numberWithInteger:headerCopy.serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:headerCopy.frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_StartSession]));
+ expect([NSNumber numberWithInteger:headerCopy.sessionID]).to(equal(@0x53));
+ expect([NSNumber numberWithInteger: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([NSNumber numberWithBool:constructedHeader.compressed]).to(equal([NSNumber numberWithBool:YES]));
+ expect([NSNumber numberWithInteger:constructedHeader.frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Control]));
+ expect([NSNumber numberWithInteger:constructedHeader.serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:constructedHeader.frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_StartSession]));
+ expect([NSNumber numberWithInteger:constructedHeader.sessionID]).to(equal(@0x53));
+ expect([NSNumber numberWithInteger:constructedHeader.bytesInPayload]).to(equal(@0x1234));
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m
new file mode 100644
index 000000000..16bd013e8
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLV2ProtocolHeaderSpec.m
@@ -0,0 +1,96 @@
+//
+// SDLV2ProtocolHeaderSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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([NSNumber numberWithInteger:testHeader.version]).to(equal(@2));
+ expect([NSNumber numberWithInteger:testHeader.size]).to(equal(@12));
+ });
+
+ it(@"Should set and get correctly", ^ {
+ expect([NSNumber numberWithBool:testHeader.compressed]).to(equal([NSNumber numberWithBool:YES]));
+ expect([NSNumber numberWithInteger:testHeader.frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Control]));
+ expect([NSNumber numberWithInteger:testHeader.serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:testHeader.frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_StartSession]));
+ expect([NSNumber numberWithInteger:testHeader.sessionID]).to(equal(@0x53));
+ expect([NSNumber numberWithInteger:testHeader.bytesInPayload]).to(equal(@0x1234));
+ expect([NSNumber numberWithInteger:testHeader.messageID]).to(equal(@0x6DAB424F));
+ });
+});
+
+describe(@"Copy Tests", ^ {
+ it(@"Should copy correctly", ^ {
+ SDLV2ProtocolHeader* headerCopy = [testHeader copy];
+
+ expect([NSNumber numberWithInteger:headerCopy.version]).to(equal(@2));
+ expect([NSNumber numberWithInteger:headerCopy.size]).to(equal(@12));
+
+ expect([NSNumber numberWithBool:headerCopy.compressed]).to(equal([NSNumber numberWithBool:YES]));
+ expect([NSNumber numberWithInteger:headerCopy.frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Control]));
+ expect([NSNumber numberWithInteger:headerCopy.serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:headerCopy.frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_StartSession]));
+ expect([NSNumber numberWithInteger:headerCopy.sessionID]).to(equal(@0x53));
+ expect([NSNumber numberWithInteger:headerCopy.bytesInPayload]).to(equal(@0x1234));
+ expect([NSNumber numberWithInteger: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([NSNumber numberWithBool:constructedHeader.compressed]).to(equal([NSNumber numberWithBool:YES]));
+ expect([NSNumber numberWithInteger:constructedHeader.frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Control]));
+ expect([NSNumber numberWithInteger:constructedHeader.serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:constructedHeader.frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_StartSession]));
+ expect([NSNumber numberWithInteger:constructedHeader.sessionID]).to(equal(@0x53));
+ expect([NSNumber numberWithInteger:constructedHeader.bytesInPayload]).to(equal(@0x1234));
+ expect([NSNumber numberWithInteger:testHeader.messageID]).to(equal(@0x6DAB424F));
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m
new file mode 100644
index 000000000..7b2c27b60
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m
@@ -0,0 +1,74 @@
+//
+// SDLProtocolMessageSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.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([NSNumber numberWithInteger:[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([NSNumber numberWithInteger:[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/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
new file mode 100644
index 000000000..ff832aaac
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
@@ -0,0 +1,480 @@
+//
+// SDLProtocolSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.h>
+
+#import "SDLProtocol.h"
+#import "SDLV1ProtocolMessage.h"
+#import "SDLV2ProtocolMessage.h"
+#import "SDLV1ProtocolHeader.h"
+#import "SDLV2ProtocolHeader.h"
+#import "SDLTransport.h"
+#import "SDLProtocolRecievedMessageRouter.h"
+#import "SDLNames.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 = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+});
+
+describe(@"SendEndSession Tests", ^ {
+ context(@"During V1 session", ^ {
+ it(@"Should send the correct data", ^ {
+ SDLProtocol* testProtocol = [[SDLProtocol alloc] init];
+ [testProtocol handleProtocolSessionStarted:SDLServiceType_RPC sessionID:0x03 version:0x01];
+
+ __block BOOL verified = NO;
+ id transportMock = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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 sessionID:0x03];
+
+ expect([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+ });
+
+ context(@"During V2 session", ^ {
+ it(@"Should send the correct data", ^ {
+ SDLProtocol* testProtocol = [[SDLProtocol alloc] init];
+ [testProtocol handleProtocolSessionStarted:SDLServiceType_RPC sessionID:0x61 version:0x02];
+
+ __block BOOL verified = NO;
+ id transportMock = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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 sessionID:0x61];
+
+ expect([NSNumber numberWithBool: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 handleProtocolSessionStarted:SDLServiceType_RPC sessionID:0xFF version:0x01];
+
+ __block BOOL verified = NO;
+ id transportMock = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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 sendRPCRequest:mockRequest];
+
+ expect([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+ });
+
+ context(@"During V2 session", ^ {
+ it(@"Should send the correct data", ^ {
+ [[[[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 handleProtocolSessionStarted:SDLServiceType_RPC sessionID:0x01 version:0x02];
+
+ __block BOOL verified = NO;
+ id transportMock = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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_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];
+
+ expect(dataSent).to(equal([testData copy]));
+ }] sendData:[OCMArg any]];
+ testProtocol.transport = transportMock;
+
+ [testProtocol sendRPCRequest:mockRequest];
+
+ expect([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+ });
+});
+
+describe(@"HandleBytesFromTransport Tests", ^ {
+ context(@"During V1 session", ^ {
+ it(@"Should parse the data correctly", ^ {
+ id routerMock = OCMClassMock(SDLProtocolRecievedMessageRouter.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 handleProtocolSessionStarted: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([NSNumber numberWithInteger:[messageReceived header].version]).to(equal(@1));
+ expect([NSNumber numberWithBool:[messageReceived header].compressed]).to(equal([NSNumber numberWithBool:NO]));
+ expect([NSNumber numberWithInteger:[messageReceived header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Single]));
+ expect([NSNumber numberWithInteger:[messageReceived header].sessionID]).to(equal(@0xFF));
+ expect([NSNumber numberWithInteger:[messageReceived header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:[messageReceived header].frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_SingleFrame]));
+ expect([NSNumber numberWithInteger:[messageReceived header].bytesInPayload]).to(equal([NSNumber numberWithInteger:dataLength]));
+ }] handleRecievedMessage:[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([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+ });
+
+ context(@"During V2 session", ^ {
+ it(@"Should parse the data correctly", ^ {
+ id routerMock = OCMClassMock(SDLProtocolRecievedMessageRouter.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 handleProtocolSessionStarted: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([NSNumber numberWithInteger:[messageReceived header].version]).to(equal(@2));
+ expect([NSNumber numberWithBool:[messageReceived header].compressed]).to(equal([NSNumber numberWithBool:NO]));
+ expect([NSNumber numberWithInteger:[messageReceived header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Single]));
+ expect([NSNumber numberWithInteger:[messageReceived header].sessionID]).to(equal(@0x01));
+ expect([NSNumber numberWithInteger:[messageReceived header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:[messageReceived header].frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_SingleFrame]));
+ expect([NSNumber numberWithInteger:[messageReceived header].bytesInPayload]).to(equal([NSNumber numberWithInteger:payloadData.length]));
+ expect([NSNumber numberWithInteger:((SDLV2ProtocolHeader*)[messageReceived header]).messageID]).to(equal(@1));
+
+ }] handleRecievedMessage:[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([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+ });
+});
+
+describe(@"SendHeartbeat Tests", ^ {
+ context(@"During V1 session", ^ {
+ it(@"Should send the correct data", ^ {
+ SDLProtocol* testProtocol = [[SDLProtocol alloc] init];
+ [testProtocol handleProtocolSessionStarted:SDLServiceType_RPC sessionID:0x43 version:0x01];
+
+ __block BOOL verified = NO;
+ id transportMock = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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;
+
+ [testProtocol sendHeartbeat];
+
+ expect([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+ });
+
+ context(@"During V2 session", ^ {
+ it(@"Should send the correct data", ^ {
+ SDLProtocol* testProtocol = [[SDLProtocol alloc] init];
+ [testProtocol handleProtocolSessionStarted:SDLServiceType_RPC sessionID:0xF5 version:0x02];
+
+ __block BOOL verified = NO;
+ id transportMock = OCMProtocolMock(@protocol(SDLTransport));
+ [[[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;
+
+ [testProtocol sendHeartbeat];
+
+ expect([NSNumber numberWithBool: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([NSNumber numberWithInteger:serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_BulkData]));
+ expect([NSNumber numberWithInteger:sessionID]).to(equal(@0x44));
+ expect([NSNumber numberWithInteger:version]).to(equal(@0x03));
+ }] ignoringNonObjectArgs] handleProtocolSessionStarted:0 sessionID:0 version:0];
+
+ testProtocol.protocolDelegate = delegateMock;
+
+ [testProtocol handleProtocolSessionStarted:SDLServiceType_BulkData sessionID:0x44 version:0x03];
+
+ expect([NSNumber numberWithBool: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.protocolDelegate = delegateMock;
+
+ [testProtocol onProtocolMessageReceived:testMessage];
+
+ expect([NSNumber numberWithBool: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.protocolDelegate = delegateMock;
+
+ [testProtocol onProtocolOpened];
+
+ expect([NSNumber numberWithBool: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.protocolDelegate = delegateMock;
+
+ [testProtocol onProtocolClosed];
+
+ expect([NSNumber numberWithBool: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.protocolDelegate = delegateMock;
+
+ [testProtocol onError:@"Nothing actually happened" exception:testException];
+
+ expect([NSNumber numberWithBool:verified]).toEventually(beTruthy());
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m
new file mode 100644
index 000000000..10ffa219d
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV1ProtocolMessageSpec.m
@@ -0,0 +1,34 @@
+//
+// SDLV1ProtocolMessageSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m
new file mode 100644
index 000000000..028c9dbf7
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLV2ProtocolMessageSpec.m
@@ -0,0 +1,60 @@
+//
+// SDLV2ProtocolMessageSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m
new file mode 100644
index 000000000..26ca1ead4
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLAbstractProtocolSpec.m
@@ -0,0 +1,60 @@
+//
+// SDLAbstractProtocolSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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.protocolDelegate = 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([NSNumber numberWithBool:verified]).to(beTruthy());
+ });
+});
+
+describe(@"OnTransportDisconnected Tests", ^ {
+ it(@"Should invoke the correct method", ^ {
+ id delegateMock = OCMProtocolMock(@protocol(SDLProtocolListener));
+
+ SDLAbstractProtocol* abstractProtocol = [[SDLAbstractProtocol alloc] init];
+ abstractProtocol.protocolDelegate = 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([NSNumber numberWithBool:verified]).to(beTruthy());
+ });
+});
+
+QuickSpecEnd
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m
new file mode 100644
index 000000000..dbacf43c8
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLFunctionIDSpec.m
@@ -0,0 +1,157 @@
+//
+// FunctionIDSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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));
+ //In Spec, but not implemented
+ //expect([functionID getFunctionName:39]).to(equal(NAMES_SendLocation));
+
+ 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));
+ //In Spec, but not implemented
+ //expect([functionID getFunctionID:NAMES_SendLocation]).to(equal(@39));
+
+ 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 \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m
new file mode 100644
index 000000000..42be3033f
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageAssemblerSpec.m
@@ -0,0 +1,103 @@
+//
+// SDLProtocolMessageAssemblerSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#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([NSNumber numberWithBool:done]).to(equal([NSNumber numberWithBool:NO]));
+ expect(assembledMessage).to(beNil());
+ };
+
+ [assembler handleMessage:testMessage withCompletionHandler:incompleteHandler];
+
+ expect([NSNumber numberWithBool: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([NSNumber numberWithBool: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;
+
+ //At the moment, this test fails because the completion handler is accidentally called twice
+ expect([NSNumber numberWithBool:done]).to(equal([NSNumber numberWithBool:YES]));
+
+ expect(assembledMessage.payload).to(equal(payloadData));
+ expect([NSNumber numberWithInteger:[assembledMessage header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Single]));
+ expect([NSNumber numberWithInteger:[assembledMessage header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_BulkData]));
+ expect([NSNumber numberWithInteger:[assembledMessage header].frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_SingleFrame]));
+ expect([NSNumber numberWithInteger:[assembledMessage header].sessionID]).to(equal(@0x16));
+ expect([NSNumber numberWithInteger:[assembledMessage header].bytesInPayload]).to(equal([NSNumber numberWithInteger:payloadData.length]));
+ }];
+
+ expect([NSNumber numberWithBool:verified]).to(beTruthy());
+ });
+});
+
+QuickSpecEnd
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m
new file mode 100644
index 000000000..7bd32402b
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m
@@ -0,0 +1,94 @@
+//
+// SDLProtocolMessageDisassemblerSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.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];
+
+ 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:512];
+
+ //Payload length per message
+ UInt32 payloadLength = 500;//MTU(512)-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 objectAtIndex:0];
+
+ //First frame
+ expect(message.payload).to(equal([NSData dataWithBytes:firstPayload length:8]));
+
+ expect([NSNumber numberWithInteger:[message header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_First]));
+ expect([NSNumber numberWithInteger:[message header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_BulkData]));
+ expect([NSNumber numberWithInteger:[message header].frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_FirstFrame]));
+ expect([NSNumber numberWithInteger:[message header].sessionID]).to(equal(@0x84));
+ expect([NSNumber numberWithInteger:[message header].bytesInPayload]).to(equal(@8));
+
+ NSUInteger offset = 0;
+ for (int i = 1; i < messageList.count - 1; i++) {
+ message = [messageList objectAtIndex:i];
+
+ //Consecutive frames
+ expect(message.payload).to(equal([NSData dataWithData:[payloadData subdataWithRange:NSMakeRange(offset, payloadLength)]]));
+
+ expect([NSNumber numberWithInteger:[message header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Consecutive]));
+ expect([NSNumber numberWithInteger:[message header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_BulkData]));
+ expect([NSNumber numberWithInteger:[message header].frameData]).to(equal([NSNumber numberWithInteger:i]));
+ expect([NSNumber numberWithInteger:[message header].sessionID]).to(equal(@0x84));
+ expect([NSNumber numberWithInteger:[message header].bytesInPayload]).to(equal([NSNumber numberWithInteger: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([NSNumber numberWithInteger:[message header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Consecutive]));
+ expect([NSNumber numberWithInteger:[message header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_BulkData]));
+ expect([NSNumber numberWithInteger:[message header].frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_ConsecutiveLastFrame]));
+ expect([NSNumber numberWithInteger:[message header].sessionID]).to(equal(@0x84));
+ expect([NSNumber numberWithInteger:[message header].bytesInPayload]).to(equal([NSNumber numberWithInteger:remaining]));
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m
new file mode 100644
index 000000000..454e59500
--- /dev/null
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m
@@ -0,0 +1,180 @@
+//
+// SDLProtocolReceivedMessageRouterSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Jacob Keeler on 2/16/15.
+// Copyright (c) 2015 Ford Motor Company. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.h>
+
+#import "SDLProtocolRecievedMessageRouter.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([NSNumber numberWithInteger:serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_RPC]));
+ expect([NSNumber numberWithInteger:sessionID]).to(equal(@0x93));
+ expect([NSNumber numberWithInteger:version]).to(equal(@0x02));
+ }] ignoringNonObjectArgs] handleProtocolSessionStarted:0 sessionID:0 version:0];
+
+ SDLProtocolRecievedMessageRouter* router = [[SDLProtocolRecievedMessageRouter alloc] init];
+ router.delegate = delegateMock;
+
+ [router handleRecievedMessage:testMessage];
+
+ expect([NSNumber numberWithBool: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]];
+
+ SDLProtocolRecievedMessageRouter* router = [[SDLProtocolRecievedMessageRouter alloc] init];
+ router.delegate = delegateMock;
+
+ [router handleRecievedMessage:testMessage];
+
+ expect([NSNumber numberWithBool: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];
+
+ SDLProtocolRecievedMessageRouter* router = [[SDLProtocolRecievedMessageRouter alloc] init];
+
+ [router handleRecievedMessage: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 handleRecievedMessage: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([NSNumber numberWithInteger:[assembledMessage header].frameType]).to(equal([NSNumber numberWithInteger:SDLFrameType_Single]));
+ expect([NSNumber numberWithInteger:[assembledMessage header].serviceType]).to(equal([NSNumber numberWithInteger:SDLServiceType_BulkData]));
+ expect([NSNumber numberWithInteger:[assembledMessage header].frameData]).to(equal([NSNumber numberWithInteger:SDLFrameData_SingleFrame]));
+ expect([NSNumber numberWithInteger:[assembledMessage header].sessionID]).to(equal(@0x33));
+ expect([NSNumber numberWithInteger:[assembledMessage header].bytesInPayload]).to(equal([NSNumber numberWithInteger:payloadData.length]));
+ }] onProtocolMessageReceived:[OCMArg any]];
+
+ router.delegate = delegateMock;
+ [router handleRecievedMessage:testMessage];
+
+ expect([NSNumber numberWithBool:verified]).to(beTruthy());
+ });
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m
index f29b311a6..6b241ec82 100644
--- a/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/FactorySpecs/SDLRPCRequestFactorySpec.m
@@ -75,7 +75,7 @@ describe(@"BuildAddSubMenu Tests", ^ {
});
describe(@"BuildAlert Tests", ^ {
- describe(@"With Text", ^ {
+ context(@"With Text", ^ {
it(@"Should build correctly", ^ {
NSArray* softButtons = @[[[SDLSoftButton alloc] init]];
SDLAlert* message = [SDLRPCRequestFactory buildAlertWithAlertText1:@"String1" alertText2:@"String2" alertText3:@"String3"
@@ -118,7 +118,7 @@ describe(@"BuildAlert Tests", ^ {
});
});
- describe(@"With TTS", ^ {
+ context(@"With TTS", ^ {
it(@"Should build correctly", ^ {
SDLAlert* message = [SDLRPCRequestFactory buildAlertWithTTS:@"Wat" alertText1:@"11" alertText2:@"12" alertText3:@"13"
playTone:[NSNumber numberWithBool:NO] duration:@3424 correlationID:@9999999];
@@ -160,7 +160,7 @@ describe(@"BuildAlert Tests", ^ {
});
});
- describe(@"With TTSChunks", ^ {
+ context(@"With TTSChunks", ^ {
it(@"Should build correctly", ^ {
NSArray* softButtons = @[[[SDLSoftButton alloc] init]];
NSArray* ttsChunks = @[[[SDLTTSChunk alloc] init]];
@@ -333,7 +333,7 @@ describe(@"BuildPerformAudioPassThru Tests", ^ {
});
describe(@"BuildPerformInteraction Tests", ^ {
- describe(@"With Initial Chunks", ^ {
+ context(@"With Initial Chunks", ^ {
it(@"Should build correctly", ^ {
NSArray* initialChunks = @[[[SDLTTSChunk alloc] init]];
NSArray* helpChunks = @[[[SDLTTSChunk alloc] init]];
@@ -356,7 +356,7 @@ describe(@"BuildPerformInteraction Tests", ^ {
});
});
- describe(@"With Initial Prompt", ^ {
+ context(@"With Initial Prompt", ^ {
it(@"Should build correctly", ^ {
NSArray* vrHelp = @[[[SDLVrHelpItem alloc] init]];
SDLPerformInteraction* message = [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:@"Nothing" initialText:@"Still Nothing" interactionChoiceSetIDList:@[@4223, @1337]
diff --git a/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m b/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m
index b231b6c40..03e705b1d 100644
--- a/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m
+++ b/SmartDeviceLink-iOS/SmartDeviceLinkTests/RPCSpecs/SuperclassSpecs/SDLEnumSpec.m
@@ -15,8 +15,8 @@
QuickSpecBegin(SDLEnumSpec)
-describe(@"InitWithValue Tests", ^ {
- it(@"Should initialize correctly", ^ {
+describe(@"Value Tests", ^ {
+ it(@"Should get value correctly when initialized", ^ {
SDLEnum* enumValue = [[SDLEnum alloc] initWithValue:@"Enum"];
expect(enumValue).toNot(beNil());