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_v1_0.h>
19 using namespace ::android::hardware::radio::V1_0;
22 * Test IRadio.sendEnvelope() for the response returned.
24 TEST_F(RadioHidlTest, sendEnvelope) {
25 int serial = GetRandomSerialNumber();
27 // Test with sending empty string
28 std::string content = "";
30 radio->sendEnvelope(serial, content);
32 EXPECT_EQ(std::cv_status::no_timeout, wait());
33 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
34 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
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);
47 * Test IRadio.sendTerminalResponseToSim() for the response returned.
49 TEST_F(RadioHidlTest, sendTerminalResponseToSim) {
50 int serial = GetRandomSerialNumber();
52 // Test with sending empty string
53 std::string commandResponse = "";
55 radio->sendTerminalResponseToSim(serial, commandResponse);
57 EXPECT_EQ(std::cv_status::no_timeout, wait());
58 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
59 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
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);
71 * Test IRadio.handleStkCallSetupRequestFromSim() for the response returned.
73 TEST_F(RadioHidlTest, handleStkCallSetupRequestFromSim) {
74 int serial = GetRandomSerialNumber();
77 radio->handleStkCallSetupRequestFromSim(serial, accept);
79 EXPECT_EQ(std::cv_status::no_timeout, wait());
80 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
81 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
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);
92 * Test IRadio.reportStkServiceIsRunning() for the response returned.
94 TEST_F(RadioHidlTest, reportStkServiceIsRunning) {
95 int serial = GetRandomSerialNumber();
97 radio->reportStkServiceIsRunning(serial);
99 EXPECT_EQ(std::cv_status::no_timeout, wait());
100 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
101 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
103 if (cardStatus.cardState == CardState::ABSENT) {
104 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
109 * Test IRadio.sendEnvelopeWithStatus() for the response returned with empty
112 TEST_F(RadioHidlTest, sendEnvelopeWithStatus) {
113 int serial = GetRandomSerialNumber();
115 // Test with sending empty string
116 std::string contents = "";
118 radio->sendEnvelopeWithStatus(serial, contents);
120 EXPECT_EQ(std::cv_status::no_timeout, wait());
121 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
122 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
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);