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.setGsmBroadcastConfig() for the response returned.
24 TEST_F(RadioHidlTest, setGsmBroadcastConfig) {
25 int serial = GetRandomSerialNumber();
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;
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;
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;
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;
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;
67 android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo> gsmBroadcastSmsConfigsInfoList = {
68 gbSmsConfig1, gbSmsConfig2, gbSmsConfig3, gbSmsConfig4, gbSmsConfig5};
70 radio->setGsmBroadcastConfig(serial, gsmBroadcastSmsConfigsInfoList);
72 EXPECT_EQ(std::cv_status::no_timeout, wait());
73 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
74 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
76 if (cardStatus.cardState == CardState::ABSENT) {
77 ASSERT_TRUE(CheckGeneralError() ||
78 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
79 radioRsp->rspInfo.error == RadioError::INVALID_STATE ||
80 radioRsp->rspInfo.error == RadioError::NONE);
85 * Test IRadio.getGsmBroadcastConfig() for the response returned.
87 TEST_F(RadioHidlTest, getGsmBroadcastConfig) {
88 int serial = GetRandomSerialNumber();
90 radio->getGsmBroadcastConfig(serial);
92 EXPECT_EQ(std::cv_status::no_timeout, wait());
93 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
94 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
96 if (cardStatus.cardState == CardState::ABSENT) {
97 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::INVALID_STATE ||
98 radioRsp->rspInfo.error == RadioError::NONE);
103 * Test IRadio.setCdmaBroadcastConfig() for the response returned.
105 TEST_F(RadioHidlTest, setCdmaBroadcastConfig) {
106 int serial = GetRandomSerialNumber();
108 CdmaBroadcastSmsConfigInfo cbSmsConfig;
109 cbSmsConfig.serviceCategory = 4096;
110 cbSmsConfig.language = 1;
111 cbSmsConfig.selected = true;
113 android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo> cdmaBroadcastSmsConfigInfoList = {
116 radio->setCdmaBroadcastConfig(serial, cdmaBroadcastSmsConfigInfoList);
118 EXPECT_EQ(std::cv_status::no_timeout, wait());
119 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
120 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
122 if (cardStatus.cardState == CardState::ABSENT) {
123 ASSERT_TRUE(CheckGeneralError() ||
124 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
129 * Test IRadio.getCdmaBroadcastConfig() for the response returned.
131 TEST_F(RadioHidlTest, getCdmaBroadcastConfig) {
132 int serial = GetRandomSerialNumber();
134 radio->getCdmaBroadcastConfig(serial);
136 EXPECT_EQ(std::cv_status::no_timeout, wait());
137 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
138 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
140 if (cardStatus.cardState == CardState::ABSENT) {
141 ASSERT_TRUE(CheckGeneralError());
146 * Test IRadio.setCdmaBroadcastActivation() for the response returned.
148 TEST_F(RadioHidlTest, setCdmaBroadcastActivation) {
149 int serial = GetRandomSerialNumber();
150 bool activate = false;
152 radio->setCdmaBroadcastActivation(serial, activate);
154 EXPECT_EQ(std::cv_status::no_timeout, wait());
155 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
156 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
158 if (cardStatus.cardState == CardState::ABSENT) {
159 ASSERT_TRUE(CheckGeneralError() ||
160 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
165 * Test IRadio.setGsmBroadcastActivation() for the response returned.
167 TEST_F(RadioHidlTest, setGsmBroadcastActivation) {
168 int serial = GetRandomSerialNumber();
169 bool activate = false;
171 radio->setGsmBroadcastActivation(serial, activate);
173 EXPECT_EQ(std::cv_status::no_timeout, wait());
174 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
175 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
177 if (cardStatus.cardState == CardState::ABSENT) {
178 ASSERT_TRUE(CheckGeneralError() ||
179 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
180 radioRsp->rspInfo.error == RadioError::INVALID_STATE ||
181 radioRsp->rspInfo.error == RadioError::NONE ||
182 radioRsp->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED);