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 "ims_test.h"
17
18 #define private public
19 #define protected public
20 #include "cellular_call_config.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 "tel_ril_call_parcel.h"
26 #include "ims_call_callback_proxy.h"
27 #include "ims_call_callback_stub.h"
28 #include "ims_call_client.h"
29 #include "ims_control.h"
30 #include "ims_error.h"
31 #include "securec.h"
32
33 namespace OHOS {
34 namespace Telephony {
35 using namespace testing::ext;
36 const int32_t SIM1_SLOTID = 0;
37 const int32_t SIM2_SLOTID = 1;
38 const std::string PHONE_NUMBER = "0000000";
39 const std::string PHONE_NUMBER_SECOND = "1111111";
40 const std::string PHONE_NUMBER_THIRD = "2222222";
41 const std::string PHONE_NUMBER_FOUR = "3333333";
42
43 /**
44 * @tc.number cellular_call_ims_test_001
45 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
46 * GetCallPreferenceMode, etc
47 * @tc.desc Function test
48 */
HWTEST_F(ImsTest, cellular_call_ims_test_001, Function | MediumTest | Level0)49 HWTEST_F(ImsTest, cellular_call_ims_test_001, Function | MediumTest | Level0)
50 {
51 AccessToken token;
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_ims_test_001";
59 }
60
61 /**
62 * @tc.number cellular_call_ims_test_002
63 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
64 * GetCallPreferenceMode, etc
65 * @tc.desc Function test
66 */
HWTEST_F(ImsTest, cellular_call_ims_test_002, Function | MediumTest | Level1)67 HWTEST_F(ImsTest, cellular_call_ims_test_002, Function | MediumTest | Level1)
68 {
69 AccessToken token;
70 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
71 ASSERT_TRUE(systemAbilityMgr != nullptr);
72 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
73 ASSERT_TRUE(remote != nullptr);
74 auto telephonyService = iface_cast<CellularCallInterface>(remote);
75 ASSERT_TRUE(telephonyService != nullptr);
76 std::cout << "HWTEST_F cellular_call_ims_test_002";
77 }
78
79 /**
80 * @tc.number cellular_call_DialCall_0001
81 * @tc.name Test for SetClip function by ims
82 * @tc.desc Function test
83 */
HWTEST_F(ImsTest, cellular_call_DialCall_0001, Function | MediumTest | Level2)84 HWTEST_F(ImsTest, cellular_call_DialCall_0001, Function | MediumTest | Level2)
85 {
86 AccessToken token;
87 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
88 return;
89 }
90 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
91 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*30#");
92 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
93 }
94 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
95 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*30#");
96 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
97 }
98 }
99
100 /**
101 * @tc.number cellular_call_DialCall_0002
102 * @tc.name Test for SetClip function by ims
103 * @tc.desc Function test
104 */
HWTEST_F(ImsTest, cellular_call_DialCall_0002, Function | MediumTest | Level2)105 HWTEST_F(ImsTest, cellular_call_DialCall_0002, Function | MediumTest | Level2)
106 {
107 AccessToken token;
108 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
109 return;
110 }
111 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
112 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#30#");
113 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
114 }
115 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
116 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#30#");
117 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
118 }
119 }
120
121 /**
122 * @tc.number cellular_call_DialCall_0003
123 * @tc.name Test for getClip function by ims
124 * @tc.desc Function test
125 */
HWTEST_F(ImsTest, cellular_call_DialCall_0003, Function | MediumTest | Level2)126 HWTEST_F(ImsTest, cellular_call_DialCall_0003, Function | MediumTest | Level2)
127 {
128 AccessToken token;
129 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
130 return;
131 }
132 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
133 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#30#");
134 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
135 }
136 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
137 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#30#");
138 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
139 }
140 }
141
142 /**
143 * @tc.number cellular_call_DialCall_0004
144 * @tc.name Test for SetClir function by ims
145 * @tc.desc Function test
146 */
HWTEST_F(ImsTest, cellular_call_DialCall_0004, Function | MediumTest | Level2)147 HWTEST_F(ImsTest, cellular_call_DialCall_0004, Function | MediumTest | Level2)
148 {
149 AccessToken token;
150 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
151 return;
152 }
153 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
154 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*31#");
155 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
156 }
157 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
158 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*31#");
159 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
160 }
161 }
162
163 /**
164 * @tc.number cellular_call_DialCall_0005
165 * @tc.name Test for SetClir function by ims
166 * @tc.desc Function test
167 */
HWTEST_F(ImsTest, cellular_call_DialCall_0005, Function | MediumTest | Level2)168 HWTEST_F(ImsTest, cellular_call_DialCall_0005, Function | MediumTest | Level2)
169 {
170 AccessToken token;
171 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
172 return;
173 }
174 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
175 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#31#");
176 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
177 }
178 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
179 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#31#");
180 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
181 }
182 }
183
184 /**
185 * @tc.number cellular_call_DialCall_0006
186 * @tc.name Test for GetClir function by ims
187 * @tc.desc Function test
188 */
HWTEST_F(ImsTest, cellular_call_DialCall_0006, Function | MediumTest | Level2)189 HWTEST_F(ImsTest, cellular_call_DialCall_0006, Function | MediumTest | Level2)
190 {
191 AccessToken token;
192 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
193 return;
194 }
195 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
196 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#31#");
197 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
198 }
199 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
200 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#31#");
201 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
202 }
203 }
204
205 /**
206 * @tc.number cellular_call_DialCall_0007
207 * @tc.name Test for SetCallTransfer function by ims
208 * @tc.desc Function test
209 */
HWTEST_F(ImsTest, cellular_call_DialCall_0007, Function | MediumTest | Level2)210 HWTEST_F(ImsTest, cellular_call_DialCall_0007, Function | MediumTest | Level2)
211 {
212 AccessToken token;
213 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
214 return;
215 }
216 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
217 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*21#");
218 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
219 }
220 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
221 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*21#");
222 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
223 }
224 }
225
226 /**
227 * @tc.number cellular_call_DialCall_0008
228 * @tc.name Test for SetCallTransfer function by ims
229 * @tc.desc Function test
230 */
HWTEST_F(ImsTest, cellular_call_DialCall_0008, Function | MediumTest | Level2)231 HWTEST_F(ImsTest, cellular_call_DialCall_0008, Function | MediumTest | Level2)
232 {
233 AccessToken token;
234 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
235 return;
236 }
237 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
238 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#21#");
239 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
240 }
241 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
242 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#21#");
243 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
244 }
245 }
246
247 /**
248 * @tc.number cellular_call_DialCall_0009
249 * @tc.name Test for GetCallTransfer function by ims
250 * @tc.desc Function test
251 */
HWTEST_F(ImsTest, cellular_call_DialCall_0009, Function | MediumTest | Level2)252 HWTEST_F(ImsTest, cellular_call_DialCall_0009, Function | MediumTest | Level2)
253 {
254 AccessToken token;
255 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
256 return;
257 }
258 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
259 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#21#");
260 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
261 }
262 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
263 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#21#");
264 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
265 }
266 }
267
268 /**
269 * @tc.number cellular_call_DialCall_0010
270 * @tc.name Test for SetCallRestriction function by ims
271 * @tc.desc Function test
272 */
HWTEST_F(ImsTest, cellular_call_DialCall_0010, Function | MediumTest | Level2)273 HWTEST_F(ImsTest, cellular_call_DialCall_0010, Function | MediumTest | Level2)
274 {
275 AccessToken token;
276 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
277 return;
278 }
279 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
280 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*33#");
281 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
282 }
283 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
284 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*33#");
285 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
286 }
287 }
288
289 /**
290 * @tc.number cellular_call_DialCall_0011
291 * @tc.name Test for SetCallRestriction function by ims
292 * @tc.desc Function test
293 */
HWTEST_F(ImsTest, cellular_call_DialCall_0011, Function | MediumTest | Level2)294 HWTEST_F(ImsTest, cellular_call_DialCall_0011, Function | MediumTest | Level2)
295 {
296 AccessToken token;
297 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
298 return;
299 }
300 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
301 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#33#");
302 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
303 }
304 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
305 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#33#");
306 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
307 }
308 }
309
310 /**
311 * @tc.number cellular_call_DialCall_0012
312 * @tc.name Test for GetCallRestriction function by ims
313 * @tc.desc Function test
314 */
HWTEST_F(ImsTest, cellular_call_DialCall_0012, Function | MediumTest | Level2)315 HWTEST_F(ImsTest, cellular_call_DialCall_0012, Function | MediumTest | Level2)
316 {
317 AccessToken token;
318 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
319 return;
320 }
321 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
322 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#33#");
323 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
324 }
325 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
326 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#33#");
327 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
328 }
329 }
330
331 /**
332 * @tc.number cellular_call_DialCall_0013
333 * @tc.name Test for SetCallWaiting function by ims
334 * @tc.desc Function test
335 */
HWTEST_F(ImsTest, cellular_call_DialCall_0013, Function | MediumTest | Level2)336 HWTEST_F(ImsTest, cellular_call_DialCall_0013, Function | MediumTest | Level2)
337 {
338 AccessToken token;
339 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
340 return;
341 }
342 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
343 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*43#");
344 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
345 }
346 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
347 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*43#");
348 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
349 }
350 }
351
352 /**
353 * @tc.number cellular_call_DialCall_0014
354 * @tc.name Test for SetCallWaiting function by ims
355 * @tc.desc Function test
356 */
HWTEST_F(ImsTest, cellular_call_DialCall_0014, Function | MediumTest | Level2)357 HWTEST_F(ImsTest, cellular_call_DialCall_0014, Function | MediumTest | Level2)
358 {
359 AccessToken token;
360 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
361 return;
362 }
363 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
364 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#43#");
365 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
366 }
367 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
368 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#43#");
369 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
370 }
371 }
372
373 /**
374 * @tc.number cellular_call_DialCall_0015
375 * @tc.name Test for GetCallWaiting function by ims
376 * @tc.desc Function test
377 */
HWTEST_F(ImsTest, cellular_call_DialCall_0015, Function | MediumTest | Level2)378 HWTEST_F(ImsTest, cellular_call_DialCall_0015, Function | MediumTest | Level2)
379 {
380 AccessToken token;
381 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
382 return;
383 }
384 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
385 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#43#");
386 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
387 ret = TestDialCallByIms(SIM1_SLOTID, "*#4@3#");
388 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
389 }
390 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
391 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#43#");
392 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
393 ret = TestDialCallByIms(SIM2_SLOTID, "*#4@3#");
394 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
395 }
396 }
397
398 /**
399 * @tc.number cellular_call_HangUpCall_0001
400 * @tc.name Test for HangUp function by ims
401 * @tc.desc Function test
402 */
HWTEST_F(ImsTest, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)403 HWTEST_F(ImsTest, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)
404 {
405 AccessToken token;
406 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
407 ASSERT_TRUE(systemAbilityMgr != nullptr);
408 auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
409 ASSERT_TRUE(hangUpCallRemote != nullptr);
410 auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
411 ASSERT_TRUE(telephonyService != nullptr);
412 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
413 return;
414 }
415 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
416 CellularCallInfo callInfo;
417 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
418 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
419 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
420 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
421 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
422 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
423 }
424 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
425 CellularCallInfo callInfo;
426 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
427 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
428 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
429 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
430 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
431 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
432 }
433 }
434
435 /**
436 * @tc.number cellular_call_AnswerCall_0001
437 * @tc.name Test for answer function by ims
438 * @tc.desc Function test
439 */
HWTEST_F(ImsTest, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)440 HWTEST_F(ImsTest, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)
441 {
442 AccessToken token;
443 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
444 ASSERT_TRUE(systemAbilityMgr != nullptr);
445 auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
446 ASSERT_TRUE(answerCallRemote != nullptr);
447 auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
448 ASSERT_TRUE(telephonyService != nullptr);
449 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
450 return;
451 }
452 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
453 CellularCallInfo callInfo;
454 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
455 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
456 ret = telephonyService->Answer(callInfo);
457 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
458 }
459 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
460 CellularCallInfo callInfo;
461 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
462 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
463 ret = telephonyService->Answer(callInfo);
464 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
465 }
466 }
467
468 /**
469 * @tc.number cellular_call_RejectCall_0001
470 * @tc.name Test for reject function by ims
471 * @tc.desc Function test
472 */
HWTEST_F(ImsTest, cellular_call_RejectCall_0001, Function | MediumTest | Level2)473 HWTEST_F(ImsTest, cellular_call_RejectCall_0001, Function | MediumTest | Level2)
474 {
475 AccessToken token;
476 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
477 ASSERT_TRUE(systemAbilityMgr != nullptr);
478 auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
479 ASSERT_TRUE(rejectCallRemote != nullptr);
480 auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
481 ASSERT_TRUE(telephonyService != nullptr);
482 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
483 return;
484 }
485 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
486 CellularCallInfo callInfo;
487 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
488 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
489 ret = telephonyService->Reject(callInfo);
490 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
491 }
492 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
493 CellularCallInfo callInfo;
494 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
495 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
496 ret = telephonyService->Reject(callInfo);
497 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
498 }
499 }
500
501 /**
502 * @tc.number cellular_call_HoldCall_0001
503 * @tc.name Test for hold call function by ims
504 * @tc.desc Function test
505 */
HWTEST_F(ImsTest, cellular_call_HoldCall_0001, Function | MediumTest | Level2)506 HWTEST_F(ImsTest, cellular_call_HoldCall_0001, Function | MediumTest | Level2)
507 {
508 AccessToken token;
509 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
510 ASSERT_TRUE(systemAbilityMgr != nullptr);
511 auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
512 ASSERT_TRUE(holdCallRemote != nullptr);
513 auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
514 ASSERT_TRUE(telephonyService != nullptr);
515 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
516 return;
517 }
518 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
519 CellularCallInfo callInfo;
520 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
521 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
522 ret = telephonyService->HoldCall(callInfo);
523 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
524 }
525 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
526 CellularCallInfo callInfo;
527 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
528 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
529 ret = telephonyService->HoldCall(callInfo);
530 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
531 }
532 }
533
534 /**
535 * @tc.number cellular_call_UnHoldCall_0001
536 * @tc.name Test for unhold call function by ims
537 * @tc.desc Function test
538 */
HWTEST_F(ImsTest, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)539 HWTEST_F(ImsTest, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)
540 {
541 AccessToken token;
542 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
543 ASSERT_TRUE(systemAbilityMgr != nullptr);
544 auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
545 ASSERT_TRUE(unHoldCallRemote != nullptr);
546 auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
547 ASSERT_TRUE(telephonyService != nullptr);
548 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
549 return;
550 }
551 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
552 CellularCallInfo callInfo;
553 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
554 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
555 ret = telephonyService->UnHoldCall(callInfo);
556 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
557 }
558 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
559 CellularCallInfo callInfo;
560 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
561 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
562 ret = telephonyService->UnHoldCall(callInfo);
563 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
564 }
565 }
566
567 /**
568 * @tc.number cellular_call_SwitchCall_0001
569 * @tc.name Test for switch call function by ims
570 * @tc.desc Function test
571 */
HWTEST_F(ImsTest, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)572 HWTEST_F(ImsTest, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)
573 {
574 AccessToken token;
575 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
576 ASSERT_TRUE(systemAbilityMgr != nullptr);
577 auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
578 ASSERT_TRUE(switchCallRemote != nullptr);
579 auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
580 ASSERT_TRUE(telephonyService != nullptr);
581 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
582 return;
583 }
584 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
585 CellularCallInfo callInfo;
586 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
587 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
588 ret = telephonyService->SwitchCall(callInfo);
589 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
590 }
591 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
592 CellularCallInfo callInfo;
593 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
594 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
595 ret = telephonyService->SwitchCall(callInfo);
596 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
597 }
598 }
599
600 /**
601 * @tc.number cellular_call_CombineConference_0001
602 * @tc.name Test for combineConference function by ims
603 * @tc.desc Function test
604 */
HWTEST_F(ImsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)605 HWTEST_F(ImsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)
606 {
607 AccessToken token;
608 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
609 ASSERT_TRUE(systemAbilityMgr != nullptr);
610 auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
611 ASSERT_TRUE(combineRemote != nullptr);
612 auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
613 ASSERT_TRUE(telephonyService != nullptr);
614 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
615 return;
616 }
617 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
618 CellularCallInfo callInfo;
619 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
620 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
621 ret = telephonyService->CombineConference(callInfo);
622 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
623 }
624 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
625 CellularCallInfo callInfo;
626 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
627 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
628 ret = telephonyService->CombineConference(callInfo);
629 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
630 }
631 }
632
633 /**
634 * @tc.number cellular_call_SeparateConference_0001
635 * @tc.name Test for separateConference function by ims
636 * @tc.desc Function test
637 */
HWTEST_F(ImsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)638 HWTEST_F(ImsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)
639 {
640 AccessToken token;
641 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
642 ASSERT_TRUE(systemAbilityMgr != nullptr);
643 auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
644 ASSERT_TRUE(separateRemote != nullptr);
645 auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
646 ASSERT_TRUE(telephonyService != nullptr);
647 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
648 return;
649 }
650 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
651 CellularCallInfo callInfo;
652 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
653 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
654 ret = telephonyService->SeparateConference(callInfo);
655 EXPECT_EQ(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
656 }
657 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
658 CellularCallInfo callInfo;
659 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
660 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
661 ret = telephonyService->SeparateConference(callInfo);
662 EXPECT_EQ(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
663 }
664 }
665
666 /**
667 * @tc.number cellular_call_KickOutFromConference_0001
668 * @tc.name Test for KickOutFromConference function by ims
669 * @tc.desc Function test
670 */
HWTEST_F(ImsTest, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)671 HWTEST_F(ImsTest, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)
672 {
673 AccessToken token;
674 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
675 ASSERT_TRUE(systemAbilityMgr != nullptr);
676 auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
677 ASSERT_TRUE(kickOutRemote != nullptr);
678 auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
679 ASSERT_TRUE(telephonyService != nullptr);
680 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
681 return;
682 }
683 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
684 CellularCallInfo callInfo;
685 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
686 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
687 ret = telephonyService->KickOutFromConference(callInfo);
688 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
689 }
690 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
691 CellularCallInfo callInfo;
692 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
693 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
694 ret = telephonyService->KickOutFromConference(callInfo);
695 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
696 }
697 }
698
699 /**
700 * @tc.number cellular_call_StartDtmf_0001
701 * @tc.name Test for startDtmf function by ims
702 * @tc.desc Function test
703 */
HWTEST_F(ImsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)704 HWTEST_F(ImsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)
705 {
706 AccessToken token;
707 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
708 ASSERT_TRUE(systemAbilityMgr != nullptr);
709 auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
710 ASSERT_TRUE(startDtmfRemote != nullptr);
711 auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
712 ASSERT_TRUE(telephonyService != nullptr);
713 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
714 return;
715 }
716 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
717 CellularCallInfo callInfo;
718 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
719 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
720 char code = '1';
721 ret = telephonyService->StartDtmf(code, callInfo);
722 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
723 }
724 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
725 CellularCallInfo callInfo;
726 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
727 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
728 char code = '1';
729 ret = telephonyService->StartDtmf(code, callInfo);
730 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
731 }
732 }
733
734 /**
735 * @tc.number cellular_call_StopDtmf_0001
736 * @tc.name Test for stopDtmf function by ims
737 * @tc.desc Function test
738 */
HWTEST_F(ImsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)739 HWTEST_F(ImsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)
740 {
741 AccessToken token;
742 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
743 ASSERT_TRUE(systemAbilityMgr != nullptr);
744 auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
745 ASSERT_TRUE(stopDtmfRemote != nullptr);
746 auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
747 ASSERT_TRUE(telephonyService != nullptr);
748 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
749 return;
750 }
751 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
752 CellularCallInfo callInfo;
753 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
754 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
755 ret = telephonyService->StopDtmf(callInfo);
756 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
757 }
758 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
759 CellularCallInfo callInfo;
760 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
761 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
762 ret = telephonyService->StopDtmf(callInfo);
763 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
764 }
765 }
766
767 /**
768 * @tc.number cellular_call_SendDtmf_0001
769 * @tc.name Test for sendDtmf function by ims
770 * @tc.desc Function test
771 */
HWTEST_F(ImsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)772 HWTEST_F(ImsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)
773 {
774 AccessToken token;
775 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
776 ASSERT_TRUE(systemAbilityMgr != nullptr);
777 auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
778 ASSERT_TRUE(sendDtmfRemote != nullptr);
779 auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
780 ASSERT_TRUE(telephonyService != nullptr);
781 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
782 return;
783 }
784 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
785 CellularCallInfo callInfo;
786 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
787 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
788 char code = '1';
789 ret = telephonyService->SendDtmf(code, callInfo);
790 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
791 }
792 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
793 CellularCallInfo callInfo;
794 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
795 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
796 char code = '1';
797 ret = telephonyService->SendDtmf(code, callInfo);
798 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
799 }
800 }
801
802 /**
803 * @tc.number cellular_call_CanSetCallTransferTime_0001
804 * @tc.name Test for CanSetCallTransferTime function by ims
805 * @tc.desc Function test
806 */
HWTEST_F(ImsTest, cellular_call_CanSetCallTransferTime_0001, Function | MediumTest | Level2)807 HWTEST_F(ImsTest, cellular_call_CanSetCallTransferTime_0001, Function | MediumTest | Level2)
808 {
809 AccessToken token;
810 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
811 ASSERT_TRUE(systemAbilityMgr != nullptr);
812 auto transferRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
813 ASSERT_TRUE(transferRemote != nullptr);
814 auto telephonyService = iface_cast<CellularCallInterface>(transferRemote);
815 ASSERT_TRUE(telephonyService != nullptr);
816 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
817 return;
818 }
819 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
820 bool result;
821 int32_t ret = telephonyService->CanSetCallTransferTime(SIM1_SLOTID, result);
822 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
823 }
824 if (HasSimCard(SIM2_SLOTID)) {
825 bool result;
826 int32_t ret = telephonyService->CanSetCallTransferTime(SIM2_SLOTID, result);
827 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
828 }
829 }
830
831
832 /**
833 * @tc.number cellular_call_SetVoNRState_0001
834 * @tc.name Test for SetVoNRState function
835 * @tc.desc Function test
836 */
HWTEST_F(ImsTest, cellular_call_SetVoNRState_0001, Function | MediumTest | Level2)837 HWTEST_F(ImsTest, cellular_call_SetVoNRState_0001, Function | MediumTest | Level2)
838 {
839 AccessToken token;
840 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
841 ASSERT_TRUE(systemAbilityMgr != nullptr);
842 auto setVoNRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
843 ASSERT_TRUE(setVoNRRemote != nullptr);
844 auto telephonyService = iface_cast<CellularCallInterface>(setVoNRRemote);
845 ASSERT_TRUE(telephonyService != nullptr);
846 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
847 return;
848 }
849 if (HasSimCard(SIM1_SLOTID)) {
850 int32_t ret = telephonyService->SetVoNRState(SIM1_SLOTID, 1);
851 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
852 }
853 if (HasSimCard(SIM2_SLOTID)) {
854 int32_t ret = telephonyService->SetVoNRState(SIM2_SLOTID, 1);
855 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
856 }
857 }
858 } // namespace Telephony
859 } // namespace OHOS
860