diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-08-09 09:38:03 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2017-08-09 09:38:03 -0400 |
commit | f0a1ef16e20b4dce4c906e499eafa45e515fbb00 (patch) | |
tree | 91698d5012e67fae2ad036074f720e5490649900 | |
parent | 08e0cd39fb1ca53f183fa760b9ed1b21580ea41c (diff) | |
download | sdl_ios-f0a1ef16e20b4dce4c906e499eafa45e515fbb00.tar.gz |
Add tests for video start service payloads
* Fix a bug in video start service ack payload
* Remove unused hash id parameter in audio start service ack payload spec
7 files changed, 181 insertions, 13 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index b7509f745..a8d219315 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -913,6 +913,8 @@ 5DB996611F28C6ED002D8795 /* SDLControlFramePayloadVideoStartServiceAck.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DB9965F1F28C6ED002D8795 /* SDLControlFramePayloadVideoStartServiceAck.m */; }; 5DBAE0AB1D3588AC00CE00BF /* SDLNotificationDispatcherSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DBAE0AA1D3588AC00CE00BF /* SDLNotificationDispatcherSpec.m */; }; 5DBAE0AD1D368D1A00CE00BF /* SDLResponseDispatcherSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DBAE0AC1D368D1A00CE00BF /* SDLResponseDispatcherSpec.m */; }; + 5DBF0D5E1F3A68C0008AF2C9 /* SDLControlFramePayloadVideoStartServiceSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DBF0D5D1F3A68C0008AF2C9 /* SDLControlFramePayloadVideoStartServiceSpec.m */; }; + 5DBF0D601F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DBF0D5F1F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m */; }; 5DC09EDA1F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DC09ED91F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m */; }; 5DC978261B7A38640012C2F1 /* SDLGlobalsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DC978251B7A38640012C2F1 /* SDLGlobalsSpec.m */; }; 5DCC19A01B8221F3004FFAD9 /* SDLURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DCC199E1B8221F3004FFAD9 /* SDLURLSession.h */; }; @@ -2017,6 +2019,8 @@ 5DB9965F1F28C6ED002D8795 /* SDLControlFramePayloadVideoStartServiceAck.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLControlFramePayloadVideoStartServiceAck.m; sourceTree = "<group>"; }; 5DBAE0AA1D3588AC00CE00BF /* SDLNotificationDispatcherSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLNotificationDispatcherSpec.m; path = DevAPISpecs/SDLNotificationDispatcherSpec.m; sourceTree = "<group>"; }; 5DBAE0AC1D368D1A00CE00BF /* SDLResponseDispatcherSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLResponseDispatcherSpec.m; path = DevAPISpecs/SDLResponseDispatcherSpec.m; sourceTree = "<group>"; }; + 5DBF0D5D1F3A68C0008AF2C9 /* SDLControlFramePayloadVideoStartServiceSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFramePayloadVideoStartServiceSpec.m; path = ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m; sourceTree = "<group>"; }; + 5DBF0D5F1F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFrameVideoStartServiceAckSpec.m; path = ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m; sourceTree = "<group>"; }; 5DC09ED91F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFramePayloadNakSpec.m; path = ControlFramePayloadSpecs/SDLControlFramePayloadNakSpec.m; sourceTree = "<group>"; }; 5DC978251B7A38640012C2F1 /* SDLGlobalsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLGlobalsSpec.m; path = UtilitiesSpecs/SDLGlobalsSpec.m; sourceTree = "<group>"; }; 5DCA93821EE0844D0015768E /* SmartDeviceLink.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmartDeviceLink.podspec; sourceTree = SOURCE_ROOT; }; @@ -3741,6 +3745,8 @@ 5DA23FF91F2FB485009C0313 /* Video Service */ = { isa = PBXGroup; children = ( + 5DBF0D5D1F3A68C0008AF2C9 /* SDLControlFramePayloadVideoStartServiceSpec.m */, + 5DBF0D5F1F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m */, ); name = "Video Service"; sourceTree = "<group>"; @@ -5206,6 +5212,7 @@ 5D9F50811BE7E6E300FEF399 /* SDLPermissionsManagerSpec.m in Sources */, 162E83361A9BDE8B00906325 /* SDLRegisterAppInterfaceSpec.m in Sources */, 162E82DD1A9BDE8B00906325 /* SDLFileTypeSpec.m in Sources */, + 5DBF0D5E1F3A68C0008AF2C9 /* SDLControlFramePayloadVideoStartServiceSpec.m in Sources */, 162E836A1A9BDE8B00906325 /* SDLSubscribeVehicleDataResponseSpec.m in Sources */, 162E83761A9BDE8B00906325 /* SDLChoiceSpec.m in Sources */, 162E83571A9BDE8B00906325 /* SDLGetDTCsResponseSpec.m in Sources */, @@ -5286,6 +5293,7 @@ 162E83471A9BDE8B00906325 /* SDLUnsubscribeVehicleDataSpec.m in Sources */, 162E839A1A9BDE8B00906325 /* SDLRPCMessageSpec.m in Sources */, 5D0A9F911F15550400CC80DD /* SDLSystemCapabilityTypeSpec.m in Sources */, + 5DBF0D601F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m in Sources */, 162E83311A9BDE8B00906325 /* SDLListFilesSpec.m in Sources */, DA9F7EB01DCC063400ACAE48 /* SDLLocationDetailsSpec.m in Sources */, 5DC978261B7A38640012C2F1 /* SDLGlobalsSpec.m in Sources */, diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m index 47ed8301a..caa6a24a2 100644 --- a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m +++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m @@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoCodecKey); if (utf8String != NULL) { - self.videoProtocol = [SDLVideoStreamingProtocol valueOf:[NSString stringWithUTF8String:utf8String]]; + self.videoCodec = [SDLVideoStreamingCodec valueOf:[NSString stringWithUTF8String:utf8String]]; } bson_object_deinitialize(&payloadObject); diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h index 0fed3ebf3..ed6c17474 100644 --- a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h +++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN /// Accepted video codec to be used. See VideoStreamingCodec RPC @property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec *videoCodec; -- (instancetype)initWithMTU:(int64_t)mtu videoHeight:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec; +- (instancetype)initWithMTU:(int64_t)mtu height:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec; @end diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m index d669f65d2..e30fe1af7 100644 --- a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m +++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m @@ -26,7 +26,7 @@ @implementation SDLControlFramePayloadVideoStartServiceAck -- (instancetype)initWithMTU:(int64_t)mtu videoHeight:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec { +- (instancetype)initWithMTU:(int64_t)mtu height:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec { self = [super init]; if (!self) return nil; diff --git a/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m new file mode 100644 index 000000000..1a5e9cc9d --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m @@ -0,0 +1,80 @@ + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLControlFramePayloadConstants.h" +#import "SDLControlFramePayloadVideoStartService.h" +#import "SDLVideoStreamingCodec.h" +#import "SDLVideoStreamingProtocol.h" + +QuickSpecBegin(SDLControlFramePayloadVideoStartServiceSpec) + +describe(@"Test encoding data", ^{ + __block SDLControlFramePayloadVideoStartService *testPayload = nil; + __block int32_t testHeight = SDLControlFrameInt32NotFound; + __block int32_t testWidth = SDLControlFrameInt32NotFound; + __block SDLVideoStreamingCodec *testCodec = nil; + __block SDLVideoStreamingProtocol *testProtocol = nil; + + context(@"with paramaters", ^{ + beforeEach(^{ + testHeight = 59794; + testWidth = 363; + testCodec = [SDLVideoStreamingCodec H265]; + testProtocol = [SDLVideoStreamingProtocol RTMP]; + + testPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithVideoHeight:testHeight width:testWidth protocol:testProtocol codec:testCodec]; + }); + + it(@"should create the correct data", ^{ + expect(testPayload.data.description).to(equal(@"<49000000 02766964 656f5072 6f746f63 6f6c0005 00000052 544d5000 10776964 7468006b 01000002 76696465 6f436f64 65630005 00000048 32363500 10686569 67687400 92e90000 00>")); + }); + }); + + context(@"without parameters", ^{ + beforeEach(^{ + testHeight = SDLControlFrameInt32NotFound; + testWidth = SDLControlFrameInt32NotFound; + testCodec = nil; + testProtocol = nil; + + testPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithVideoHeight:testHeight width:testWidth protocol:testProtocol codec:testCodec]; + }); + + it(@"should create no data", ^{ + expect(testPayload.data.length).to(equal(0)); + }); + }); +}); + +describe(@"Test decoding data", ^{ + __block SDLControlFramePayloadVideoStartService *testPayload = nil; + __block NSData *testData = nil; + __block int32_t testHeight = SDLControlFrameInt32NotFound; + __block int32_t testWidth = SDLControlFrameInt32NotFound; + __block SDLVideoStreamingCodec *testCodec = nil; + __block SDLVideoStreamingProtocol *testProtocol = nil; + + beforeEach(^{ + testHeight = 787; + testWidth = 36365; + testCodec = [SDLVideoStreamingCodec THEORA]; + testProtocol = [SDLVideoStreamingProtocol RTSP]; + + SDLControlFramePayloadVideoStartService *firstPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithVideoHeight:testHeight width:testWidth protocol:testProtocol codec:testCodec]; + testData = firstPayload.data; + + testPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithData:testData]; + }); + + it(@"should output the correct params", ^{ + expect(testPayload.height).to(equal(testHeight)); + expect(testPayload.width).to(equal(testWidth)); + expect(testPayload.videoCodec).to(equal(testCodec)); + expect(testPayload.videoProtocol).to(equal(testProtocol)); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m new file mode 100644 index 000000000..b52740312 --- /dev/null +++ b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m @@ -0,0 +1,86 @@ + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLControlFramePayloadConstants.h" +#import "SDLControlFramePayloadVideoStartServiceAck.h" +#import "SDLVideoStreamingCodec.h" +#import "SDLVideoStreamingProtocol.h" + +QuickSpecBegin(SDLControlFramePayloadVideoStartServiceAckSpec) + +describe(@"Test encoding data", ^{ + __block SDLControlFramePayloadVideoStartServiceAck *testPayload = nil; + __block int64_t testMTU = SDLControlFrameInt64NotFound; + __block int32_t testHeight = SDLControlFrameInt32NotFound; + __block int32_t testWidth = SDLControlFrameInt32NotFound; + __block SDLVideoStreamingCodec *testCodec = nil; + __block SDLVideoStreamingProtocol *testProtocol = nil; + + context(@"with paramaters", ^{ + beforeEach(^{ + testMTU = 1247988; + testHeight = 5974; + testWidth = 36; + testCodec = [SDLVideoStreamingCodec H264]; + testProtocol = [SDLVideoStreamingProtocol RAW]; + + testPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testHeight width:testWidth protocol:testProtocol codec:testCodec]; + }); + + it(@"should create the correct data", ^{ + expect(testPayload.data.description).to(equal(@"<55000000 126d7475 00f40a13 00000000 00027669 64656f50 726f746f 636f6c00 04000000 52415700 10776964 74680024 00000002 76696465 6f436f64 65630005 00000048 32363400 10686569 67687400 56170000 00>")); + }); + }); + + context(@"without parameters", ^{ + beforeEach(^{ + testMTU = SDLControlFrameInt64NotFound; + testHeight = SDLControlFrameInt32NotFound; + testWidth = SDLControlFrameInt32NotFound; + testCodec = nil; + testProtocol = nil; + + testPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testHeight width:testWidth protocol:testProtocol codec:testCodec]; + }); + + it(@"should create no data", ^{ + expect(testPayload.data.length).to(equal(0)); + }); + }); +}); + +describe(@"Test decoding data", ^{ + __block SDLControlFramePayloadVideoStartServiceAck *testPayload = nil; + __block NSData *testData = nil; + __block int64_t testMTU = SDLControlFrameInt64NotFound; + __block int32_t testHeight = SDLControlFrameInt32NotFound; + __block int32_t testWidth = SDLControlFrameInt32NotFound; + __block SDLVideoStreamingCodec *testCodec = nil; + __block SDLVideoStreamingProtocol *testProtocol = nil; + + beforeEach(^{ + testMTU = 4584651; + testHeight = 787; + testWidth = 36365; + testCodec = [SDLVideoStreamingCodec VP8]; + testProtocol = [SDLVideoStreamingProtocol RTSP]; + + SDLControlFramePayloadVideoStartServiceAck *firstPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testHeight width:testWidth protocol:testProtocol codec:testCodec]; + testData = firstPayload.data; + + testPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithData:testData]; + }); + + it(@"should output the correct params", ^{ + expect(testPayload.mtu).to(equal(testMTU)); + expect(testPayload.height).to(equal(testHeight)); + expect(testPayload.width).to(equal(testWidth)); + expect(testPayload.videoCodec).to(equal(testCodec)); + expect(testPayload.videoProtocol).to(equal(testProtocol)); + }); +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLControlFramePayloadAudioStartServiceAckSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLControlFramePayloadAudioStartServiceAckSpec.m index 18f42bd2a..a168fc39d 100644 --- a/SmartDeviceLinkTests/ProtocolSpecs/SDLControlFramePayloadAudioStartServiceAckSpec.m +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLControlFramePayloadAudioStartServiceAckSpec.m @@ -11,28 +11,25 @@ QuickSpecBegin(SDLControlFramePayloadAudioStartServiceAckSpec) describe(@"Test encoding data", ^{ __block SDLControlFramePayloadAudioStartServiceAck *testPayload = nil; - __block int32_t testHashId = 0; __block int64_t testMTU = 0; context(@"with paramaters", ^{ beforeEach(^{ - testHashId = 1457689; testMTU = 598464979; - testPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithHashId:testHashId mtu:testMTU]; + testPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithMTU:testMTU]; }); it(@"should create the correct data", ^{ - expect(testPayload.data.description).to(equal(@"<1e000000 10686173 68496400 193e1600 126d7475 00d3d9ab 23000000 0000>")); + expect(testPayload.data.description).to(equal(@"<12000000 126d7475 00d3d9ab 23000000 0000>")); }); }); context(@"without parameters", ^{ beforeEach(^{ - testHashId = SDLControlFrameInt32NotFound; testMTU = SDLControlFrameInt64NotFound; - testPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithHashId:testHashId mtu:testMTU]; + testPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithMTU:testMTU]; }); it(@"should create no data", ^{ @@ -44,21 +41,18 @@ describe(@"Test encoding data", ^{ describe(@"Test decoding data", ^{ __block SDLControlFramePayloadAudioStartServiceAck *testPayload = nil; __block NSData *testData = nil; - __block int32_t testHashId = 0; __block int64_t testMTU = 0; beforeEach(^{ - testHashId = 1545784; testMTU = 989786483; - SDLControlFramePayloadAudioStartServiceAck *firstPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithHashId:testHashId mtu:testMTU]; + SDLControlFramePayloadAudioStartServiceAck *firstPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithMTU:testMTU]; testData = firstPayload.data; testPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithData:testData]; }); it(@"should output the correct params", ^{ - expect(testPayload.hashId).to(equal(testHashId)); expect(testPayload.mtu).to(equal(testMTU)); }); }); |