• 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 using namespace ::android::hardware::radio::V1_0;
20 
21 /*
22  * Test IRadio.sendEnvelope() for the response returned.
23  */
TEST_F(RadioHidlTest,sendEnvelope)24 TEST_F(RadioHidlTest, sendEnvelope) {
25     serial = GetRandomSerialNumber();
26 
27     // Test with sending empty string
28     std::string content = "";
29 
30     radio->sendEnvelope(serial, content);
31 
32     EXPECT_EQ(std::cv_status::no_timeout, wait());
33     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
34     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
35 
36     if (cardStatus.cardState == CardState::ABSENT) {
37         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
38                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
39                                       RadioError::MODEM_ERR, RadioError::SIM_ABSENT},
40                                      CHECK_GENERAL_ERROR));
41     }
42 }
43 
44 /*
45  * Test IRadio.sendTerminalResponseToSim() for the response returned.
46  */
TEST_F(RadioHidlTest,sendTerminalResponseToSim)47 TEST_F(RadioHidlTest, sendTerminalResponseToSim) {
48     serial = GetRandomSerialNumber();
49 
50     // Test with sending empty string
51     std::string commandResponse = "";
52 
53     radio->sendTerminalResponseToSim(serial, commandResponse);
54 
55     EXPECT_EQ(std::cv_status::no_timeout, wait());
56     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
57     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
58 
59     if (cardStatus.cardState == CardState::ABSENT) {
60         ASSERT_TRUE(CheckAnyOfErrors(
61             radioRsp->rspInfo.error,
62             {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::SIM_ABSENT},
63             CHECK_GENERAL_ERROR));
64     }
65 }
66 
67 /*
68  * Test IRadio.handleStkCallSetupRequestFromSim() for the response returned.
69  */
TEST_F(RadioHidlTest,handleStkCallSetupRequestFromSim)70 TEST_F(RadioHidlTest, handleStkCallSetupRequestFromSim) {
71     serial = GetRandomSerialNumber();
72     bool accept = false;
73 
74     radio->handleStkCallSetupRequestFromSim(serial, accept);
75 
76     EXPECT_EQ(std::cv_status::no_timeout, wait());
77     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
78     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
79 
80     if (cardStatus.cardState == CardState::ABSENT) {
81         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
82                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
83                                       RadioError::MODEM_ERR, RadioError::SIM_ABSENT},
84                                      CHECK_GENERAL_ERROR));
85     }
86 }
87 
88 /*
89  * Test IRadio.reportStkServiceIsRunning() for the response returned.
90  */
TEST_F(RadioHidlTest,reportStkServiceIsRunning)91 TEST_F(RadioHidlTest, reportStkServiceIsRunning) {
92     serial = GetRandomSerialNumber();
93 
94     radio->reportStkServiceIsRunning(serial);
95 
96     EXPECT_EQ(std::cv_status::no_timeout, wait());
97     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
98     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
99 
100     if (cardStatus.cardState == CardState::ABSENT) {
101         ASSERT_TRUE(
102             CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::NONE}, CHECK_GENERAL_ERROR));
103     }
104 }
105 
106 /*
107  * Test IRadio.sendEnvelopeWithStatus() for the response returned with empty
108  * string.
109  */
TEST_F(RadioHidlTest,sendEnvelopeWithStatus)110 TEST_F(RadioHidlTest, sendEnvelopeWithStatus) {
111     serial = GetRandomSerialNumber();
112 
113     // Test with sending empty string
114     std::string contents = "";
115 
116     radio->sendEnvelopeWithStatus(serial, contents);
117 
118     EXPECT_EQ(std::cv_status::no_timeout, wait());
119     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
120     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
121 
122     if (cardStatus.cardState == CardState::ABSENT) {
123         ASSERT_TRUE(CheckAnyOfErrors(
124             radioRsp->rspInfo.error,
125             {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR, RadioError::SIM_ABSENT},
126             CHECK_GENERAL_ERROR));
127     }
128 }
129