1/*
2 * Copyright (C) 2021-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
16#include "cs_test.h"
17
18#define private public
19#define protected public
20#include "cellular_call_callback.h"
21#include "cellular_call_handler.h"
22#include "cellular_call_proxy.h"
23#include "cellular_call_register.h"
24#include "cellular_call_service.h"
25#include "cellular_call_supplement.h"
26#include "config_request.h"
27#include "core_service_client.h"
28#include "cs_control.h"
29#include "tel_ril_call_parcel.h"
30#include "operator_config_types.h"
31#include "radio_event.h"
32#include "securec.h"
33#include "sim_state_type.h"
34
35namespace OHOS {
36namespace Telephony {
37using namespace testing::ext;
38const int32_t SIM1_SLOTID = 0;
39const int32_t SIM2_SLOTID = 1;
40const int32_t INVALID_SLOTID = 0xFF;
41const std::string PHONE_NUMBER = "0000000";
42const std::string PHONE_NUMBER_SECOND = "1111111";
43const std::string PHONE_NUMBER_THIRD = "2222222";
44
45/**
46 * @tc.number   cellular_call_cs_test_001
47 * @tc.name     Test the corresponding functions by entering commands, such as 1 -- Dial, 2 -- Hangup, 3 -- Reject, etc
48 * @tc.desc     Function test
49 */
50HWTEST_F(CsTest, cellular_call_cs_test_001, Function | MediumTest | Level0)
51{
52    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
53    ASSERT_TRUE(systemAbilityMgr != nullptr);
54    auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
55    ASSERT_TRUE(remote != nullptr);
56    auto telephonyService = iface_cast<CellularCallInterface>(remote);
57    ASSERT_TRUE(telephonyService != nullptr);
58    std::cout << "HWTEST_F cellular_call_cs_test_001";
59}
60
61/**
62 * @tc.number   cellular_call_cs_test_002
63 * @tc.name     Test the corresponding functions by entering commands, such as 1 -- Dial, 2 -- Hangup, 3 -- Reject, etc
64 * @tc.desc     Function test
65 */
66HWTEST_F(CsTest, cellular_call_cs_test_002, Function | MediumTest | Level1)
67{
68    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
69    ASSERT_TRUE(systemAbilityMgr != nullptr);
70    auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
71    ASSERT_TRUE(remote != nullptr);
72    auto telephonyService = iface_cast<CellularCallInterface>(remote);
73    ASSERT_TRUE(telephonyService != nullptr);
74    std::cout << "HWTEST_F cellular_call_cs_test_002";
75}
76
77/**
78 * @tc.number   Telephony_CallManager_SetEmergencyCallList_0101
79 * @tc.name     SetEmergencyCallList "443,356,789",test SetEmergencyCallList(),return success
80 * @tc.desc     Function test
81 */
82HWTEST_F(CsTest, cellular_call_SetEmergencyCallList_0101, Function | MediumTest | Level3)
83{
84    AccessToken token;
85    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
86    ASSERT_TRUE(systemAbilityMgr != nullptr);
87    auto emergencyRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
88    ASSERT_TRUE(emergencyRemote != nullptr);
89    auto telephonyService = iface_cast<CellularCallInterface>(emergencyRemote);
90    ASSERT_TRUE(telephonyService != nullptr);
91
92    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
93        return;
94    }
95
96    std::vector<EmergencyCall> eccVec;
97    EmergencyCall temp0 = { "499", "460", EccType::TYPE_CATEGORY, SimpresentType::TYPE_NO_CARD,
98        AbnormalServiceType::TYPE_ALL };
99    EmergencyCall temp1 = { "443", "460", EccType::TYPE_POLICE, SimpresentType::TYPE_NO_CARD,
100        AbnormalServiceType::TYPE_ALL };
101    EmergencyCall temp2 = { "356", "460", EccType::TYPE_AMBULANCE, SimpresentType::TYPE_NO_CARD,
102        AbnormalServiceType::TYPE_ALL };
103    EmergencyCall temp3 = { "783", "460", EccType::TYPE_FIRE, SimpresentType::TYPE_NO_CARD,
104        AbnormalServiceType::TYPE_ALL };
105    EmergencyCall temp4 = { "975", "460", EccType::TYPE_SEA, SimpresentType::TYPE_HAS_CARD,
106        AbnormalServiceType::TYPE_ONLY_CS };
107    EmergencyCall temp5 = { "350", "460", EccType::TYPE_MOUNTAIN, SimpresentType::TYPE_HAS_CARD,
108        AbnormalServiceType::TYPE_ALL };
109    eccVec.push_back(temp0);
110    eccVec.push_back(temp1);
111    eccVec.push_back(temp2);
112    eccVec.push_back(temp3);
113    eccVec.push_back(temp4);
114    eccVec.push_back(temp5);
115    if (HasSimCard(SIM1_SLOTID)) {
116        EXPECT_EQ(telephonyService->SetEmergencyCallList(SIM1_SLOTID, eccVec), 0);
117    }
118    if (HasSimCard(SIM2_SLOTID)) {
119        EXPECT_EQ(telephonyService->SetEmergencyCallList(SIM2_SLOTID, eccVec), 0);
120    }
121    JudgeIsEmergencyPhoneNumber();
122}
123
124HWTEST_F(CsTest, cellular_call_IsOperatorConfigEmergencyCallList_0001, Function | MediumTest | Level3)
125{
126    AccessToken token;
127    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
128    ASSERT_TRUE(systemAbilityMgr != nullptr);
129    auto operatorRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
130    ASSERT_TRUE(operatorRemote != nullptr);
131    auto telephonyService = iface_cast<CellularCallInterface>(operatorRemote);
132    ASSERT_TRUE(telephonyService != nullptr);
133
134    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
135        return;
136    }
137    OperatorConfig opc;
138    if (HasSimCard(SIM1_SLOTID)) {
139        DelayedRefSingleton<CoreServiceClient>::GetInstance().GetOperatorConfigs(SIM1_SLOTID, opc);
140        if (opc.stringArrayValue.find(KEY_EMERGENCY_CALL_STRING_ARRAY) != opc.stringArrayValue.end()) {
141            for (auto number : opc.stringArrayValue[KEY_EMERGENCY_CALL_STRING_ARRAY]) {
142                bool enabled = false;
143                int32_t errorCode = telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, number, enabled);
144                EXPECT_EQ(TELEPHONY_SUCCESS, errorCode);
145            }
146        }
147    }
148    if (HasSimCard(SIM2_SLOTID)) {
149        DelayedRefSingleton<CoreServiceClient>::GetInstance().GetOperatorConfigs(SIM2_SLOTID, opc);
150        if (opc.stringArrayValue.find(KEY_EMERGENCY_CALL_STRING_ARRAY) != opc.stringArrayValue.end()) {
151            for (auto number : opc.stringArrayValue[KEY_EMERGENCY_CALL_STRING_ARRAY]) {
152                bool enabled = false;
153                int32_t errorCode = telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, number, enabled);
154                EXPECT_EQ(TELEPHONY_SUCCESS, errorCode);
155            }
156        }
157    }
158}
159
160/**
161 * @tc.number   cellular_call_DialCall_0001
162 * @tc.name     Test for SetClip function by cs
163 * @tc.desc     Function test
164 */
165HWTEST_F(CsTest, cellular_call_DialCall_0001, Function | MediumTest | Level2)
166{
167    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
168        return;
169    }
170    if (HasSimCard(SIM1_SLOTID)) {
171        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*30#");
172        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
173    }
174    if (HasSimCard(SIM2_SLOTID)) {
175        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*30#");
176        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
177    }
178}
179
180/**
181 * @tc.number   cellular_call_DialCall_0002
182 * @tc.name     Test for SetClip function by cs
183 * @tc.desc     Function test
184 */
185HWTEST_F(CsTest, cellular_call_DialCall_0002, Function | MediumTest | Level2)
186{
187    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
188        return;
189    }
190    if (HasSimCard(SIM1_SLOTID)) {
191        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#30#");
192        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
193    }
194    if (HasSimCard(SIM2_SLOTID)) {
195        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#30#");
196        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
197    }
198}
199
200/**
201 * @tc.number   cellular_call_DialCall_0003
202 * @tc.name     Test for getClip function by cs
203 * @tc.desc     Function test
204 */
205HWTEST_F(CsTest, cellular_call_DialCall_0003, Function | MediumTest | Level2)
206{
207    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
208        return;
209    }
210    if (HasSimCard(SIM1_SLOTID)) {
211        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#30#");
212        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
213    }
214    if (HasSimCard(SIM2_SLOTID)) {
215        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#30#");
216        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
217    }
218}
219
220/**
221 * @tc.number   cellular_call_DialCall_0004
222 * @tc.name     Test for SetClir function by cs
223 * @tc.desc     Function test
224 */
225HWTEST_F(CsTest, cellular_call_DialCall_0004, Function | MediumTest | Level2)
226{
227    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
228        return;
229    }
230    if (HasSimCard(SIM1_SLOTID)) {
231        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*31#");
232        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
233    }
234    if (HasSimCard(SIM2_SLOTID)) {
235        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*31#");
236        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
237    }
238}
239
240/**
241 * @tc.number   cellular_call_DialCall_0005
242 * @tc.name     Test for SetClir function by cs
243 * @tc.desc     Function test
244 */
245HWTEST_F(CsTest, cellular_call_DialCall_0005, Function | MediumTest | Level2)
246{
247    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
248        return;
249    }
250    if (HasSimCard(SIM1_SLOTID)) {
251        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#31#");
252        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
253    }
254    if (HasSimCard(SIM2_SLOTID)) {
255        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#31#");
256        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
257    }
258}
259
260/**
261 * @tc.number   cellular_call_DialCall_0006
262 * @tc.name     Test for GetClir function by cs
263 * @tc.desc     Function test
264 */
265HWTEST_F(CsTest, cellular_call_DialCall_0006, Function | MediumTest | Level2)
266{
267    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
268        return;
269    }
270    if (HasSimCard(SIM1_SLOTID)) {
271        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#31#");
272        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
273    }
274    if (HasSimCard(SIM2_SLOTID)) {
275        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#31#");
276        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
277    }
278}
279
280/**
281 * @tc.number   cellular_call_DialCall_0007
282 * @tc.name     Test for SetCallTransfer function by cs
283 * @tc.desc     Function test
284 */
285HWTEST_F(CsTest, cellular_call_DialCall_0007, Function | MediumTest | Level2)
286{
287    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
288        return;
289    }
290    if (HasSimCard(SIM1_SLOTID)) {
291        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*21#");
292        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
293    }
294    if (HasSimCard(SIM2_SLOTID)) {
295        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*21#");
296        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
297    }
298}
299
300/**
301 * @tc.number   cellular_call_DialCall_0008
302 * @tc.name     Test for SetCallTransfer function by cs
303 * @tc.desc     Function test
304 */
305HWTEST_F(CsTest, cellular_call_DialCall_0008, Function | MediumTest | Level2)
306{
307    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
308        return;
309    }
310    if (HasSimCard(SIM1_SLOTID)) {
311        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#21#");
312        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
313    }
314    if (HasSimCard(SIM2_SLOTID)) {
315        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#21#");
316        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
317    }
318}
319
320/**
321 * @tc.number   cellular_call_DialCall_0009
322 * @tc.name     Test for GetCallTransfer function by cs
323 * @tc.desc     Function test
324 */
325HWTEST_F(CsTest, cellular_call_DialCall_0009, Function | MediumTest | Level2)
326{
327    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
328        return;
329    }
330    if (HasSimCard(SIM1_SLOTID)) {
331        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#21#");
332        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
333    }
334    if (HasSimCard(SIM2_SLOTID)) {
335        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#21#");
336        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
337    }
338}
339
340/**
341 * @tc.number   cellular_call_DialCall_0010
342 * @tc.name     Test for SetCallRestriction function by cs
343 * @tc.desc     Function test
344 */
345HWTEST_F(CsTest, cellular_call_DialCall_0010, Function | MediumTest | Level2)
346{
347    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
348        return;
349    }
350    if (HasSimCard(SIM1_SLOTID)) {
351        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*33#");
352        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
353    }
354    if (HasSimCard(SIM2_SLOTID)) {
355        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*33#");
356        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
357    }
358}
359
360/**
361 * @tc.number   cellular_call_DialCall_0011
362 * @tc.name     Test for SetCallRestriction function by cs
363 * @tc.desc     Function test
364 */
365HWTEST_F(CsTest, cellular_call_DialCall_0011, Function | MediumTest | Level2)
366{
367    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
368        return;
369    }
370    if (HasSimCard(SIM1_SLOTID)) {
371        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#33#");
372        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
373    }
374    if (HasSimCard(SIM2_SLOTID)) {
375        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#33#");
376        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
377    }
378}
379
380/**
381 * @tc.number   cellular_call_DialCall_0012
382 * @tc.name     Test for GetCallRestriction function by cs
383 * @tc.desc     Function test
384 */
385HWTEST_F(CsTest, cellular_call_DialCall_0012, Function | MediumTest | Level2)
386{
387    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
388        return;
389    }
390    if (HasSimCard(SIM1_SLOTID)) {
391        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#33#");
392        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
393    }
394    if (HasSimCard(SIM2_SLOTID)) {
395        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#33#");
396        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
397    }
398}
399
400/**
401 * @tc.number   cellular_call_DialCall_0013
402 * @tc.name     Test for SetCallWaiting function by cs
403 * @tc.desc     Function test
404 */
405HWTEST_F(CsTest, cellular_call_DialCall_0013, Function | MediumTest | Level2)
406{
407    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
408        return;
409    }
410    if (HasSimCard(SIM1_SLOTID)) {
411        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*43#");
412        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
413    }
414    if (HasSimCard(SIM2_SLOTID)) {
415        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*43#");
416        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
417    }
418}
419
420/**
421 * @tc.number   cellular_call_DialCall_0014
422 * @tc.name     Test for SetCallWaiting function by cs
423 * @tc.desc     Function test
424 */
425HWTEST_F(CsTest, cellular_call_DialCall_0014, Function | MediumTest | Level2)
426{
427    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
428        return;
429    }
430    if (HasSimCard(SIM1_SLOTID)) {
431        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#43#");
432        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
433    }
434    if (HasSimCard(SIM2_SLOTID)) {
435        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#43#");
436        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
437    }
438}
439
440/**
441 * @tc.number   cellular_call_DialCall_0015
442 * @tc.name     Test for GetCallWaiting function by cs
443 * @tc.desc     Function test
444 */
445HWTEST_F(CsTest, cellular_call_DialCall_0015, Function | MediumTest | Level2)
446{
447    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
448        return;
449    }
450    if (HasSimCard(SIM1_SLOTID)) {
451        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#43#");
452        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
453    }
454    if (HasSimCard(SIM2_SLOTID)) {
455        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#43#");
456        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
457    }
458}
459
460/**
461 * @tc.number   cellular_call_DialCall_0016
462 * @tc.name     Test for AlterPinPassword function by cs
463 * @tc.desc     Function test
464 */
465HWTEST_F(CsTest, cellular_call_DialCall_0016, Function | MediumTest | Level2)
466{
467    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
468        return;
469    }
470    if (HasSimCard(SIM1_SLOTID)) {
471        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*04#");
472        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
473    }
474    if (HasSimCard(SIM2_SLOTID)) {
475        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*04#");
476        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
477    }
478}
479
480/**
481 * @tc.number   cellular_call_DialCall_0017
482 * @tc.name     Test for UnlockPuk function by cs
483 * @tc.desc     Function test
484 */
485HWTEST_F(CsTest, cellular_call_DialCall_0017, Function | MediumTest | Level2)
486{
487    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
488        return;
489    }
490    if (HasSimCard(SIM1_SLOTID)) {
491        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*05#");
492        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
493    }
494    if (HasSimCard(SIM2_SLOTID)) {
495        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*05#");
496        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
497    }
498}
499
500/**
501 * @tc.number   cellular_call_DialCall_0018
502 * @tc.name     Test for AlterPin2Password function by cs
503 * @tc.desc     Function test
504 */
505HWTEST_F(CsTest, cellular_call_DialCall_0018, Function | MediumTest | Level2)
506{
507    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
508        return;
509    }
510    if (HasSimCard(SIM1_SLOTID)) {
511        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*042#");
512        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
513    }
514    if (HasSimCard(SIM2_SLOTID)) {
515        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*042#");
516        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
517    }
518}
519
520/**
521 * @tc.number   cellular_call_DialCall_0019
522 * @tc.name     Test for UnlockPuk2 function by cs
523 * @tc.desc     Function test
524 */
525HWTEST_F(CsTest, cellular_call_DialCall_0019, Function | MediumTest | Level2)
526{
527    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
528        return;
529    }
530    if (HasSimCard(SIM1_SLOTID)) {
531        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*052#");
532        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
533    }
534    if (HasSimCard(SIM2_SLOTID)) {
535        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*052#");
536        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
537    }
538}
539
540/**
541 * @tc.number   cellular_call_DialCall_0020
542 * @tc.name     Test for SendUssd function by cs
543 * @tc.desc     Function test
544 */
545HWTEST_F(CsTest, cellular_call_DialCall_0020, Function | MediumTest | Level2)
546{
547    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
548        return;
549    }
550    if (HasSimCard(SIM1_SLOTID)) {
551        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*4444#");
552        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
553    }
554    if (HasSimCard(SIM2_SLOTID)) {
555        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*4444#");
556        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
557    }
558}
559
560/**
561 * @tc.number   cellular_call_DialCall_0021
562 * @tc.name     Test for dial function with invalid slot by cs
563 * @tc.desc     Function test
564 */
565HWTEST_F(CsTest, cellular_call_DialCall_0021, Function | MediumTest | Level2)
566{
567    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
568        return;
569    }
570    if (HasSimCard(SIM1_SLOTID)) {
571        int32_t ret = TestDialCallByCs(INVALID_SLOTID, PHONE_NUMBER);
572        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
573    }
574    if (HasSimCard(SIM2_SLOTID)) {
575        int32_t ret = TestDialCallByCs(INVALID_SLOTID, PHONE_NUMBER);
576        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
577    }
578}
579
580/**
581 * @tc.number   cellular_call_HangUpCall_0001
582 * @tc.name     Test for HangUp function by cs
583 * @tc.desc     Function test
584 */
585HWTEST_F(CsTest, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)
586{
587    AccessToken token;
588    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
589    ASSERT_TRUE(systemAbilityMgr != nullptr);
590    auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
591    ASSERT_TRUE(hangUpCallRemote != nullptr);
592    auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
593    ASSERT_TRUE(telephonyService != nullptr);
594    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
595        return;
596    }
597    CellularCallInfo hangUpCallInfo;
598    if (HasSimCard(SIM1_SLOTID)) {
599        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, hangUpCallInfo);
600        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
601        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
602        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
603        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
604        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
605    }
606    if (HasSimCard(SIM2_SLOTID)) {
607        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, hangUpCallInfo);
608        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
609        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
610        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
611        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
612        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
613    }
614}
615
616/**
617 * @tc.number   cellular_call_HangUpCall_0002
618 * @tc.name     Test for HangUp function with invalid slot by cs
619 * @tc.desc     Function test
620 */
621HWTEST_F(CsTest, cellular_call_HangUpCall_0002, Function | MediumTest | Level2)
622{
623    AccessToken token;
624    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
625        return;
626    }
627    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
628    ASSERT_TRUE(systemAbilityMgr != nullptr);
629    auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
630    ASSERT_TRUE(hangUpCallRemote != nullptr);
631    auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
632    ASSERT_TRUE(telephonyService != nullptr);
633    if (HasSimCard(SIM1_SLOTID)) {
634        CellularCallInfo hangUpCallInfo;
635        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, hangUpCallInfo);
636        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
637        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
638        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
639    }
640    if (HasSimCard(SIM2_SLOTID)) {
641        CellularCallInfo hangUpCallInfo;
642        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, hangUpCallInfo);
643        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
644        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
645        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
646    }
647}
648
649/**
650 * @tc.number   cellular_call_AnswerCall_0001
651 * @tc.name     Test for answer function by cs
652 * @tc.desc     Function test
653 */
654HWTEST_F(CsTest, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)
655{
656    AccessToken token;
657    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
658    ASSERT_TRUE(systemAbilityMgr != nullptr);
659    auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
660    ASSERT_TRUE(answerCallRemote != nullptr);
661    auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
662    ASSERT_TRUE(telephonyService != nullptr);
663    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
664        return;
665    }
666    if (HasSimCard(SIM1_SLOTID)) {
667        CellularCallInfo answerCallInfo;
668        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, answerCallInfo);
669        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
670        ret = telephonyService->Answer(answerCallInfo);
671        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
672    }
673    if (HasSimCard(SIM2_SLOTID)) {
674        CellularCallInfo answerCallInfo;
675        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, answerCallInfo);
676        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
677        ret = telephonyService->Answer(answerCallInfo);
678        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
679    }
680}
681
682/**
683 * @tc.number   cellular_call_AnswerCall_0002
684 * @tc.name     Test for answer function with invalid slot by cs
685 * @tc.desc     Function test
686 */
687HWTEST_F(CsTest, cellular_call_AnswerCall_0002, Function | MediumTest | Level2)
688{
689    AccessToken token;
690    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
691        return;
692    }
693    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
694    ASSERT_TRUE(systemAbilityMgr != nullptr);
695    auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
696    ASSERT_TRUE(answerCallRemote != nullptr);
697    auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
698    ASSERT_TRUE(telephonyService != nullptr);
699    if (HasSimCard(SIM1_SLOTID)) {
700        CellularCallInfo answerCallInfo;
701        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, answerCallInfo);
702        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
703        ret = telephonyService->Answer(answerCallInfo);
704        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
705    }
706    if (HasSimCard(SIM2_SLOTID)) {
707        CellularCallInfo answerCallInfo;
708        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, answerCallInfo);
709        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
710        ret = telephonyService->Answer(answerCallInfo);
711        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
712    }
713}
714
715/**
716 * @tc.number   cellular_call_RejectCall_0001
717 * @tc.name     Test for reject function by cs
718 * @tc.desc     Function test
719 */
720HWTEST_F(CsTest, cellular_call_RejectCall_0001, Function | MediumTest | Level2)
721{
722    AccessToken token;
723    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
724    ASSERT_TRUE(systemAbilityMgr != nullptr);
725    auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
726    ASSERT_TRUE(rejectCallRemote != nullptr);
727    auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
728    ASSERT_TRUE(telephonyService != nullptr);
729    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
730        return;
731    }
732    if (HasSimCard(SIM1_SLOTID)) {
733        CellularCallInfo rejectCallInfo;
734        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, rejectCallInfo);
735        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
736        ret = telephonyService->Reject(rejectCallInfo);
737        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
738    }
739    if (HasSimCard(SIM2_SLOTID)) {
740        CellularCallInfo rejectCallInfo;
741        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, rejectCallInfo);
742        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
743        ret = telephonyService->Reject(rejectCallInfo);
744        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
745    }
746}
747
748/**
749 * @tc.number   cellular_call_RejectCall_0002
750 * @tc.name     Test for reject function with invalid slot by cs
751 * @tc.desc     Function test
752 */
753HWTEST_F(CsTest, cellular_call_RejectCall_0002, Function | MediumTest | Level2)
754{
755    AccessToken token;
756    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
757        return;
758    }
759    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
760    ASSERT_TRUE(systemAbilityMgr != nullptr);
761    auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
762    ASSERT_TRUE(rejectCallRemote != nullptr);
763    auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
764    ASSERT_TRUE(telephonyService != nullptr);
765    if (HasSimCard(SIM1_SLOTID)) {
766        CellularCallInfo rejectCallInfo;
767        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, rejectCallInfo);
768        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
769        ret = telephonyService->Reject(rejectCallInfo);
770        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
771    }
772    if (HasSimCard(SIM2_SLOTID)) {
773        CellularCallInfo rejectCallInfo;
774        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, rejectCallInfo);
775        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
776        ret = telephonyService->Reject(rejectCallInfo);
777        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
778    }
779}
780
781/**
782 * @tc.number   cellular_call_HoldCall_0001
783 * @tc.name     Test for hold call function by cs
784 * @tc.desc     Function test
785 */
786HWTEST_F(CsTest, cellular_call_HoldCall_0001, Function | MediumTest | Level2)
787{
788    AccessToken token;
789    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
790    ASSERT_TRUE(systemAbilityMgr != nullptr);
791    auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
792    ASSERT_TRUE(holdCallRemote != nullptr);
793    auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
794    ASSERT_TRUE(telephonyService != nullptr);
795    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
796        return;
797    }
798    if (HasSimCard(SIM1_SLOTID)) {
799        CellularCallInfo holdCallInfo;
800        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, holdCallInfo);
801        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
802        ret = telephonyService->HoldCall(holdCallInfo);
803        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
804    }
805    if (HasSimCard(SIM2_SLOTID)) {
806        CellularCallInfo holdCallInfo;
807        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, holdCallInfo);
808        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
809        ret = telephonyService->HoldCall(holdCallInfo);
810        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
811    }
812}
813
814/**
815 * @tc.number   cellular_call_HoldCall_0002
816 * @tc.name     Test for hold function with invalid slot by cs
817 * @tc.desc     Function test
818 */
819HWTEST_F(CsTest, cellular_call_HoldCall_0002, Function | MediumTest | Level2)
820{
821    AccessToken token;
822    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
823        return;
824    }
825    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
826    ASSERT_TRUE(systemAbilityMgr != nullptr);
827    auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
828    ASSERT_TRUE(holdCallRemote != nullptr);
829    auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
830    ASSERT_TRUE(telephonyService != nullptr);
831    if (HasSimCard(SIM1_SLOTID)) {
832        CellularCallInfo holdCallInfo;
833        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, holdCallInfo);
834        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
835        ret = telephonyService->HoldCall(holdCallInfo);
836        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
837    }
838    if (HasSimCard(SIM2_SLOTID)) {
839        CellularCallInfo holdCallInfo;
840        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, holdCallInfo);
841        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
842        ret = telephonyService->HoldCall(holdCallInfo);
843        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
844    }
845}
846
847/**
848 * @tc.number   cellular_call_UnHoldCall_0001
849 * @tc.name     Test for unhold call function by cs
850 * @tc.desc     Function test
851 */
852HWTEST_F(CsTest, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)
853{
854    AccessToken token;
855    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
856    ASSERT_TRUE(systemAbilityMgr != nullptr);
857    auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
858    ASSERT_TRUE(unHoldCallRemote != nullptr);
859    auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
860    ASSERT_TRUE(telephonyService != nullptr);
861    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
862        return;
863    }
864    if (HasSimCard(SIM1_SLOTID)) {
865        CellularCallInfo unHoldCallInfo;
866        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, unHoldCallInfo);
867        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
868        ret = telephonyService->UnHoldCall(unHoldCallInfo);
869        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
870    }
871    if (HasSimCard(SIM2_SLOTID)) {
872        CellularCallInfo unHoldCallInfo;
873        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, unHoldCallInfo);
874        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
875        ret = telephonyService->UnHoldCall(unHoldCallInfo);
876        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
877    }
878}
879
880/**
881 * @tc.number   cellular_call_UnHoldCall_0002
882 * @tc.name     Test for unhold function with invalid slot by cs
883 * @tc.desc     Function test
884 */
885HWTEST_F(CsTest, cellular_call_UnHoldCall_0002, Function | MediumTest | Level2)
886{
887    AccessToken token;
888    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
889        return;
890    }
891    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
892    ASSERT_TRUE(systemAbilityMgr != nullptr);
893    auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
894    ASSERT_TRUE(unHoldCallRemote != nullptr);
895    auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
896    ASSERT_TRUE(telephonyService != nullptr);
897    if (HasSimCard(SIM1_SLOTID)) {
898        CellularCallInfo unHoldCallInfo;
899        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, unHoldCallInfo);
900        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
901        ret = telephonyService->UnHoldCall(unHoldCallInfo);
902        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
903    }
904    if (HasSimCard(SIM2_SLOTID)) {
905        CellularCallInfo unHoldCallInfo;
906        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, unHoldCallInfo);
907        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
908        ret = telephonyService->UnHoldCall(unHoldCallInfo);
909        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
910    }
911}
912
913/**
914 * @tc.number   cellular_call_SwitchCall_0001
915 * @tc.name     Test for switch call function by cs
916 * @tc.desc     Function test
917 */
918HWTEST_F(CsTest, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)
919{
920    AccessToken token;
921    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
922    ASSERT_TRUE(systemAbilityMgr != nullptr);
923    auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
924    ASSERT_TRUE(switchCallRemote != nullptr);
925    auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
926    ASSERT_TRUE(telephonyService != nullptr);
927    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
928        return;
929    }
930    if (HasSimCard(SIM1_SLOTID)) {
931        CellularCallInfo switchCallInfo;
932        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, switchCallInfo);
933        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
934        ret = telephonyService->SwitchCall(switchCallInfo);
935        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
936    }
937    if (HasSimCard(SIM2_SLOTID)) {
938        CellularCallInfo switchCallInfo;
939        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, switchCallInfo);
940        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
941        ret = telephonyService->SwitchCall(switchCallInfo);
942        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
943    }
944}
945
946/**
947 * @tc.number   cellular_call_SwitchCall_0002
948 * @tc.name     Test for switch function with invalid slot by cs
949 * @tc.desc     Function test
950 */
951HWTEST_F(CsTest, cellular_call_SwitchCall_0002, Function | MediumTest | Level2)
952{
953    AccessToken token;
954    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
955        return;
956    }
957    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
958    ASSERT_TRUE(systemAbilityMgr != nullptr);
959    auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
960    ASSERT_TRUE(switchCallRemote != nullptr);
961    auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
962    ASSERT_TRUE(telephonyService != nullptr);
963    if (HasSimCard(SIM1_SLOTID)) {
964        CellularCallInfo switchCallInfo;
965        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, switchCallInfo);
966        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
967        ret = telephonyService->SwitchCall(switchCallInfo);
968        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
969    }
970    if (HasSimCard(SIM2_SLOTID)) {
971        CellularCallInfo switchCallInfo;
972        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, switchCallInfo);
973        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
974        ret = telephonyService->SwitchCall(switchCallInfo);
975        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
976    }
977}
978} // namespace Telephony
979} // namespace OHOS
980