blob: ce42ce9d289678f0110a915d587edf68eb82005a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
//
// 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;
NSNumber *hapticDataSupported = @NO;
SDLVideoStreamingFormat *format1 = [[SDLVideoStreamingFormat alloc] init];
format1.codec = SDLVideoStreamingCodecH264;
format1.protocol = SDLVideoStreamingProtocolRTP;
SDLVideoStreamingFormat *format2 = [[SDLVideoStreamingFormat alloc] init];
format2.codec = SDLVideoStreamingCodecH265;
format2.protocol = SDLVideoStreamingProtocolRTSP;
NSArray<SDLVideoStreamingFormat *> *formatArray = @[format1, format2];
NSMutableDictionary* dict = [@{SDLNamePreferredResolution: resolution,
SDLNameMaxBitrate: maxBitrate,
SDLNameSupportedFormats: formatArray,
SDLNameHapticSpatialDataSupported: hapticDataSupported} 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));
expect(testStruct.hapticSpatialDataSupported).to(equal(hapticDataSupported));
});
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:maxBitrate:suportedFormats", ^ {
SDLImageResolution* resolution = [[SDLImageResolution alloc] init];
resolution.resolutionWidth = @600;
resolution.resolutionHeight = @500;
int32_t maxBitrate = 100;
NSNumber *hapticDataSupported = @YES;
SDLVideoStreamingFormat *format1 = [[SDLVideoStreamingFormat alloc] init];
format1.codec = SDLVideoStreamingCodecH264;
format1.protocol = SDLVideoStreamingProtocolRTP;
SDLVideoStreamingFormat *format2 = [[SDLVideoStreamingFormat alloc] init];
format2.codec = SDLVideoStreamingCodecH265;
format2.protocol = SDLVideoStreamingProtocolRTSP;
NSArray<SDLVideoStreamingFormat *> *formatArray = @[format1, format2];
SDLVideoStreamingCapability *testStruct = [[SDLVideoStreamingCapability alloc] initWithPreferredResolution:resolution maxBitrate:maxBitrate supportedFormats:formatArray hapticDataSupported:hapticDataSupported];
expect(testStruct.preferredResolution).to(equal(resolution));
expect(testStruct.maxBitrate).to(equal(maxBitrate));
expect(testStruct.supportedFormats).to(equal(formatArray));
expect(testStruct.hapticSpatialDataSupported).to(equal(hapticDataSupported));
});
});
QuickSpecEnd
|