OSDN Git Service

Merge "NO PARTIAL RERUN Camera: Update stream consumer usage flag" into oc-dev
[android-x86/hardware-interfaces.git] / radio / 1.0 / vts / functional / radio_hidl_hal_ims.cpp
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.getClir() for the response returned.
23  */
24 TEST_F(RadioHidlTest, getClir) {
25     int serial = GetRandomSerialNumber();
26
27     radio->getClir(serial);
28
29     EXPECT_EQ(std::cv_status::no_timeout, wait());
30     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
31     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
32
33     if (cardStatus.cardState == CardState::ABSENT) {
34         ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::MODEM_ERR);
35     }
36 }
37
38 /*
39  * Test IRadio.setClir() for the response returned.
40  */
41 TEST_F(RadioHidlTest, setClir) {
42     int serial = GetRandomSerialNumber();
43     int32_t status = 1;
44
45     radio->setClir(serial, status);
46
47     EXPECT_EQ(std::cv_status::no_timeout, wait());
48     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
49     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
50
51     if (cardStatus.cardState == CardState::ABSENT) {
52         EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
53     }
54 }
55
56 /*
57  * Test IRadio.getFacilityLockForApp() for the response returned.
58  */
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 = "";
65
66     radio->getFacilityLockForApp(serial, facility, password, serviceClass, appId);
67
68     EXPECT_EQ(std::cv_status::no_timeout, wait());
69     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
70     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
71
72     if (cardStatus.cardState == CardState::ABSENT) {
73         ASSERT_TRUE(CheckGeneralError() ||
74                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
75                     radioRsp->rspInfo.error == RadioError::MODEM_ERR);
76     }
77 }
78
79 /*
80  * Test IRadio.setFacilityLockForApp() for the response returned.
81  */
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 = "";
89
90     radio->setFacilityLockForApp(serial, facility, lockState, password, serviceClass, appId);
91
92     EXPECT_EQ(std::cv_status::no_timeout, wait());
93     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
94     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
95
96     if (cardStatus.cardState == CardState::ABSENT) {
97         ASSERT_TRUE(CheckGeneralError() ||
98                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
99                     radioRsp->rspInfo.error == RadioError::MODEM_ERR);
100     }
101 }
102
103 /*
104  * Test IRadio.setBarringPassword() for the response returned.
105  */
106 TEST_F(RadioHidlTest, setBarringPassword) {
107     int serial = GetRandomSerialNumber();
108     std::string facility = "";
109     std::string oldPassword = "";
110     std::string newPassword = "";
111
112     radio->setBarringPassword(serial, facility, oldPassword, newPassword);
113
114     EXPECT_EQ(std::cv_status::no_timeout, wait());
115     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
116     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
117
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);
124     }
125 }
126
127 /*
128  * Test IRadio.getClip() for the response returned.
129  */
130 TEST_F(RadioHidlTest, getClip) {
131     int serial = GetRandomSerialNumber();
132
133     radio->getClip(serial);
134
135     EXPECT_EQ(std::cv_status::no_timeout, wait());
136     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
137     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
138
139     if (cardStatus.cardState == CardState::ABSENT) {
140         ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::MODEM_ERR);
141     }
142 }
143
144 /*
145  * Test IRadio.setSuppServiceNotifications() for the response returned.
146  */
147 TEST_F(RadioHidlTest, setSuppServiceNotifications) {
148     int serial = GetRandomSerialNumber();
149     bool enable = false;
150
151     radio->setSuppServiceNotifications(serial, enable);
152
153     EXPECT_EQ(std::cv_status::no_timeout, wait());
154     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
155     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
156
157     if (cardStatus.cardState == CardState::ABSENT) {
158         EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
159     }
160 }
161
162 /*
163  * Test IRadio.requestIsimAuthentication() for the response returned.
164  */
165 TEST_F(RadioHidlTest, requestIsimAuthentication) {
166     int serial = GetRandomSerialNumber();
167     std::string challenge = "";
168
169     radio->requestIsimAuthentication(serial, challenge);
170
171     EXPECT_EQ(std::cv_status::no_timeout, wait());
172     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
173     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
174
175     if (cardStatus.cardState == CardState::ABSENT) {
176         ASSERT_TRUE(CheckGeneralError());
177     }
178 }
179
180 /*
181  * Test IRadio.getImsRegistrationState() for the response returned.
182  */
183 TEST_F(RadioHidlTest, getImsRegistrationState) {
184     int serial = GetRandomSerialNumber();
185
186     radio->getImsRegistrationState(serial);
187
188     EXPECT_EQ(std::cv_status::no_timeout, wait());
189     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
190     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
191
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);
196     }
197 }