/
SDLRadioControlDataSpec.m
198 lines (165 loc) 路 9.27 KB
/
SDLRadioControlDataSpec.m
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//
// 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());
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
expect(testStruct.availableHDs).to(beNil());
#pragma clang diagnostic pop
expect(testStruct.availableHDChannels).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,
SDLRPCParameterNameAvailableHDChannels : @2,
SDLRPCParameterNameHDChannel : @2,
SDLRPCParameterNameSignalStrength : @54,
SDLRPCParameterNameSignalChangeThreshold : @76,
SDLRPCParameterNameRadioEnable : @YES,
SDLRPCParameterNameState : SDLRadioStateNotFound,
SDLRPCParameterNameHDRadioEnable : @NO
} mutableCopy];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initWithDictionary:dict];
#pragma clang diagnostic pop
expect(testStruct.frequencyInteger).to(equal(@101));
expect(testStruct.frequencyFraction).to(equal(@7));
expect(testStruct.band).to(equal(SDLRadioBandAM));
expect(testStruct.rdsData).to(equal(someRdsData));
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
expect(testStruct.availableHDs).to(equal(@2));
#pragma clang diagnostic pop
expect(testStruct.availableHDChannels).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.availableHDChannels = @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.availableHDChannels).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));
});
it(@"Should get correctly when initialized FM radio control capabilities parameters", ^ {
SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initFMWithFrequencyInteger:@101 frequencyFraction:@7];
expect(testStruct.frequencyInteger).to(equal(@101));
expect(testStruct.frequencyFraction).to(equal(@7));
expect(testStruct.band).to(equal(SDLRadioBandFM));
});
it(@"Should get correctly when initialized FM radio control capabilities parameters", ^ {
SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initFMWithHdChannel:@5];
expect(testStruct.hdChannel).to(equal(@5));
expect(testStruct.band).to(equal(SDLRadioBandFM));
});
it(@"Should get correctly when initialized AM radio control capabilities parameters", ^ {
SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initAMWithFrequencyInteger:@101];
expect(testStruct.frequencyInteger).to(equal(@101));
expect(testStruct.band).to(equal(SDLRadioBandAM));
});
it(@"Should get correctly when initialized AM radio control capabilities parameters", ^ {
SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initAMWithHdChannel:@5];
expect(testStruct.hdChannel).to(equal(@5));
expect(testStruct.band).to(equal(SDLRadioBandAM));
});
it(@"Should get correctly when initialized XM radio control capabilities parameters", ^ {
SDLRadioControlData* testStruct = [[SDLRadioControlData alloc] initXMWithFrequencyInteger:@101];
expect(testStruct.frequencyInteger).to(equal(@101));
expect(testStruct.band).to(equal(SDLRadioBandXM));
});
});
QuickSpecEnd