• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <radio_hidl_hal_utils_v1_0.h>
18 
19 /*
20  * Test IRadio.getCurrentCalls() for the response returned.
21  */
TEST_F(RadioHidlTest,getCurrentCalls)22 TEST_F(RadioHidlTest, getCurrentCalls) {
23     serial = GetRandomSerialNumber();
24 
25     radio->getCurrentCalls(serial);
26     EXPECT_EQ(std::cv_status::no_timeout, wait());
27     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
28     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
29 
30     if (cardStatus.cardState == CardState::ABSENT) {
31         EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
32     }
33 }
34 
35 /*
36  * Test IRadio.dial() for the response returned.
37  */
TEST_F(RadioHidlTest,dial)38 TEST_F(RadioHidlTest, dial) {
39     serial = GetRandomSerialNumber();
40 
41     Dial dialInfo;
42     memset(&dialInfo, 0, sizeof(dialInfo));
43     dialInfo.address = hidl_string("123456789");
44 
45     radio->dial(serial, dialInfo);
46     EXPECT_EQ(std::cv_status::no_timeout, wait());
47     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
48     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
49 
50     if (cardStatus.cardState == CardState::ABSENT) {
51         ASSERT_TRUE(CheckAnyOfErrors(
52             radioRsp->rspInfo.error,
53             {RadioError::CANCELLED, RadioError::DEVICE_IN_USE, RadioError::FDN_CHECK_FAILURE,
54              RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID,
55              RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE, RadioError::MODEM_ERR,
56              RadioError::NO_NETWORK_FOUND, RadioError::NO_SUBSCRIPTION,
57              RadioError::OPERATION_NOT_ALLOWED},
58             CHECK_GENERAL_ERROR));
59     }
60 }
61 
62 /*
63  * Test IRadio.hangup() for the response returned.
64  */
TEST_F(RadioHidlTest,hangup)65 TEST_F(RadioHidlTest, hangup) {
66     serial = GetRandomSerialNumber();
67 
68     radio->hangup(serial, 1);
69     EXPECT_EQ(std::cv_status::no_timeout, wait());
70     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
71     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
72 
73     if (cardStatus.cardState == CardState::ABSENT) {
74         ASSERT_TRUE(CheckAnyOfErrors(
75             radioRsp->rspInfo.error,
76             {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
77             CHECK_GENERAL_ERROR));
78     }
79 }
80 
81 /*
82  * Test IRadio.hangupWaitingOrBackground() for the response returned.
83  */
TEST_F(RadioHidlTest,hangupWaitingOrBackground)84 TEST_F(RadioHidlTest, hangupWaitingOrBackground) {
85     serial = GetRandomSerialNumber();
86 
87     radio->hangupWaitingOrBackground(serial);
88     EXPECT_EQ(std::cv_status::no_timeout, wait());
89     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
90     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
91 
92     if (cardStatus.cardState == CardState::ABSENT) {
93         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
94                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
95                                      CHECK_GENERAL_ERROR));
96     }
97 }
98 
99 /*
100  * Test IRadio.hangupForegroundResumeBackground() for the response returned.
101  */
TEST_F(RadioHidlTest,hangupForegroundResumeBackground)102 TEST_F(RadioHidlTest, hangupForegroundResumeBackground) {
103     serial = GetRandomSerialNumber();
104 
105     radio->hangupForegroundResumeBackground(serial);
106     EXPECT_EQ(std::cv_status::no_timeout, wait());
107     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
108     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
109 
110     if (cardStatus.cardState == CardState::ABSENT) {
111         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
112                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
113                                      CHECK_GENERAL_ERROR));
114     }
115 }
116 
117 /*
118  * Test IRadio.switchWaitingOrHoldingAndActive() for the response returned.
119  */
TEST_F(RadioHidlTest,switchWaitingOrHoldingAndActive)120 TEST_F(RadioHidlTest, switchWaitingOrHoldingAndActive) {
121     serial = GetRandomSerialNumber();
122 
123     radio->switchWaitingOrHoldingAndActive(serial);
124     EXPECT_EQ(std::cv_status::no_timeout, wait());
125     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
126     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
127 
128     if (cardStatus.cardState == CardState::ABSENT) {
129         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
130                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
131                                      CHECK_GENERAL_ERROR));
132     }
133 }
134 
135 /*
136  * Test IRadio.conference() for the response returned.
137  */
TEST_F(RadioHidlTest,conference)138 TEST_F(RadioHidlTest, conference) {
139     serial = GetRandomSerialNumber();
140 
141     radio->conference(serial);
142     EXPECT_EQ(std::cv_status::no_timeout, wait());
143     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
144     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
145 
146     if (cardStatus.cardState == CardState::ABSENT) {
147         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
148                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
149                                      CHECK_GENERAL_ERROR));
150     }
151 }
152 
153 /*
154  * Test IRadio.rejectCall() for the response returned.
155  */
TEST_F(RadioHidlTest,rejectCall)156 TEST_F(RadioHidlTest, rejectCall) {
157     serial = GetRandomSerialNumber();
158 
159     radio->rejectCall(serial);
160     EXPECT_EQ(std::cv_status::no_timeout, wait());
161     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
162     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
163 
164     if (cardStatus.cardState == CardState::ABSENT) {
165         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
166                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
167                                      CHECK_GENERAL_ERROR));
168     }
169 }
170 
171 /*
172  * Test IRadio.getLastCallFailCause() for the response returned.
173  */
TEST_F(RadioHidlTest,getLastCallFailCause)174 TEST_F(RadioHidlTest, getLastCallFailCause) {
175     serial = GetRandomSerialNumber();
176 
177     radio->getLastCallFailCause(serial);
178     EXPECT_EQ(std::cv_status::no_timeout, wait());
179     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
180     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
181 
182     if (cardStatus.cardState == CardState::ABSENT) {
183         ASSERT_TRUE(
184             CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::NONE}, CHECK_GENERAL_ERROR));
185     }
186 }
187 
188 /*
189  * Test IRadio.sendUssd() for the response returned.
190  */
TEST_F(RadioHidlTest,sendUssd)191 TEST_F(RadioHidlTest, sendUssd) {
192     serial = GetRandomSerialNumber();
193     radio->sendUssd(serial, hidl_string("test"));
194     EXPECT_EQ(std::cv_status::no_timeout, wait());
195     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
196     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
197 
198     if (cardStatus.cardState == CardState::ABSENT) {
199         ASSERT_TRUE(CheckAnyOfErrors(
200             radioRsp->rspInfo.error,
201             {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
202             CHECK_GENERAL_ERROR));
203     }
204 }
205 
206 /*
207  * Test IRadio.cancelPendingUssd() for the response returned.
208  */
TEST_F(RadioHidlTest,cancelPendingUssd)209 TEST_F(RadioHidlTest, cancelPendingUssd) {
210     serial = GetRandomSerialNumber();
211 
212     radio->cancelPendingUssd(serial);
213     EXPECT_EQ(std::cv_status::no_timeout, wait());
214     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
215     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
216 
217     if (cardStatus.cardState == CardState::ABSENT) {
218         ASSERT_TRUE(
219             CheckAnyOfErrors(radioRsp->rspInfo.error,
220                              {RadioError::NONE, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
221                              CHECK_GENERAL_ERROR));
222     }
223 }
224 
225 /*
226  * Test IRadio.getCallForwardStatus() for the response returned.
227  */
TEST_F(RadioHidlTest,getCallForwardStatus)228 TEST_F(RadioHidlTest, getCallForwardStatus) {
229     serial = GetRandomSerialNumber();
230     CallForwardInfo callInfo;
231     memset(&callInfo, 0, sizeof(callInfo));
232     callInfo.number = hidl_string();
233 
234     radio->getCallForwardStatus(serial, callInfo);
235     EXPECT_EQ(std::cv_status::no_timeout, wait());
236     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
237     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
238 
239     if (cardStatus.cardState == CardState::ABSENT) {
240         ASSERT_TRUE(CheckAnyOfErrors(
241             radioRsp->rspInfo.error,
242             {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
243             CHECK_GENERAL_ERROR));
244     }
245 }
246 
247 /*
248  * Test IRadio.setCallForward() for the response returned.
249  */
TEST_F(RadioHidlTest,setCallForward)250 TEST_F(RadioHidlTest, setCallForward) {
251     serial = GetRandomSerialNumber();
252     CallForwardInfo callInfo;
253     memset(&callInfo, 0, sizeof(callInfo));
254     callInfo.number = hidl_string();
255 
256     radio->setCallForward(serial, callInfo);
257     EXPECT_EQ(std::cv_status::no_timeout, wait());
258     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
259     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
260 
261     if (cardStatus.cardState == CardState::ABSENT) {
262         ASSERT_TRUE(CheckAnyOfErrors(
263             radioRsp->rspInfo.error,
264             {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
265             CHECK_GENERAL_ERROR));
266     }
267 }
268 
269 /*
270  * Test IRadio.getCallWaiting() for the response returned.
271  */
TEST_F(RadioHidlTest,getCallWaiting)272 TEST_F(RadioHidlTest, getCallWaiting) {
273     serial = GetRandomSerialNumber();
274 
275     radio->getCallWaiting(serial, 1);
276     EXPECT_EQ(std::cv_status::no_timeout, wait());
277     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
278     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
279 
280     if (cardStatus.cardState == CardState::ABSENT) {
281         ASSERT_TRUE(CheckAnyOfErrors(
282             radioRsp->rspInfo.error,
283             {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR},
284             CHECK_GENERAL_ERROR));
285     }
286 }
287 
288 /*
289  * Test IRadio.setCallWaiting() for the response returned.
290  */
TEST_F(RadioHidlTest,setCallWaiting)291 TEST_F(RadioHidlTest, setCallWaiting) {
292     serial = GetRandomSerialNumber();
293 
294     radio->setCallWaiting(serial, true, 1);
295     EXPECT_EQ(std::cv_status::no_timeout, wait());
296     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
297     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
298 
299     if (cardStatus.cardState == CardState::ABSENT) {
300         ASSERT_TRUE(CheckAnyOfErrors(
301             radioRsp->rspInfo.error,
302             {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
303             CHECK_GENERAL_ERROR));
304     }
305 }
306 
307 /*
308  * Test IRadio.acceptCall() for the response returned.
309  */
TEST_F(RadioHidlTest,acceptCall)310 TEST_F(RadioHidlTest, acceptCall) {
311     serial = GetRandomSerialNumber();
312 
313     radio->acceptCall(serial);
314     EXPECT_EQ(std::cv_status::no_timeout, wait());
315     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
316     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
317 
318     if (cardStatus.cardState == CardState::ABSENT) {
319         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
320                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
321                                      CHECK_GENERAL_ERROR));
322     }
323 }
324 
325 /*
326  * Test IRadio.separateConnection() for the response returned.
327  */
TEST_F(RadioHidlTest,separateConnection)328 TEST_F(RadioHidlTest, separateConnection) {
329     serial = GetRandomSerialNumber();
330 
331     radio->separateConnection(serial, 1);
332     EXPECT_EQ(std::cv_status::no_timeout, wait());
333     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
334     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
335 
336     if (cardStatus.cardState == CardState::ABSENT) {
337         ASSERT_TRUE(CheckAnyOfErrors(
338             radioRsp->rspInfo.error,
339             {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
340             CHECK_GENERAL_ERROR));
341     }
342 }
343 
344 /*
345  * Test IRadio.explicitCallTransfer() for the response returned.
346  */
TEST_F(RadioHidlTest,explicitCallTransfer)347 TEST_F(RadioHidlTest, explicitCallTransfer) {
348     serial = GetRandomSerialNumber();
349 
350     radio->explicitCallTransfer(serial);
351     EXPECT_EQ(std::cv_status::no_timeout, wait());
352     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
353     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
354 
355     if (cardStatus.cardState == CardState::ABSENT) {
356         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
357                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
358                                      CHECK_GENERAL_ERROR));
359     }
360 }
361 
362 /*
363  * Test IRadio.sendCDMAFeatureCode() for the response returned.
364  */
TEST_F(RadioHidlTest,sendCDMAFeatureCode)365 TEST_F(RadioHidlTest, sendCDMAFeatureCode) {
366     serial = GetRandomSerialNumber();
367 
368     radio->sendCDMAFeatureCode(serial, hidl_string());
369     EXPECT_EQ(std::cv_status::no_timeout, wait());
370     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
371     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
372 
373     if (cardStatus.cardState == CardState::ABSENT) {
374         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
375                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
376                                       RadioError::INVALID_CALL_ID, RadioError::INVALID_MODEM_STATE,
377                                       RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED},
378                                      CHECK_GENERAL_ERROR));
379     }
380 }
381 
382 /*
383  * Test IRadio.sendDtmf() for the response returned.
384  */
TEST_F(RadioHidlTest,sendDtmf)385 TEST_F(RadioHidlTest, sendDtmf) {
386     serial = GetRandomSerialNumber();
387 
388     radio->sendDtmf(serial, "1");
389     EXPECT_EQ(std::cv_status::no_timeout, wait());
390     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
391     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
392 
393     if (cardStatus.cardState == CardState::ABSENT) {
394         ASSERT_TRUE(CheckAnyOfErrors(
395             radioRsp->rspInfo.error,
396             {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID,
397              RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR},
398             CHECK_GENERAL_ERROR));
399     }
400 }
401 
402 /*
403  * Test IRadio.startDtmf() for the response returned.
404  */
TEST_F(RadioHidlTest,startDtmf)405 TEST_F(RadioHidlTest, startDtmf) {
406     serial = GetRandomSerialNumber();
407 
408     radio->startDtmf(serial, "1");
409     EXPECT_EQ(std::cv_status::no_timeout, wait());
410     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
411     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
412 
413     if (cardStatus.cardState == CardState::ABSENT) {
414         ASSERT_TRUE(CheckAnyOfErrors(
415             radioRsp->rspInfo.error,
416             {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID,
417              RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR},
418             CHECK_GENERAL_ERROR));
419     }
420 }
421 
422 /*
423  * Test IRadio.stopDtmf() for the response returned.
424  */
TEST_F(RadioHidlTest,stopDtmf)425 TEST_F(RadioHidlTest, stopDtmf) {
426     serial = GetRandomSerialNumber();
427 
428     radio->stopDtmf(serial);
429     EXPECT_EQ(std::cv_status::no_timeout, wait());
430     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
431     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
432 
433     if (cardStatus.cardState == CardState::ABSENT) {
434         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
435                                      {RadioError::NONE, RadioError::INVALID_CALL_ID,
436                                       RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR},
437                                      CHECK_GENERAL_ERROR));
438     }
439 }
440 
441 /*
442  * Test IRadio.setMute() for the response returned.
443  */
TEST_F(RadioHidlTest,setMute)444 TEST_F(RadioHidlTest, setMute) {
445     serial = GetRandomSerialNumber();
446 
447     radio->setMute(serial, true);
448     EXPECT_EQ(std::cv_status::no_timeout, wait());
449     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
450     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
451 
452     if (cardStatus.cardState == CardState::ABSENT) {
453         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
454                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS},
455                                      CHECK_GENERAL_ERROR));
456     }
457 }
458 
459 /*
460  * Test IRadio.getMute() for the response returned.
461  */
TEST_F(RadioHidlTest,getMute)462 TEST_F(RadioHidlTest, getMute) {
463     serial = GetRandomSerialNumber();
464 
465     radio->getMute(serial);
466     EXPECT_EQ(std::cv_status::no_timeout, wait());
467     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
468     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
469 
470     if (cardStatus.cardState == CardState::ABSENT) {
471         EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
472     }
473 }
474 
475 /*
476  * Test IRadio.sendBurstDtmf() for the response returned.
477  */
TEST_F(RadioHidlTest,sendBurstDtmf)478 TEST_F(RadioHidlTest, sendBurstDtmf) {
479     serial = GetRandomSerialNumber();
480 
481     radio->sendBurstDtmf(serial, "1", 0, 0);
482     EXPECT_EQ(std::cv_status::no_timeout, wait());
483     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
484     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
485 
486     if (cardStatus.cardState == CardState::ABSENT) {
487         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
488                                      {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE,
489                                       RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED},
490                                      CHECK_GENERAL_ERROR));
491     }
492 }
493