OSDN Git Service

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