summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m
blob: cc7db881c4c863bc51ff54776f276d13b8e87592 (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

#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 = SDLVideoStreamingCodecH264;
            testProtocol = SDLVideoStreamingProtocolRAW;

            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 = SDLVideoStreamingCodecVP8;
        testProtocol = SDLVideoStreamingProtocolRTSP;

        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