• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "token.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 #include "ims_video_call_control.h"
44 
45 namespace OHOS {
46 namespace Telephony {
47 using namespace testing::ext;
48 
49 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
50 static const int32_t INVALID_VALUE = -1;
51 #endif
52 
53 namespace {
54 const int32_t INVALID_SLOTID = 2;
55 const int32_t SIM1_SLOTID = 0;
56 const int32_t SIM2_SLOTID = 1;
57 const std::string PHONE_NUMBER = "00000000";
58 const int32_t DEFAULT_INDEX = 1;
59 } // namespace
60 
61 class DemoHandler : public AppExecFwk::EventHandler {
62 public:
DemoHandler(std::shared_ptr<AppExecFwk::EventRunner> & runner)63     explicit DemoHandler(std::shared_ptr<AppExecFwk::EventRunner> &runner) : AppExecFwk::EventHandler(runner) {}
~DemoHandler()64     virtual ~DemoHandler() {}
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)65     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) {}
66 };
67 
68 class ZeroBranchTest : public testing::Test {
69 public:
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 
SetUpTestCase()80 void ZeroBranchTest::SetUpTestCase()
81 {
82     std::cout << "---------- CellularCallService start ------------" << std::endl;
83     DelayedSingleton<CellularCallService>::GetInstance()->Init();
84     DelayedSingleton<ImsCallClient>::GetInstance()->Init();
85 }
86 
TearDownTestCase()87 void ZeroBranchTest::TearDownTestCase() {}
88 
SetUp()89 void ZeroBranchTest::SetUp() {}
90 
TearDown()91 void ZeroBranchTest::TearDown() {}
92 
93 
InitCellularCallInfo(int32_t accountId,std::string phonenumber,CellularCallInfo & callInfo)94 int32_t ZeroBranchTest::InitCellularCallInfo(int32_t accountId, std::string phonenumber, CellularCallInfo &callInfo)
95 {
96     callInfo.accountId = accountId;
97     callInfo.slotId = accountId;
98     callInfo.index = accountId;
99     callInfo.callType = CallType::TYPE_IMS;
100     callInfo.videoState = 0; // 0 means audio
101     if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
102         return TELEPHONY_ERR_MEMSET_FAIL;
103     }
104     if (phonenumber.length() > static_cast<size_t>(kMaxNumberLen)) {
105         return CALL_ERR_NUMBER_OUT_OF_RANGE;
106     }
107     if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, phonenumber.c_str(), phonenumber.length()) != EOK) {
108         return TELEPHONY_ERR_MEMCPY_FAIL;
109     }
110     return TELEPHONY_SUCCESS;
111 }
112 
InitImsCallInfoList(ImsCurrentCallList & callInfoList,int32_t num)113 void ZeroBranchTest::InitImsCallInfoList(ImsCurrentCallList &callInfoList, int32_t num)
114 {
115     callInfoList.callSize = num;
116     ImsCurrentCall call;
117     int32_t callStateSum = 6;
118     for (int32_t i = 0; i < num; ++i) {
119         call.index = i;
120         call.state = i % callStateSum;
121         callInfoList.calls.push_back(call);
122     }
123 }
124 
MakeCallInfoParcelData(bool isError,MessageParcel & data)125 void ZeroBranchTest::MakeCallInfoParcelData(bool isError, MessageParcel &data)
126 {
127     if (isError) {
128         int32_t errorSize = 0;
129         data.WriteInt32(errorSize);
130     } else {
131         CellularCallInfo callInfo;
132         callInfo.slotId = -1;
133         int32_t size = 1;
134         data.WriteInt32(size);
135         data.WriteRawData(static_cast<const void *>(&callInfo), sizeof(CellularCallInfo));
136     }
137 }
138 
InitCsCallInfoList(CallInfoList & callInfoList,int32_t num)139 void ZeroBranchTest::InitCsCallInfoList(CallInfoList &callInfoList, int32_t num)
140 {
141     callInfoList.callSize = num;
142     CallInfo call;
143     int32_t callStateSum = 9;
144     for (int32_t i = 0; i < num; ++i) {
145         call.index = i;
146         call.state = i % callStateSum;
147         callInfoList.calls.push_back(call);
148     }
149 }
150 
151 /**
152  * @tc.number   Telephony_CellularCallConfig_001
153  * @tc.name     Test error branch
154  * @tc.desc     Function test
155  */
156 HWTEST_F(ZeroBranchTest, Telephony_CellularCallConfig_001, TestSize.Level1)
157 {
158     AccessToken token;
159     CellularCallConfig config;
160     config.SetDomainPreferenceMode(SIM1_SLOTID, 1);
161     config.SetDomainPreferenceMode(SIM1_SLOTID, -1);
162     config.GetDomainPreferenceMode(SIM1_SLOTID);
163     bool enabled = false;
164     config.SetImsSwitchStatus(INVALID_SLOTID, enabled);
165     config.SetImsSwitchStatus(SIM1_SLOTID, enabled);
166     config.volteSupported_[SIM1_SLOTID] = true;
167     config.volteSupported_[INVALID_SLOTID] = true;
168     config.volteProvisioningSupported_[SIM1_SLOTID] = true;
169     config.volteProvisioningSupported_[INVALID_SLOTID] = true;
170     config.SetImsSwitchStatus(INVALID_SLOTID, enabled);
171     config.SetImsSwitchStatus(SIM1_SLOTID, true);
172     config.volteSupported_[SIM1_SLOTID] = enabled;
173     config.volteSupported_[INVALID_SLOTID] = enabled;
174     config.volteProvisioningSupported_[SIM1_SLOTID] = enabled;
175     config.volteProvisioningSupported_[INVALID_SLOTID] = enabled;
176     config.GetImsSwitchStatus(SIM1_SLOTID, enabled);
177     config.saveImsSwitchStatusToLocalForPowerOn(SIM1_SLOTID);
178     config.saveImsSwitchStatusToLocal(SIM1_SLOTID, true);
179     config.GetImsSwitchStatus(SIM1_SLOTID, enabled);
180     int32_t state = 0;
181     config.SetVoNRSwitchStatus(SIM1_SLOTID, state);
182     config.SetVoNRSwitchStatus(INVALID_SLOTID, state);
183     config.GetVoNRSwitchStatus(SIM1_SLOTID, state);
184     config.GetVoNRSwitchStatus(SIM2_SLOTID, state);
185     config.GetDomainPreferenceModeResponse(SIM1_SLOTID, 1);
186     config.GetImsSwitchStatusResponse(SIM1_SLOTID, 1);
187     config.GetPreferenceMode(SIM1_SLOTID);
188     std::string value = "";
189     config.SetImsConfig(ImsConfigItem::ITEM_VIDEO_QUALITY, value);
190     config.SetImsConfig(ImsConfigItem::ITEM_VIDEO_QUALITY, 1);
191     config.GetImsConfig(ImsConfigItem::ITEM_VIDEO_QUALITY);
192     config.SetImsFeatureValue(FeatureType::TYPE_VOICE_OVER_LTE, 1);
193     int32_t res = config.GetImsFeatureValue(FeatureType::TYPE_VOICE_OVER_LTE);
194     config.HandleFactoryReset(0);
195     config.HandleFactoryReset(1);
196 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
197     ASSERT_EQ(res, CALL_ERR_RESOURCE_UNAVAILABLE);
198 #else
199     ASSERT_EQ(res, TELEPHONY_SUCCESS);
200 #endif
201 }
202 
203 /**
204  * @tc.number   Telephony_CellularCallConfig_002
205  * @tc.name     Test error branch
206  * @tc.desc     Function test
207  */
208 HWTEST_F(ZeroBranchTest, Telephony_CellularCallConfig_002, Function | MediumTest | Level3)
209 {
210     AccessToken token;
211     CellularCallConfig config;
212     config.SetMute(SIM1_SLOTID, 0);
213     config.GetMute(SIM1_SLOTID);
214     config.GetEmergencyCallList(SIM1_SLOTID);
215     std::vector<EmergencyCall> eccVec = {};
216     config.SetEmergencyCallList(SIM1_SLOTID, eccVec);
217     config.SetTempMode(SIM1_SLOTID);
218     config.InitModeActive();
219     EmergencyInfoList eccList;
220     config.UpdateEmergencyCallFromRadio(SIM1_SLOTID, eccList);
221     config.GetEccCallList(SIM1_SLOTID);
222     config.GetMcc(SIM1_SLOTID);
223     config.SetReadyToCall(SIM1_SLOTID, true);
224     config.SetReadyToCall(INVALID_SLOTID, true);
225     config.IsReadyToCall(SIM1_SLOTID);
226     config.IsReadyToCall(INVALID_SLOTID);
227 
228     config.HandleSimStateChanged(SIM1_SLOTID);
229     config.HandleSetLteImsSwitchResult(SIM1_SLOTID, ErrType::NONE);
230     config.HandleSetVoNRSwitchResult(SIM1_SLOTID, ErrType::NONE);
231     config.HandleSimRecordsLoaded(SIM1_SLOTID);
232     config.HandleOperatorConfigChanged(SIM1_SLOTID, 0);
233     config.UpdateImsConfiguration(SIM1_SLOTID, -1, false);
234     OperatorConfig poc;
235     config.ParseAndCacheOperatorConfigs(SIM1_SLOTID, poc);
236     config.UpdateImsCapabilities(SIM1_SLOTID, true, false, -1);
237     bool enabled = false;
238     config.SaveImsSwitch(SIM1_SLOTID, true);
239     config.IsUtProvisioned(SIM1_SLOTID);
240     config.utProvisioningSupported_[SIM1_SLOTID] = true;
241     config.IsUtProvisioned(SIM1_SLOTID);
242     config.utProvisioningSupported_[SIM1_SLOTID] = enabled;
243     config.ResetImsSwitch(SIM1_SLOTID);
244     config.HandleSimAccountLoaded(SIM1_SLOTID);
245     ASSERT_FALSE(config.utProvisioningSupported_[SIM1_SLOTID]);
246 }
247 
248 /**
249  * @tc.number   Telephony_CellularCallSupplement_001
250  * @tc.name     Test error branch
251  * @tc.desc     Function test
252  */
253 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_001, Function | MediumTest | Level3)
254 {
255     AccessToken token;
256     CellularCallSupplement callSup;
257     MMIData mmiDataEmp = {};
258     MMIData mmiDataAct = { .actionString = "*" };
259     MMIData mmiDataDeact = { .actionString = "#" };
260     MMIData mmiDataInterrogate = { .actionString = "*#" };
261     callSup.HandleClip(SIM1_SLOTID, mmiDataEmp);
262     callSup.HandleClip(SIM1_SLOTID, mmiDataAct);
263     callSup.HandleClip(SIM1_SLOTID, mmiDataDeact);
264     callSup.HandleClip(SIM1_SLOTID, mmiDataInterrogate);
265     callSup.HandleClir(SIM1_SLOTID, mmiDataEmp);
266     callSup.HandleClir(SIM1_SLOTID, mmiDataAct);
267     callSup.HandleClir(SIM1_SLOTID, mmiDataDeact);
268     callSup.HandleClir(SIM1_SLOTID, mmiDataInterrogate);
269     callSup.HandleColr(SIM1_SLOTID, mmiDataEmp);
270     callSup.HandleColr(SIM1_SLOTID, mmiDataAct);
271     callSup.HandleColr(SIM1_SLOTID, mmiDataDeact);
272     callSup.HandleColr(SIM1_SLOTID, mmiDataInterrogate);
273     callSup.HandleColp(SIM1_SLOTID, mmiDataEmp);
274     callSup.HandleColp(SIM1_SLOTID, mmiDataAct);
275     callSup.HandleColp(SIM1_SLOTID, mmiDataDeact);
276     callSup.HandleColp(SIM1_SLOTID, mmiDataInterrogate);
277     callSup.HandleCallTransfer(SIM1_SLOTID, mmiDataEmp);
278     callSup.HandleCallTransfer(SIM1_SLOTID, mmiDataInterrogate);
279     callSup.HandleCallTransfer(SIM1_SLOTID, mmiDataAct);
280     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataEmp);
281     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataAct);
282     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataDeact);
283     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataInterrogate);
284     callSup.HandleCallWaiting(SIM1_SLOTID, mmiDataEmp);
285     callSup.HandleCallWaiting(SIM1_SLOTID, mmiDataAct);
286     callSup.HandleCallWaiting(SIM1_SLOTID, mmiDataDeact);
287     ASSERT_EQ(callSup.ObtainCause("002"), static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_ALL));
288     ASSERT_EQ(callSup.ObtainCause("004"), static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_CONDITIONAL));
289     ASSERT_FALSE(mmiDataAct.actionString.empty());
290 }
291 
292 /**
293  * @tc.number   Telephony_CellularCallSupplement_002
294  * @tc.name     Test error branch
295  * @tc.desc     Function test
296  */
297 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_002, Function | MediumTest | Level3)
298 {
299     AccessToken token;
300     CellularCallSupplement callSup;
301     callSup.SendUssd(SIM1_SLOTID, "*#21#");
302     PinPukResponse pinPuk;
303     callSup.EventSetPinPuk(pinPuk);
304     MMIData mmiDataPin = { .serviceInfoA = "1234", .serviceInfoB = "1111", .serviceInfoC = "1111" };
305     callSup.AlterPinPassword(SIM1_SLOTID, mmiDataPin);
306     callSup.UnlockPuk(SIM1_SLOTID, mmiDataPin);
307     callSup.AlterPin2Password(SIM1_SLOTID, mmiDataPin);
308     callSup.UnlockPuk2(SIM1_SLOTID, mmiDataPin);
309     mmiDataPin = { .serviceInfoA = "1234", .serviceInfoB = "1111", .serviceInfoC = "1112" };
310     callSup.AlterPinPassword(SIM1_SLOTID, mmiDataPin);
311     callSup.UnlockPuk(SIM1_SLOTID, mmiDataPin);
312     callSup.AlterPin2Password(SIM1_SLOTID, mmiDataPin);
313     callSup.UnlockPuk2(SIM1_SLOTID, mmiDataPin);
314     mmiDataPin = { .serviceInfoA = "1234", .serviceInfoB = "1111", .serviceInfoC = "111111111" };
315     callSup.AlterPinPassword(SIM1_SLOTID, mmiDataPin);
316     callSup.UnlockPuk(SIM1_SLOTID, mmiDataPin);
317     callSup.AlterPin2Password(SIM1_SLOTID, mmiDataPin);
318     callSup.UnlockPuk2(SIM1_SLOTID, mmiDataPin);
319     callSup.CloseUnFinishedUssd(SIM1_SLOTID);
320     GetClipResult getClipResult;
321     std::string message = "";
322     callSup.EventGetClip(getClipResult, message, 0);
323     callSup.EventGetClip(getClipResult, message, 1);
324     callSup.EventSetClip(0, message, 0, 1);
325     callSup.EventSetClip(0, message, 1, 1);
326     GetClirResult getClirResult;
327     callSup.EventGetClir(getClirResult, message, 0);
328     callSup.EventGetClir(getClirResult, message, 1);
329     callSup.EventSetClir(0, message, 0, 1);
330     callSup.EventSetClir(0, message, 1, 1);
331     GetColrResult getColrResult;
332     callSup.EventGetColr(getColrResult, message, 0);
333     callSup.EventGetColr(getColrResult, message, 1);
334     callSup.EventSetColr(0, message, 0, 1);
335     callSup.EventSetColr(0, message, 1, 1);
336     ASSERT_TRUE(mmiDataPin.actionString.empty());
337 }
338 
339 /**
340  * @tc.number   Telephony_CellularCallSupplement_003
341  * @tc.name     Test error branch
342  * @tc.desc     Function test
343  */
344 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_003, Function | MediumTest | Level3)
345 {
346     AccessToken token;
347     CellularCallSupplement callSup;
348     GetColpResult getColpResult;
349     std::string message = "";
350     callSup.EventGetColp(getColpResult, message, 0);
351     callSup.EventGetColp(getColpResult, message, 1);
352     callSup.EventSetColp(0, message, 0, 1);
353     callSup.EventSetColp(0, message, 1, 1);
354     CallRestrictionResult callResResult;
355     callSup.EventGetCallRestriction(callResResult, message, 0);
356     callSup.EventGetCallRestriction(callResResult, message, 1);
357     callResResult.status = 1;
358     callSup.EventGetCallRestriction(callResResult, message, 0);
359     callResResult.result.result = 1;
360     callSup.EventGetCallRestriction(callResResult, message, 0);
361     callSup.EventSetCallRestriction(0, message, 0, 1);
362     callSup.EventSetCallRestriction(0, message, 1, 1);
363     callSup.EventSetBarringPassword(0, message, 0);
364     callSup.EventSetBarringPassword(0, message, 1);
365     callSup.EventSetCallWaiting(0, message, 0, 1);
366     callSup.EventSetCallWaiting(0, message, 1, 1);
367     CallForwardQueryInfoList cFQueryList;
368     callSup.EventGetCallTransferInfo(cFQueryList, message, 0);
369     CallForwardQueryResult queryResult;
370     callSup.BuildCallForwardQueryInfo(queryResult, message, 0);
371     callSup.BuildCallForwardQueryInfo(queryResult, message, 1);
372     queryResult.classx = 1;
373     callSup.BuildCallForwardQueryInfo(queryResult, message, 0);
374     queryResult.status = 1;
375     callSup.BuildCallForwardQueryInfo(queryResult, message, 0);
376     queryResult.reason = 2;
377     callSup.BuildCallForwardQueryInfo(queryResult, message, 0);
378     std::string targetNumber = "1234567";
379     callSup.EventSetCallTransferInfo(0, message, 0, 1, targetNumber);
380     callSup.EventSetCallTransferInfo(0, message, 1, 1, targetNumber);
381     RadioResponseInfo responseInfo;
382     callSup.EventSendUssd(responseInfo);
383     SsNoticeInfo ssNoticeInfo;
384     callSup.EventSsNotify(ssNoticeInfo);
385     UssdNoticeInfo ussdNoticeInfo;
386     callSup.EventUssdNotify(ussdNoticeInfo, SIM1_SLOTID);
387     RadioResponseInfo response;
388     callSup.EventCloseUnFinishedUssd(response);
389     callSup.GetCallTransferInfo(SIM1_SLOTID, CallTransferType::TRANSFER_TYPE_UNCONDITIONAL);
390     ASSERT_EQ(callSup.GetCallTransferInfo(SIM2_SLOTID, CallTransferType::TRANSFER_TYPE_UNCONDITIONAL),
391         TELEPHONY_ERR_LOCAL_PTR_NULL);
392 }
393 
394 /**
395  * @tc.number   Telephony_CellularCallSupplement_004
396  * @tc.name     Test error branch
397  * @tc.desc     Function test
398  */
399 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_004, Function | MediumTest | Level3)
400 {
401     AccessToken token;
402     CellularCallSupplement callSup;
403     CallWaitResult waitingInfo;
404     std::string message = "";
405     callSup.EventGetCallWaiting(waitingInfo, message, 0);
406     callSup.EventGetCallWaiting(waitingInfo, message, 1);
407     waitingInfo.status =1;
408     callSup.EventGetCallWaiting(waitingInfo, message, 0);
409     waitingInfo.classCw =1;
410     callSup.EventGetCallWaiting(waitingInfo, message, 0);
411     waitingInfo.classCw =4;
412     callSup.EventGetCallWaiting(waitingInfo, message, 0);
413     waitingInfo.classCw =8;
414     callSup.EventGetCallWaiting(waitingInfo, message, 0);
415     waitingInfo.classCw =16;
416     callSup.EventGetCallWaiting(waitingInfo, message, 0);
417     waitingInfo.classCw =32;
418     callSup.EventGetCallWaiting(waitingInfo, message, 0);
419     waitingInfo.classCw =64;
420     callSup.EventGetCallWaiting(waitingInfo, message, 0);
421     waitingInfo.classCw =128;
422     callSup.EventGetCallWaiting(waitingInfo, message, 0);
423     CallTransferInfo cfInfo;
424     callSup.SetCallTransferInfo(SIM1_SLOTID, cfInfo);
425     strcpy_s(cfInfo.transferNum, kMaxNumberLen + 1, "111");
426     callSup.SetCallTransferInfo(SIM1_SLOTID, cfInfo);
427     callSup.SetCallTransferInfo(SIM2_SLOTID, cfInfo);
428     auto utCommand = std::make_shared<SsRequestCommand>();
429     callSup.SetCallTransferInfoByIms(SIM1_SLOTID, cfInfo, utCommand);
430     callSup.SetCallTransferInfoByIms(SIM2_SLOTID, cfInfo, utCommand);
431     bool activate = false;
432     callSup.SetCallWaiting(SIM1_SLOTID, activate);
433     callSup.SetCallWaiting(SIM2_SLOTID, activate);
434     callSup.GetCallWaiting(SIM1_SLOTID);
435     callSup.GetCallWaiting(SIM2_SLOTID);
436     CallRestrictionInfo crInfo;
437     callSup.SetCallRestriction(SIM1_SLOTID, crInfo);
438     callSup.SetCallRestriction(SIM2_SLOTID, crInfo);
439     auto crCommand = std::make_shared<SsRequestCommand>();
440     std::string info(crInfo.password);
441     std::string fac("AO");
442     callSup.SetCallRestrictionByIms(SIM1_SLOTID, fac, static_cast<int32_t>(crInfo.mode), info, crCommand);
443     callSup.SetCallRestrictionByIms(SIM2_SLOTID, fac, static_cast<int32_t>(crInfo.mode), info, crCommand);
444     callSup.GetCallRestriction(SIM1_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING);
445     callSup.GetCallRestriction(SIM2_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING);
446     callSup.SetBarringPassword(SIM1_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING, "1111", "0000");
447     ASSERT_NE(callSup.SetBarringPassword(SIM2_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING,
448         "1111", "0000"), TELEPHONY_SUCCESS);
449 }
450 
451 /**
452  * @tc.number   Telephony_CellularCallSupplement_005
453  * @tc.name     Test error branch
454  * @tc.desc     Function test
455  */
456 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_005, Function | MediumTest | Level3)
457 {
458     AccessToken token;
459     CellularCallSupplement callSup;
460     MMIData mmiDataEmp = {};
461     MMIData mmiDataAct = { .actionString = "*" };
462     MMIData mmiDataDeact = { .actionString = "#" };
463     MMIData mmiDataInterrogate = { .actionString = "*#" };
464     callSup.HandleClip(SIM2_SLOTID, mmiDataEmp);
465     callSup.HandleClip(SIM2_SLOTID, mmiDataAct);
466     callSup.HandleClip(SIM2_SLOTID, mmiDataDeact);
467     callSup.HandleClip(SIM2_SLOTID, mmiDataInterrogate);
468     callSup.HandleColr(SIM2_SLOTID, mmiDataEmp);
469     callSup.HandleColr(SIM2_SLOTID, mmiDataAct);
470     callSup.HandleColr(SIM2_SLOTID, mmiDataDeact);
471     callSup.HandleColr(SIM2_SLOTID, mmiDataInterrogate);
472     callSup.HandleColp(SIM2_SLOTID, mmiDataEmp);
473     callSup.HandleColp(SIM2_SLOTID, mmiDataAct);
474     callSup.HandleColp(SIM2_SLOTID, mmiDataDeact);
475     callSup.HandleColp(SIM2_SLOTID, mmiDataInterrogate);
476     callSup.HandleCallTransfer(SIM2_SLOTID, mmiDataEmp);
477     callSup.HandleCallTransfer(SIM2_SLOTID, mmiDataInterrogate);
478     callSup.HandleCallTransfer(SIM2_SLOTID, mmiDataAct);
479     callSup.HandleCallRestriction(SIM2_SLOTID, mmiDataEmp);
480     callSup.HandleCallRestriction(SIM2_SLOTID, mmiDataAct);
481     callSup.HandleCallRestriction(SIM2_SLOTID, mmiDataDeact);
482     callSup.HandleCallRestriction(SIM2_SLOTID, mmiDataInterrogate);
483     callSup.HandleCallWaiting(SIM2_SLOTID, mmiDataEmp);
484     callSup.HandleCallWaiting(SIM2_SLOTID, mmiDataAct);
485     callSup.HandleCallWaiting(SIM2_SLOTID, mmiDataDeact);
486     bool enable = false;
487 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
488     ASSERT_EQ(callSup.CanSetCallTransferTime(SIM1_SLOTID, enable), CALL_ERR_RESOURCE_UNAVAILABLE);
489 #else
490     ASSERT_EQ(callSup.CanSetCallTransferTime(SIM1_SLOTID, enable), TELEPHONY_SUCCESS);
491 #endif
492 }
493 
494 /**
495  * @tc.number   Telephony_CellularCallSupplement_006
496  * @tc.name     Test error branch
497  * @tc.desc     Function test
498  */
499 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_006, Function | MediumTest | Level3)
500 {
501     AccessToken token;
502     CellularCallSupplement callSup;
503     MMIData mmiDataEmp = {};
504     MMIData mmiDataAct = { .actionString = "*" };
505     MMIData mmiDataDeact = { .actionString = "#" };
506     MMIData mmiDataInterrogate = { .actionString = "*#" };
507     EventFwk::MatchingSkills matchingSkills;
508     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
509     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
510     auto handler = std::make_shared<CellularCallHandler>(subscriberInfo);
511     auto callClient = DelayedSingleton<SatelliteCallClient>::GetInstance();
512     ASSERT_EQ(callClient->RegisterSatelliteCallCallbackHandler(SIM1_SLOTID, handler), TELEPHONY_SUCCESS);
513     callSup.HandleClip(SIM1_SLOTID, mmiDataAct);
514     callSup.HandleClip(SIM1_SLOTID, mmiDataDeact);
515     callSup.HandleClip(SIM1_SLOTID, mmiDataInterrogate);
516     callSup.HandleColr(SIM1_SLOTID, mmiDataAct);
517     callSup.HandleColr(SIM1_SLOTID, mmiDataDeact);
518     callSup.HandleColr(SIM1_SLOTID, mmiDataInterrogate);
519     callSup.HandleColp(SIM1_SLOTID, mmiDataAct);
520     callSup.HandleColp(SIM1_SLOTID, mmiDataDeact);
521     callSup.HandleColp(SIM1_SLOTID, mmiDataInterrogate);
522     int32_t cause = 0;
523     callSup.HandleGetCallTransfer(SIM1_SLOTID, cause);
524     int32_t serviceCode = 0;
525     std::string phoneNumber("1234567890");
526     CallTransferSettingType callTransferAction = CallTransferSettingType::CALL_TRANSFER_DISABLE;
527     callSup.HandleSetCallTransfer(SIM1_SLOTID, serviceCode, cause, phoneNumber, callTransferAction);
528     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataAct);
529     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataDeact);
530     callSup.HandleCallRestriction(SIM1_SLOTID, mmiDataInterrogate);
531     callSup.HandleCallWaiting(SIM1_SLOTID, mmiDataAct);
532     callSup.HandleCallWaiting(SIM1_SLOTID, mmiDataDeact);
533     callSup.HandleCallWaiting(SIM1_SLOTID, mmiDataInterrogate);
534 }
535 
536 /**
537  * @tc.number   Telephony_CellularCallSupplement_007
538  * @tc.name     Test error branch
539  * @tc.desc     Function test
540  */
541 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_007, Function | MediumTest | Level3)
542 {
543     AccessToken token;
544     CellularCallSupplement callSup;
545     MMIData mmiDataEmp = {};
546     MMIData mmiDataAct = { .actionString = "*" };
547     MMIData mmiDataDeact = { .actionString = "#" };
548     MMIData mmiDataInterrogate = { .actionString = "*#" };
549     EventFwk::MatchingSkills matchingSkills;
550     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
551     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
552     auto handler = std::make_shared<CellularCallHandler>(subscriberInfo);
553     auto callClient = DelayedSingleton<SatelliteCallClient>::GetInstance();
554     ASSERT_EQ(callClient->RegisterSatelliteCallCallbackHandler(SIM1_SLOTID, handler), TELEPHONY_SUCCESS);
555     std::string serviceInfoB("10");
556     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 13);
557     serviceInfoB = "11";
558     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 1);
559     serviceInfoB = "12";
560     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 12);
561     serviceInfoB = "13";
562     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 4);
563     serviceInfoB = "16";
564     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 8);
565     serviceInfoB = "19";
566     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 5);
567     serviceInfoB = "20";
568     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 48);
569     serviceInfoB = "21";
570     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 160);
571     serviceInfoB = "22";
572     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 80);
573     serviceInfoB = "24";
574     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 16);
575     serviceInfoB = "25";
576     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 32);
577     serviceInfoB = "99";
578     ASSERT_EQ(callSup.ObtainServiceCode(serviceInfoB), 64);
579     std::string phoneNumber("1234");
580     CallTransferSettingType callTransferAction;
581     ASSERT_EQ(callSup.ObtainCallTrasferAction("*", phoneNumber, callTransferAction), TELEPHONY_SUCCESS);
582     ASSERT_EQ(callSup.ObtainCallTrasferAction("**", phoneNumber, callTransferAction), TELEPHONY_SUCCESS);
583     ASSERT_EQ(callSup.ObtainCallTrasferAction("#", phoneNumber, callTransferAction), TELEPHONY_SUCCESS);
584     ASSERT_EQ(callSup.ObtainCallTrasferAction("##", phoneNumber, callTransferAction), TELEPHONY_SUCCESS);
585     ASSERT_EQ(callSup.ObtainCause("21"), static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_UNCONDITIONAL));
586     ASSERT_EQ(callSup.ObtainCause("61"), static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_NO_REPLY));
587     ASSERT_EQ(callSup.ObtainCause("62"), static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_NOT_REACHABLE));
588     ASSERT_EQ(callSup.ObtainCause("67"), static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_BUSY));
589     ASSERT_EQ(callSup.ObtainCause("99"), TELEPHONY_ERROR);
590 }
591 
592 /**
593  * @tc.number   Telephony_CellularCallSupplement_008
594  * @tc.name     Test error branch
595  * @tc.desc     Function test
596  */
597 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_008, Function | MediumTest | Level3)
598 {
599     AccessToken token;
600     CellularCallSupplement callSup;
601     EventFwk::MatchingSkills matchingSkills;
602     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
603     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
604     auto handler = std::make_shared<CellularCallHandler>(subscriberInfo);
605     auto callClient = DelayedSingleton<SatelliteCallClient>::GetInstance();
606     ASSERT_EQ(callClient->RegisterSatelliteCallCallbackHandler(SIM1_SLOTID, handler), TELEPHONY_SUCCESS);
607     ASSERT_EQ(callSup.ObtainBarringInstallation("33"), "AO");
608     ASSERT_EQ(callSup.ObtainBarringInstallation("331"), "OI");
609     ASSERT_EQ(callSup.ObtainBarringInstallation("332"), "OX");
610     ASSERT_EQ(callSup.ObtainBarringInstallation("351"), "IR");
611     ASSERT_EQ(callSup.ObtainBarringInstallation("35"), "AI");
612     ASSERT_EQ(callSup.ObtainBarringInstallation("330"), "AB");
613     ASSERT_EQ(callSup.ObtainBarringInstallation("333"), "AG");
614     ASSERT_EQ(callSup.ObtainBarringInstallation("353"), "AC");
615     ASSERT_EQ(callSup.ObtainBarringInstallation("1000"), "");
616     std::string fac;
617     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_ALL_OUTGOING),
618         TELEPHONY_SUCCESS);
619     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_INTERNATIONAL),
620         TELEPHONY_SUCCESS);
621     ASSERT_EQ(callSup.CheckCallRestrictionType(fac,
622         CallRestrictionType::RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME), TELEPHONY_SUCCESS);
623     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING),
624         TELEPHONY_SUCCESS);
625     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_ROAMING_INCOMING),
626         TELEPHONY_SUCCESS);
627     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_ALL_CALLS),
628         TELEPHONY_SUCCESS);
629     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_OUTGOING_SERVICES),
630         TELEPHONY_SUCCESS);
631     ASSERT_EQ(callSup.CheckCallRestrictionType(fac, CallRestrictionType::RESTRICTION_TYPE_INCOMING_SERVICES),
632         TELEPHONY_SUCCESS);
633     MmiCodeInfo mmiCodeInfo;
634     SsNoticeInfo ssNoticeInfo;
635     ssNoticeInfo.result = 0;
636     callSup.GetMessage(mmiCodeInfo, ssNoticeInfo);
637     ssNoticeInfo.result = 1;
638     ssNoticeInfo.serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_UNCONDITIONAL);
639     callSup.GetMessage(mmiCodeInfo, ssNoticeInfo);
640     ssNoticeInfo.serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_BUSY);
641     callSup.GetMessage(mmiCodeInfo, ssNoticeInfo);
642     ssNoticeInfo.serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_NO_REPLY);
643     callSup.GetMessage(mmiCodeInfo, ssNoticeInfo);
644     ssNoticeInfo.serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_NOT_REACHABLE);
645     callSup.GetMessage(mmiCodeInfo, ssNoticeInfo);
646 }
647 
648 /**
649  * @tc.number   Telephony_CellularCallSupplement_009
650  * @tc.name     Test error branch
651  * @tc.desc     Function test
652  */
653 HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_009, Function | MediumTest | Level3)
654 {
655     AccessToken token;
656     CellularCallSupplement callSup;
657     MMIData mmiDataAct = { .actionString = "*" };
658     auto command = std::make_shared<SsRequestCommand>();
659     CallTransferInfo cfInfo;
660 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
661     ASSERT_EQ(callSup.SetCallTransferInfoByIms(SIM1_SLOTID, cfInfo, command), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
662 #else
663     ASSERT_EQ(callSup.SetCallTransferInfoByIms(SIM1_SLOTID, cfInfo, command), TELEPHONY_SUCCESS);
664 #endif
665     ASSERT_EQ(callSup.SetCallTransferInfo(SIM1_SLOTID, cfInfo), TELEPHONY_ERR_ARGUMENT_INVALID);
666     ASSERT_NE(callSup.GetCallTransferInfo(SIM1_SLOTID, CallTransferType::TRANSFER_TYPE_UNCONDITIONAL),
667         TELEPHONY_SUCCESS);
668     bool activate = true;
669     ASSERT_EQ(callSup.SetCallWaiting(SIM1_SLOTID, activate), CALL_ERR_UNSUPPORTED_NETWORK_TYPE);
670     ASSERT_EQ(callSup.GetCallWaiting(SIM1_SLOTID), CALL_ERR_UNSUPPORTED_NETWORK_TYPE);
671     CallRestrictionInfo cRInfo;
672     std::string info(cRInfo.password);
673     std::string fac("AO");
674 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
675     ASSERT_EQ(callSup.SetCallRestrictionByIms(SIM1_SLOTID, fac, static_cast<int32_t>(cRInfo.mode), info, command),
676         TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
677 #else
678     ASSERT_EQ(callSup.SetCallRestrictionByIms(SIM1_SLOTID, fac, static_cast<int32_t>(cRInfo.mode), info, command),
679         TELEPHONY_SUCCESS);
680 #endif
681     ASSERT_EQ(callSup.GetCallRestriction(SIM1_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING),
682         CALL_ERR_UNSUPPORTED_NETWORK_TYPE);
683     ASSERT_EQ(callSup.SetBarringPassword(SIM1_SLOTID, CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING,
684         "1111", "0000"), CALL_ERR_UNSUPPORTED_NETWORK_TYPE);
685     ASSERT_EQ(callSup.SetCallRestriction(SIM1_SLOTID, cRInfo), CALL_ERR_UNSUPPORTED_NETWORK_TYPE);
686     callSup.AlterPinPassword(SIM1_SLOTID, mmiDataAct);
687     callSup.UnlockPuk(SIM1_SLOTID, mmiDataAct);
688     callSup.AlterPin2Password(SIM1_SLOTID, mmiDataAct);
689     callSup.UnlockPuk2(SIM1_SLOTID, mmiDataAct);
690     ASSERT_FALSE(callSup.IsVaildPinOrPuk("123", "123"));
691     ASSERT_FALSE(callSup.IsVaildPinOrPuk("1234567", "123"));
692     ASSERT_TRUE(callSup.IsVaildPinOrPuk("1234567", "1234567"));
693 }
694 
695 /**
696  * @tc.number   Telephony_CellularCallCsControl_001
697  * @tc.name     Test error branch
698  * @tc.desc     Function test
699  */
700 HWTEST_F(ZeroBranchTest, Telephony_CellularCallCsControl_001, Function | MediumTest | Level3)
701 {
702     AccessToken token;
703     CSControl csControl;
704     CellularCallInfo cellularCallInfo;
705     InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, cellularCallInfo);
706     CallInfoList callInfoList;
707     csControl.ReportCsCallsData(SIM1_SLOTID, callInfoList);
708     csControl.connectionMap_.insert(std::make_pair(1, CellularCallConnectionCS()));
709     csControl.ReportCsCallsData(SIM1_SLOTID, callInfoList);
710     csControl.connectionMap_.insert(std::make_pair(1, CellularCallConnectionCS()));
711     InitCsCallInfoList(callInfoList, 5);
712     csControl.ReportCsCallsData(SIM1_SLOTID, callInfoList);
713     csControl.connectionMap_.clear();
714     csControl.ReportCsCallsData(SIM1_SLOTID, callInfoList);
715     bool enabled = false;
716     csControl.Dial(cellularCallInfo, enabled);
717     csControl.DialCdma(cellularCallInfo);
718     csControl.DialGsm(cellularCallInfo);
719     csControl.CalculateInternationalRoaming(SIM1_SLOTID);
720     csControl.Answer(cellularCallInfo);
721     csControl.Reject(cellularCallInfo);
722     csControl.SeparateConference(SIM1_SLOTID, PHONE_NUMBER, 1);
723     csControl.SeparateConference(SIM1_SLOTID, "", 1);
724     int32_t invlaidCallType = -1;
725     csControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_DEFAULT);
726     csControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
727     csControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ALL);
728     csControl.HangUp(cellularCallInfo, static_cast<CallSupplementType>(invlaidCallType));
729     csControl.HoldCall(SIM1_SLOTID);
730     csControl.UnHoldCall(SIM1_SLOTID);
731     csControl.SwitchCall(SIM1_SLOTID);
732     csControl.CombineConference(SIM1_SLOTID);
733     csControl.HangUpAllConnection(SIM1_SLOTID);
734     csControl.GetConnectionMap();
735     csControl.ReportHangUpInfo(SIM1_SLOTID);
736     csControl.ReportIncomingInfo(SIM1_SLOTID, callInfoList);
737     csControl.ReportUpdateInfo(SIM1_SLOTID, callInfoList);
738     CallInfo callInfo;
739     csControl.EncapsulationCallReportInfo(SIM1_SLOTID, callInfo);
740     std::string phoneNum = "00000000";
741     CLIRMode clirMode = CLIRMode::DEFAULT;
742     int res = csControl.EncapsulateDialCommon(SIM1_SLOTID, phoneNum, clirMode);
743     CallsReportInfo callsReportInfo;
744     csControl.DeleteConnection(callsReportInfo, callInfoList);
745     csControl.ReleaseAllConnection();
746     ASSERT_EQ(res, TELEPHONY_SUCCESS);
747 }
748 
749 /**
750  * @tc.number   Telephony_CellularCallCsControl_002
751  * @tc.name     Test error branch
752  * @tc.desc     Function test
753  */
754 HWTEST_F(ZeroBranchTest, Telephony_CellularCallCsControl_002, Function | MediumTest | Level3)
755 {
756     AccessToken token;
757     CSControl csControl;
758     CellularCallInfo cellularCallInfo;
759     InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, cellularCallInfo);
760     CellularCallInfo cellularCallInfo_new;
761     cellularCallInfo_new.callType = CallType::TYPE_CS;
762     std::vector<CellularCallInfo> infos;
763     bool enabled = false;
764     infos.emplace_back(cellularCallInfo);
765     infos.emplace_back(cellularCallInfo_new);
766     csControl.PostDialProceed(cellularCallInfo, true);
767     csControl.PostDialProceed(cellularCallInfo, enabled);
768     csControl.ExecutePostDial(SIM1_SLOTID, 0);
769     csControl.connectionMap_.insert(std::make_pair(1, CellularCallConnectionCS()));
770     cellularCallInfo.index = 1;
771     csControl.Answer(cellularCallInfo);
772     csControl.PostDialProceed(cellularCallInfo, true);
773     csControl.ExecutePostDial(SIM1_SLOTID, 0);
774     csControl.ExecutePostDial(SIM1_SLOTID, 1);
775     csControl.connectionMap_.clear();
776     for (uint16_t i = 0; i <= 7; ++i) {
777         csControl.connectionMap_.insert(std::make_pair(i, CellularCallConnectionCS()));
778     }
779     csControl.DialCdma(cellularCallInfo);
780     csControl.DialGsm(cellularCallInfo);
781     csControl.connectionMap_.clear();
782     ASSERT_EQ(csControl.ReportHangUp(infos, SIM1_SLOTID), TELEPHONY_SUCCESS);
783 }
784 
785 /**
786  * @tc.number   Telephony_CellularCallImsControl_001
787  * @tc.name     Test error branch
788  * @tc.desc     Function test
789  */
790 HWTEST_F(ZeroBranchTest, Telephony_CellularCallImsControl_001, Function | MediumTest | Level3)
791 {
792     AccessToken token;
793     IMSControl imsControl;
794     CellularCallInfo cellularCallInfo;
795     std::vector<CellularCallInfo> infos;
796     infos.emplace_back(cellularCallInfo);
797     CellularCallInfo cellularCallInfo_new;
798     bool enabled = false;
799     int32_t invalidSupType = -1;
800     ImsCurrentCallList ImsCallList;
801     InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, cellularCallInfo);
802     imsControl.ReportImsCallsData(SIM1_SLOTID, ImsCallList);
803     InitImsCallInfoList(ImsCallList, 5);
804     imsControl.ReportImsCallsData(SIM1_SLOTID, ImsCallList);
805     imsControl.Dial(cellularCallInfo, true);
806     cellularCallInfo_new.slotId = 1;
807     imsControl.Dial(cellularCallInfo_new, true);
808     cellularCallInfo_new.callType = CallType::TYPE_IMS;
809     infos.emplace_back(cellularCallInfo_new);
810     imsControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_DEFAULT);
811     imsControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_HOLD_WAIT);
812     imsControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
813     imsControl.HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ALL);
814     imsControl.HangUp(cellularCallInfo, static_cast<CallSupplementType>(invalidSupType));
815     imsControl.Answer(cellularCallInfo);
816     imsControl.Reject(cellularCallInfo);
817     imsControl.PostDialProceed(cellularCallInfo, true);
818     imsControl.PostDialProceed(cellularCallInfo, enabled);
819     imsControl.RestoreConnection(infos, SIM1_SLOTID);
820     imsControl.RestoreConnection(infos, SIM2_SLOTID);
821     imsControl.ReportHangUp(infos, SIM1_SLOTID);
822     imsControl.ReportHangUp(infos, SIM2_SLOTID);
823     imsControl.HoldCall(SIM1_SLOTID);
824     imsControl.UnHoldCall(SIM1_SLOTID);
825     imsControl.SwitchCall(SIM1_SLOTID);
826     imsControl.CombineConference(SIM1_SLOTID);
827     std::vector<std::string> numberList;
828     imsControl.InviteToConference(SIM1_SLOTID, numberList);
829     std::string kickOutStr = "";
830     imsControl.KickOutFromConference(SIM1_SLOTID, kickOutStr, 0);
831     kickOutStr = "111";
832     imsControl.KickOutFromConference(SIM1_SLOTID, kickOutStr, 0);
833     imsControl.HangUpAllConnection(SIM1_SLOTID);
834 }
835 
836 /**
837  * @tc.number   Telephony_CellularCallImsControl_002
838  * @tc.name     Test error branch
839  * @tc.desc     Function test
840  */
841 HWTEST_F(ZeroBranchTest, Telephony_CellularCallImsControl_002, Function | MediumTest | Level3)
842 {
843     AccessToken token;
844     IMSControl imsControl;
845     ImsCurrentCallList ImsCallList;
846     imsControl.ReportImsCallsData(SIM1_SLOTID, ImsCallList);
847     InitImsCallInfoList(ImsCallList, 5);
848     imsControl.ReportImsCallsData(SIM1_SLOTID, ImsCallList);
849     CallInfoList callInfoList;
850     imsControl.ReportCallsData(SIM1_SLOTID, callInfoList);
851     imsControl.ReportHangUpInfo(SIM1_SLOTID);
852     imsControl.ReportIncomingInfo(SIM1_SLOTID, ImsCallList);
853     imsControl.ReportUpdateInfo(SIM1_SLOTID, ImsCallList);
854     ImsCurrentCall ImsCallInfo;
855     imsControl.EncapsulationCallReportInfo(SIM1_SLOTID, ImsCallInfo);
856     CallsReportInfo callsReportInfo;
857     imsControl.DeleteConnection(callsReportInfo, ImsCallList);
858     imsControl.ReleaseAllConnection();
859     imsControl.DialAfterHold(SIM1_SLOTID);
860     std::string msg = "";
861     imsControl.StartRtt(SIM1_SLOTID, msg);
862     imsControl.GetConnectionMap();
863     imsControl.ReleaseAllConnection();
864     CLIRMode clirMode = CLIRMode::DEFAULT;
865     int32_t videoState = 0;
866     imsControl.DialJudgment(SIM1_SLOTID, PHONE_NUMBER, clirMode, videoState);
867 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
868     ASSERT_EQ(imsControl.StopRtt(SIM1_SLOTID), INVALID_VALUE);
869     ASSERT_EQ(imsControl.EncapsulateDial(SIM1_SLOTID, PHONE_NUMBER, clirMode, videoState),
870         TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
871 #else
872     ASSERT_EQ(imsControl.StopRtt(SIM1_SLOTID), TELEPHONY_SUCCESS);
873     ASSERT_EQ(imsControl.EncapsulateDial(SIM1_SLOTID, PHONE_NUMBER, clirMode, videoState), TELEPHONY_SUCCESS);
874 #endif
875 }
876 
877 /**
878  * @tc.number   Telephony_CellularCallImsControl_003
879  * @tc.name     Test error branch
880  * @tc.desc     Function test
881  */
882 HWTEST_F(ZeroBranchTest, Telephony_CellularCallImsControl_003, Function | MediumTest | Level3)
883 {
884     AccessToken token;
885     IMSControl imsControl;
886     imsControl.connectionMap_.insert(std::make_pair(1, CellularCallConnectionIMS()));
887     imsControl.RecoverPendingHold();
888     imsControl.DialAfterHold(SIM1_SLOTID);
889     imsControl.HangUpAllConnection(SIM1_SLOTID);
890     ImsCurrentCallList imsCallList;
891     CallsReportInfo callsReportInfo;
892     imsControl.DeleteConnection(callsReportInfo, imsCallList);
893     ASSERT_EQ(imsControl.ReportHangUpInfo(SIM1_SLOTID), TELEPHONY_SUCCESS);
894 }
895 
896 /**
897  * @tc.number   Telephony_ImsVideoCallControl_001
898  * @tc.name     Test error branch
899  * @tc.desc     Function test
900  */
901 HWTEST_F(ZeroBranchTest, Telephony_ImsVideoCallControl_001, Function | MediumTest | Level3)
902 {
903     AccessToken token;
904     auto imsVideoCallControl = DelayedSingleton<ImsVideoCallControl>::GetInstance();
905     ASSERT_NE(imsVideoCallControl, nullptr);
906     std::string cameraId = "";
907     std::string surfaceId = "";
908     std::string path = "";
909     CellularCallInfo cellularCallInfo;
910     InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, cellularCallInfo);
911 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
912     ASSERT_EQ(imsVideoCallControl->ControlCamera(SIM1_SLOTID, DEFAULT_INDEX, cameraId), INVALID_VALUE);
913     ASSERT_EQ(imsVideoCallControl->SetPreviewWindow(SIM1_SLOTID, DEFAULT_INDEX, surfaceId, nullptr),
914         INVALID_VALUE);
915     ASSERT_EQ(imsVideoCallControl->SetDisplayWindow(SIM1_SLOTID, DEFAULT_INDEX, surfaceId, nullptr),
916         INVALID_VALUE);
917     ASSERT_EQ(imsVideoCallControl->SetCameraZoom(1.0), INVALID_VALUE);
918     ASSERT_EQ(imsVideoCallControl->SetPausePicture(SIM1_SLOTID, DEFAULT_INDEX, path), INVALID_VALUE);
919     ASSERT_EQ(imsVideoCallControl->SetDeviceDirection(SIM1_SLOTID, DEFAULT_INDEX, 0), INVALID_VALUE);
920     ASSERT_EQ(imsVideoCallControl->SendUpdateCallMediaModeRequest(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY),
921         INVALID_VALUE);
922     ASSERT_EQ(imsVideoCallControl->SendUpdateCallMediaModeResponse(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY),
923         INVALID_VALUE);
924     ASSERT_EQ(imsVideoCallControl->CancelCallUpgrade(SIM1_SLOTID, DEFAULT_INDEX), INVALID_VALUE);
925     ASSERT_EQ(imsVideoCallControl->RequestCameraCapabilities(SIM1_SLOTID, DEFAULT_INDEX), INVALID_VALUE);
926 #else
927     ASSERT_EQ(imsVideoCallControl->ControlCamera(SIM1_SLOTID, DEFAULT_INDEX, cameraId), TELEPHONY_SUCCESS);
928     ASSERT_EQ(imsVideoCallControl->SetPreviewWindow(SIM1_SLOTID, DEFAULT_INDEX, surfaceId, nullptr),
929         TELEPHONY_SUCCESS);
930     ASSERT_EQ(imsVideoCallControl->SetDisplayWindow(SIM1_SLOTID, DEFAULT_INDEX, surfaceId, nullptr),
931         TELEPHONY_SUCCESS);
932     ASSERT_EQ(imsVideoCallControl->SetCameraZoom(1.0), TELEPHONY_SUCCESS);
933     ASSERT_EQ(imsVideoCallControl->SetPausePicture(SIM1_SLOTID, DEFAULT_INDEX, path), TELEPHONY_SUCCESS);
934     ASSERT_EQ(imsVideoCallControl->SetDeviceDirection(SIM1_SLOTID, DEFAULT_INDEX, 0), TELEPHONY_SUCCESS);
935     ASSERT_EQ(imsVideoCallControl->SendUpdateCallMediaModeRequest(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY),
936         TELEPHONY_ERR_FAIL);
937     ASSERT_EQ(imsVideoCallControl->SendUpdateCallMediaModeResponse(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY),
938         TELEPHONY_ERR_FAIL);
939     ASSERT_EQ(imsVideoCallControl->CancelCallUpgrade(SIM1_SLOTID, DEFAULT_INDEX), TELEPHONY_SUCCESS);
940     ASSERT_EQ(imsVideoCallControl->RequestCameraCapabilities(SIM1_SLOTID, DEFAULT_INDEX), TELEPHONY_SUCCESS);
941 #endif
942 }
943 
944 /**
945  * @tc.number   Telephony_ImsVideoCallControl_002
946  * @tc.name     Test error branch
947  * @tc.desc     Function test
948  */
949 HWTEST_F(ZeroBranchTest, Telephony_ImsVideoCallControl_002, Function | MediumTest | Level3)
950 {
951     AccessToken token;
952     auto imsVideoCallControl = DelayedSingleton<ImsVideoCallControl>::GetInstance();
953     ASSERT_NE(imsVideoCallControl, nullptr);
954     ImsCallMode mode = ImsCallMode::CALL_MODE_AUDIO_ONLY;
955     ASSERT_EQ(imsVideoCallControl->ConverToImsCallType(mode), ImsCallType::TEL_IMS_CALL_TYPE_VOICE);
956     mode = ImsCallMode::CALL_MODE_RECEIVE_ONLY;
957     ASSERT_EQ(imsVideoCallControl->ConverToImsCallType(mode), ImsCallType::TEL_IMS_CALL_TYPE_VT_RX);
958     mode = ImsCallMode::CALL_MODE_SEND_ONLY;
959     ASSERT_EQ(imsVideoCallControl->ConverToImsCallType(mode), ImsCallType::TEL_IMS_CALL_TYPE_VT_TX);
960     mode = ImsCallMode::CALL_MODE_SEND_RECEIVE;
961     ASSERT_EQ(imsVideoCallControl->ConverToImsCallType(mode), ImsCallType::TEL_IMS_CALL_TYPE_VT);
962     mode = ImsCallMode::CALL_MODE_VIDEO_PAUSED;
963     ASSERT_EQ(imsVideoCallControl->ConverToImsCallType(mode), ImsCallType::TEL_IMS_CALL_TYPE_PAUSE);
964 }
965 
966 /**
967  * @tc.number   Telephony_CellularCallConnectionIms_001
968  * @tc.name     Test error branch
969  * @tc.desc     Function test
970  */
971 HWTEST_F(ZeroBranchTest, Telephony_CellularCallConnectionIms_001, Function | MediumTest | Level3)
972 {
973     AccessToken token;
974     CellularCallConnectionIMS callConn;
975     ImsDialInfoStruct dialRequest;
976     std::vector<std::string> numberList = {};
977     std::string msg = "";
978     int32_t videoState = 0;
979 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
980     ASSERT_EQ(callConn.DialRequest(SIM1_SLOTID, dialRequest), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
981     ASSERT_EQ(callConn.HangUpRequest(SIM1_SLOTID, PHONE_NUMBER, 0), INVALID_VALUE);
982     ASSERT_EQ(callConn.AnswerRequest(SIM1_SLOTID, PHONE_NUMBER, 0, 0), INVALID_VALUE);
983     ASSERT_EQ(callConn.RejectRequest(SIM1_SLOTID, PHONE_NUMBER, 0), INVALID_VALUE);
984     ASSERT_EQ(callConn.HoldCallRequest(SIM1_SLOTID), INVALID_VALUE);
985     ASSERT_EQ(callConn.UnHoldCallRequest(SIM1_SLOTID), INVALID_VALUE);
986     ASSERT_EQ(callConn.SwitchCallRequest(SIM1_SLOTID, videoState), INVALID_VALUE);
987     ASSERT_EQ(callConn.CombineConferenceRequest(SIM1_SLOTID, 0), INVALID_VALUE);
988     ASSERT_EQ(callConn.InviteToConferenceRequest(SIM1_SLOTID, numberList), INVALID_VALUE);
989     ASSERT_EQ(callConn.KickOutFromConferenceRequest(SIM1_SLOTID, 0), INVALID_VALUE);
990     ASSERT_EQ(callConn.CallSupplementRequest(SIM1_SLOTID, CallSupplementType::TYPE_DEFAULT), TELEPHONY_SUCCESS);
991     ASSERT_EQ(callConn.StartRttRequest(SIM1_SLOTID, msg), INVALID_VALUE);
992     ASSERT_EQ(callConn.StopRttRequest(SIM1_SLOTID), INVALID_VALUE);
993     ASSERT_EQ(callConn.GetImsCallsDataRequest(SIM1_SLOTID, 0), INVALID_VALUE);
994     ASSERT_EQ(callConn.SendDtmfRequest(SIM1_SLOTID, '*', 0), INVALID_VALUE);
995     ASSERT_EQ(callConn.StartDtmfRequest(SIM1_SLOTID, '*', 0), INVALID_VALUE);
996     ASSERT_EQ(callConn.StopDtmfRequest(SIM1_SLOTID, 0), INVALID_VALUE);
997     ASSERT_EQ(callConn.GetCallFailReasonRequest(SIM1_SLOTID), INVALID_VALUE);
998 #else
999     ASSERT_EQ(callConn.DialRequest(SIM1_SLOTID, dialRequest), TELEPHONY_SUCCESS);
1000     ASSERT_EQ(callConn.HangUpRequest(SIM1_SLOTID, PHONE_NUMBER, 0), TELEPHONY_SUCCESS);
1001     ASSERT_EQ(callConn.AnswerRequest(SIM1_SLOTID, PHONE_NUMBER, 0, 0), TELEPHONY_SUCCESS);
1002     ASSERT_EQ(callConn.RejectRequest(SIM1_SLOTID, PHONE_NUMBER, 0), TELEPHONY_SUCCESS);
1003     ASSERT_EQ(callConn.HoldCallRequest(SIM1_SLOTID), TELEPHONY_SUCCESS);
1004     ASSERT_EQ(callConn.UnHoldCallRequest(SIM1_SLOTID), TELEPHONY_SUCCESS);
1005     ASSERT_EQ(callConn.SwitchCallRequest(SIM1_SLOTID, videoState), TELEPHONY_SUCCESS);
1006     ASSERT_EQ(callConn.CombineConferenceRequest(SIM1_SLOTID, 0), TELEPHONY_SUCCESS);
1007     ASSERT_EQ(callConn.InviteToConferenceRequest(SIM1_SLOTID, numberList), TELEPHONY_SUCCESS);
1008     ASSERT_EQ(callConn.KickOutFromConferenceRequest(SIM1_SLOTID, 0), TELEPHONY_SUCCESS);
1009     ASSERT_EQ(callConn.CallSupplementRequest(SIM1_SLOTID, CallSupplementType::TYPE_DEFAULT), TELEPHONY_SUCCESS);
1010     ASSERT_EQ(callConn.StartRttRequest(SIM1_SLOTID, msg), TELEPHONY_SUCCESS);
1011     ASSERT_EQ(callConn.StopRttRequest(SIM1_SLOTID), TELEPHONY_SUCCESS);
1012     ASSERT_EQ(callConn.GetImsCallsDataRequest(SIM1_SLOTID, 0), TELEPHONY_SUCCESS);
1013     ASSERT_EQ(callConn.SendDtmfRequest(SIM1_SLOTID, '*', 0), TELEPHONY_SUCCESS);
1014     ASSERT_EQ(callConn.StartDtmfRequest(SIM1_SLOTID, '*', 0), TELEPHONY_SUCCESS);
1015     ASSERT_EQ(callConn.StopDtmfRequest(SIM1_SLOTID, 0), TELEPHONY_SUCCESS);
1016     ASSERT_EQ(callConn.GetCallFailReasonRequest(SIM1_SLOTID), TELEPHONY_SUCCESS);
1017 #endif
1018 }
1019 
1020 /**
1021  * @tc.number   Telephony_CellularCallConfigRequest_001
1022  * @tc.name     Test error branch
1023  * @tc.desc     Function test
1024  */
1025 HWTEST_F(ZeroBranchTest, Telephony_CellularCallConfigRequest_001, Function | MediumTest | Level3)
1026 {
1027     AccessToken token;
1028     ConfigRequest configReq;
1029     configReq.SetDomainPreferenceModeRequest(SIM1_SLOTID, 1);
1030     configReq.GetDomainPreferenceModeRequest(SIM1_SLOTID);
1031     configReq.SetDomainPreferenceModeRequest(SIM2_SLOTID, 1);
1032     configReq.GetDomainPreferenceModeRequest(SIM2_SLOTID);
1033     bool enabled = false;
1034     configReq.SetImsSwitchStatusRequest(SIM1_SLOTID, enabled);
1035     configReq.GetImsSwitchStatusRequest(SIM1_SLOTID);
1036     int32_t state = 0;
1037     configReq.SetVoNRSwitchStatusRequest(SIM1_SLOTID, state);
1038     configReq.SetVoNRSwitchStatusRequest(SIM2_SLOTID, state);
1039     std::string value = "";
1040     configReq.SetImsConfigRequest(ImsConfigItem::ITEM_VIDEO_QUALITY, value);
1041     configReq.SetImsConfigRequest(ImsConfigItem::ITEM_VIDEO_QUALITY, 1);
1042     configReq.GetImsConfigRequest(ImsConfigItem::ITEM_VIDEO_QUALITY);
1043     configReq.SetImsFeatureValueRequest(FeatureType::TYPE_VOICE_OVER_LTE, 1);
1044     int32_t imsFeature = 0;
1045     configReq.GetImsFeatureValueRequest(FeatureType::TYPE_VOICE_OVER_LTE, imsFeature);
1046     configReq.SetMuteRequest(SIM1_SLOTID, 0);
1047     configReq.GetMuteRequest(SIM1_SLOTID);
1048     configReq.SetMuteRequest(SIM2_SLOTID, 0);
1049     configReq.GetMuteRequest(SIM2_SLOTID);
1050     std::vector<EmergencyCall> eccVec = {};
1051     configReq.GetEmergencyCallListRequest(SIM1_SLOTID);
1052     configReq.SetEmergencyCallListRequest(SIM1_SLOTID, eccVec);
1053     configReq.GetEmergencyCallListRequest(SIM2_SLOTID);
1054     configReq.SetEmergencyCallListRequest(SIM2_SLOTID, eccVec);
1055     ImsCapabilityList imsCapabilityList;
1056 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
1057     ASSERT_EQ(configReq.UpdateImsCapabilities(SIM1_SLOTID, imsCapabilityList), CALL_ERR_RESOURCE_UNAVAILABLE);
1058 #else
1059     ASSERT_EQ(configReq.UpdateImsCapabilities(SIM1_SLOTID, imsCapabilityList), TELEPHONY_SUCCESS);
1060 #endif
1061 }
1062 } // namespace Telephony
1063 } // namespace OHOS