2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <radio_hidl_hal_utils.h>
19 using namespace ::android::hardware::radio::V1_0;
22 * Test IRadio.getClir() for the response returned.
24 TEST_F(RadioHidlTest, getClir) {
25 int serial = GetRandomSerialNumber();
27 radio->getClir(serial);
29 EXPECT_EQ(std::cv_status::no_timeout, wait());
30 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
31 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
33 if (cardStatus.cardState == CardState::ABSENT) {
34 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::MODEM_ERR);
39 * Test IRadio.setClir() for the response returned.
41 TEST_F(RadioHidlTest, setClir) {
42 int serial = GetRandomSerialNumber();
45 radio->setClir(serial, status);
47 EXPECT_EQ(std::cv_status::no_timeout, wait());
48 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
49 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
51 if (cardStatus.cardState == CardState::ABSENT) {
52 EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
57 * Test IRadio.getFacilityLockForApp() for the response returned.
59 TEST_F(RadioHidlTest, getFacilityLockForApp) {
60 int serial = GetRandomSerialNumber();
61 std::string facility = "";
62 std::string password = "";
63 int32_t serviceClass = 1;
64 std::string appId = "";
66 radio->getFacilityLockForApp(serial, facility, password, serviceClass, appId);
68 EXPECT_EQ(std::cv_status::no_timeout, wait());
69 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
70 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
72 if (cardStatus.cardState == CardState::ABSENT) {
73 ASSERT_TRUE(CheckGeneralError() ||
74 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
75 radioRsp->rspInfo.error == RadioError::MODEM_ERR);
80 * Test IRadio.setFacilityLockForApp() for the response returned.
82 TEST_F(RadioHidlTest, setFacilityLockForApp) {
83 int serial = GetRandomSerialNumber();
84 std::string facility = "";
85 bool lockState = false;
86 std::string password = "";
87 int32_t serviceClass = 1;
88 std::string appId = "";
90 radio->setFacilityLockForApp(serial, facility, lockState, password, serviceClass, appId);
92 EXPECT_EQ(std::cv_status::no_timeout, wait());
93 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
94 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
96 if (cardStatus.cardState == CardState::ABSENT) {
97 ASSERT_TRUE(CheckGeneralError() ||
98 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
99 radioRsp->rspInfo.error == RadioError::MODEM_ERR);
104 * Test IRadio.setBarringPassword() for the response returned.
106 TEST_F(RadioHidlTest, setBarringPassword) {
107 int serial = GetRandomSerialNumber();
108 std::string facility = "";
109 std::string oldPassword = "";
110 std::string newPassword = "";
112 radio->setBarringPassword(serial, facility, oldPassword, newPassword);
114 EXPECT_EQ(std::cv_status::no_timeout, wait());
115 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
116 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
118 if (cardStatus.cardState == CardState::ABSENT) {
119 ASSERT_TRUE(CheckGeneralError() ||
120 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
121 radioRsp->rspInfo.error == RadioError::NONE ||
122 radioRsp->rspInfo.error == RadioError::MODEM_ERR ||
123 radioRsp->rspInfo.error == RadioError::FDN_CHECK_FAILURE);
128 * Test IRadio.getClip() for the response returned.
130 TEST_F(RadioHidlTest, getClip) {
131 int serial = GetRandomSerialNumber();
133 radio->getClip(serial);
135 EXPECT_EQ(std::cv_status::no_timeout, wait());
136 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
137 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
139 if (cardStatus.cardState == CardState::ABSENT) {
140 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::MODEM_ERR);
145 * Test IRadio.setSuppServiceNotifications() for the response returned.
147 TEST_F(RadioHidlTest, setSuppServiceNotifications) {
148 int serial = GetRandomSerialNumber();
151 radio->setSuppServiceNotifications(serial, enable);
153 EXPECT_EQ(std::cv_status::no_timeout, wait());
154 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
155 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
157 if (cardStatus.cardState == CardState::ABSENT) {
158 EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
163 * Test IRadio.requestIsimAuthentication() for the response returned.
165 TEST_F(RadioHidlTest, requestIsimAuthentication) {
166 int serial = GetRandomSerialNumber();
167 std::string challenge = "";
169 radio->requestIsimAuthentication(serial, challenge);
171 EXPECT_EQ(std::cv_status::no_timeout, wait());
172 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
173 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
175 if (cardStatus.cardState == CardState::ABSENT) {
176 ASSERT_TRUE(CheckGeneralError());
181 * Test IRadio.getImsRegistrationState() for the response returned.
183 TEST_F(RadioHidlTest, getImsRegistrationState) {
184 int serial = GetRandomSerialNumber();
186 radio->getImsRegistrationState(serial);
188 EXPECT_EQ(std::cv_status::no_timeout, wait());
189 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
190 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
192 if (cardStatus.cardState == CardState::ABSENT) {
193 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE ||
194 radioRsp->rspInfo.error == RadioError::MODEM_ERR ||
195 radioRsp->rspInfo.error == RadioError::INVALID_MODEM_STATE);