1/*
2 * Copyright (C) 2023 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#define private public
16#define protected public
17
18#include "cellular_call_config.h"
19#include "cellular_call_connection_ims.h"
20#include "cellular_call_handler.h"
21#include "cellular_call_proxy.h"
22#include "cellular_call_register.h"
23#include "cellular_call_service.h"
24#include "cellular_call_supplement.h"
25#include "config_request.h"
26#include "control_base.h"
27#include "cs_control.h"
28#include "gtest/gtest.h"
29#include "tel_ril_call_parcel.h"
30#include "ims_call_callback_proxy.h"
31#include "ims_call_callback_stub.h"
32#include "ims_call_client.h"
33#include "ims_control.h"
34#include "ims_error.h"
35#include "ims_test.h"
36#include "securec.h"
37#include "cellular_call_hisysevent.h"
38#include "standardize_utils.h"
39#include "cellular_call_rdb_helper.h"
40#include "cellular_call_dump_helper.h"
41#include "emergency_utils.h"
42#include "satellite_call_client.h"
43
44namespace OHOS {
45namespace Telephony {
46using namespace testing::ext;
47
48#ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
49static const int32_t INVALID_VALUE = -1;
50#endif
51
52namespace {
53const int32_t INVALID_SLOTID = 2;
54const int32_t SIM1_SLOTID = 0;
55const int32_t SIM2_SLOTID = 1;
56const int32_t ACTIVATE_ACTION = 1;
57const std::string PHONE_NUMBER = "00000000";
58const int32_t DEFAULT_INDEX = 1;
59} // namespace
60
61class DemoHandler : public AppExecFwk::EventHandler {
62public:
63    explicit DemoHandler(std::shared_ptr<AppExecFwk::EventRunner> &runner) : AppExecFwk::EventHandler(runner) {}
64    virtual ~DemoHandler() {}
65    void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) {}
66};
67
68class BranchTest : public testing::Test {
69public:
70    static void SetUpTestCase();
71    static void TearDownTestCase();
72    void SetUp();
73    void TearDown();
74    int32_t InitCellularCallInfo(int32_t accountId, std::string phonenumber, CellularCallInfo &callInfo);
75    void InitImsCallInfoList(ImsCurrentCallList &callInfoList, int32_t num);
76    void InitCsCallInfoList(CallInfoList &callInfoList, int32_t num);
77    void MakeCallInfoParcelData(bool isError, MessageParcel &data);
78};
79
80void BranchTest::SetUpTestCase()
81{
82    std::cout << "---------- CellularCallService start ------------" << std::endl;
83    DelayedSingleton<CellularCallService>::GetInstance()->Init();
84    DelayedSingleton<ImsCallClient>::GetInstance()->Init();
85}
86
87void BranchTest::TearDownTestCase() {}
88
89void BranchTest::SetUp() {}
90
91void BranchTest::TearDown() {}
92
93int32_t BranchTest::InitCellularCallInfo(int32_t accountId, std::string phonenumber, CellularCallInfo &callInfo)
94{
95    callInfo.accountId = accountId;
96    callInfo.slotId = accountId;
97    callInfo.index = accountId;
98    callInfo.callType = CallType::TYPE_IMS;
99    callInfo.videoState = 0; // 0 means audio
100    if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
101        return TELEPHONY_ERR_MEMSET_FAIL;
102    }
103    if (phonenumber.length() > static_cast<size_t>(kMaxNumberLen)) {
104        return CALL_ERR_NUMBER_OUT_OF_RANGE;
105    }
106    if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, phonenumber.c_str(), phonenumber.length()) != EOK) {
107        return TELEPHONY_ERR_MEMCPY_FAIL;
108    }
109    return TELEPHONY_SUCCESS;
110}
111
112void BranchTest::InitImsCallInfoList(ImsCurrentCallList &callInfoList, int32_t num)
113{
114    callInfoList.callSize = num;
115    ImsCurrentCall call;
116    int32_t callStateSum = 6;
117    for (int32_t i = 0; i < num; ++i) {
118        call.index = i;
119        call.state = i % callStateSum;
120        callInfoList.calls.push_back(call);
121    }
122}
123
124void BranchTest::MakeCallInfoParcelData(bool isError, MessageParcel &data)
125{
126    if (isError) {
127        int32_t errorSize = 0;
128        data.WriteInt32(errorSize);
129    } else {
130        CellularCallInfo callInfo;
131        callInfo.slotId = -1;
132        int32_t size = 1;
133        data.WriteInt32(size);
134        data.WriteRawData(static_cast<const void *>(&callInfo), sizeof(CellularCallInfo));
135    }
136}
137
138void BranchTest::InitCsCallInfoList(CallInfoList &callInfoList, int32_t num)
139{
140    callInfoList.callSize = num;
141    CallInfo call;
142    int32_t callStateSum = 9;
143    for (int32_t i = 0; i < num; ++i) {
144        call.index = i;
145        call.state = i % callStateSum;
146        callInfoList.calls.push_back(call);
147    }
148}
149
150/**
151 * @tc.number   Telephony_CellularCallStub_001
152 * @tc.name     Test error branch
153 * @tc.desc     Function test
154 */
155HWTEST_F(BranchTest, Telephony_CellularCallStub_001, Function | MediumTest | Level3)
156{
157    AccessToken token;
158    CellularCallService callStub;
159    MessageParcel reply;
160
161    MessageParcel dialErrorData;
162    MakeCallInfoParcelData(true, dialErrorData);
163    callStub.OnDialInner(dialErrorData, reply);
164    MessageParcel dialData;
165    MakeCallInfoParcelData(false, dialData);
166    callStub.OnDialInner(dialData, reply);
167
168    MessageParcel hangUpErrorData;
169    MakeCallInfoParcelData(true, hangUpErrorData);
170    callStub.OnHangUpInner(hangUpErrorData, reply);
171    MessageParcel hangUpData;
172    MakeCallInfoParcelData(false, hangUpData);
173    hangUpData.WriteInt32(1);
174    callStub.OnHangUpInner(hangUpData, reply);
175
176    MessageParcel rejectErrorData;
177    MakeCallInfoParcelData(true, rejectErrorData);
178    callStub.OnRejectInner(rejectErrorData, reply);
179    MessageParcel rejectData;
180    MakeCallInfoParcelData(false, rejectData);
181    callStub.OnRejectInner(rejectData, reply);
182
183    MessageParcel answerErrorData;
184    MakeCallInfoParcelData(true, answerErrorData);
185    callStub.OnAnswerInner(answerErrorData, reply);
186    MessageParcel answerData;
187    MakeCallInfoParcelData(false, answerData);
188    callStub.OnAnswerInner(answerData, reply);
189
190    MessageParcel holdErrorData;
191    MakeCallInfoParcelData(true, holdErrorData);
192    callStub.OnHoldCallInner(holdErrorData, reply);
193    MessageParcel holdData;
194    MakeCallInfoParcelData(false, answerData);
195    callStub.OnHoldCallInner(holdData, reply);
196
197    MessageParcel unholdErrorData;
198    MakeCallInfoParcelData(true, unholdErrorData);
199    callStub.OnUnHoldCallInner(unholdErrorData, reply);
200    MessageParcel unholdData;
201    MakeCallInfoParcelData(false, unholdData);
202    callStub.OnUnHoldCallInner(unholdData, reply);
203
204    MessageParcel switchCallErrorData;
205    MakeCallInfoParcelData(true, switchCallErrorData);
206    callStub.OnSwitchCallInner(switchCallErrorData, reply);
207    MessageParcel switchCallData;
208    MakeCallInfoParcelData(false, switchCallData);
209    ASSERT_EQ(callStub.OnSwitchCallInner(switchCallData, reply), TELEPHONY_SUCCESS);
210}
211
212/**
213 * @tc.number   Telephony_CellularCallStub_002
214 * @tc.name     Test error branch
215 * @tc.desc     Function test
216 */
217HWTEST_F(BranchTest, Telephony_CellularCallStub_002, Function | MediumTest | Level3)
218{
219    AccessToken token;
220    CellularCallService callStub;
221    MessageParcel reply;
222    int32_t size = 1;
223
224    MessageParcel combineErrorData;
225    MakeCallInfoParcelData(true, combineErrorData);
226    callStub.OnCombineConferenceInner(combineErrorData, reply);
227    MessageParcel combineData;
228    MakeCallInfoParcelData(false, combineData);
229    callStub.OnCombineConferenceInner(combineData, reply);
230
231    MessageParcel separateErrorData;
232    MakeCallInfoParcelData(true, separateErrorData);
233    callStub.OnSeparateConferenceInner(separateErrorData, reply);
234    MessageParcel separateData;
235    MakeCallInfoParcelData(false, separateData);
236    callStub.OnSeparateConferenceInner(separateData, reply);
237
238    MessageParcel kickOutErrorData;
239    MakeCallInfoParcelData(true, kickOutErrorData);
240    callStub.OnKickOutFromConferenceInner(kickOutErrorData, reply);
241    MessageParcel kickOutData;
242    MakeCallInfoParcelData(false, kickOutData);
243    callStub.OnKickOutFromConferenceInner(kickOutData, reply);
244
245    MessageParcel stopDtmfErrorData;
246    MakeCallInfoParcelData(true, stopDtmfErrorData);
247    callStub.OnStopDtmfInner(stopDtmfErrorData, reply);
248    MessageParcel stopDtmfData;
249    MakeCallInfoParcelData(false, stopDtmfData);
250    callStub.OnStopDtmfInner(stopDtmfData, reply);
251
252    MessageParcel postDialErrorData;
253    MakeCallInfoParcelData(true, postDialErrorData);
254    callStub.OnPostDialProceedInner(postDialErrorData, reply);
255    MessageParcel postDialData;
256    MakeCallInfoParcelData(false, postDialData);
257    postDialData.WriteBool(false);
258    callStub.OnPostDialProceedInner(postDialData, reply);
259
260    MessageParcel cameraData;
261    cameraData.WriteInt32(size);
262    ASSERT_EQ(callStub.OnControlCameraInner(cameraData, reply), TELEPHONY_SUCCESS);
263}
264
265/**
266 * @tc.number   Telephony_CellularCallStub_003
267 * @tc.name     Test error branch
268 * @tc.desc     Function test
269 */
270HWTEST_F(BranchTest, Telephony_CellularCallStub_003, Function | MediumTest | Level3)
271{
272    AccessToken token;
273    CellularCallService callStub;
274    CellularCallInfo callInfo;
275    callInfo.slotId = -1;
276    int32_t errorSize = -1;
277    int32_t size = 1;
278    MessageParcel reply;
279
280    MessageParcel hangUpAllData;
281    hangUpAllData.WriteInt32(size);
282    callStub.OnHangUpAllConnectionInner(hangUpAllData, reply);
283    MessageParcel startDtmfData;
284    startDtmfData.WriteInt32(size);
285    startDtmfData.WriteInt8('1');
286    startDtmfData.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo));
287    callStub.OnStartDtmfInner(startDtmfData, reply);
288    MessageParcel sendDtmfData;
289    sendDtmfData.WriteInt32(size);
290    sendDtmfData.WriteInt8('1');
291    sendDtmfData.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo));
292    callStub.OnSendDtmfInner(sendDtmfData, reply);
293    MessageParcel emergencyData;
294    emergencyData.WriteInt32(size);
295    emergencyData.WriteInt32(errorSize);
296    callStub.OnIsEmergencyPhoneNumberInner(emergencyData, reply);
297    MessageParcel setReadyData;
298    setReadyData.WriteInt32(errorSize);
299    callStub.OnSetReadyToCallInner(setReadyData, reply);
300    MessageParcel setCallTransferData;
301    setCallTransferData.WriteInt32(size);
302    setCallTransferData.WriteInt32(errorSize);
303    callStub.OnSetCallTransferInner(setCallTransferData, reply);
304    MessageParcel canSetTimerData;
305    canSetTimerData.WriteInt32(size);
306    canSetTimerData.WriteInt32(errorSize);
307    callStub.OnCanSetCallTransferTimeInner(canSetTimerData, reply);
308    MessageParcel getCallTransferData;
309    getCallTransferData.WriteInt32(size);
310    getCallTransferData.WriteInt32(errorSize);
311    callStub.OnGetCallTransferInner(getCallTransferData, reply);
312    MessageParcel setCallWaitData;
313    setCallWaitData.WriteInt32(size);
314    setCallWaitData.WriteInt32(errorSize);
315    callStub.OnSetCallWaitingInner(setCallWaitData, reply);
316    MessageParcel getCallWaitData;
317    getCallWaitData.WriteInt32(size);
318    getCallWaitData.WriteInt32(errorSize);
319    ASSERT_EQ(callStub.OnGetCallWaitingInner(getCallWaitData, reply), TELEPHONY_SUCCESS);
320}
321
322/**
323 * @tc.number   Telephony_CellularCallStub_004
324 * @tc.name     Test error branch
325 * @tc.desc     Function test
326 */
327HWTEST_F(BranchTest, Telephony_CellularCallStub_004, Function | MediumTest | Level3)
328{
329    AccessToken token;
330    CellularCallService callStub;
331    int32_t errorSize = -1;
332    int32_t size = 1;
333    MessageParcel reply;
334
335    MessageParcel setCallRestData;
336    setCallRestData.WriteInt32(size);
337    setCallRestData.WriteInt32(errorSize);
338    callStub.OnSetCallRestrictionInner(setCallRestData, reply);
339    MessageParcel getCallRestData;
340    getCallRestData.WriteInt32(size);
341    getCallRestData.WriteInt32(errorSize);
342    callStub.OnGetCallRestrictionInner(getCallRestData, reply);
343    MessageParcel setCallRestPwdData;
344    setCallRestPwdData.WriteInt32(size);
345    setCallRestPwdData.WriteInt32(errorSize);
346    callStub.OnSetCallRestrictionPasswordInner(setCallRestPwdData, reply);
347    MessageParcel setDomainData;
348    setDomainData.WriteInt32(size);
349    setDomainData.WriteInt32(errorSize);
350    callStub.OnSetDomainPreferenceModeInner(setDomainData, reply);
351    MessageParcel getDomainData;
352    getDomainData.WriteInt32(size);
353    getDomainData.WriteInt32(errorSize);
354    callStub.OnGetDomainPreferenceModeInner(getDomainData, reply);
355    MessageParcel setImsSwitchData;
356    setImsSwitchData.WriteInt32(size);
357    setImsSwitchData.WriteInt32(errorSize);
358    callStub.OnSetImsSwitchStatusInner(setImsSwitchData, reply);
359    MessageParcel getImsSwitchData;
360    getImsSwitchData.WriteInt32(size);
361    getImsSwitchData.WriteInt32(errorSize);
362    callStub.OnGetImsSwitchStatusInner(getImsSwitchData, reply);
363    MessageParcel setVonrData;
364    setVonrData.WriteInt32(size);
365    setVonrData.WriteInt32(errorSize);
366    callStub.OnSetVoNRStateInner(setVonrData, reply);
367    MessageParcel getVonrData;
368    getVonrData.WriteInt32(size);
369    getVonrData.WriteInt32(errorSize);
370    callStub.OnGetVoNRStateInner(getVonrData, reply);
371    MessageParcel setconfigData;
372    setconfigData.WriteInt32(size);
373    setconfigData.WriteInt32(errorSize);
374    ASSERT_EQ(callStub.OnSetImsConfigStringInner(setconfigData, reply), TELEPHONY_SUCCESS);
375}
376
377/**
378 * @tc.number   Telephony_CellularCallStub_005
379 * @tc.name     Test error branch
380 * @tc.desc     Function test
381 */
382HWTEST_F(BranchTest, Telephony_CellularCallStub_005, Function | MediumTest | Level3)
383{
384    AccessToken token;
385    CellularCallService callStub;
386    int32_t errorSize = -1;
387    int32_t size = 1;
388    MessageParcel reply;
389
390    MessageParcel setconfigData;
391    setconfigData.WriteInt32(size);
392    setconfigData.WriteInt32(errorSize);
393    callStub.OnSetImsConfigIntInner(setconfigData, reply);
394    MessageParcel getconfigData;
395    getconfigData.WriteInt32(size);
396    getconfigData.WriteInt32(errorSize);
397    callStub.OnGetImsConfigInner(getconfigData, reply);
398    MessageParcel setFeatureData;
399    setFeatureData.WriteInt32(size);
400    setFeatureData.WriteInt32(errorSize);
401    callStub.OnSetImsFeatureValueInner(setFeatureData, reply);
402    MessageParcel getFeatureData;
403    getFeatureData.WriteInt32(size);
404    getFeatureData.WriteInt32(errorSize);
405    callStub.OnGetImsFeatureValueInner(getFeatureData, reply);
406    MessageParcel setMuteData;
407    setMuteData.WriteInt32(size);
408    setMuteData.WriteInt32(errorSize);
409    callStub.OnSetMuteInner(setMuteData, reply);
410    MessageParcel getMuteData;
411    getMuteData.WriteInt32(size);
412    getMuteData.WriteInt32(errorSize);
413    callStub.OnGetMuteInner(getMuteData, reply);
414    MessageParcel closeUssdData;
415    closeUssdData.WriteInt32(size);
416    closeUssdData.WriteInt32(errorSize);
417    callStub.OnCloseUnFinishedUssdInner(closeUssdData, reply);
418    MessageParcel clearCallsData;
419    MakeCallInfoParcelData(false, clearCallsData);
420    ASSERT_EQ(callStub.OnClearAllCallsInner(clearCallsData, reply), TELEPHONY_SUCCESS);
421}
422
423/**
424 * @tc.number   Telephony_CellularCallStub_006
425 * @tc.name     Test error branch
426 * @tc.desc     Function test
427 */
428HWTEST_F(BranchTest, Telephony_CellularCallStub_006, Function | MediumTest | Level3)
429{
430    AccessToken token;
431    CellularCallService callStub;
432    int32_t errorSize = -1;
433    int32_t size = 1;
434    MessageParcel reply;
435    MessageParcel setPreviewData;
436    setPreviewData.WriteInt32(errorSize);
437    callStub.OnSetPreviewWindowInner(setPreviewData, reply);
438    MessageParcel setDisplayData;
439    setDisplayData.WriteInt32(errorSize);
440    callStub.OnSetDisplayWindowInner(setDisplayData, reply);
441    MessageParcel setCameraData;
442    setCameraData.WriteInt32(errorSize);
443    callStub.OnSetCameraZoomInner(setCameraData, reply);
444    MessageParcel setImageData;
445    setImageData.WriteInt32(errorSize);
446    callStub.OnSetPausePictureInner(setImageData, reply);
447    MessageParcel setDirectionData;
448    setDirectionData.WriteInt32(errorSize);
449    callStub.OnSetDeviceDirectionInner(setDirectionData, reply);
450
451    MessageParcel setEmergencyData;
452    setEmergencyData.WriteInt32(size);
453    setEmergencyData.WriteInt32(errorSize);
454    setEmergencyData.WriteInt32(size);
455    if (setEmergencyData.WriteString("123") && setEmergencyData.WriteString("456") &&
456        setEmergencyData.WriteInt32(size) && setEmergencyData.WriteInt32(size) && setEmergencyData.WriteInt32(size)) {
457        callStub.OnSetEmergencyCallList(setEmergencyData, reply);
458    }
459
460    MessageParcel registerData;
461    registerData.WriteInt32(size);
462    callStub.OnRegisterCallBackInner(registerData, reply);
463    MessageParcel unRegisterData;
464    unRegisterData.WriteInt32(errorSize);
465    callStub.OnUnRegisterCallBackInner(unRegisterData, reply);
466    MessageParcel inviteData;
467    registerData.WriteInt32(size);
468    inviteData.WriteInt32(errorSize);
469    callStub.OnInviteToConferenceInner(inviteData, reply);
470    MessageParcel startRttData;
471    startRttData.WriteInt32(size);
472    startRttData.WriteInt32(errorSize);
473    startRttData.WriteString("1");
474    callStub.OnStartRttInner(startRttData, reply);
475    MessageParcel stopRttData;
476    stopRttData.WriteInt32(size);
477    stopRttData.WriteInt32(errorSize);
478    ASSERT_EQ(callStub.OnStopRttInner(stopRttData, reply), TELEPHONY_SUCCESS);
479}
480
481/**
482 * @tc.number   Telephony_CellularCallStub_007
483 * @tc.name     Test error branch
484 * @tc.desc     Function test
485 */
486HWTEST_F(BranchTest, Telephony_CellularCallStub_007, Function | MediumTest | Level3)
487{
488    AccessToken token;
489    CellularCallService callStub;
490    int32_t size = 1;
491    MessageParcel reply;
492    MessageParcel callMediaModeRequestData;
493    MakeCallInfoParcelData(false, callMediaModeRequestData);
494    ImsCallMode requestMode = ImsCallMode::CALL_MODE_AUDIO_ONLY;
495    callMediaModeRequestData.WriteInt32(static_cast<int32_t>(requestMode));
496    callStub.OnSendUpdateCallMediaModeRequestInner(callMediaModeRequestData, reply);
497
498    MessageParcel callMediaModeResponseData;
499    MakeCallInfoParcelData(false, callMediaModeResponseData);
500    ImsCallMode responseMode = ImsCallMode::CALL_MODE_AUDIO_ONLY;
501    callMediaModeResponseData.WriteInt32(static_cast<int32_t>(responseMode));
502    callStub.OnSendUpdateCallMediaModeResponseInner(callMediaModeResponseData, reply);
503
504    MessageParcel callUpgradeData;
505    callUpgradeData.WriteInt32(size);
506    callUpgradeData.WriteInt32(SIM1_SLOTID);
507    callUpgradeData.WriteInt32(DEFAULT_INDEX);
508    callStub.OnCancelCallUpgradeInner(callUpgradeData, reply);
509
510    MessageParcel cameraCapabilitiesData;
511    cameraCapabilitiesData.WriteInt32(size);
512    cameraCapabilitiesData.WriteInt32(SIM1_SLOTID);
513    cameraCapabilitiesData.WriteInt32(DEFAULT_INDEX);
514    ASSERT_EQ(callStub.OnRequestCameraCapabilitiesInner(cameraCapabilitiesData, reply), TELEPHONY_SUCCESS);
515}
516
517/**
518 * @tc.number   Telephony_CellularCallService_001
519 * @tc.name     Test error branch
520 * @tc.desc     Function test
521 */
522HWTEST_F(BranchTest, Telephony_CellularCallService_001, Function | MediumTest | Level3)
523{
524    // AccessToken token;
525    CellularCallService cellularCall;
526    std::vector<std::u16string> args = { u"1", u"2" };
527    cellularCall.Dump(-1, args);
528    cellularCall.Dump(1, args);
529    cellularCall.GetServiceRunningState();
530    cellularCall.GetBindTime();
531    cellularCall.GetEndTime();
532    cellularCall.GetSpendTime();
533
534    CellularCallInfo csCallInfo = { .callType = CallType::TYPE_CS };
535    CellularCallInfo imsCallInfo = { .callType = CallType::TYPE_IMS };
536    CellularCallInfo errCallInfo = { .callType = CallType::TYPE_ERR_CALL };
537    cellularCall.Dial(csCallInfo);
538    cellularCall.Dial(imsCallInfo);
539    cellularCall.Dial(errCallInfo);
540
541    cellularCall.HangUp(csCallInfo, CallSupplementType::TYPE_HANG_UP_HOLD_WAIT);
542    cellularCall.HangUp(imsCallInfo, CallSupplementType::TYPE_HANG_UP_HOLD_WAIT);
543    cellularCall.HangUp(errCallInfo, CallSupplementType::TYPE_HANG_UP_HOLD_WAIT);
544
545    cellularCall.Reject(csCallInfo);
546    cellularCall.Reject(imsCallInfo);
547    cellularCall.Reject(errCallInfo);
548
549    cellularCall.Answer(csCallInfo);
550    cellularCall.Answer(imsCallInfo);
551    cellularCall.Answer(errCallInfo);
552
553    cellularCall.HoldCall(csCallInfo);
554    cellularCall.HoldCall(imsCallInfo);
555    cellularCall.HoldCall(errCallInfo);
556
557    cellularCall.UnHoldCall(csCallInfo);
558    cellularCall.UnHoldCall(imsCallInfo);
559    cellularCall.UnHoldCall(errCallInfo);
560
561    cellularCall.SwitchCall(csCallInfo);
562    cellularCall.SwitchCall(imsCallInfo);
563    cellularCall.SwitchCall(errCallInfo);
564
565    bool enabled = false;
566    std::string phoneNum = "000";
567    cellularCall.IsEmergencyPhoneNumber(INVALID_SLOTID, phoneNum, enabled);
568    ASSERT_EQ(cellularCall.IsEmergencyPhoneNumber(SIM1_SLOTID, phoneNum, enabled), TELEPHONY_SUCCESS);
569}
570
571/**
572 * @tc.number   Telephony_CellularCallService_002
573 * @tc.name     Test error branch
574 * @tc.desc     Function test
575 */
576HWTEST_F(BranchTest, Telephony_CellularCallService_002, Function | MediumTest | Level3)
577{
578    // AccessToken token;
579    CellularCallService cellularCall;
580    CellularCallInfo csCallInfo = { .callType = CallType::TYPE_CS };
581    CellularCallInfo imsCallInfo = { .callType = CallType::TYPE_IMS };
582    CellularCallInfo errCallInfo = { .callType = CallType::TYPE_ERR_CALL };
583    EmergencyCall ecc;
584    std::vector<EmergencyCall> eccVec;
585    eccVec.push_back(ecc);
586    cellularCall.SetEmergencyCallList(SIM1_SLOTID, eccVec);
587    cellularCall.CombineConference(csCallInfo);
588    cellularCall.CombineConference(imsCallInfo);
589    cellularCall.CombineConference(errCallInfo);
590
591    cellularCall.SeparateConference(csCallInfo);
592    cellularCall.SeparateConference(imsCallInfo);
593    cellularCall.SeparateConference(errCallInfo);
594
595    std::vector<std::string> numberList = { "111", "222" };
596    cellularCall.InviteToConference(SIM1_SLOTID, numberList);
597    cellularCall.KickOutFromConference(csCallInfo);
598    cellularCall.KickOutFromConference(imsCallInfo);
599    cellularCall.KickOutFromConference(errCallInfo);
600    cellularCall.HangUpAllConnection();
601    cellularCall.HangUpAllConnection(SIM1_SLOTID);
602
603    cellularCall.SetReadyToCall(SIM1_SLOTID, 0, true);
604    cellularCall.SetReadyToCall(SIM1_SLOTID, 1, true);
605    cellularCall.SetReadyToCall(SIM1_SLOTID, 3, true);
606    cellularCall.StartDtmf('*', csCallInfo);
607    cellularCall.StartDtmf('*', imsCallInfo);
608    cellularCall.StartDtmf('*', errCallInfo);
609    cellularCall.StopDtmf(csCallInfo);
610    cellularCall.StopDtmf(imsCallInfo);
611    cellularCall.StopDtmf(errCallInfo);
612
613    cellularCall.PostDialProceed(csCallInfo, true);
614    cellularCall.PostDialProceed(imsCallInfo, true);
615    cellularCall.PostDialProceed(errCallInfo, true);
616    cellularCall.SendDtmf('*', csCallInfo);
617    cellularCall.SendDtmf('*', imsCallInfo);
618    cellularCall.SendDtmf('*', errCallInfo);
619    std::string msg = "";
620    cellularCall.StartRtt(SIM1_SLOTID, msg);
621    ASSERT_NE(cellularCall.StopRtt(SIM1_SLOTID), TELEPHONY_SUCCESS);
622}
623
624/**
625 * @tc.number   Telephony_CellularCallService_003
626 * @tc.name     Test error branch
627 * @tc.desc     Function test
628 */
629HWTEST_F(BranchTest, Telephony_CellularCallService_003, Function | MediumTest | Level3)
630{
631    AccessToken token;
632    CellularCallService cellularCall;
633    CallTransferInfo cTInfoDisable = { .settingType = CallTransferSettingType::CALL_TRANSFER_DISABLE };
634    CallTransferInfo cTInfoEnable = { .settingType = CallTransferSettingType::CALL_TRANSFER_ENABLE };
635    cellularCall.SetCallTransferInfo(SIM1_SLOTID, cTInfoDisable);
636    cellularCall.SetCallTransferInfo(SIM1_SLOTID, cTInfoEnable);
637    bool result = false;
638    cellularCall.CanSetCallTransferTime(SIM1_SLOTID, result);
639    cellularCall.GetCallTransferInfo(SIM1_SLOTID, CallTransferType::TRANSFER_TYPE_UNCONDITIONAL);
640    cellularCall.SetCallWaiting(SIM1_SLOTID, true);
641    cellularCall.GetCallWaiting(SIM1_SLOTID);
642    CallRestrictionInfo crInfo;
643    cellularCall.SetCallRestriction(SIM1_SLOTID, crInfo);
644    cellularCall.GetCallRestriction(SIM1_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING);
645    std::string password = "1111";
646    cellularCall.SetCallRestrictionPassword(
647        SIM1_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING, password.c_str(), password.c_str());
648    cellularCall.SetDomainPreferenceMode(SIM1_SLOTID, 1);
649    cellularCall.GetDomainPreferenceMode(SIM1_SLOTID);
650    cellularCall.SetImsSwitchStatus(SIM1_SLOTID, true);
651    bool enabled = false;
652    cellularCall.GetImsSwitchStatus(SIM1_SLOTID, enabled);
653    std::string value = "";
654    cellularCall.SetImsConfig(SIM1_SLOTID, ImsConfigItem::ITEM_VIDEO_QUALITY, value);
655    int32_t state = 0;
656    cellularCall.SetVoNRState(SIM1_SLOTID, state);
657    cellularCall.GetVoNRState(SIM1_SLOTID, state);
658    cellularCall.SetImsConfig(SIM1_SLOTID, ImsConfigItem::ITEM_VIDEO_QUALITY, 1);
659    cellularCall.GetImsConfig(SIM1_SLOTID, ImsConfigItem::ITEM_VIDEO_QUALITY);
660    cellularCall.SetImsFeatureValue(SIM1_SLOTID, FeatureType::TYPE_VOICE_OVER_LTE, 1);
661    cellularCall.GetImsFeatureValue(SIM1_SLOTID, FeatureType::TYPE_VOICE_OVER_LTE);
662    std::string cameraId = "";
663    cellularCall.ControlCamera(SIM1_SLOTID, DEFAULT_INDEX, cameraId);
664    std::string surfaceId = "";
665    cellularCall.SetPreviewWindow(SIM1_SLOTID, DEFAULT_INDEX, surfaceId, nullptr);
666    cellularCall.SetDisplayWindow(SIM1_SLOTID, DEFAULT_INDEX, surfaceId, nullptr);
667    cellularCall.SetCameraZoom(1.0);
668    std::string path = "";
669    cellularCall.SetPausePicture(SIM1_SLOTID, DEFAULT_INDEX, path);
670    cellularCall.SetDeviceDirection(SIM1_SLOTID, DEFAULT_INDEX, 0);
671    CellularCallInfo cellularCallInfo;
672    InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, cellularCallInfo);
673    cellularCall.SendUpdateCallMediaModeRequest(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY);
674    cellularCall.SendUpdateCallMediaModeResponse(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY);
675    cellularCall.CancelCallUpgrade(SIM1_SLOTID, DEFAULT_INDEX);
676#ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
677    ASSERT_EQ(cellularCall.RequestCameraCapabilities(SIM1_SLOTID, DEFAULT_INDEX), INVALID_VALUE);
678#else
679    ASSERT_EQ(cellularCall.RequestCameraCapabilities(SIM1_SLOTID, DEFAULT_INDEX), TELEPHONY_SUCCESS);
680#endif
681}
682
683/**
684 * @tc.number   Telephony_CellularCallService_004
685 * @tc.name     Test error branch
686 * @tc.desc     Function test
687 */
688HWTEST_F(BranchTest, Telephony_CellularCallService_004, Function | MediumTest | Level3)
689{
690    // AccessToken token;
691    CellularCallService cellularCall;
692    cellularCall.SetMute(SIM1_SLOTID, 0);
693    cellularCall.GetMute(SIM1_SLOTID);
694    cellularCall.CloseUnFinishedUssd(SIM1_SLOTID);
695    std::vector<CellularCallInfo> infos = {};
696    cellularCall.ClearAllCalls(infos);
697    cellularCall.IsNeedIms(SIM1_SLOTID);
698    cellularCall.GetCsControl(SIM1_SLOTID);
699    cellularCall.GetImsControl(SIM1_SLOTID);
700    std::shared_ptr<CSControl> csControl;
701    cellularCall.SetCsControl(SIM1_SLOTID, csControl);
702    std::shared_ptr<IMSControl> imsControl;
703    cellularCall.SetImsControl(SIM1_SLOTID, imsControl);
704    cellularCall.GetHandler(SIM1_SLOTID);
705    cellularCall.SetSrvccState(SrvccState::SRVCC_NONE);
706    cellularCall.GetSrvccState();
707    cellularCall.RegisterHandler();
708#ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
709    cellularCall.StartCallManagerService();
710#endif
711    cellularCall.Init();
712    cellularCall.RegisterCoreServiceHandler();
713    cellularCall.CreateHandler();
714    cellularCall.SendEventRegisterHandler();
715
716    cellularCall.IsValidSlotId(SIM1_SLOTID);
717    CellularCallInfo imsCallInfo = { .callType = CallType::TYPE_IMS };
718    CellularCallInfo csCallInfo = { .callType = CallType::TYPE_CS };
719    cellularCall.UseImsForEmergency(imsCallInfo, true);
720    cellularCall.HandleCallManagerException();
721    cellularCall.HandleCellularControlException(imsCallInfo);
722    cellularCall.HandleCellularControlException(csCallInfo);
723    cellularCall.HangUpWithCellularCallRestart(infos);
724    cellularCall.SetControl(imsCallInfo);
725    cellularCall.SetControl(csCallInfo);
726
727    sptr<ICallStatusCallback> callback;
728    cellularCall.RegisterCallManagerCallBack(callback);
729    cellularCall.UnRegisterCallManagerCallBack();
730    cellularCall.HandlerResetUnRegister();
731    cellularCall.OnStop();
732    ASSERT_EQ(callback, nullptr);
733}
734
735/**
736 * @tc.number	Telephony_CellularCallSupplementRequestIms_001
737 * @tc.name 	Test error branch
738 * @tc.desc 	Function test
739 */
740HWTEST_F(BranchTest, Telephony_CellularCallSupplementRequestIms_001, Function | MediumTest | Level3)
741{
742    SupplementRequestIms SRequestIms;
743    CallTransferInfo CTransferInfo;
744    std::string fac = "";
745    SRequestIms.SetClipRequest(SIM1_SLOTID, ACTIVATE_ACTION, 0);
746    SRequestIms.GetClipRequest(SIM1_SLOTID, 0);
747    SRequestIms.SetClirRequest(SIM1_SLOTID, ACTIVATE_ACTION, 0);
748    SRequestIms.GetClirRequest(SIM1_SLOTID, 0);
749    SRequestIms.GetCallTransferRequest(SIM1_SLOTID, 0, 0);
750    SRequestIms.SetCallTransferRequest(SIM1_SLOTID, CTransferInfo, ACTIVATE_ACTION, 0);
751    bool enable = false;
752    SRequestIms.CanSetCallTransferTime(SIM1_SLOTID, enable);
753    SRequestIms.GetCallRestrictionRequest(SIM1_SLOTID, fac, 0);
754    std::string pw = "";
755    SRequestIms.SetCallRestrictionRequest(SIM1_SLOTID, fac, 0, pw, 0);
756    SRequestIms.SetCallWaitingRequest(SIM1_SLOTID, true, 0, 0);
757    SRequestIms.GetCallWaitingRequest(SIM1_SLOTID, 0);
758    SRequestIms.SetColrRequest(SIM1_SLOTID, 0, 0);
759    SRequestIms.GetColrRequest(SIM1_SLOTID, 0);
760    SRequestIms.SetColpRequest(SIM1_SLOTID, 0, 0);
761    SRequestIms.GetMMIHandler(SIM1_SLOTID);
762    ASSERT_NE(SRequestIms.GetColpRequest(SIM1_SLOTID, 0), TELEPHONY_SUCCESS);
763}
764
765/**
766 * @tc.number	Telephony_CellularCallbaseconnection_001
767 * @tc.name 	Test error branch
768 * @tc.desc 	Function test
769 */
770HWTEST_F(BranchTest, Telephony_CellularCallbaseconnection_001, Function | MediumTest | Level3)
771{
772    BaseConnection BConnection;
773    char c = ' ';
774    BConnection.postDialCalltate_ = PostDialCallState::POST_DIAL_CALL_CANCELED;
775    BConnection.ProcessNextChar(SIM1_SLOTID, c);
776    BConnection.GetLeftPostDialCallString();
777    BConnection.postDialCallString_ = "111111";
778    BConnection.ProcessNextChar(SIM1_SLOTID, c);
779    BConnection.postDialCalltate_ = PostDialCallState::POST_DIAL_CALL_NOT_STARTED;
780    BConnection.ProcessNextChar(SIM1_SLOTID, c);
781    BConnection.GetLeftPostDialCallString();
782}
783/**
784 * @tc.number   Telephony_CellularCallHiSysEvent_001
785 * @tc.name     Test error branch
786 * @tc.desc     Function test
787 */
788HWTEST_F(BranchTest, Telephony_CellularCallHiSysEvent_001, Function | MediumTest | Level3)
789{
790    // AccessToken token;
791    std::shared_ptr<CellularCallHiSysEvent> cellularCallHiSysEvent = std::make_shared<CellularCallHiSysEvent>();
792    std::string desc;
793    cellularCallHiSysEvent->WriteFoundationRestartFaultEvent(2);
794    CallBehaviorParameterInfo Info = { .callType = 1 };
795    CallResponseResult result = CallResponseResult::COMMAND_FAILURE;
796    cellularCallHiSysEvent->WriteDialCallBehaviorEvent(Info, result);
797    result = CallResponseResult::COMMAND_SUCCESS;
798    cellularCallHiSysEvent->WriteDialCallBehaviorEvent(Info, result);
799    Info = { .callType = 0 };
800    cellularCallHiSysEvent->WriteDialCallBehaviorEvent(Info, result);
801    Info = { .callType = 1 };
802    result = CallResponseResult::COMMAND_FAILURE;
803    cellularCallHiSysEvent->WriteHangUpCallBehaviorEvent(Info, result);
804    result = CallResponseResult::COMMAND_SUCCESS;
805    cellularCallHiSysEvent->WriteHangUpCallBehaviorEvent(Info, result);
806    Info = { .callType = 0 };
807    cellularCallHiSysEvent->WriteHangUpCallBehaviorEvent(Info, result);
808    cellularCallHiSysEvent->WriteIncomingCallFaultEvent(
809        0, 0, 0, static_cast<int32_t>(TELEPHONY_ERR_MEMCPY_FAIL), desc);
810    cellularCallHiSysEvent->WriteIncomingCallFaultEvent(0, 0, 0, -1, desc);
811    cellularCallHiSysEvent->JudgingIncomingTimeOut(0, 0, 0);
812    CallForwardingInfo cfInfo;
813    cellularCallHiSysEvent->GetCallForwardingInfo(cfInfo);
814    ASSERT_TRUE(desc.empty());
815}
816
817/**
818 * @tc.number   Telephony_CellularCallHiSysEvent_002
819 * @tc.name     Test error branch
820 * @tc.desc     Function test
821 */
822HWTEST_F(BranchTest, Telephony_CellularCallHiSysEvent_002, Function | MediumTest | Level3)
823{
824    // AccessToken token;
825    std::shared_ptr<CellularCallHiSysEvent> cellularCallHiSysEvent = std::make_shared<CellularCallHiSysEvent>();
826    CallErrorCode eventValue;
827    cellularCallHiSysEvent->TelephonyErrorCodeConversion(-1, eventValue);
828    cellularCallHiSysEvent->TelephonyErrorCodeConversion(
829        static_cast<int32_t>(TELEPHONY_ERR_LOCAL_PTR_NULL), eventValue);
830    cellularCallHiSysEvent->TelephonyErrorCodeConversion(
831        static_cast<int32_t>(TELEPHONY_ERR_ARGUMENT_INVALID), eventValue);
832    cellularCallHiSysEvent->TelephonyErrorCodeConversion(
833        static_cast<int32_t>(TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL), eventValue);
834    cellularCallHiSysEvent->TelephonyErrorCodeConversion(
835        static_cast<int32_t>(TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL), eventValue);
836    cellularCallHiSysEvent->TelephonyErrorCodeConversion(
837        static_cast<int32_t>(TELEPHONY_ERR_WRITE_DATA_FAIL), eventValue);
838    cellularCallHiSysEvent->TelephonyErrorCodeConversion(
839        static_cast<int32_t>(TELEPHONY_ERR_PERMISSION_ERR), eventValue);
840    cellularCallHiSysEvent->TelephonyErrorCodeConversion(static_cast<int32_t>(TELEPHONY_ERR_MEMSET_FAIL), eventValue);
841    cellularCallHiSysEvent->TelephonyErrorCodeConversion(static_cast<int32_t>(TELEPHONY_ERR_MEMCPY_FAIL), eventValue);
842    cellularCallHiSysEvent->CallDataErrorCodeConversion(-1, eventValue);
843    cellularCallHiSysEvent->CallDataErrorCodeConversion(static_cast<int32_t>(CALL_ERR_INVALID_SLOT_ID), eventValue);
844    cellularCallHiSysEvent->CallDataErrorCodeConversion(static_cast<int32_t>(CALL_ERR_INVALID_CALLID), eventValue);
845    cellularCallHiSysEvent->CallDataErrorCodeConversion(static_cast<int32_t>(CALL_ERR_PHONE_NUMBER_EMPTY), eventValue);
846    cellularCallHiSysEvent->CallDataErrorCodeConversion(
847        static_cast<int32_t>(CALL_ERR_NUMBER_OUT_OF_RANGE), eventValue);
848    cellularCallHiSysEvent->CallDataErrorCodeConversion(
849        static_cast<int32_t>(CALL_ERR_UNSUPPORTED_NETWORK_TYPE), eventValue);
850    cellularCallHiSysEvent->CallDataErrorCodeConversion(static_cast<int32_t>(CALL_ERR_INVALID_DIAL_SCENE), eventValue);
851    cellularCallHiSysEvent->CallDataErrorCodeConversion(
852        static_cast<int32_t>(CALL_ERR_INVALID_VIDEO_STATE), eventValue);
853    cellularCallHiSysEvent->CallDataErrorCodeConversion(static_cast<int32_t>(CALL_ERR_UNKNOW_DIAL_TYPE), eventValue);
854    cellularCallHiSysEvent->CallDataErrorCodeConversion(static_cast<int32_t>(CALL_ERR_UNKNOW_CALL_TYPE), eventValue);
855    cellularCallHiSysEvent->CallDataErrorCodeConversion(
856        static_cast<int32_t>(CALL_ERR_CALL_OBJECT_IS_NULL), eventValue);
857    cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(-1, eventValue);
858    cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(static_cast<int32_t>(CALL_ERR_DIAL_IS_BUSY), eventValue);
859    cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(
860        static_cast<int32_t>(CALL_ERR_ILLEGAL_CALL_OPERATION), eventValue);
861    cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(
862        static_cast<int32_t>(CALL_ERR_PHONE_CALLSTATE_NOTIFY_FAILED), eventValue);
863    cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(
864        static_cast<int32_t>(CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE), eventValue);
865    cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(
866        static_cast<int32_t>(CALL_ERR_CALL_COUNTS_EXCEED_LIMIT), eventValue);
867    ASSERT_NE(cellularCallHiSysEvent->CallInterfaceErrorCodeConversion(
868        static_cast<int32_t>(CALL_ERR_GET_RADIO_STATE_FAILED), eventValue), 0);
869}
870
871/**
872 * @tc.number	Telephony_CellularCallConnectionCs_001
873 * @tc.name 	Test error branch
874 * @tc.desc 	Function test
875 */
876HWTEST_F(BranchTest, Telephony_CellularCallConnectionCs_001, Function | MediumTest | Level3)
877{
878    CellularCallConnectionCS cellularCallConnectionCS;
879    DialRequestStruct dialRequestStruct;
880    cellularCallConnectionCS.DialRequest(SIM2_SLOTID, dialRequestStruct);
881    cellularCallConnectionCS.HangUpRequest(SIM2_SLOTID);
882    cellularCallConnectionCS.AnswerRequest(SIM2_SLOTID);
883    cellularCallConnectionCS.AnswerRequest(SIM1_SLOTID);
884    cellularCallConnectionCS.RejectRequest(SIM2_SLOTID);
885    cellularCallConnectionCS.HoldRequest(SIM2_SLOTID);
886    cellularCallConnectionCS.UnHoldCallRequest(SIM2_SLOTID);
887    cellularCallConnectionCS.SwitchCallRequest(SIM2_SLOTID);
888    cellularCallConnectionCS.CombineConferenceRequest(SIM2_SLOTID, 0);
889    cellularCallConnectionCS.SeparateConferenceRequest(SIM2_SLOTID, 0, 0);
890    cellularCallConnectionCS.CallSupplementRequest(SIM2_SLOTID, CallSupplementType::TYPE_DEFAULT);
891    char cDtmfCode = ' ';
892    cellularCallConnectionCS.SendDtmfRequest(SIM2_SLOTID, cDtmfCode, 0);
893    cellularCallConnectionCS.StartDtmfRequest(SIM2_SLOTID, cDtmfCode, 0);
894    cellularCallConnectionCS.StopDtmfRequest(SIM2_SLOTID, 0);
895    cellularCallConnectionCS.GetCsCallsDataRequest(SIM2_SLOTID, 0);
896    cellularCallConnectionCS.GetCallFailReasonRequest(SIM2_SLOTID);
897    ASSERT_EQ(cellularCallConnectionCS.ProcessPostDialCallChar(SIM1_SLOTID, cDtmfCode), TELEPHONY_SUCCESS);
898}
899
900/**
901 * @tc.number	Telephony_SupplementRequestCs_001
902 * @tc.name 	Test error branch
903 * @tc.desc 	Function test
904 */
905HWTEST_F(BranchTest, Telephony_SupplementRequestCs_001, Function | MediumTest | Level3)
906{
907    SupplementRequestCs supplementRequestCs;
908    std::string msg = "11111";
909    std::string fac = "";
910    std::string pw = "";
911    std::string oldPin = "123456";
912    std::string newPin = "789101";
913    std::string puk = "22222";
914    CallTransferParam callTransferParam;
915    ASSERT_EQ(supplementRequestCs.SendUssdRequest(SIM1_SLOTID, msg), TELEPHONY_ERR_LOCAL_PTR_NULL);
916    ASSERT_EQ(supplementRequestCs.CloseUnFinishedUssdRequest(SIM1_SLOTID), TELEPHONY_ERR_LOCAL_PTR_NULL);
917    ASSERT_EQ(supplementRequestCs.SetClirRequest(SIM1_SLOTID, ACTIVATE_ACTION, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
918    ASSERT_EQ(supplementRequestCs.GetClipRequest(SIM1_SLOTID, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
919    ASSERT_EQ(supplementRequestCs.GetClirRequest(SIM1_SLOTID, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
920    ASSERT_EQ(supplementRequestCs.SetCallTransferRequest(SIM1_SLOTID, callTransferParam, 0),
921        TELEPHONY_ERR_LOCAL_PTR_NULL);
922    ASSERT_EQ(supplementRequestCs.GetCallTransferRequest(SIM1_SLOTID, 0, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
923    ASSERT_EQ(supplementRequestCs.GetCallRestrictionRequest(SIM1_SLOTID, fac, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
924    ASSERT_EQ(supplementRequestCs.SetCallRestrictionRequest(SIM1_SLOTID, fac, 0, pw, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
925    ASSERT_EQ(supplementRequestCs.SetBarringPasswordRequest(SIM1_SLOTID, msg, 0, oldPin.c_str(), newPin.c_str()),
926        TELEPHONY_ERR_LOCAL_PTR_NULL);
927    ASSERT_EQ(supplementRequestCs.SetCallWaitingRequest(SIM1_SLOTID, true, 0, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
928    ASSERT_EQ(supplementRequestCs.AlterPinPassword(SIM1_SLOTID, newPin, oldPin), TELEPHONY_ERROR);
929    ASSERT_EQ(supplementRequestCs.UnlockPuk(SIM1_SLOTID, newPin, puk), TELEPHONY_ERROR);
930    ASSERT_EQ(supplementRequestCs.AlterPin2Password(SIM1_SLOTID, newPin, oldPin), TELEPHONY_ERROR);
931    ASSERT_EQ(supplementRequestCs.UnlockPuk2(SIM1_SLOTID, newPin, puk), TELEPHONY_ERROR);
932    ASSERT_EQ(supplementRequestCs.GetCallWaitingRequest(SIM1_SLOTID, 0), TELEPHONY_ERR_LOCAL_PTR_NULL);
933}
934
935/**
936 * @tc.number	Telephony_StandardizeUtils_001
937 * @tc.name 	Test error branch
938 * @tc.desc 	Function test
939 */
940HWTEST_F(BranchTest, Telephony_StandardizeUtils_001, Function | MediumTest | Level3)
941{
942    StandardizeUtils standardizeUtils;
943    std::string phoneString = {0};
944    std::string networkAddress = "1111111";
945    std::string postDial = "11111111";
946    ASSERT_EQ(standardizeUtils.RemoveSeparatorsPhoneNumber(phoneString), "");
947    phoneString = "1111111,123321";
948    standardizeUtils.ExtractAddressAndPostDial(phoneString, networkAddress, postDial);
949    ASSERT_EQ(postDial, "11111111,123321");
950    std::vector<std::string> split = standardizeUtils.Split(phoneString, ",");
951    ASSERT_FALSE(split.empty());
952}
953
954/**
955 * @tc.number	Telephony_MmiCodeUtils_001
956 * @tc.name 	Test error branch
957 * @tc.desc 	Function test
958 */
959HWTEST_F(BranchTest, Telephony_MmiCodeUtils_001, Function | MediumTest | Level3)
960{
961    MMICodeUtils mmiCodeUtils;
962    bool enable = false;
963    ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi("111111#", enable));
964    mmiCodeUtils.isNeedUseIms_ = true;
965    ASSERT_FALSE(mmiCodeUtils.ExecuteMmiCode(SIM1_SLOTID));
966    mmiCodeUtils.isNeedUseIms_ = false;
967    mmiCodeUtils.mmiData_.serviceCode = "11111";
968    ASSERT_FALSE(mmiCodeUtils.ExecuteMmiCode(SIM1_SLOTID));
969    mmiCodeUtils.mmiData_.serviceCode.clear();
970    mmiCodeUtils.mmiData_.fullString = "11111";
971    ASSERT_TRUE(mmiCodeUtils.ExecuteMmiCode(SIM1_SLOTID));
972    mmiCodeUtils.mmiData_.fullString.clear();
973    mmiCodeUtils.mmiData_.dialString = "11111#";
974    ASSERT_FALSE(mmiCodeUtils.RegexMatchMmi("111111#"));
975}
976
977/**
978 * @tc.number	Telephony_CellularCallRdbHelper_001
979 * @tc.name 	Test error branch
980 * @tc.desc 	Function test
981 */
982HWTEST_F(BranchTest, Telephony_CellularCallRdbHelper_001, Function | MediumTest | Level3)
983{
984    std::u16string u16Hplmn = u"";
985    CoreManagerInner::GetInstance().GetSimOperatorNumeric(SIM1_SLOTID, u16Hplmn);
986    std::string hplmn = Str16ToStr8(u16Hplmn);
987    std::vector<EccNum> eccVec;
988    ASSERT_NE(DelayedSingleton<CellularCallRdbHelper>::GetInstance()->QueryEccList(hplmn, eccVec), TELEPHONY_SUCCESS);
989}
990
991/**
992 * @tc.number	Telephony_CellularCallDumpHelper_001
993 * @tc.name 	Test error branch
994 * @tc.desc 	Function test
995 */
996HWTEST_F(BranchTest, Telephony_CellularCallDumpHelper_001, Function | MediumTest | Level3)
997{
998    CellularCallDumpHelper cellularCallDumpHelper;
999    std::vector<std::string> args = { "123456", "234567" };
1000    std::string result;
1001    cellularCallDumpHelper.WhetherHasSimCard(SIM1_SLOTID);
1002    ASSERT_NE(cellularCallDumpHelper.Dump(args, result), TELEPHONY_SUCCESS);
1003}
1004
1005/**
1006 * @tc.number	Telephony_EmergencyUtils_001
1007 * @tc.name 	Test error branch
1008 * @tc.desc 	Function test
1009 */
1010HWTEST_F(BranchTest, Telephony_EmergencyUtils_001, Function | MediumTest | Level3)
1011{
1012    EmergencyUtils emergencyUtils;
1013    std::string phoneNum = "1234567";
1014    bool enabled = false;
1015    ASSERT_EQ(emergencyUtils.IsEmergencyCall(SIM1_SLOTID, phoneNum, enabled), TELEPHONY_SUCCESS);
1016}
1017
1018} // namespace Telephony
1019} // namespace OHOS