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.setGsmBroadcastConfig() for the response returned.
23 */
TEST_F(RadioHidlTest,setGsmBroadcastConfig)24 TEST_F(RadioHidlTest, setGsmBroadcastConfig) {
25 serial = GetRandomSerialNumber();
26
27 // Create GsmBroadcastSmsConfigInfo #1
28 GsmBroadcastSmsConfigInfo gbSmsConfig1;
29 gbSmsConfig1.fromServiceId = 4352;
30 gbSmsConfig1.toServiceId = 4354;
31 gbSmsConfig1.fromCodeScheme = 0;
32 gbSmsConfig1.toCodeScheme = 255;
33 gbSmsConfig1.selected = true;
34
35 // Create GsmBroadcastSmsConfigInfo #2
36 GsmBroadcastSmsConfigInfo gbSmsConfig2;
37 gbSmsConfig2.fromServiceId = 4356;
38 gbSmsConfig2.toServiceId = 4356;
39 gbSmsConfig2.fromCodeScheme = 0;
40 gbSmsConfig2.toCodeScheme = 255;
41 gbSmsConfig2.selected = true;
42
43 // Create GsmBroadcastSmsConfigInfo #3
44 GsmBroadcastSmsConfigInfo gbSmsConfig3;
45 gbSmsConfig3.fromServiceId = 4370;
46 gbSmsConfig3.toServiceId = 4379;
47 gbSmsConfig3.fromCodeScheme = 0;
48 gbSmsConfig3.toCodeScheme = 255;
49 gbSmsConfig3.selected = true;
50
51 // Create GsmBroadcastSmsConfigInfo #4
52 GsmBroadcastSmsConfigInfo gbSmsConfig4;
53 gbSmsConfig4.fromServiceId = 4383;
54 gbSmsConfig4.toServiceId = 4391;
55 gbSmsConfig4.fromCodeScheme = 0;
56 gbSmsConfig4.toCodeScheme = 255;
57 gbSmsConfig4.selected = true;
58
59 // Create GsmBroadcastSmsConfigInfo #5
60 GsmBroadcastSmsConfigInfo gbSmsConfig5;
61 gbSmsConfig5.fromServiceId = 4392;
62 gbSmsConfig5.toServiceId = 4392;
63 gbSmsConfig5.fromCodeScheme = 0;
64 gbSmsConfig5.toCodeScheme = 255;
65 gbSmsConfig5.selected = true;
66
67 android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo> gsmBroadcastSmsConfigsInfoList = {
68 gbSmsConfig1, gbSmsConfig2, gbSmsConfig3, gbSmsConfig4, gbSmsConfig5};
69
70 radio->setGsmBroadcastConfig(serial, gsmBroadcastSmsConfigsInfoList);
71
72 EXPECT_EQ(std::cv_status::no_timeout, wait());
73 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
74 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
75
76 if (cardStatus.cardState == CardState::ABSENT) {
77 ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
78 {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
79 RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE},
80 CHECK_GENERAL_ERROR));
81 }
82 }
83
84 /*
85 * Test IRadio.getGsmBroadcastConfig() for the response returned.
86 */
TEST_F(RadioHidlTest,getGsmBroadcastConfig)87 TEST_F(RadioHidlTest, getGsmBroadcastConfig) {
88 serial = GetRandomSerialNumber();
89
90 radio->getGsmBroadcastConfig(serial);
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(CheckAnyOfErrors(
98 radioRsp->rspInfo.error,
99 {RadioError::NONE, RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE},
100 CHECK_GENERAL_ERROR));
101 }
102 }
103
104 /*
105 * Test IRadio.setCdmaBroadcastConfig() for the response returned.
106 */
TEST_F(RadioHidlTest,setCdmaBroadcastConfig)107 TEST_F(RadioHidlTest, setCdmaBroadcastConfig) {
108 serial = GetRandomSerialNumber();
109
110 CdmaBroadcastSmsConfigInfo cbSmsConfig;
111 cbSmsConfig.serviceCategory = 4096;
112 cbSmsConfig.language = 1;
113 cbSmsConfig.selected = true;
114
115 android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo> cdmaBroadcastSmsConfigInfoList = {
116 cbSmsConfig};
117
118 radio->setCdmaBroadcastConfig(serial, cdmaBroadcastSmsConfigInfoList);
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(CheckAnyOfErrors(radioRsp->rspInfo.error,
126 {RadioError::NONE, RadioError::INVALID_MODEM_STATE},
127 CHECK_GENERAL_ERROR));
128 }
129 }
130
131 /*
132 * Test IRadio.getCdmaBroadcastConfig() for the response returned.
133 */
TEST_F(RadioHidlTest,getCdmaBroadcastConfig)134 TEST_F(RadioHidlTest, getCdmaBroadcastConfig) {
135 serial = GetRandomSerialNumber();
136
137 radio->getCdmaBroadcastConfig(serial);
138
139 EXPECT_EQ(std::cv_status::no_timeout, wait());
140 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
141 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
142
143 if (cardStatus.cardState == CardState::ABSENT) {
144 ASSERT_TRUE(
145 CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::NONE}, CHECK_GENERAL_ERROR));
146 }
147 }
148
149 /*
150 * Test IRadio.setCdmaBroadcastActivation() for the response returned.
151 */
TEST_F(RadioHidlTest,setCdmaBroadcastActivation)152 TEST_F(RadioHidlTest, setCdmaBroadcastActivation) {
153 serial = GetRandomSerialNumber();
154 bool activate = false;
155
156 radio->setCdmaBroadcastActivation(serial, activate);
157
158 EXPECT_EQ(std::cv_status::no_timeout, wait());
159 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
160 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
161
162 if (cardStatus.cardState == CardState::ABSENT) {
163 ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
164 {RadioError::NONE, RadioError::INVALID_ARGUMENTS},
165 CHECK_GENERAL_ERROR));
166 }
167 }
168
169 /*
170 * Test IRadio.setGsmBroadcastActivation() for the response returned.
171 */
TEST_F(RadioHidlTest,setGsmBroadcastActivation)172 TEST_F(RadioHidlTest, setGsmBroadcastActivation) {
173 serial = GetRandomSerialNumber();
174 bool activate = false;
175
176 radio->setGsmBroadcastActivation(serial, activate);
177
178 EXPECT_EQ(std::cv_status::no_timeout, wait());
179 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
180 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
181
182 if (cardStatus.cardState == CardState::ABSENT) {
183 ASSERT_TRUE(CheckAnyOfErrors(
184 radioRsp->rspInfo.error,
185 {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_MODEM_STATE,
186 RadioError::INVALID_STATE, RadioError::OPERATION_NOT_ALLOWED},
187 CHECK_GENERAL_ERROR));
188 }
189 }
190