summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLDisplayCapabilitiesSpec.m
blob: 367028e0cc3f09c6b086a69c2fc00888e4c071b8 (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
92
93
94
95
//
//  SDLDisplayCapabilitiesSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLDisplayCapabilities.h"
#import "SDLDisplayType.h"
#import "SDLImageField.h"
#import "SDLMediaClockFormat.h"
#import "SDLRPCParameterNames.h"
#import "SDLScreenParams.h"
#import "SDLTextField.h"


QuickSpecBegin(SDLDisplayCapabilitiesSpec)

SDLScreenParams* screenParams = [[SDLScreenParams alloc] init];
SDLTextField* textField = [[SDLTextField alloc] init];
SDLImageField* imageField = [[SDLImageField alloc] init];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

describe(@"Getter/Setter Tests", ^ {
    it(@"Should set and get correctly", ^ {
        SDLDisplayCapabilities* testStruct = [[SDLDisplayCapabilities alloc] init];
        
        testStruct.displayType = SDLDisplayTypeGen26DMA;
        testStruct.displayName = @"test";
        testStruct.textFields = [@[textField] mutableCopy];
        testStruct.imageFields = [@[imageField] mutableCopy];
        testStruct.mediaClockFormats = [@[SDLMediaClockFormatClockText1, SDLMediaClockFormatClock3, SDLMediaClockFormatClockText3] copy];
        testStruct.graphicSupported = @YES;
        testStruct.templatesAvailable = [@[@"String", @"String", @"String"] mutableCopy];
        testStruct.screenParams = screenParams;
        testStruct.numCustomPresetsAvailable = @43;

        expect(testStruct.displayType).to(equal(SDLDisplayTypeGen26DMA));
        expect(testStruct.displayName).to(equal(@"test"));
        expect(testStruct.textFields).to(equal([@[textField] mutableCopy]));
        expect(testStruct.imageFields).to(equal([@[imageField] mutableCopy]));
        expect(testStruct.mediaClockFormats).to(equal([@[SDLMediaClockFormatClockText1, SDLMediaClockFormatClock3, SDLMediaClockFormatClockText3] copy]));
        expect(testStruct.graphicSupported).to(equal(@YES));
        expect(testStruct.templatesAvailable).to(equal([@[@"String", @"String", @"String"] mutableCopy]));
        expect(testStruct.screenParams).to(equal(screenParams));
        expect(testStruct.numCustomPresetsAvailable).to(equal(@43));
    });
    
    it(@"Should get correctly when initialized", ^ {
        NSMutableDictionary* dict = [@{SDLRPCParameterNameDisplayType:SDLDisplayTypeGen26DMA,
                                       SDLRPCParameterNameDisplayName: @"test",
                                       SDLRPCParameterNameTextFields:[@[textField] mutableCopy],
                                       SDLRPCParameterNameImageFields:[@[imageField] mutableCopy],
                                       SDLRPCParameterNameMediaClockFormats:[@[SDLMediaClockFormatClockText1, SDLMediaClockFormatClock3, SDLMediaClockFormatClockText3] copy],
                                       SDLRPCParameterNameGraphicSupported:@YES,
                                       SDLRPCParameterNameTemplatesAvailable:[@[@"String", @"String", @"String"] mutableCopy],
                                       SDLRPCParameterNameScreenParams:screenParams,
                                       SDLRPCParameterNameNumberCustomPresetsAvailable:@43,
                                      } mutableCopy];
        SDLDisplayCapabilities* testStruct = [[SDLDisplayCapabilities alloc] initWithDictionary:dict];
        
        expect(testStruct.displayType).to(equal(SDLDisplayTypeGen26DMA));
        expect(testStruct.displayName).to(equal(@"test"));
        expect(testStruct.textFields).to(equal([@[textField] mutableCopy]));
        expect(testStruct.imageFields).to(equal([@[imageField] mutableCopy]));
        expect(testStruct.mediaClockFormats).to(equal([@[SDLMediaClockFormatClockText1, SDLMediaClockFormatClock3, SDLMediaClockFormatClockText3] copy]));
        expect(testStruct.graphicSupported).to(equal(@YES));
        expect(testStruct.templatesAvailable).to(equal([@[@"String", @"String", @"String"] mutableCopy]));
        expect(testStruct.screenParams).to(equal(screenParams));
        expect(testStruct.numCustomPresetsAvailable).to(equal(@43));
    });
    
    it(@"Should return nil if not set", ^ {
        SDLDisplayCapabilities* testStruct = [[SDLDisplayCapabilities alloc] init];
        
        expect(testStruct.displayType).to(beNil());
        expect(testStruct.displayName).to(beNil());
        expect(testStruct.textFields).to(beNil());
        expect(testStruct.imageFields).to(beNil());
        expect(testStruct.mediaClockFormats).to(beNil());
        expect(testStruct.graphicSupported).to(beNil());
        expect(testStruct.templatesAvailable).to(beNil());
        expect(testStruct.screenParams).to(beNil());
        expect(testStruct.numCustomPresetsAvailable).to(beNil());
    });
});

#pragma clang diagnostic pop

QuickSpecEnd