summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLRadioControlDataSpec.m
blob: 58d9f8f9297dc96a56357707e35b115eca5d8f37 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
//  SDLRadioControlDataSpec.m
//  SmartDeviceLink-iOS
//

#import <Foundation/Foundation.h>

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

#import "SDLRadioControlData.h"
#import "SDLRadioBand.h"
#import "SDLRadioState.h"
#import "SDLRDSData.h"
#import "SDLSISData.h"
#import "SDLRPCParameterNames.h"

QuickSpecBegin(SDLRadioControlDataSpec)
__block SDLRDSData* someRdsData = [[SDLRDSData alloc] init];

describe(@"Initialization tests", ^{
    
    it(@"should properly initialize init", ^{
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] init];

        expect(testStruct.frequencyInteger).to(beNil());
        expect(testStruct.frequencyFraction).to(beNil());
        expect(testStruct.band).to(beNil());
        expect(testStruct.rdsData).to(beNil());
        expect(testStruct.availableHDs).to(beNil());
        expect(testStruct.hdChannel).to(beNil());
        expect(testStruct.signalStrength).to(beNil());
        expect(testStruct.signalChangeThreshold).to(beNil());
        expect(testStruct.radioEnable).to(beNil());
        expect(testStruct.state).to(beNil());
        expect(testStruct.hdRadioEnable).to(beNil());
    });
    
    it(@"should properly initialize initWithDictionary", ^{
        NSMutableDictionary* dict = [@{SDLRPCParameterNameFrequencyInteger : @101,
                                       SDLRPCParameterNameFrequencyFraction : @7,
                                       SDLRPCParameterNameBand : SDLRadioBandAM,
                                       SDLRPCParameterNameRDSData : someRdsData,
                                       SDLRPCParameterNameAvailableHDs : @2,
                                       SDLRPCParameterNameHDChannel : @2,
                                       SDLRPCParameterNameSignalStrength : @54,
                                       SDLRPCParameterNameSignalChangeThreshold : @76,
                                       SDLRPCParameterNameRadioEnable : @YES,
                                       SDLRPCParameterNameState : SDLRadioStateNotFound,
                                       SDLRPCParameterNameHDRadioEnable : @NO
                                       } mutableCopy];
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initWithDictionary:dict];
        
        expect(testStruct.frequencyInteger).to(equal(@101));
        expect(testStruct.frequencyFraction).to(equal(@7));
        expect(testStruct.band).to(equal(SDLRadioBandAM));
        expect(testStruct.rdsData).to(equal(someRdsData));
        expect(testStruct.availableHDs).to(equal(@2));
        expect(testStruct.hdChannel).to(equal(@2));
        expect(testStruct.signalStrength).to(equal(@54));
        expect(testStruct.signalChangeThreshold).to(equal(@76));
        expect(testStruct.radioEnable).to(equal(@YES));
        expect(testStruct.state).to(equal(SDLRadioStateNotFound));
        expect(testStruct.hdRadioEnable).to(equal(@NO));
    });

    it(@"Should set and get correctly", ^{
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] init];
        testStruct.frequencyInteger = @101;
        testStruct.frequencyFraction = @7;
        testStruct.band = SDLRadioBandAM;
        testStruct.rdsData = someRdsData;
        testStruct.availableHDs = @2;
        testStruct.hdChannel = @2;
        testStruct.signalStrength = @54;
        testStruct.signalChangeThreshold = @76;
        testStruct.radioEnable = @YES;
        testStruct.state = SDLRadioStateNotFound;
        testStruct.hdRadioEnable = @YES;

        expect(testStruct.frequencyInteger).to(equal(@101));
        expect(testStruct.frequencyFraction).to(equal(@7));
        expect(testStruct.band).to(equal(SDLRadioBandAM));
        expect(testStruct.rdsData).to(equal(someRdsData));
        expect(testStruct.availableHDs).to(equal(@2));
        expect(testStruct.hdChannel).to(equal(@2));
        expect(testStruct.signalStrength).to(equal(@54));
        expect(testStruct.signalChangeThreshold).to(equal(@76));
        expect(testStruct.radioEnable).to(equal(@YES));
        expect(testStruct.state).to(equal(SDLRadioStateNotFound));
        expect(testStruct.hdRadioEnable).to(equal(@YES));
    });

    it(@"Should get correctly when initialized with Module Name and other radio control capabilities parameters", ^ {
        #pragma clang diagnostic push
        #pragma clang diagnostic ignored "-Wdeprecated-declarations"
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initWithFrequencyInteger:@101 frequencyFraction:@7 band:SDLRadioBandAM hdChannel:@2 radioEnable:@YES];

        expect(testStruct.frequencyInteger).to(equal(@101));
        expect(testStruct.frequencyFraction).to(equal(@7));
        expect(testStruct.band).to(equal(SDLRadioBandAM));
        expect(testStruct.hdChannel).to(equal(@2));
        expect(testStruct.radioEnable).to(equal(@YES));
        #pragma clang diagnostic pop
    });
    
    it(@"Should get correctly when initialized with Module Name and other radio control capabilities parameters", ^ {
        #pragma clang diagnostic push
        #pragma clang diagnostic ignored "-Wdeprecated-declarations"
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initWithFrequencyInteger:@101 frequencyFraction:@7 band:SDLRadioBandAM hdChannel:@2 radioEnable:@YES];
        
        expect(testStruct.frequencyInteger).to(equal(@101));
        expect(testStruct.frequencyFraction).to(equal(@7));
        expect(testStruct.band).to(equal(SDLRadioBandAM));
        expect(testStruct.hdChannel).to(equal(@2));
        expect(testStruct.radioEnable).to(equal(@YES));
        #pragma clang diagnostic pop
    });
    
    it(@"Should get correctly when initialized with Module Name and other radio control capabilities parameters", ^ {
        #pragma clang diagnostic push
        #pragma clang diagnostic ignored "-Wdeprecated-declarations"
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initWithFrequencyInteger:@101 frequencyFraction:@7 band:SDLRadioBandAM hdChannel:@2 radioEnable:@YES];
        
        expect(testStruct.frequencyInteger).to(equal(@101));
        expect(testStruct.frequencyFraction).to(equal(@7));
        expect(testStruct.band).to(equal(SDLRadioBandAM));
        expect(testStruct.hdChannel).to(equal(@2));
        expect(testStruct.radioEnable).to(equal(@YES));
        expect(testStruct.sisData).to(beNil());
        #pragma clang diagnostic pop
    });
    
    it(@"Should get correctly when initialized with Module Name and other radio control capabilities parameters", ^ {
        SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initWithFrequencyInteger:@101 frequencyFraction:@7 band:SDLRadioBandAM hdChannel:@2 radioEnable:@YES hdRadioEnable:@YES];
        
        expect(testStruct.frequencyInteger).to(equal(@101));
        expect(testStruct.frequencyFraction).to(equal(@7));
        expect(testStruct.band).to(equal(SDLRadioBandAM));
        expect(testStruct.hdChannel).to(equal(@2));
        expect(testStruct.radioEnable).to(equal(@YES));
        expect(testStruct.hdRadioEnable).to(equal(@YES));
    });

});

QuickSpecEnd