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
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_DialCall_0001
47 * @tc.name     Test for SetClip function by cs
48 * @tc.desc     Function test
49 */
50HWTEST_F(CsTest, cellular_call_DialCall_0001, Function | MediumTest | Level2)
51{
52    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
53        return;
54    }
55    if (HasSimCard(SIM1_SLOTID)) {
56        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*30#");
57        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
58    }
59    if (HasSimCard(SIM2_SLOTID)) {
60        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*30#");
61        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
62    }
63}
64
65/**
66 * @tc.number   cellular_call_DialCall_0002
67 * @tc.name     Test for SetClip function by cs
68 * @tc.desc     Function test
69 */
70HWTEST_F(CsTest, cellular_call_DialCall_0002, Function | MediumTest | Level2)
71{
72    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
73        return;
74    }
75    if (HasSimCard(SIM1_SLOTID)) {
76        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#30#");
77        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
78    }
79    if (HasSimCard(SIM2_SLOTID)) {
80        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#30#");
81        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
82    }
83}
84
85/**
86 * @tc.number   cellular_call_DialCall_0003
87 * @tc.name     Test for getClip function by cs
88 * @tc.desc     Function test
89 */
90HWTEST_F(CsTest, cellular_call_DialCall_0003, Function | MediumTest | Level2)
91{
92    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
93        return;
94    }
95    if (HasSimCard(SIM1_SLOTID)) {
96        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#30#");
97        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
98    }
99    if (HasSimCard(SIM2_SLOTID)) {
100        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#30#");
101        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
102    }
103}
104
105/**
106 * @tc.number   cellular_call_DialCall_0004
107 * @tc.name     Test for SetClir function by cs
108 * @tc.desc     Function test
109 */
110HWTEST_F(CsTest, cellular_call_DialCall_0004, Function | MediumTest | Level2)
111{
112    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
113        return;
114    }
115    if (HasSimCard(SIM1_SLOTID)) {
116        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*31#");
117        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
118    }
119    if (HasSimCard(SIM2_SLOTID)) {
120        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*31#");
121        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
122    }
123}
124
125/**
126 * @tc.number   cellular_call_DialCall_0005
127 * @tc.name     Test for SetClir function by cs
128 * @tc.desc     Function test
129 */
130HWTEST_F(CsTest, cellular_call_DialCall_0005, Function | MediumTest | Level2)
131{
132    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
133        return;
134    }
135    if (HasSimCard(SIM1_SLOTID)) {
136        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#31#");
137        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
138    }
139    if (HasSimCard(SIM2_SLOTID)) {
140        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#31#");
141        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
142    }
143}
144
145/**
146 * @tc.number   cellular_call_DialCall_0006
147 * @tc.name     Test for GetClir function by cs
148 * @tc.desc     Function test
149 */
150HWTEST_F(CsTest, cellular_call_DialCall_0006, Function | MediumTest | Level2)
151{
152    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
153        return;
154    }
155    if (HasSimCard(SIM1_SLOTID)) {
156        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#31#");
157        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
158    }
159    if (HasSimCard(SIM2_SLOTID)) {
160        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#31#");
161        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
162    }
163}
164
165/**
166 * @tc.number   cellular_call_DialCall_0007
167 * @tc.name     Test for SetCallTransfer function by cs
168 * @tc.desc     Function test
169 */
170HWTEST_F(CsTest, cellular_call_DialCall_0007, Function | MediumTest | Level2)
171{
172    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
173        return;
174    }
175    if (HasSimCard(SIM1_SLOTID)) {
176        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*21#");
177        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
178    }
179    if (HasSimCard(SIM2_SLOTID)) {
180        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*21#");
181        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
182    }
183}
184
185/**
186 * @tc.number   cellular_call_DialCall_0008
187 * @tc.name     Test for SetCallTransfer function by cs
188 * @tc.desc     Function test
189 */
190HWTEST_F(CsTest, cellular_call_DialCall_0008, Function | MediumTest | Level2)
191{
192    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
193        return;
194    }
195    if (HasSimCard(SIM1_SLOTID)) {
196        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#21#");
197        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
198    }
199    if (HasSimCard(SIM2_SLOTID)) {
200        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#21#");
201        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
202    }
203}
204
205/**
206 * @tc.number   cellular_call_DialCall_0009
207 * @tc.name     Test for GetCallTransfer function by cs
208 * @tc.desc     Function test
209 */
210HWTEST_F(CsTest, cellular_call_DialCall_0009, Function | MediumTest | Level2)
211{
212    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
213        return;
214    }
215    if (HasSimCard(SIM1_SLOTID)) {
216        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#21#");
217        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
218    }
219    if (HasSimCard(SIM2_SLOTID)) {
220        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#21#");
221        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
222    }
223}
224
225/**
226 * @tc.number   cellular_call_DialCall_0010
227 * @tc.name     Test for SetCallRestriction function by cs
228 * @tc.desc     Function test
229 */
230HWTEST_F(CsTest, cellular_call_DialCall_0010, Function | MediumTest | Level2)
231{
232    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
233        return;
234    }
235    if (HasSimCard(SIM1_SLOTID)) {
236        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*33#");
237        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
238    }
239    if (HasSimCard(SIM2_SLOTID)) {
240        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*33#");
241        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
242    }
243}
244
245/**
246 * @tc.number   cellular_call_DialCall_0011
247 * @tc.name     Test for SetCallRestriction function by cs
248 * @tc.desc     Function test
249 */
250HWTEST_F(CsTest, cellular_call_DialCall_0011, Function | MediumTest | Level2)
251{
252    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
253        return;
254    }
255    if (HasSimCard(SIM1_SLOTID)) {
256        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#33#");
257        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
258    }
259    if (HasSimCard(SIM2_SLOTID)) {
260        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#33#");
261        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
262    }
263}
264
265/**
266 * @tc.number   cellular_call_DialCall_0012
267 * @tc.name     Test for GetCallRestriction function by cs
268 * @tc.desc     Function test
269 */
270HWTEST_F(CsTest, cellular_call_DialCall_0012, Function | MediumTest | Level2)
271{
272    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
273        return;
274    }
275    if (HasSimCard(SIM1_SLOTID)) {
276        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#33#");
277        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
278    }
279    if (HasSimCard(SIM2_SLOTID)) {
280        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#33#");
281        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
282    }
283}
284
285/**
286 * @tc.number   cellular_call_DialCall_0013
287 * @tc.name     Test for SetCallWaiting function by cs
288 * @tc.desc     Function test
289 */
290HWTEST_F(CsTest, cellular_call_DialCall_0013, Function | MediumTest | Level2)
291{
292    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
293        return;
294    }
295    if (HasSimCard(SIM1_SLOTID)) {
296        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*43#");
297        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
298    }
299    if (HasSimCard(SIM2_SLOTID)) {
300        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*43#");
301        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
302    }
303}
304
305/**
306 * @tc.number   cellular_call_DialCall_0014
307 * @tc.name     Test for SetCallWaiting function by cs
308 * @tc.desc     Function test
309 */
310HWTEST_F(CsTest, cellular_call_DialCall_0014, Function | MediumTest | Level2)
311{
312    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
313        return;
314    }
315    if (HasSimCard(SIM1_SLOTID)) {
316        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "#43#");
317        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
318    }
319    if (HasSimCard(SIM2_SLOTID)) {
320        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "#43#");
321        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
322    }
323}
324
325/**
326 * @tc.number   cellular_call_DialCall_0015
327 * @tc.name     Test for GetCallWaiting function by cs
328 * @tc.desc     Function test
329 */
330HWTEST_F(CsTest, cellular_call_DialCall_0015, Function | MediumTest | Level2)
331{
332    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
333        return;
334    }
335    if (HasSimCard(SIM1_SLOTID)) {
336        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*#43#");
337        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
338    }
339    if (HasSimCard(SIM2_SLOTID)) {
340        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*#43#");
341        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
342    }
343}
344
345/**
346 * @tc.number   cellular_call_DialCall_0016
347 * @tc.name     Test for AlterPinPassword function by cs
348 * @tc.desc     Function test
349 */
350HWTEST_F(CsTest, cellular_call_DialCall_0016, Function | MediumTest | Level2)
351{
352    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
353        return;
354    }
355    if (HasSimCard(SIM1_SLOTID)) {
356        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*04#");
357        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
358    }
359    if (HasSimCard(SIM2_SLOTID)) {
360        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*04#");
361        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
362    }
363}
364
365/**
366 * @tc.number   cellular_call_DialCall_0017
367 * @tc.name     Test for UnlockPuk function by cs
368 * @tc.desc     Function test
369 */
370HWTEST_F(CsTest, cellular_call_DialCall_0017, Function | MediumTest | Level2)
371{
372    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
373        return;
374    }
375    if (HasSimCard(SIM1_SLOTID)) {
376        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*05#");
377        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
378    }
379    if (HasSimCard(SIM2_SLOTID)) {
380        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*05#");
381        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
382    }
383}
384
385/**
386 * @tc.number   cellular_call_DialCall_0018
387 * @tc.name     Test for AlterPin2Password function by cs
388 * @tc.desc     Function test
389 */
390HWTEST_F(CsTest, cellular_call_DialCall_0018, Function | MediumTest | Level2)
391{
392    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
393        return;
394    }
395    if (HasSimCard(SIM1_SLOTID)) {
396        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*042#");
397        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
398    }
399    if (HasSimCard(SIM2_SLOTID)) {
400        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*042#");
401        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
402    }
403}
404
405/**
406 * @tc.number   cellular_call_DialCall_0019
407 * @tc.name     Test for UnlockPuk2 function by cs
408 * @tc.desc     Function test
409 */
410HWTEST_F(CsTest, cellular_call_DialCall_0019, Function | MediumTest | Level2)
411{
412    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
413        return;
414    }
415    if (HasSimCard(SIM1_SLOTID)) {
416        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*052#");
417        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
418    }
419    if (HasSimCard(SIM2_SLOTID)) {
420        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*052#");
421        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
422    }
423}
424
425/**
426 * @tc.number   cellular_call_DialCall_0020
427 * @tc.name     Test for SendUssd function by cs
428 * @tc.desc     Function test
429 */
430HWTEST_F(CsTest, cellular_call_DialCall_0020, Function | MediumTest | Level2)
431{
432    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
433        return;
434    }
435    if (HasSimCard(SIM1_SLOTID)) {
436        int32_t ret = TestDialCallByCs(SIM1_SLOTID, "*4444#");
437        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
438    }
439    if (HasSimCard(SIM2_SLOTID)) {
440        int32_t ret = TestDialCallByCs(SIM2_SLOTID, "*4444#");
441        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
442    }
443}
444
445/**
446 * @tc.number   cellular_call_DialCall_0021
447 * @tc.name     Test for dial function with invalid slot by cs
448 * @tc.desc     Function test
449 */
450HWTEST_F(CsTest, cellular_call_DialCall_0021, Function | MediumTest | Level2)
451{
452    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
453        return;
454    }
455    if (HasSimCard(SIM1_SLOTID)) {
456        int32_t ret = TestDialCallByCs(INVALID_SLOTID, PHONE_NUMBER);
457        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
458    }
459    if (HasSimCard(SIM2_SLOTID)) {
460        int32_t ret = TestDialCallByCs(INVALID_SLOTID, PHONE_NUMBER);
461        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
462    }
463}
464
465/**
466 * @tc.number   cellular_call_HangUpCall_0001
467 * @tc.name     Test for HangUp function by cs
468 * @tc.desc     Function test
469 */
470HWTEST_F(CsTest, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)
471{
472    AccessToken token;
473    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
474    ASSERT_TRUE(systemAbilityMgr != nullptr);
475    auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
476    ASSERT_TRUE(hangUpCallRemote != nullptr);
477    auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
478    ASSERT_TRUE(telephonyService != nullptr);
479    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
480        return;
481    }
482    CellularCallInfo hangUpCallInfo;
483    if (HasSimCard(SIM1_SLOTID)) {
484        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, hangUpCallInfo);
485        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
486        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
487        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
488        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
489        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
490    }
491    if (HasSimCard(SIM2_SLOTID)) {
492        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, hangUpCallInfo);
493        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
494        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
495        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
496        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
497        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
498    }
499}
500
501/**
502 * @tc.number   cellular_call_HangUpCall_0002
503 * @tc.name     Test for HangUp function with invalid slot by cs
504 * @tc.desc     Function test
505 */
506HWTEST_F(CsTest, cellular_call_HangUpCall_0002, Function | MediumTest | Level2)
507{
508    AccessToken token;
509    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
510        return;
511    }
512    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
513    ASSERT_TRUE(systemAbilityMgr != nullptr);
514    auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
515    ASSERT_TRUE(hangUpCallRemote != nullptr);
516    auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
517    ASSERT_TRUE(telephonyService != nullptr);
518    if (HasSimCard(SIM1_SLOTID)) {
519        CellularCallInfo hangUpCallInfo;
520        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, hangUpCallInfo);
521        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
522        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
523        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
524    }
525    if (HasSimCard(SIM2_SLOTID)) {
526        CellularCallInfo hangUpCallInfo;
527        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, hangUpCallInfo);
528        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
529        ret = telephonyService->HangUp(hangUpCallInfo, CallSupplementType::TYPE_DEFAULT);
530        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
531    }
532}
533
534/**
535 * @tc.number   cellular_call_AnswerCall_0001
536 * @tc.name     Test for answer function by cs
537 * @tc.desc     Function test
538 */
539HWTEST_F(CsTest, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)
540{
541    AccessToken token;
542    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
543    ASSERT_TRUE(systemAbilityMgr != nullptr);
544    auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
545    ASSERT_TRUE(answerCallRemote != nullptr);
546    auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
547    ASSERT_TRUE(telephonyService != nullptr);
548    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
549        return;
550    }
551    if (HasSimCard(SIM1_SLOTID)) {
552        CellularCallInfo answerCallInfo;
553        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, answerCallInfo);
554        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
555        ret = telephonyService->Answer(answerCallInfo);
556        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
557    }
558    if (HasSimCard(SIM2_SLOTID)) {
559        CellularCallInfo answerCallInfo;
560        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, answerCallInfo);
561        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
562        ret = telephonyService->Answer(answerCallInfo);
563        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
564    }
565}
566
567/**
568 * @tc.number   cellular_call_AnswerCall_0002
569 * @tc.name     Test for answer function with invalid slot by cs
570 * @tc.desc     Function test
571 */
572HWTEST_F(CsTest, cellular_call_AnswerCall_0002, Function | MediumTest | Level2)
573{
574    AccessToken token;
575    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
576        return;
577    }
578    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
579    ASSERT_TRUE(systemAbilityMgr != nullptr);
580    auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
581    ASSERT_TRUE(answerCallRemote != nullptr);
582    auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
583    ASSERT_TRUE(telephonyService != nullptr);
584    if (HasSimCard(SIM1_SLOTID)) {
585        CellularCallInfo answerCallInfo;
586        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, answerCallInfo);
587        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
588        ret = telephonyService->Answer(answerCallInfo);
589        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
590    }
591    if (HasSimCard(SIM2_SLOTID)) {
592        CellularCallInfo answerCallInfo;
593        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, answerCallInfo);
594        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
595        ret = telephonyService->Answer(answerCallInfo);
596        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
597    }
598}
599
600/**
601 * @tc.number   cellular_call_RejectCall_0001
602 * @tc.name     Test for reject function by cs
603 * @tc.desc     Function test
604 */
605HWTEST_F(CsTest, cellular_call_RejectCall_0001, Function | MediumTest | Level2)
606{
607    AccessToken token;
608    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
609    ASSERT_TRUE(systemAbilityMgr != nullptr);
610    auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
611    ASSERT_TRUE(rejectCallRemote != nullptr);
612    auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
613    ASSERT_TRUE(telephonyService != nullptr);
614    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
615        return;
616    }
617    if (HasSimCard(SIM1_SLOTID)) {
618        CellularCallInfo rejectCallInfo;
619        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, rejectCallInfo);
620        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
621        ret = telephonyService->Reject(rejectCallInfo);
622        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
623    }
624    if (HasSimCard(SIM2_SLOTID)) {
625        CellularCallInfo rejectCallInfo;
626        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, rejectCallInfo);
627        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
628        ret = telephonyService->Reject(rejectCallInfo);
629        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
630    }
631}
632
633/**
634 * @tc.number   cellular_call_RejectCall_0002
635 * @tc.name     Test for reject function with invalid slot by cs
636 * @tc.desc     Function test
637 */
638HWTEST_F(CsTest, cellular_call_RejectCall_0002, Function | MediumTest | Level2)
639{
640    AccessToken token;
641    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
642        return;
643    }
644    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
645    ASSERT_TRUE(systemAbilityMgr != nullptr);
646    auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
647    ASSERT_TRUE(rejectCallRemote != nullptr);
648    auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
649    ASSERT_TRUE(telephonyService != nullptr);
650    if (HasSimCard(SIM1_SLOTID)) {
651        CellularCallInfo rejectCallInfo;
652        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, rejectCallInfo);
653        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
654        ret = telephonyService->Reject(rejectCallInfo);
655        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
656    }
657    if (HasSimCard(SIM2_SLOTID)) {
658        CellularCallInfo rejectCallInfo;
659        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, rejectCallInfo);
660        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
661        ret = telephonyService->Reject(rejectCallInfo);
662        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
663    }
664}
665
666/**
667 * @tc.number   cellular_call_HoldCall_0001
668 * @tc.name     Test for hold call function by cs
669 * @tc.desc     Function test
670 */
671HWTEST_F(CsTest, cellular_call_HoldCall_0001, Function | MediumTest | Level2)
672{
673    AccessToken token;
674    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
675    ASSERT_TRUE(systemAbilityMgr != nullptr);
676    auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
677    ASSERT_TRUE(holdCallRemote != nullptr);
678    auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
679    ASSERT_TRUE(telephonyService != nullptr);
680    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
681        return;
682    }
683    if (HasSimCard(SIM1_SLOTID)) {
684        CellularCallInfo holdCallInfo;
685        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, holdCallInfo);
686        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
687        ret = telephonyService->HoldCall(holdCallInfo);
688        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
689    }
690    if (HasSimCard(SIM2_SLOTID)) {
691        CellularCallInfo holdCallInfo;
692        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, holdCallInfo);
693        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
694        ret = telephonyService->HoldCall(holdCallInfo);
695        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
696    }
697}
698
699/**
700 * @tc.number   cellular_call_HoldCall_0002
701 * @tc.name     Test for hold function with invalid slot by cs
702 * @tc.desc     Function test
703 */
704HWTEST_F(CsTest, cellular_call_HoldCall_0002, Function | MediumTest | Level2)
705{
706    AccessToken token;
707    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
708        return;
709    }
710    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
711    ASSERT_TRUE(systemAbilityMgr != nullptr);
712    auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
713    ASSERT_TRUE(holdCallRemote != nullptr);
714    auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
715    ASSERT_TRUE(telephonyService != nullptr);
716    if (HasSimCard(SIM1_SLOTID)) {
717        CellularCallInfo holdCallInfo;
718        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, holdCallInfo);
719        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
720        ret = telephonyService->HoldCall(holdCallInfo);
721        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
722    }
723    if (HasSimCard(SIM2_SLOTID)) {
724        CellularCallInfo holdCallInfo;
725        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, holdCallInfo);
726        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
727        ret = telephonyService->HoldCall(holdCallInfo);
728        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
729    }
730}
731
732/**
733 * @tc.number   cellular_call_UnHoldCall_0001
734 * @tc.name     Test for unhold call function by cs
735 * @tc.desc     Function test
736 */
737HWTEST_F(CsTest, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)
738{
739    AccessToken token;
740    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
741    ASSERT_TRUE(systemAbilityMgr != nullptr);
742    auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
743    ASSERT_TRUE(unHoldCallRemote != nullptr);
744    auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
745    ASSERT_TRUE(telephonyService != nullptr);
746    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
747        return;
748    }
749    if (HasSimCard(SIM1_SLOTID)) {
750        CellularCallInfo unHoldCallInfo;
751        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, unHoldCallInfo);
752        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
753        ret = telephonyService->UnHoldCall(unHoldCallInfo);
754        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
755    }
756    if (HasSimCard(SIM2_SLOTID)) {
757        CellularCallInfo unHoldCallInfo;
758        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, unHoldCallInfo);
759        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
760        ret = telephonyService->UnHoldCall(unHoldCallInfo);
761        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
762    }
763}
764
765/**
766 * @tc.number   cellular_call_UnHoldCall_0002
767 * @tc.name     Test for unhold function with invalid slot by cs
768 * @tc.desc     Function test
769 */
770HWTEST_F(CsTest, cellular_call_UnHoldCall_0002, Function | MediumTest | Level2)
771{
772    AccessToken token;
773    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
774        return;
775    }
776    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
777    ASSERT_TRUE(systemAbilityMgr != nullptr);
778    auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
779    ASSERT_TRUE(unHoldCallRemote != nullptr);
780    auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
781    ASSERT_TRUE(telephonyService != nullptr);
782    if (HasSimCard(SIM1_SLOTID)) {
783        CellularCallInfo unHoldCallInfo;
784        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, unHoldCallInfo);
785        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
786        ret = telephonyService->UnHoldCall(unHoldCallInfo);
787        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
788    }
789    if (HasSimCard(SIM2_SLOTID)) {
790        CellularCallInfo unHoldCallInfo;
791        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, unHoldCallInfo);
792        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
793        ret = telephonyService->UnHoldCall(unHoldCallInfo);
794        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
795    }
796}
797
798/**
799 * @tc.number   cellular_call_SwitchCall_0001
800 * @tc.name     Test for switch call function by cs
801 * @tc.desc     Function test
802 */
803HWTEST_F(CsTest, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)
804{
805    AccessToken token;
806    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
807    ASSERT_TRUE(systemAbilityMgr != nullptr);
808    auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
809    ASSERT_TRUE(switchCallRemote != nullptr);
810    auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
811    ASSERT_TRUE(telephonyService != nullptr);
812    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
813        return;
814    }
815    if (HasSimCard(SIM1_SLOTID)) {
816        CellularCallInfo switchCallInfo;
817        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, switchCallInfo);
818        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
819        ret = telephonyService->SwitchCall(switchCallInfo);
820        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
821    }
822    if (HasSimCard(SIM2_SLOTID)) {
823        CellularCallInfo switchCallInfo;
824        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, switchCallInfo);
825        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
826        ret = telephonyService->SwitchCall(switchCallInfo);
827        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
828    }
829}
830
831/**
832 * @tc.number   cellular_call_SwitchCall_0002
833 * @tc.name     Test for switch function with invalid slot by cs
834 * @tc.desc     Function test
835 */
836HWTEST_F(CsTest, cellular_call_SwitchCall_0002, Function | MediumTest | Level2)
837{
838    AccessToken token;
839    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
840        return;
841    }
842    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
843    ASSERT_TRUE(systemAbilityMgr != nullptr);
844    auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
845    ASSERT_TRUE(switchCallRemote != nullptr);
846    auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
847    ASSERT_TRUE(telephonyService != nullptr);
848    if (HasSimCard(SIM1_SLOTID)) {
849        CellularCallInfo switchCallInfo;
850        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, switchCallInfo);
851        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
852        ret = telephonyService->SwitchCall(switchCallInfo);
853        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
854    }
855    if (HasSimCard(SIM2_SLOTID)) {
856        CellularCallInfo switchCallInfo;
857        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, switchCallInfo);
858        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
859        ret = telephonyService->SwitchCall(switchCallInfo);
860        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
861    }
862}
863
864/**
865 * @tc.number   cellular_call_CombineConference_0001
866 * @tc.name     Test for combineConference function by cs
867 * @tc.desc     Function test
868 */
869HWTEST_F(CsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)
870{
871    AccessToken token;
872    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
873    ASSERT_TRUE(systemAbilityMgr != nullptr);
874    auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
875    ASSERT_TRUE(combineRemote != nullptr);
876    auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
877    ASSERT_TRUE(telephonyService != nullptr);
878    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
879        return;
880    }
881    if (HasSimCard(SIM1_SLOTID)) {
882        CellularCallInfo conferenceCallInfo;
883        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, conferenceCallInfo);
884        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
885        ret = telephonyService->CombineConference(conferenceCallInfo);
886        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
887    }
888    if (HasSimCard(SIM2_SLOTID)) {
889        CellularCallInfo conferenceCallInfo;
890        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, conferenceCallInfo);
891        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
892        ret = telephonyService->CombineConference(conferenceCallInfo);
893        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
894    }
895}
896
897/**
898 * @tc.number   cellular_call_CombineConference_0002
899 * @tc.name     Test for combineConference function with invalid slot by cs
900 * @tc.desc     Function test
901 */
902HWTEST_F(CsTest, cellular_call_CombineConference_0002, Function | MediumTest | Level2)
903{
904    AccessToken token;
905    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
906        return;
907    }
908    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
909    ASSERT_TRUE(systemAbilityMgr != nullptr);
910    auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
911    ASSERT_TRUE(combineRemote != nullptr);
912    auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
913    ASSERT_TRUE(telephonyService != nullptr);
914    if (HasSimCard(SIM1_SLOTID)) {
915        CellularCallInfo conferenceCallInfo;
916        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, conferenceCallInfo);
917        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
918        ret = telephonyService->CombineConference(conferenceCallInfo);
919        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
920    }
921    if (HasSimCard(SIM2_SLOTID)) {
922        CellularCallInfo conferenceCallInfo;
923        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, conferenceCallInfo);
924        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
925        ret = telephonyService->CombineConference(conferenceCallInfo);
926        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
927    }
928}
929
930/**
931 * @tc.number   cellular_call_SeparateConference_0001
932 * @tc.name     Test for separateConference function by cs
933 * @tc.desc     Function test
934 */
935HWTEST_F(CsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)
936{
937    AccessToken token;
938    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
939    ASSERT_TRUE(systemAbilityMgr != nullptr);
940    auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
941    ASSERT_TRUE(separateRemote != nullptr);
942    auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
943    ASSERT_TRUE(telephonyService != nullptr);
944    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
945        return;
946    }
947    if (HasSimCard(SIM1_SLOTID)) {
948        CellularCallInfo callInfo;
949        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
950        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
951        ret = telephonyService->SeparateConference(callInfo);
952        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
953    }
954    if (HasSimCard(SIM2_SLOTID)) {
955        CellularCallInfo callInfo;
956        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
957        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
958        ret = telephonyService->SeparateConference(callInfo);
959        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
960    }
961}
962
963/**
964 * @tc.number   cellular_call_SeparateConference_0002
965 * @tc.name     Test for separateConference function with invalid slot by cs
966 * @tc.desc     Function test
967 */
968HWTEST_F(CsTest, cellular_call_SeparateConference_0002, Function | MediumTest | Level2)
969{
970    AccessToken token;
971    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
972        return;
973    }
974    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
975    ASSERT_TRUE(systemAbilityMgr != nullptr);
976    auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
977    ASSERT_TRUE(separateRemote != nullptr);
978    auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
979    ASSERT_TRUE(telephonyService != nullptr);
980    if (HasSimCard(SIM1_SLOTID)) {
981        CellularCallInfo separateCallInfo;
982        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, separateCallInfo);
983        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
984        ret = telephonyService->SeparateConference(separateCallInfo);
985        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
986    }
987    if (HasSimCard(SIM2_SLOTID)) {
988        CellularCallInfo separateCallInfo;
989        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, separateCallInfo);
990        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
991        ret = telephonyService->SeparateConference(separateCallInfo);
992        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
993    }
994}
995
996/**
997 * @tc.number   cellular_call_KickOutFromConference_0001
998 * @tc.name     Test for separateConference function by cs
999 * @tc.desc     Function test
1000 */
1001HWTEST_F(CsTest, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)
1002{
1003    AccessToken token;
1004    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1005    ASSERT_TRUE(systemAbilityMgr != nullptr);
1006    auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1007    ASSERT_TRUE(kickOutRemote != nullptr);
1008    auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
1009    ASSERT_TRUE(telephonyService != nullptr);
1010    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1011        return;
1012    }
1013    if (HasSimCard(SIM1_SLOTID)) {
1014        CellularCallInfo kickOutCallInfo;
1015        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, kickOutCallInfo);
1016        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1017        ret = telephonyService->KickOutFromConference(kickOutCallInfo);
1018        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1019    }
1020    if (HasSimCard(SIM2_SLOTID)) {
1021        CellularCallInfo kickOutCallInfo;
1022        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, kickOutCallInfo);
1023        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1024        ret = telephonyService->KickOutFromConference(kickOutCallInfo);
1025        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1026    }
1027}
1028
1029/**
1030 * @tc.number   cellular_call_KickOutFromConference_0002
1031 * @tc.name     Test for KickOutFromConference function with invalid slot by cs
1032 * @tc.desc     Function test
1033 */
1034HWTEST_F(CsTest, cellular_call_KickOutFromConference_0002, Function | MediumTest | Level2)
1035{
1036    AccessToken token;
1037    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1038        return;
1039    }
1040    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1041    ASSERT_TRUE(systemAbilityMgr != nullptr);
1042    auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1043    ASSERT_TRUE(kickOutRemote != nullptr);
1044    auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
1045    ASSERT_TRUE(telephonyService != nullptr);
1046    if (HasSimCard(SIM1_SLOTID)) {
1047        CellularCallInfo kickOutCallInfo;
1048        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, kickOutCallInfo);
1049        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1050        ret = telephonyService->KickOutFromConference(kickOutCallInfo);
1051        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1052    }
1053    if (HasSimCard(SIM2_SLOTID)) {
1054        CellularCallInfo kickOutCallInfo;
1055        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, kickOutCallInfo);
1056        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1057        ret = telephonyService->KickOutFromConference(kickOutCallInfo);
1058        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1059    }
1060}
1061
1062/**
1063 * @tc.number   cellular_call_HangUpAllConnection_0001
1064 * @tc.name     Test for hangup all connection function by cs
1065 * @tc.desc     Function test
1066 */
1067HWTEST_F(CsTest, cellular_call_HangUpAllConnection_0001, Function | MediumTest | Level2)
1068{
1069    AccessToken token;
1070    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1071    ASSERT_TRUE(systemAbilityMgr != nullptr);
1072    auto hangUpAllConRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1073    ASSERT_TRUE(hangUpAllConRemote != nullptr);
1074    auto telephonyService = iface_cast<CellularCallInterface>(hangUpAllConRemote);
1075    ASSERT_TRUE(telephonyService != nullptr);
1076    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1077        return;
1078    }
1079    if (HasSimCard(SIM1_SLOTID)) {
1080        int32_t ret = telephonyService->HangUpAllConnection();
1081        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1082    }
1083    if (HasSimCard(SIM2_SLOTID)) {
1084        int32_t ret = telephonyService->HangUpAllConnection();
1085        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1086    }
1087}
1088
1089/**
1090 * @tc.number   cellular_call_StartDtmf_0001
1091 * @tc.name     Test for startDtmf function by cs
1092 * @tc.desc     Function test
1093 */
1094HWTEST_F(CsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)
1095{
1096    AccessToken token;
1097    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1098    ASSERT_TRUE(systemAbilityMgr != nullptr);
1099    auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1100    ASSERT_TRUE(startDtmfRemote != nullptr);
1101    auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
1102    ASSERT_TRUE(telephonyService != nullptr);
1103    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1104        return;
1105    }
1106    if (HasSimCard(SIM1_SLOTID)) {
1107        CellularCallInfo callInfo;
1108        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
1109        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1110        char code = '1';
1111        ret = telephonyService->StartDtmf(code, callInfo);
1112        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1113    }
1114    if (HasSimCard(SIM2_SLOTID)) {
1115        CellularCallInfo callInfo;
1116        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
1117        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1118        char code = '1';
1119        ret = telephonyService->StartDtmf(code, callInfo);
1120        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1121    }
1122}
1123
1124/**
1125 * @tc.number   cellular_call_StartDtmf_0002
1126 * @tc.name     Test for startDtmf function with invalid slot by cs
1127 * @tc.desc     Function test
1128 */
1129HWTEST_F(CsTest, cellular_call_StartDtmf_0002, Function | MediumTest | Level2)
1130{
1131    AccessToken token;
1132    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1133        return;
1134    }
1135    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1136    ASSERT_TRUE(systemAbilityMgr != nullptr);
1137    auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1138    ASSERT_TRUE(startDtmfRemote != nullptr);
1139    auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
1140    ASSERT_TRUE(telephonyService != nullptr);
1141    CellularCallInfo callInfo;
1142    if (HasSimCard(SIM1_SLOTID)) {
1143        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
1144        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1145        char code = '1';
1146        ret = telephonyService->StartDtmf(code, callInfo);
1147        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1148    }
1149    if (HasSimCard(SIM2_SLOTID)) {
1150        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
1151        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1152        char code = '1';
1153        ret = telephonyService->StartDtmf(code, callInfo);
1154        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1155    }
1156}
1157
1158/**
1159 * @tc.number   cellular_call_StopDtmf_0001
1160 * @tc.name     Test for stopDtmf function by cs
1161 * @tc.desc     Function test
1162 */
1163HWTEST_F(CsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)
1164{
1165    AccessToken token;
1166    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1167    ASSERT_TRUE(systemAbilityMgr != nullptr);
1168    auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1169    ASSERT_TRUE(stopDtmfRemote != nullptr);
1170    auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
1171    ASSERT_TRUE(telephonyService != nullptr);
1172    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1173        return;
1174    }
1175    if (HasSimCard(SIM1_SLOTID)) {
1176        CellularCallInfo callInfo;
1177        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
1178        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1179        ret = telephonyService->StopDtmf(callInfo);
1180        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1181    }
1182    if (HasSimCard(SIM2_SLOTID)) {
1183        CellularCallInfo callInfo;
1184        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
1185        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1186        ret = telephonyService->StopDtmf(callInfo);
1187        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1188    }
1189}
1190
1191/**
1192 * @tc.number   cellular_call_StopDtmf_0002
1193 * @tc.name     Test for stopDtmf function with invalid slot by cs
1194 * @tc.desc     Function test
1195 */
1196HWTEST_F(CsTest, cellular_call_StopDtmf_0002, Function | MediumTest | Level2)
1197{
1198    AccessToken token;
1199    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1200        return;
1201    }
1202    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1203    ASSERT_TRUE(systemAbilityMgr != nullptr);
1204    auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1205    ASSERT_TRUE(stopDtmfRemote != nullptr);
1206    auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
1207    ASSERT_TRUE(telephonyService != nullptr);
1208    if (HasSimCard(SIM1_SLOTID)) {
1209        CellularCallInfo stopDtmfCallInfo;
1210        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
1211        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1212        ret = telephonyService->StopDtmf(stopDtmfCallInfo);
1213        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1214    }
1215    if (HasSimCard(SIM2_SLOTID)) {
1216        CellularCallInfo stopDtmfCallInfo;
1217        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
1218        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1219        ret = telephonyService->StopDtmf(stopDtmfCallInfo);
1220        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1221    }
1222}
1223
1224/**
1225 * @tc.number   cellular_call_SendDtmf_0001
1226 * @tc.name     Test for sendDtmf function by cs
1227 * @tc.desc     Function test
1228 */
1229HWTEST_F(CsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)
1230{
1231    AccessToken token;
1232    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1233    ASSERT_TRUE(systemAbilityMgr != nullptr);
1234    auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1235    ASSERT_TRUE(sendDtmfRemote != nullptr);
1236    auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
1237    ASSERT_TRUE(telephonyService != nullptr);
1238    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1239        return;
1240    }
1241    if (HasSimCard(SIM1_SLOTID)) {
1242        CellularCallInfo sendDtmfCallInfo;
1243        int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
1244        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1245        char code = '1';
1246        ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
1247        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1248    }
1249    if (HasSimCard(SIM2_SLOTID)) {
1250        CellularCallInfo sendDtmfCallInfo;
1251        int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
1252        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1253        char code = '1';
1254        ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
1255        EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1256    }
1257}
1258
1259/**
1260 * @tc.number   cellular_call_SendDtmf_0002
1261 * @tc.name     Test for sendDtmf function with invalid slot by cs
1262 * @tc.desc     Function test
1263 */
1264HWTEST_F(CsTest, cellular_call_SendDtmf_0002, Function | MediumTest | Level2)
1265{
1266    AccessToken token;
1267    if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1268        return;
1269    }
1270    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1271    ASSERT_TRUE(systemAbilityMgr != nullptr);
1272    auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1273    ASSERT_TRUE(sendDtmfRemote != nullptr);
1274    auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
1275    ASSERT_TRUE(telephonyService != nullptr);
1276    if (HasSimCard(SIM1_SLOTID)) {
1277        CellularCallInfo sendDtmfCallInfo;
1278        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
1279        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1280        char code = '1';
1281        ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
1282        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1283    }
1284    if (HasSimCard(SIM2_SLOTID)) {
1285        CellularCallInfo sendDtmfCallInfo;
1286        int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
1287        EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1288        char code = '1';
1289        ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
1290        EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
1291    }
1292}
1293} // namespace Telephony
1294} // namespace OHOS
1295