1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"));
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #define private public
17 #define protected public
18 #include "gtest/gtest.h"
19 #include "hril_data.h"
20 #include "hril_hdf.h"
21 #include "hril_manager.h"
22 #include "hril_modem.h"
23 #include "hril_network.h"
24 #include "hril_sim.h"
25 #include "hril_sms.h"
26 #include "telephony_log_wrapper.h"
27 #include "v1_1/iril.h"
28
29 namespace OHOS {
30 namespace Telephony {
31 using namespace testing::ext;
32 namespace {
33 constexpr int32_t WAIT_TELEPHONY_RETART_TIME = 60;
34 constexpr int32_t MAX_BUF_SIZE = 255;
35 }
36
37 class BranchTest : public testing::Test {
38 public:
39 static void SetUpTestCase();
40 static void TearDownTestCase();
41 void SetUp();
42 void TearDown();
43 };
SetUpTestCase()44 void BranchTest::SetUpTestCase() {}
45
ReStartTelephony()46 void ReStartTelephony()
47 {
48 FILE *fp;
49 char buf[MAX_BUF_SIZE];
50 std::string cmd = "pidof telephony";
51 pid_t pid = -1;
52 if ((fp = popen(cmd.c_str(), "r")) != nullptr) {
53 if (fgets(buf, MAX_BUF_SIZE, fp) != nullptr) {
54 pid = atoi(buf);
55 }
56 }
57 kill(pid, SIGKILL);
58 pclose(fp);
59 sleep(WAIT_TELEPHONY_RETART_TIME);
60 }
61
TearDownTestCase()62 void BranchTest::TearDownTestCase()
63 {
64 ReStartTelephony();
65 }
66
SetUp()67 void BranchTest::SetUp() {}
68
TearDown()69 void BranchTest::TearDown() {}
70
TestCallInterface(std::shared_ptr<HRilManager> manager)71 bool TestCallInterface(std::shared_ptr<HRilManager> manager)
72 {
73 OHOS::HDI::Ril::V1_1::EmergencyInfoList emergencyInfoList;
74 EXPECT_NE(HDF_SUCCESS, manager->SetEmergencyCallList(0, 0, emergencyInfoList));
75 EXPECT_NE(HDF_SUCCESS, manager->GetEmergencyCallList(0, 0));
76 EXPECT_NE(HDF_SUCCESS, manager->GetCallList(0, 0));
77 OHOS::HDI::Ril::V1_1::DialInfo dialInfo;
78 EXPECT_NE(HDF_SUCCESS, manager->Dial(0, 0, dialInfo));
79 EXPECT_NE(HDF_SUCCESS, manager->Reject(0, 0));
80 EXPECT_NE(HDF_SUCCESS, manager->Hangup(0, 0, 0));
81 EXPECT_NE(HDF_SUCCESS, manager->Answer(0, 0));
82 EXPECT_NE(HDF_SUCCESS, manager->HoldCall(0, 0));
83 EXPECT_NE(HDF_SUCCESS, manager->UnHoldCall(0, 0));
84 EXPECT_NE(HDF_SUCCESS, manager->SwitchCall(0, 0));
85 EXPECT_NE(HDF_SUCCESS, manager->CombineConference(0, 0, 0));
86 EXPECT_NE(HDF_SUCCESS, manager->SeparateConference(0, 0, 0, 0));
87 EXPECT_NE(HDF_SUCCESS, manager->GetCallWaiting(0, 0));
88 EXPECT_NE(HDF_SUCCESS, manager->SetCallWaiting(0, 0, 0));
89 EXPECT_NE(HDF_SUCCESS, manager->GetCallTransferInfo(0, 0, 0));
90 OHOS::HDI::Ril::V1_1::CallForwardSetInfo callForwardSetInfo;
91 EXPECT_NE(HDF_SUCCESS, manager->SetCallTransferInfo(0, 0, callForwardSetInfo));
92 EXPECT_NE(HDF_SUCCESS, manager->GetCallRestriction(0, 0, "0"));
93 OHOS::HDI::Ril::V1_1::CallRestrictionInfo callRestrictionInfo;
94 EXPECT_NE(HDF_SUCCESS, manager->SetCallRestriction(0, 0, callRestrictionInfo));
95 EXPECT_NE(HDF_SUCCESS, manager->GetClip(0, 0));
96 EXPECT_NE(HDF_SUCCESS, manager->SetClip(0, 0, 0));
97 EXPECT_NE(HDF_SUCCESS, manager->GetClir(0, 0));
98 EXPECT_NE(HDF_SUCCESS, manager->SetClir(0, 0, 0));
99 EXPECT_NE(HDF_SUCCESS, manager->GetCallPreferenceMode(0, 0));
100 EXPECT_NE(HDF_SUCCESS, manager->SetCallPreferenceMode(0, 0, 0));
101 EXPECT_NE(HDF_SUCCESS, manager->SetUssd(0, 0, "0"));
102 EXPECT_NE(HDF_SUCCESS, manager->GetUssd(0, 0));
103 EXPECT_NE(HDF_SUCCESS, manager->SetMute(0, 0, 0));
104 EXPECT_NE(HDF_SUCCESS, manager->GetMute(0, 0));
105 EXPECT_NE(HDF_SUCCESS, manager->GetCallFailReason(0, 0));
106 EXPECT_NE(HDF_SUCCESS, manager->CallSupplement(0, 0, 0));
107 OHOS::HDI::Ril::V1_1::DtmfInfo info;
108 EXPECT_NE(HDF_SUCCESS, manager->SendDtmf(0, 0, info));
109 EXPECT_NE(HDF_SUCCESS, manager->StartDtmf(0, 0, info));
110 EXPECT_NE(HDF_SUCCESS, manager->StopDtmf(0, 0, info));
111 const OHOS::HDI::Ril::V1_1::SetBarringInfo setBarringInfo;
112 EXPECT_NE(HDF_SUCCESS, manager->SetBarringPassword(0, 0, setBarringInfo));
113 EXPECT_NE(HDF_SUCCESS, manager->SetVonrSwitch(0, 0, 0));
114 return true;
115 }
116
TestDataInterface(std::shared_ptr<HRilManager> manager)117 bool TestDataInterface(std::shared_ptr<HRilManager> manager)
118 {
119 OHOS::HDI::Ril::V1_1::DataCallInfo dataCallInfo;
120 EXPECT_NE(HDF_SUCCESS, manager->ActivatePdpContext(0, 0, dataCallInfo));
121 OHOS::HDI::Ril::V1_1::UniInfo uniInfo;
122 EXPECT_NE(HDF_SUCCESS, manager->DeactivatePdpContext(0, 0, uniInfo));
123 EXPECT_NE(HDF_SUCCESS, manager->GetPdpContextList(0, 0, uniInfo));
124 OHOS::HDI::Ril::V1_1::DataProfileDataInfo dataProfileDataInfo;
125 EXPECT_NE(HDF_SUCCESS, manager->SetInitApnInfo(0, 0, dataProfileDataInfo));
126 EXPECT_NE(HDF_SUCCESS, manager->GetLinkBandwidthInfo(0, 0, 0));
127 EXPECT_NE(HDF_SUCCESS, manager->GetLinkCapability(0, 0));
128 OHOS::HDI::Ril::V1_1::DataLinkBandwidthReportingRule dataLinkBandwidthReportingRule;
129 EXPECT_NE(HDF_SUCCESS, manager->SetLinkBandwidthReportingRule(0, 0, dataLinkBandwidthReportingRule));
130 EXPECT_NE(HDF_SUCCESS, manager->SetDataPermitted(0, 0, 0));
131 OHOS::HDI::Ril::V1_1::DataProfilesInfo dataProfilesInfo;
132 EXPECT_NE(HDF_SUCCESS, manager->SetDataProfileInfo(0, 0, dataProfilesInfo));
133 OHOS::HDI::Ril::V1_1::DataPerformanceInfo dataPerformanceInfo;
134 EXPECT_NE(HDF_SUCCESS, manager->SendDataPerformanceMode(0, 0, dataPerformanceInfo));
135 OHOS::HDI::Ril::V1_1::DataSleepInfo dataSleepInfo;
136 EXPECT_NE(HDF_SUCCESS, manager->SendDataSleepMode(0, 0, dataSleepInfo));
137 return true;
138 }
139
TestModemInterface(std::shared_ptr<HRilManager> manager)140 bool TestModemInterface(std::shared_ptr<HRilManager> manager)
141 {
142 EXPECT_NE(HDF_SUCCESS, manager->SetRadioState(0, 0, 0, 1));
143 EXPECT_NE(HDF_SUCCESS, manager->GetRadioState(0, 0));
144 EXPECT_NE(HDF_SUCCESS, manager->GetImei(0, 0));
145 EXPECT_NE(HDF_SUCCESS, manager->GetMeid(0, 0));
146 EXPECT_NE(HDF_SUCCESS, manager->GetVoiceRadioTechnology(0, 0));
147 EXPECT_NE(HDF_SUCCESS, manager->GetBasebandVersion(0, 0));
148 EXPECT_NE(HDF_SUCCESS, manager->ShutDown(0, 0));
149 return true;
150 }
151
TestSimInterface(std::shared_ptr<HRilManager> manager)152 bool TestSimInterface(std::shared_ptr<HRilManager> manager)
153 {
154 OHOS::HDI::Ril::V1_1::SimIoRequestInfo simIO;
155 EXPECT_NE(HDF_SUCCESS, manager->GetSimIO(0, 0, simIO));
156 EXPECT_NE(HDF_SUCCESS, manager->GetSimStatus(0, 0));
157 EXPECT_NE(HDF_SUCCESS, manager->GetImsi(0, 0));
158 OHOS::HDI::Ril::V1_1::SimLockInfo simLockInfo;
159 EXPECT_NE(HDF_SUCCESS, manager->GetSimLockStatus(0, 0, simLockInfo));
160 EXPECT_NE(HDF_SUCCESS, manager->SetSimLock(0, 0, simLockInfo));
161 OHOS::HDI::Ril::V1_1::SimPasswordInfo simPassword;
162 EXPECT_NE(HDF_SUCCESS, manager->ChangeSimPassword(0, 0, simPassword));
163 EXPECT_NE(HDF_SUCCESS, manager->UnlockPin(0, 0, ""));
164 EXPECT_NE(HDF_SUCCESS, manager->UnlockPuk(0, 0, "", ""));
165 EXPECT_NE(HDF_SUCCESS, manager->UnlockPin2(0, 0, ""));
166 EXPECT_NE(HDF_SUCCESS, manager->UnlockPuk2(0, 0, "", ""));
167 EXPECT_NE(HDF_SUCCESS, manager->SetActiveSim(0, 0, 0, 0));
168 EXPECT_NE(HDF_SUCCESS, manager->SimStkSendTerminalResponse(0, 0, "0"));
169 EXPECT_NE(HDF_SUCCESS, manager->SimStkSendEnvelope(0, 0, "0"));
170 EXPECT_NE(HDF_SUCCESS, manager->SimStkSendCallSetupRequestResult(0, 0, 0));
171 EXPECT_NE(HDF_SUCCESS, manager->SimStkIsReady(0, 0));
172 EXPECT_NE(HDF_SUCCESS, manager->GetRadioProtocol(0, 0));
173 HDI::Ril::V1_1::RadioProtocol radioProtocol;
174 EXPECT_NE(HDF_SUCCESS, manager->SetRadioProtocol(0, 0, radioProtocol));
175 EXPECT_NE(HDF_SUCCESS, manager->SimOpenLogicalChannel(0, 0, "0", 0));
176 EXPECT_NE(HDF_SUCCESS, manager->SimCloseLogicalChannel(0, 0, 0));
177 OHOS::HDI::Ril::V1_1::ApduSimIORequestInfo apduSimIO;
178 EXPECT_NE(HDF_SUCCESS, manager->SimTransmitApduLogicalChannel(0, 0, apduSimIO));
179 EXPECT_NE(HDF_SUCCESS, manager->SimTransmitApduBasicChannel(0, 0, apduSimIO));
180 OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo simAuthInfo;
181 EXPECT_NE(HDF_SUCCESS, manager->SimAuthentication(0, 0, simAuthInfo));
182 EXPECT_NE(HDF_SUCCESS, manager->UnlockSimLock(0, 0, 0, ""));
183 return true;
184 }
185
TestNetWorkInterface(std::shared_ptr<HRilManager> manager)186 bool TestNetWorkInterface(std::shared_ptr<HRilManager> manager)
187 {
188 EXPECT_NE(HDF_SUCCESS, manager->GetSignalStrength(0, 0));
189 EXPECT_NE(HDF_SUCCESS, manager->GetCsRegStatus(0, 0));
190 EXPECT_NE(HDF_SUCCESS, manager->GetPsRegStatus(0, 0));
191 EXPECT_NE(HDF_SUCCESS, manager->GetOperatorInfo(0, 0));
192 EXPECT_NE(HDF_SUCCESS, manager->GetNetworkSearchInformation(0, 0));
193 EXPECT_NE(HDF_SUCCESS, manager->GetNetworkSelectionMode(0, 0));
194 HDI::Ril::V1_1::SetNetworkModeInfo networkModeInfo;
195 EXPECT_NE(HDF_SUCCESS, manager->SetNetworkSelectionMode(0, 0, networkModeInfo));
196 EXPECT_NE(HDF_SUCCESS, manager->GetNeighboringCellInfoList(0, 0));
197 EXPECT_NE(HDF_SUCCESS, manager->GetCurrentCellInfo(0, 0));
198 EXPECT_NE(HDF_SUCCESS, manager->SetPreferredNetwork(0, 0, 0));
199 EXPECT_NE(HDF_SUCCESS, manager->GetPreferredNetwork(0, 0));
200 EXPECT_NE(HDF_SUCCESS, manager->GetPhysicalChannelConfig(0, 0));
201 EXPECT_NE(HDF_SUCCESS, manager->SetLocateUpdates(0, 0, static_cast<HDI::Ril::V1_1::RilRegNotifyMode>(0)));
202 EXPECT_NE(HDF_SUCCESS, manager->SetNotificationFilter(0, 0, 0));
203 EXPECT_NE(HDF_SUCCESS, manager->SetDeviceState(0, 0, 0, 0));
204 EXPECT_NE(HDF_SUCCESS, manager->GetRrcConnectionState(0, 0));
205 EXPECT_NE(HDF_SUCCESS, manager->GetNrOptionMode(0, 0));
206 EXPECT_NE(HDF_SUCCESS, manager->SetNrOptionMode(0, 0, 1));
207 return true;
208 }
209
TestSmsInterface(std::shared_ptr<HRilManager> manager)210 bool TestSmsInterface(std::shared_ptr<HRilManager> manager)
211 {
212 OHOS::HDI::Ril::V1_1::GsmSmsMessageInfo gsmSmsMessageInfo;
213 EXPECT_NE(HDF_SUCCESS, manager->SendGsmSms(0, 0, gsmSmsMessageInfo));
214 OHOS::HDI::Ril::V1_1::SendCdmaSmsMessageInfo cdmaSmsMessageInfo;
215 EXPECT_NE(HDF_SUCCESS, manager->SendCdmaSms(0, 0, cdmaSmsMessageInfo));
216 OHOS::HDI::Ril::V1_1::SmsMessageIOInfo smsMessageIOInfo;
217 EXPECT_NE(HDF_SUCCESS, manager->AddSimMessage(0, 0, smsMessageIOInfo));
218 EXPECT_NE(HDF_SUCCESS, manager->DelSimMessage(0, 0, 0));
219 EXPECT_NE(HDF_SUCCESS, manager->UpdateSimMessage(0, 0, smsMessageIOInfo));
220 EXPECT_NE(HDF_SUCCESS, manager->AddCdmaSimMessage(0, 0, smsMessageIOInfo));
221 EXPECT_NE(HDF_SUCCESS, manager->DelCdmaSimMessage(0, 0, 0));
222 EXPECT_NE(HDF_SUCCESS, manager->UpdateCdmaSimMessage(0, 0, smsMessageIOInfo));
223 OHOS::HDI::Ril::V1_1::ServiceCenterAddress serviceCenterAddress;
224 EXPECT_NE(HDF_SUCCESS, manager->SetSmscAddr(0, 0, serviceCenterAddress));
225 EXPECT_NE(HDF_SUCCESS, manager->GetSmscAddr(0, 0));
226 OHOS::HDI::Ril::V1_1::CBConfigInfo cellBroadcastInfo;
227 EXPECT_NE(HDF_SUCCESS, manager->SetCBConfig(0, 0, cellBroadcastInfo));
228 EXPECT_NE(HDF_SUCCESS, manager->GetCBConfig(0, 0));
229 OHOS::HDI::Ril::V1_1::CdmaCBConfigInfoList cdmaCBConfigInfoList;
230 EXPECT_NE(HDF_SUCCESS, manager->SetCdmaCBConfig(0, 0, cdmaCBConfigInfoList));
231 EXPECT_NE(HDF_SUCCESS, manager->GetCdmaCBConfig(0, 0));
232 EXPECT_NE(HDF_SUCCESS, manager->SendSmsMoreMode(0, 0, gsmSmsMessageInfo));
233 OHOS::HDI::Ril::V1_1::ModeData modeData;
234 EXPECT_NE(HDF_SUCCESS, manager->SendSmsAck(0, 0, modeData));
235 return true;
236 }
237
238 /**
239 * @tc.number Telephony_HrilManager_001
240 * @tc.name test error branch
241 * @tc.desc Function test
242 */
243 HWTEST_F(BranchTest, Telephony_HrilManager_Call_001, Function | MediumTest | Level2)
244 {
245 auto manager = std::make_shared<HRilManager>();
246 manager->hrilCall_.clear();
247 std::unique_ptr<HRilCall> call;
248 manager->hrilCall_.push_back(std::move(call));
249 EXPECT_EQ(true, TestCallInterface(manager));
250 ReqDataInfo *requestInfo = manager->CreateHRilRequest(0, 0, 0);
251 manager->ReleaseHRilRequest(0, requestInfo);
252 manager->RegisterCallFuncs(0, nullptr);
253 manager->RegisterDataFuncs(0, nullptr);
254 manager->RegisterModemFuncs(0, nullptr);
255 manager->RegisterNetworkFuncs(0, nullptr);
256 manager->RegisterSimFuncs(0, nullptr);
257 manager->RegisterSmsFuncs(0, nullptr);
258 manager->ApplyRunningLock();
259 manager->ReleaseRunningLock();
260 manager->OnCallReport(0, nullptr, nullptr, 0);
261 manager->OnDataReport(0, nullptr, nullptr, 0);
262 manager->OnModemReport(0, nullptr, nullptr, 0);
263 manager->OnNetworkReport(0, nullptr, nullptr, 0);
264 manager->OnSimReport(0, nullptr, nullptr, 0);
265 manager->OnSmsReport(0, nullptr, nullptr, 0);
266 HRilRegOps(nullptr);
267 ReleaseRilAdapter();
268 OnTimerCallback(nullptr, nullptr, nullptr);
269 VoiceRadioTechnology voiceRadioTechnology;
270 VoiceRadioTechnology test = voiceRadioTechnology;
271 EXPECT_EQ(manager->SendRilAck(), 0);
272 manager->hrilCall_.clear();
273 EXPECT_NE(manager->CloseUnFinishedUssd(0, 0), 0);
274 EXPECT_GT(manager->GetMaxSimSlotCount(), 0);
275 }
276
277 /**
278 * @tc.number Telephony_HrilManager_Call_002
279 * @tc.name test error branch
280 * @tc.desc Function test
281 */
282 HWTEST_F(BranchTest, Telephony_HrilManager_Call_002, Function | MediumTest | Level2)
283 {
284 auto manager = std::make_shared<HRilManager>();
285 auto call = std::make_unique<HRilCall>(0, *manager);
286 HRilRadioResponseInfo responseInfo;
287 EXPECT_NE(HDF_SUCCESS, call->GetCallListResponse(0, responseInfo, nullptr, 1));
288 EXPECT_NE(HDF_SUCCESS, call->DialResponse(0, responseInfo, nullptr, 1));
289 EXPECT_NE(HDF_SUCCESS, call->HangupResponse(0, responseInfo, nullptr, 1));
290 EXPECT_NE(HDF_SUCCESS, call->RejectResponse(0, responseInfo, nullptr, 1));
291 EXPECT_NE(HDF_SUCCESS, call->HoldCallResponse(0, responseInfo, nullptr, 1));
292 EXPECT_NE(HDF_SUCCESS, call->UnHoldCallResponse(0, responseInfo, nullptr, 1));
293 EXPECT_NE(HDF_SUCCESS, call->SwitchCallResponse(0, responseInfo, nullptr, 1));
294 EXPECT_NE(HDF_SUCCESS, call->AnswerResponse(0, responseInfo, nullptr, 1));
295 EXPECT_NE(HDF_SUCCESS, call->GetClipResponse(0, responseInfo, nullptr, 1));
296 EXPECT_NE(HDF_SUCCESS, call->SetClipResponse(0, responseInfo, nullptr, 1));
297 EXPECT_NE(HDF_SUCCESS, call->CombineConferenceResponse(0, responseInfo, nullptr, 1));
298 EXPECT_NE(HDF_SUCCESS, call->SeparateConferenceResponse(0, responseInfo, nullptr, 1));
299 EXPECT_NE(HDF_SUCCESS, call->CallSupplementResponse(0, responseInfo, nullptr, 1));
300 EXPECT_NE(HDF_SUCCESS, call->GetCallWaitingResponse(0, responseInfo, nullptr, 1));
301 EXPECT_NE(HDF_SUCCESS, call->SetCallWaitingResponse(0, responseInfo, nullptr, 1));
302 EXPECT_NE(HDF_SUCCESS, call->GetCallTransferInfoResponse(0, responseInfo, nullptr, 1));
303 EXPECT_NE(HDF_SUCCESS, call->SetCallTransferInfoResponse(0, responseInfo, nullptr, 1));
304 EXPECT_NE(HDF_SUCCESS, call->GetCallRestrictionResponse(0, responseInfo, nullptr, 1));
305 EXPECT_NE(HDF_SUCCESS, call->SetCallRestrictionResponse(0, responseInfo, nullptr, 1));
306 EXPECT_NE(HDF_SUCCESS, call->GetClirResponse(0, responseInfo, nullptr, 1));
307 EXPECT_NE(HDF_SUCCESS, call->SetClirResponse(0, responseInfo, nullptr, 1));
308 EXPECT_NE(HDF_SUCCESS, call->StartDtmfResponse(0, responseInfo, nullptr, 1));
309 EXPECT_NE(HDF_SUCCESS, call->SendDtmfResponse(0, responseInfo, nullptr, 1));
310 EXPECT_NE(HDF_SUCCESS, call->StopDtmfResponse(0, responseInfo, nullptr, 1));
311 EXPECT_NE(HDF_SUCCESS, call->GetCallPreferenceModeResponse(0, responseInfo, nullptr, 1));
312 EXPECT_NE(HDF_SUCCESS, call->SetCallPreferenceModeResponse(0, responseInfo, nullptr, 1));
313 EXPECT_NE(HDF_SUCCESS, call->SetUssdResponse(0, responseInfo, nullptr, 1));
314 EXPECT_NE(HDF_SUCCESS, call->GetUssdResponse(0, responseInfo, nullptr, 1));
315 EXPECT_NE(HDF_SUCCESS, call->SetMuteResponse(0, responseInfo, nullptr, 1));
316 EXPECT_NE(HDF_SUCCESS, call->GetMuteResponse(0, responseInfo, nullptr, 1));
317 EXPECT_NE(HDF_SUCCESS, call->GetEmergencyCallListResponse(0, responseInfo, nullptr, 1));
318 EXPECT_NE(HDF_SUCCESS, call->GetCallFailReasonResponse(0, responseInfo, nullptr, 1));
319 EXPECT_NE(HDF_SUCCESS, call->SetEmergencyCallListResponse(0, responseInfo, nullptr, 1));
320 EXPECT_NE(HDF_SUCCESS, call->SetBarringPasswordResponse(0, responseInfo, nullptr, 1));
321 EXPECT_NE(HDF_SUCCESS, call->CallStateUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 1));
322 EXPECT_NE(HDF_SUCCESS, call->CallUssdNotice(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 1));
323 EXPECT_NE(HDF_SUCCESS, call->CallRingbackVoiceNotice(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
324 EXPECT_NE(HDF_SUCCESS, call->CallSrvccStatusNotice(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
325 EXPECT_NE(HDF_SUCCESS, call->CallEmergencyNotice(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
326 EXPECT_NE(HDF_SUCCESS, call->CallSsNotice(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
327 EXPECT_NE(HDF_SUCCESS, call->CallRsrvccStatusNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
328 EXPECT_NE(HDF_SUCCESS, call->SetVonrSwitchResponse(0, responseInfo, nullptr, 1));
329 }
330
331 /**
332 * @tc.number Telephony_HrilManager_Data_001
333 * @tc.name test error branch
334 * @tc.desc Function test
335 */
336 HWTEST_F(BranchTest, Telephony_HrilManager_Data_001, Function | MediumTest | Level2)
337 {
338 auto manager = std::make_shared<HRilManager>();
339 manager->hrilData_.clear();
340 std::unique_ptr<HRilData> data;
341 manager->hrilData_.push_back(std::move(data));
342 EXPECT_EQ(true, TestDataInterface(manager));
343 }
344
345 /**
346 * @tc.number Telephony_HrilManager_Data_002
347 * @tc.name test error branch
348 * @tc.desc Function test
349 */
350 HWTEST_F(BranchTest, Telephony_HrilManager_Data_002, Function | MediumTest | Level2)
351 {
352 auto manager = std::make_shared<HRilManager>();
353 auto data = std::make_unique<HRilData>(0, *manager);
354 HRilRadioResponseInfo responseInfo;
355 EXPECT_NE(HDF_SUCCESS, data->ActivatePdpContextResponse(0, responseInfo, nullptr, 0));
356 EXPECT_NE(HDF_SUCCESS, data->DeactivatePdpContextResponse(0, responseInfo, nullptr, 0));
357 EXPECT_NE(HDF_SUCCESS, data->GetPdpContextListResponse(0, responseInfo, nullptr, 0));
358 EXPECT_NE(HDF_SUCCESS, data->SetInitApnInfoResponse(0, responseInfo, nullptr, 0));
359 EXPECT_NE(HDF_SUCCESS, data->PdpContextListUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
360 EXPECT_NE(HDF_SUCCESS, data->DataLinkCapabilityUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
361 EXPECT_NE(HDF_SUCCESS, data->GetLinkBandwidthInfoResponse(0, responseInfo, nullptr, 0));
362 EXPECT_NE(HDF_SUCCESS, data->SetLinkBandwidthReportingRuleResponse(0, responseInfo, nullptr, 0));
363 EXPECT_EQ(HDF_SUCCESS, data->SetDataProfileInfoResponse(0, responseInfo, nullptr, 0));
364 EXPECT_NE(HDF_SUCCESS, data->SetDataPermittedResponse(0, responseInfo, nullptr, 0));
365 EXPECT_NE(HDF_SUCCESS, data->GetLinkCapabilityResponse(0, responseInfo, nullptr, 0));
366 }
367
368 /**
369 * @tc.number Telephony_HrilManager_Modem_001
370 * @tc.name test error branch
371 * @tc.desc Function test
372 */
373 HWTEST_F(BranchTest, Telephony_HrilManager_Modem_001, Function | MediumTest | Level2)
374 {
375 auto manager = std::make_shared<HRilManager>();
376 manager->hrilModem_.clear();
377 std::unique_ptr<HRilModem> data;
378 manager->hrilModem_.push_back(std::move(data));
379 EXPECT_EQ(true, TestModemInterface(manager));
380 }
381
382 /**
383 * @tc.number Telephony_HrilManager_Modem_002
384 * @tc.name test error branch
385 * @tc.desc Function test
386 */
387 HWTEST_F(BranchTest, Telephony_HrilManager_Modem_002, Function | MediumTest | Level2)
388 {
389 auto manager = std::make_shared<HRilManager>();
390 auto modem = std::make_unique<HRilModem>(0, *manager);
391 HRilRadioResponseInfo responseInfo;
392 EXPECT_NE(HDF_SUCCESS, modem->ShutDownResponse(0, responseInfo, nullptr, 0));
393 EXPECT_NE(HDF_SUCCESS, modem->SetRadioStateResponse(0, responseInfo, nullptr, 0));
394 EXPECT_NE(HDF_SUCCESS, modem->GetRadioStateResponse(0, responseInfo, nullptr, 0));
395 EXPECT_NE(HDF_SUCCESS, modem->GetImeiResponse(0, responseInfo, nullptr, 0));
396 EXPECT_NE(HDF_SUCCESS, modem->GetMeidResponse(0, responseInfo, nullptr, 0));
397 EXPECT_NE(HDF_SUCCESS, modem->GetVoiceRadioTechnologyResponse(0, responseInfo, nullptr, 0));
398 EXPECT_NE(HDF_SUCCESS, modem->GetBasebandVersionResponse(0, responseInfo, nullptr, 0));
399 EXPECT_NE(HDF_SUCCESS, modem->RadioStateUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
400 EXPECT_NE(HDF_SUCCESS, modem->VoiceRadioTechUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
401 EXPECT_NE(HDF_SUCCESS, modem->DsdsModeUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
402 }
403
404 /**
405 * @tc.number Telephony_HrilManager_Network_001
406 * @tc.name test error branch
407 * @tc.desc Function test
408 */
409 HWTEST_F(BranchTest, Telephony_HrilManager_Sim_001, Function | MediumTest | Level2)
410 {
411 auto manager = std::make_shared<HRilManager>();
412 manager->hrilSim_.clear();
413 std::unique_ptr<HRilSim> data;
414 manager->hrilSim_.push_back(std::move(data));
415 EXPECT_EQ(true, TestSimInterface(manager));
416 }
417
418 /**
419 * @tc.number Telephony_HrilManager_Sim_002
420 * @tc.name test error branch
421 * @tc.desc Function test
422 */
423 HWTEST_F(BranchTest, Telephony_HrilManager_Sim_002, Function | MediumTest | Level2)
424 {
425 auto manager = std::make_shared<HRilManager>();
426 auto sim = std::make_unique<HRilSim>(0, *manager);
427 HRilRadioResponseInfo responseInfo;
428 EXPECT_NE(HDF_SUCCESS, sim->GetSimIOResponse(0, responseInfo, nullptr, 0));
429 EXPECT_NE(HDF_SUCCESS, sim->GetSimStatusResponse(0, responseInfo, nullptr, 0));
430 EXPECT_NE(HDF_SUCCESS, sim->GetImsiResponse(0, responseInfo, nullptr, 0));
431 EXPECT_NE(HDF_SUCCESS, sim->GetSimLockStatusResponse(0, responseInfo, nullptr, 0));
432 EXPECT_NE(HDF_SUCCESS, sim->SetSimLockResponse(0, responseInfo, nullptr, 0));
433 EXPECT_NE(HDF_SUCCESS, sim->ChangeSimPasswordResponse(0, responseInfo, nullptr, 0));
434 EXPECT_NE(HDF_SUCCESS, sim->UnlockPinResponse(0, responseInfo, nullptr, 0));
435 EXPECT_NE(HDF_SUCCESS, sim->UnlockPukResponse(0, responseInfo, nullptr, 0));
436 EXPECT_NE(HDF_SUCCESS, sim->UnlockPin2Response(0, responseInfo, nullptr, 0));
437 EXPECT_NE(HDF_SUCCESS, sim->UnlockPuk2Response(0, responseInfo, nullptr, 0));
438 EXPECT_NE(HDF_SUCCESS, sim->SetActiveSimResponse(0, responseInfo, nullptr, 0));
439 EXPECT_NE(HDF_SUCCESS, sim->SimStkSendTerminalResponseResponse(0, responseInfo, nullptr, 0));
440 EXPECT_NE(HDF_SUCCESS, sim->SimStkSendEnvelopeResponse(0, responseInfo, nullptr, 0));
441 EXPECT_NE(HDF_SUCCESS, sim->SimStkSendCallSetupRequestResultResponse(0, responseInfo, nullptr, 0));
442 EXPECT_NE(HDF_SUCCESS, sim->SimStkIsReadyResponse(0, responseInfo, nullptr, 0));
443 EXPECT_NE(HDF_SUCCESS, sim->GetRadioProtocolResponse(0, responseInfo, nullptr, 0));
444 EXPECT_NE(HDF_SUCCESS, sim->SetRadioProtocolResponse(0, responseInfo, nullptr, 0));
445 EXPECT_NE(HDF_SUCCESS, sim->SimOpenLogicalChannelResponse(0, responseInfo, nullptr, 0));
446 EXPECT_NE(HDF_SUCCESS, sim->SimCloseLogicalChannelResponse(0, responseInfo, nullptr, 0));
447 EXPECT_NE(HDF_SUCCESS, sim->SimTransmitApduLogicalChannelResponse(0, responseInfo, nullptr, 0));
448 EXPECT_NE(HDF_SUCCESS, sim->SimTransmitApduBasicChannelResponse(0, responseInfo, nullptr, 0));
449 EXPECT_NE(HDF_SUCCESS, sim->SimAuthenticationResponse(0, responseInfo, nullptr, 0));
450 EXPECT_NE(HDF_SUCCESS, sim->UnlockSimLockResponse(0, responseInfo, nullptr, 0));
451
452 EXPECT_NE(HDF_SUCCESS, sim->SimStateUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
453 EXPECT_NE(HDF_SUCCESS, sim->SimStkSessionEndNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
454 EXPECT_NE(HDF_SUCCESS, sim->SimStkProactiveNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
455 EXPECT_NE(HDF_SUCCESS, sim->SimStkAlphaNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
456 EXPECT_NE(HDF_SUCCESS, sim->SimStkEventNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
457 EXPECT_NE(HDF_SUCCESS, sim->SimStkCallSetupNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
458 EXPECT_NE(HDF_SUCCESS, sim->SimRefreshNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
459 EXPECT_NE(HDF_SUCCESS, sim->SimRadioProtocolUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
460 }
461
462 /**
463 * @tc.number Telephony_HrilManager_Network_001
464 * @tc.name test error branch
465 * @tc.desc Function test
466 */
467 HWTEST_F(BranchTest, Telephony_HrilManager_Network_001, Function | MediumTest | Level2)
468 {
469 auto manager = std::make_shared<HRilManager>();
470 manager->hrilNetwork_.clear();
471 std::unique_ptr<HRilNetwork> data;
472 manager->hrilNetwork_.push_back(std::move(data));
473 EXPECT_EQ(true, TestNetWorkInterface(manager));
474 }
475
476 /**
477 * @tc.number Telephony_HrilManager_Network_002
478 * @tc.name test error branch
479 * @tc.desc Function test
480 */
481 HWTEST_F(BranchTest, Telephony_HrilManager_Network_002, Function | MediumTest | Level3)
482 {
483 auto manager = std::make_shared<HRilManager>();
484 auto network = std::make_unique<HRilNetwork>(0, *manager);
485 HRilRadioResponseInfo responseInfo;
486 EXPECT_NE(HDF_SUCCESS, network->GetSignalStrengthResponse(0, responseInfo, nullptr, 0));
487 EXPECT_NE(HDF_SUCCESS, network->GetCsRegStatusResponse(0, responseInfo, nullptr, 0));
488 EXPECT_NE(HDF_SUCCESS, network->GetPsRegStatusResponse(0, responseInfo, nullptr, 0));
489 EXPECT_NE(HDF_SUCCESS, network->GetOperatorInfoResponse(0, responseInfo, nullptr, 0));
490 EXPECT_NE(HDF_SUCCESS, network->GetNetworkSearchInformationResponse(0, responseInfo, nullptr, 0));
491 EXPECT_NE(HDF_SUCCESS, network->GetNetworkSelectionModeResponse(0, responseInfo, nullptr, 0));
492 EXPECT_NE(HDF_SUCCESS, network->SetNetworkSelectionModeResponse(0, responseInfo, nullptr, 0));
493 EXPECT_NE(HDF_SUCCESS, network->SetPreferredNetworkResponse(0, responseInfo, nullptr, 0));
494 EXPECT_NE(HDF_SUCCESS, network->GetPreferredNetworkResponse(0, responseInfo, nullptr, 0));
495 EXPECT_NE(HDF_SUCCESS, network->GetNeighboringCellInfoListResponse(0, responseInfo, nullptr, 0));
496 EXPECT_NE(HDF_SUCCESS, network->GetCurrentCellInfoResponse(0, responseInfo, nullptr, 0));
497 EXPECT_NE(HDF_SUCCESS, network->GetPhysicalChannelConfigResponse(0, responseInfo, nullptr, 0));
498 EXPECT_NE(HDF_SUCCESS, network->SetLocateUpdatesResponse(0, responseInfo, nullptr, 0));
499 EXPECT_NE(HDF_SUCCESS, network->SetNotificationFilterResponse(0, responseInfo, nullptr, 0));
500 EXPECT_NE(HDF_SUCCESS, network->SetDeviceStateResponse(0, responseInfo, nullptr, 0));
501 EXPECT_NE(HDF_SUCCESS, network->GetRrcConnectionStateResponse(0, responseInfo, nullptr, 0));
502 EXPECT_NE(HDF_SUCCESS, network->GetNrOptionModeResponse(0, responseInfo, nullptr, 0));
503 EXPECT_NE(HDF_SUCCESS, network->SetNrOptionModeResponse(0, responseInfo, nullptr, 0));
504 EXPECT_NE(HDF_SUCCESS, network->NetworkCsRegStatusUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
505 EXPECT_NE(HDF_SUCCESS, network->NetworkPsRegStatusUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
506 EXPECT_NE(HDF_SUCCESS, network->SignalStrengthUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
507 EXPECT_NE(HDF_SUCCESS, network->NetworkTimeUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
508 EXPECT_NE(HDF_SUCCESS, network->NetworkTimeZoneUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
509 EXPECT_NE(HDF_SUCCESS, network->NetworkPhyChnlCfgUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
510 EXPECT_NE(HDF_SUCCESS, network->NetworkCurrentCellUpdated(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
511 }
512
513 /**
514 * @tc.number Telephony_HrilManager_Sms_001
515 * @tc.name test error branch
516 * @tc.desc Function test
517 */
518 HWTEST_F(BranchTest, Telephony_HrilManager_Sms_001, Function | MediumTest | Level3)
519 {
520 auto manager = std::make_shared<HRilManager>();
521 manager->hrilSms_.clear();
522 std::unique_ptr<HRilSms> data;
523 manager->hrilSms_.push_back(std::move(data));
524 EXPECT_EQ(true, TestSmsInterface(manager));
525 }
526
527 /**
528 * @tc.number Telephony_HrilManager_Sms_002
529 * @tc.name test error branch
530 * @tc.desc Function test
531 */
532 HWTEST_F(BranchTest, Telephony_HrilManager_Sms_002, Function | MediumTest | Level3)
533 {
534 auto manager = std::make_shared<HRilManager>();
535 auto sms = std::make_unique<HRilSms>(0, *manager);
536 HRilRadioResponseInfo responseInfo;
537 EXPECT_NE(HDF_SUCCESS, sms->SendGsmSmsResponse(0, responseInfo, nullptr, 0));
538 EXPECT_NE(HDF_SUCCESS, sms->SendCdmaSmsResponse(0, responseInfo, nullptr, 0));
539 EXPECT_NE(HDF_SUCCESS, sms->AddSimMessageResponse(0, responseInfo, nullptr, 0));
540 EXPECT_NE(HDF_SUCCESS, sms->DelSimMessageResponse(0, responseInfo, nullptr, 0));
541 EXPECT_NE(HDF_SUCCESS, sms->UpdateSimMessageResponse(0, responseInfo, nullptr, 0));
542 EXPECT_NE(HDF_SUCCESS, sms->SetSmscAddrResponse(0, responseInfo, nullptr, 0));
543 EXPECT_NE(HDF_SUCCESS, sms->GetSmscAddrResponse(0, responseInfo, nullptr, 0));
544 EXPECT_NE(HDF_SUCCESS, sms->SetCBConfigResponse(0, responseInfo, nullptr, 0));
545 EXPECT_NE(HDF_SUCCESS, sms->GetCBConfigResponse(0, responseInfo, nullptr, 0));
546 EXPECT_NE(HDF_SUCCESS, sms->SetCdmaCBConfigResponse(0, responseInfo, nullptr, 0));
547 EXPECT_NE(HDF_SUCCESS, sms->GetCdmaCBConfigResponse(0, responseInfo, nullptr, 0));
548 EXPECT_NE(HDF_SUCCESS, sms->SendSmsMoreModeResponse(0, responseInfo, nullptr, 0));
549 EXPECT_NE(HDF_SUCCESS, sms->SendSmsAckResponse(0, responseInfo, nullptr, 0));
550 EXPECT_NE(HDF_SUCCESS, sms->AddCdmaSimMessageResponse(0, responseInfo, nullptr, 0));
551 EXPECT_NE(HDF_SUCCESS, sms->DelCdmaSimMessageResponse(0, responseInfo, nullptr, 0));
552 EXPECT_NE(HDF_SUCCESS, sms->UpdateCdmaSimMessageResponse(0, responseInfo, nullptr, 0));
553 EXPECT_NE(HDF_SUCCESS, sms->SmsStatusReportNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
554 EXPECT_NE(HDF_SUCCESS, sms->NewSmsNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
555 EXPECT_NE(HDF_SUCCESS, sms->NewCdmaSmsNotify(0, HRilErrNumber::HRIL_ERR_NULL_POINT, nullptr, 0));
556 }
557
558 /**
559 * @tc.number Telephony_HrilManager_Sms_001
560 * @tc.name test error branch
561 * @tc.desc Function test
562 */
563 HWTEST_F(BranchTest, Telephony_HrilManager_HrilBase_001, Function | MediumTest | Level3)
564 {
565 HRilManager manager;
566 HRilBase base { 0, manager };
567 EXPECT_EQ(HRIL_ERR_GENERIC_FAILURE, base.ConvertHexStringToInt(nullptr, 0, 0));
568 EXPECT_EQ(10, base.ConvertHexCharToInt('a'));
569 EXPECT_EQ(0, base.ConvertHexCharToInt('0'));
570 EXPECT_EQ(HRIL_INVALID_HEX_CHAR, base.ConvertHexCharToInt('z'));
571 ASSERT_TRUE(base.ConvertHexStringToBytes(nullptr, 0) == nullptr);
572 ASSERT_TRUE(base.ConvertHexStringToBytes(this, 0) == nullptr);
573 ASSERT_FALSE(base.ConvertToString(nullptr, ""));
574 char *dest = nullptr;
575 ASSERT_TRUE(base.ConvertToString(&dest, ""));
576 }
577
578 } // namespace Telephony
579 } // namespace OHOS
580