diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2017-07-28 14:12:39 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2017-07-28 14:12:39 -0400 |
commit | f3ff3c0377fb8b4f0d2c3109431ba88fefe5cc3a (patch) | |
tree | 62c5253f80f4cdd88cd205440ce09cdd070aa78e | |
parent | bf45b711cf5ff29ef9573b1d02126a544ae7e669 (diff) | |
download | sdl_ios-f3ff3c0377fb8b4f0d2c3109431ba88fefe5cc3a.tar.gz |
working unit tests
7 files changed, 210 insertions, 3 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 4d7f12421..813d8687b 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -913,6 +913,8 @@ 8BD729B31F2A61DF0029AC93 /* SDLVideoStreamingCapability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD729B11F2A61DF0029AC93 /* SDLVideoStreamingCapability.m */; }; 8BD729B51F2A711D0029AC93 /* SDLVideoStreamingCodecSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD729B41F2A711D0029AC93 /* SDLVideoStreamingCodecSpec.m */; }; 8BD729B71F2A75FD0029AC93 /* SDLVideoStreamingProtocolSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD729B61F2A75FD0029AC93 /* SDLVideoStreamingProtocolSpec.m */; }; + 8BF9DE071F2BAEEE004FFCBB /* SDLVideoStreamingFormatSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BF9DE061F2BAEEE004FFCBB /* SDLVideoStreamingFormatSpec.m */; }; + 8BF9DE091F2BAF0C004FFCBB /* SDLVideoStreamingCapabilitySpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BF9DE081F2BAF0C004FFCBB /* SDLVideoStreamingCapabilitySpec.m */; }; 97E26DEC1E807AD70074A3C7 /* SDLMutableDataQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 97E26DEA1E807AD70074A3C7 /* SDLMutableDataQueue.h */; }; 97E26DED1E807AD70074A3C7 /* SDLMutableDataQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E26DEB1E807AD70074A3C7 /* SDLMutableDataQueue.m */; }; DA4353DF1D271FD10099B8C4 /* CGPointUtilSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */; }; @@ -1983,6 +1985,8 @@ 8BD729B11F2A61DF0029AC93 /* SDLVideoStreamingCapability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLVideoStreamingCapability.m; sourceTree = "<group>"; }; 8BD729B41F2A711D0029AC93 /* SDLVideoStreamingCodecSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLVideoStreamingCodecSpec.m; sourceTree = "<group>"; }; 8BD729B61F2A75FD0029AC93 /* SDLVideoStreamingProtocolSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLVideoStreamingProtocolSpec.m; sourceTree = "<group>"; }; + 8BF9DE061F2BAEEE004FFCBB /* SDLVideoStreamingFormatSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLVideoStreamingFormatSpec.m; sourceTree = "<group>"; }; + 8BF9DE081F2BAF0C004FFCBB /* SDLVideoStreamingCapabilitySpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLVideoStreamingCapabilitySpec.m; sourceTree = "<group>"; }; 97E26DEA1E807AD70074A3C7 /* SDLMutableDataQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLMutableDataQueue.h; sourceTree = "<group>"; }; 97E26DEB1E807AD70074A3C7 /* SDLMutableDataQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLMutableDataQueue.m; sourceTree = "<group>"; }; DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CGPointUtilSpec.m; path = UtilitiesSpecs/Touches/CGPointUtilSpec.m; sourceTree = "<group>"; }; @@ -2399,6 +2403,8 @@ 162E82B41A9BDE8A00906325 /* SDLVehicleDataResultSpec.m */, 162E82B51A9BDE8A00906325 /* SDLVehicleTypeSpec.m */, 162E82B61A9BDE8A00906325 /* SDLVrHelpItemSpec.m */, + 8BF9DE061F2BAEEE004FFCBB /* SDLVideoStreamingFormatSpec.m */, + 8BF9DE081F2BAF0C004FFCBB /* SDLVideoStreamingCapabilitySpec.m */, ); path = StructSpecs; sourceTree = "<group>"; @@ -5055,6 +5061,7 @@ 162E83311A9BDE8B00906325 /* SDLListFilesSpec.m in Sources */, DA9F7EB01DCC063400ACAE48 /* SDLLocationDetailsSpec.m in Sources */, 5DC978261B7A38640012C2F1 /* SDLGlobalsSpec.m in Sources */, + 8BF9DE071F2BAEEE004FFCBB /* SDLVideoStreamingFormatSpec.m in Sources */, 162E82FF1A9BDE8B00906325 /* SDLTextAlignmentSpec.m in Sources */, 162E831F1A9BDE8B00906325 /* SDLOnTouchEventSpec.m in Sources */, 162E83921A9BDE8B00906325 /* SDLTouchEventCapabilitiesSpec.m in Sources */, @@ -5067,6 +5074,7 @@ 162E831D1A9BDE8B00906325 /* SDLOnSystemRequestSpec.m in Sources */, 162E835D1A9BDE8B00906325 /* SDLReadDIDResponseSpec.m in Sources */, 162E82D41A9BDE8A00906325 /* SDLCharacterSetSpec.m in Sources */, + 8BF9DE091F2BAF0C004FFCBB /* SDLVideoStreamingCapabilitySpec.m in Sources */, 162E830F1A9BDE8B00906325 /* SDLOnAppInterfaceUnregisteredSpec.m in Sources */, 162E83971A9BDE8B00906325 /* SDLVehicleTypeSpec.m in Sources */, 1680B1131A9CD7AD00DBD79E /* SDLProtocolHeaderSpec.m in Sources */, diff --git a/SmartDeviceLink/SDLVideoStreamingCapability.h b/SmartDeviceLink/SDLVideoStreamingCapability.h index b8d6692ec..783bc91a5 100644 --- a/SmartDeviceLink/SDLVideoStreamingCapability.h +++ b/SmartDeviceLink/SDLVideoStreamingCapability.h @@ -24,6 +24,7 @@ */ - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)initWithVideoStreaming:(SDLImageResolution *)preferredResolution maxBitrate:(NSNumber *)maxBitrate suportedFormats:(NSArray<SDLVideoStreamingFormat *> *)suportedFormats; /** * @abstract The preferred resolution of a video stream for decoding and rendering on HMI, optional */ @@ -39,6 +40,6 @@ /** * @abstract Detailed information on each format supported by this system, in its preferred order, optional */ -@property (strong, nonatomic) NSMutableArray *supportedFormats; +@property (strong, nonatomic) NSMutableArray<SDLVideoStreamingFormat *> *supportedFormats; @end diff --git a/SmartDeviceLink/SDLVideoStreamingCapability.m b/SmartDeviceLink/SDLVideoStreamingCapability.m index 6531b0167..c2e720ca8 100644 --- a/SmartDeviceLink/SDLVideoStreamingCapability.m +++ b/SmartDeviceLink/SDLVideoStreamingCapability.m @@ -24,6 +24,20 @@ return self; } +- (instancetype)initWithVideoStreaming:(SDLImageResolution *)preferredResolution maxBitrate:(NSNumber *)maxBitrate suportedFormats:(NSArray<SDLVideoStreamingFormat *> *)suportedFormats { + + self = [self init]; + if (!self) { + return self; + } + + self.maxBitrate = maxBitrate; + self.preferredResolution = preferredResolution; + self.supportedFormats = [suportedFormats mutableCopy]; + + return self; +} + - (void)setPreferredResolution:(SDLImageResolution *)preferredResolution { if (preferredResolution != nil) { [store setObject:preferredResolution forKey:NAMES_preferredResolution]; @@ -45,7 +59,7 @@ } - (NSNumber *)maxBitrate { - return store[NAMES_maxBitrate]; + return [store objectForKey:NAMES_maxBitrate]; } - (void)setSupportedFormats:(NSMutableArray *)supportedFormats { diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m index e9935bedf..ba452bb7e 100644 --- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLHMICapabilitiesSpec.m @@ -16,12 +16,14 @@ describe(@"SDLHMICapabilities struct", ^{ __block SDLHMICapabilities *testStruct = nil; __block NSNumber *somePhoneCallState = @NO; __block NSNumber *someNavigationState = @YES; + __block NSNumber *someVideoStreamState = @NO; context(@"When initialized with properties", ^{ beforeEach(^{ testStruct = [[SDLHMICapabilities alloc] init]; testStruct.phoneCall = somePhoneCallState; testStruct.navigation = someNavigationState; + testStruct.videoStreaming = someVideoStreamState; }); it(@"should properly set phone call", ^{ @@ -31,13 +33,18 @@ describe(@"SDLHMICapabilities struct", ^{ it(@"should properly set navigation", ^{ expect(testStruct.navigation).to(equal(someNavigationState)); }); + + it(@"should properly set video streaming", ^{ + expect(testStruct.videoStreaming).to(equal(someVideoStreamState)); + }); }); context(@"When initialized with a dictionary", ^{ beforeEach(^{ NSDictionary *structInitDict = @{ NAMES_navigation: someNavigationState, - NAMES_phoneCall: somePhoneCallState + NAMES_phoneCall: somePhoneCallState, + NAMES_videoStreaming: someVideoStreamState }; testStruct = [[SDLHMICapabilities alloc] initWithDictionary:[structInitDict mutableCopy]]; }); @@ -49,6 +56,10 @@ describe(@"SDLHMICapabilities struct", ^{ it(@"should properly set navigation", ^{ expect(testStruct.navigation).to(equal(someNavigationState)); }); + + it(@"should properly set video streaming", ^{ + expect(testStruct.videoStreaming).to(equal(someVideoStreamState)); + }); }); context(@"When not initialized", ^{ @@ -63,6 +74,10 @@ describe(@"SDLHMICapabilities struct", ^{ it(@"navigation should be nil", ^{ expect(testStruct.navigation).to(beNil()); }); + + it(@"video streaming should be nil", ^{ + expect(testStruct.videoStreaming).to(beNil()); + }); }); }); diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSystemCapabilitySpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSystemCapabilitySpec.m index 9a2909128..f17f1dbbb 100644 --- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSystemCapabilitySpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLSystemCapabilitySpec.m @@ -5,9 +5,15 @@ #import "SDLSystemCapability.h" +#import "SDLImageResolution.h" #import "SDLNavigationCapability.h" #import "SDLPhoneCapability.h" #import "SDLSystemCapabilityType.h" +#import "SDLVideoStreamingCapability.h" +#import "SDLVideoStreamingCodec.h" +#import "SDLVideoStreamingFormat.h" +#import "SDLVideoStreamingProtocol.h" + #import "SDLNames.h" QuickSpecBegin(SDLSystemCapabilitySpec) @@ -24,6 +30,11 @@ describe(@"Getter/Setter Tests", ^ { expect(testStruct.navigationCapability.sendLocationEnabled).to(equal(YES)); expect(testStruct.navigationCapability.getWayPointsEnabled).to(equal(NO)); expect(testStruct.phoneCapability.dialNumberEnabled).to(equal(YES)); + + testStruct.systemCapabilityType = [SDLSystemCapabilityType VIDEO_STREAMING]; + + expect(testStruct.systemCapabilityType).to(equal([SDLSystemCapabilityType VIDEO_STREAMING])); + }); }); @@ -47,6 +58,7 @@ describe(@"Initialization tests", ^{ expect(testStruct.systemCapabilityType).to(beNil()); expect(testStruct.navigationCapability).to(beNil()); expect(testStruct.phoneCapability).to(beNil()); + expect(testStruct.videoStreamingCapability).to(beNil()); }); it(@"should initialize correctly with initWithPhoneCapability:", ^{ @@ -56,6 +68,7 @@ describe(@"Initialization tests", ^{ expect(testStruct.systemCapabilityType).to(equal([SDLSystemCapabilityType PHONE_CALL])); expect(testStruct.phoneCapability.dialNumberEnabled).to(equal(YES)); expect(testStruct.navigationCapability).to(beNil()); + expect(testStruct.videoStreamingCapability).to(beNil()); }); it(@"should initialize correctly with initWithNavigationCapability:", ^{ @@ -66,6 +79,35 @@ describe(@"Initialization tests", ^{ expect(testStruct.navigationCapability.sendLocationEnabled).to(equal(YES)); expect(testStruct.navigationCapability.getWayPointsEnabled).to(equal(YES)); expect(testStruct.phoneCapability).to(beNil()); + expect(testStruct.videoStreamingCapability).to(beNil()); + }); + + it(@"should initialize correctly with initWithVideoStreamingCapability:", ^{ + + SDLImageResolution* resolution = [[SDLImageResolution alloc] init]; + resolution.resolutionWidth = @600; + resolution.resolutionHeight = @500; + + NSNumber *maxBitrate = @100; + + SDLVideoStreamingFormat *format1 = [[SDLVideoStreamingFormat alloc] init]; + format1.codec = [SDLVideoStreamingCodec H264]; + format1.protocol = [SDLVideoStreamingProtocol RTP]; + + SDLVideoStreamingFormat *format2 = [[SDLVideoStreamingFormat alloc] init]; + format2.codec = [SDLVideoStreamingCodec H265]; + format2.protocol = [SDLVideoStreamingProtocol RTSP]; + + NSArray<SDLVideoStreamingFormat *> *formatArray = @[format1, format2]; + + SDLVideoStreamingCapability *testVidStruct = [[SDLVideoStreamingCapability alloc] initWithVideoStreaming:resolution maxBitrate:maxBitrate suportedFormats:formatArray]; + SDLSystemCapability *testStruct = [[SDLSystemCapability alloc] initWithVideoStreamingCapability:testVidStruct]; + + expect(testStruct.systemCapabilityType).to(equal([SDLSystemCapabilityType VIDEO_STREAMING])); + expect(testStruct.navigationCapability.sendLocationEnabled).to(beNil()); + expect(testStruct.navigationCapability.getWayPointsEnabled).to(beNil()); + expect(testStruct.phoneCapability).to(beNil()); + }); }); diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingCapabilitySpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingCapabilitySpec.m new file mode 100644 index 000000000..12e47b8a9 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingCapabilitySpec.m @@ -0,0 +1,88 @@ +// +// SDLVideoStreamingCapabilitySpec.m +// SmartDeviceLink-iOS +// +// Created by Brett McIsaac on 7/28/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLImageResolution.h" +#import "SDLVideoStreamingCapability.h" +#import "SDLVideoStreamingCodec.h" +#import "SDLVideoStreamingFormat.h" +#import "SDLVideoStreamingProtocol.h" + +QuickSpecBegin(SDLVideoStreamingCapabilitySpec) + +describe(@"Initialization tests", ^{ + it(@"Should get correctly when initialized with a dictionary", ^ { + + SDLImageResolution* resolution = [[SDLImageResolution alloc] init]; + resolution.resolutionWidth = @600; + resolution.resolutionHeight = @500; + + NSNumber *maxBitrate = @100; + + SDLVideoStreamingFormat *format1 = [[SDLVideoStreamingFormat alloc] init]; + format1.codec = [SDLVideoStreamingCodec H264]; + format1.protocol = [SDLVideoStreamingProtocol RTP]; + + SDLVideoStreamingFormat *format2 = [[SDLVideoStreamingFormat alloc] init]; + format2.codec = [SDLVideoStreamingCodec H265]; + format2.protocol = [SDLVideoStreamingProtocol RTSP]; + + NSArray<SDLVideoStreamingFormat *> *formatArray = @[format1, format2]; + + NSMutableDictionary* dict = [@{NAMES_preferredResolution: resolution, + NAMES_maxBitrate: maxBitrate, + NAMES_supportedFormats: formatArray} mutableCopy]; + + SDLVideoStreamingCapability* testStruct = [[SDLVideoStreamingCapability alloc] initWithDictionary:dict]; + + expect(testStruct.preferredResolution).to(equal(resolution)); + expect(testStruct.maxBitrate).to(equal(maxBitrate)); + expect(testStruct.supportedFormats).to(equal(formatArray)); + }); + + it(@"Should return nil if not set", ^ { + SDLVideoStreamingCapability* testStruct = [[SDLVideoStreamingCapability alloc] init]; + + expect(testStruct.preferredResolution).to(beNil()); + expect(testStruct.maxBitrate).to(beNil()); + expect(testStruct.supportedFormats).to(beNil()); + }); + + it(@"Should initialize correctly with initWithVideoStreaming:(SDLImageResolution *)preferredResolution (NSNumber *)maxBitrate (NSArray<SDLVideoStreamingFormat *> *)suportedFormats", ^ { + + SDLImageResolution* resolution = [[SDLImageResolution alloc] init]; + resolution.resolutionWidth = @600; + resolution.resolutionHeight = @500; + + NSNumber *maxBitrate = @100; + + SDLVideoStreamingFormat *format1 = [[SDLVideoStreamingFormat alloc] init]; + format1.codec = [SDLVideoStreamingCodec H264]; + format1.protocol = [SDLVideoStreamingProtocol RTP]; + + SDLVideoStreamingFormat *format2 = [[SDLVideoStreamingFormat alloc] init]; + format2.codec = [SDLVideoStreamingCodec H265]; + format2.protocol = [SDLVideoStreamingProtocol RTSP]; + + NSArray<SDLVideoStreamingFormat *> *formatArray = @[format1, format2]; + + SDLVideoStreamingCapability *testStruct = [[SDLVideoStreamingCapability alloc] initWithVideoStreaming:resolution maxBitrate:maxBitrate suportedFormats:formatArray]; + + expect(testStruct.preferredResolution).to(equal(resolution)); + expect(testStruct.maxBitrate).to(equal(maxBitrate)); + expect(testStruct.supportedFormats).to(equal(formatArray)); + }); + +}); + +QuickSpecEnd diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingFormatSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingFormatSpec.m new file mode 100644 index 000000000..b1f0a4e16 --- /dev/null +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingFormatSpec.m @@ -0,0 +1,39 @@ +// +// SDLVideoStreamingFormatSpec.m +// SmartDeviceLink-iOS +// +// Created by Brett McIsaac on 7/28/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#import <Quick/Quick.h> +#import <Nimble/Nimble.h> + +#import "SDLNames.h" +#import "SDLVideoStreamingCodec.h" +#import "SDLVideoStreamingFormat.h" +#import "SDLVideoStreamingProtocol.h" + +QuickSpecBegin(SDLVideoStreamingFormatSpec) + +describe(@"Initialization tests", ^{ + it(@"Should get correctly when initialized with a dictionary", ^ { + NSMutableDictionary* dict = [@{NAMES_videoProtocol: [SDLVideoStreamingProtocol RAW], + NAMES_videoCodec: [SDLVideoStreamingCodec H264]} mutableCopy]; + SDLVideoStreamingFormat* testStruct = [[SDLVideoStreamingFormat alloc] initWithDictionary:dict]; + + expect(testStruct.protocol).to(equal([SDLVideoStreamingProtocol RAW])); + expect(testStruct.codec).to(equal([SDLVideoStreamingCodec H264])); + }); + + it(@"Should return nil if not set", ^ { + SDLVideoStreamingFormat* testStruct = [[SDLVideoStreamingFormat alloc] init]; + + expect(testStruct.protocol).to(beNil()); + expect(testStruct.codec).to(beNil()); + }); +}); + +QuickSpecEnd |