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