1 /*
2 * Copyright (C) 2021-2022 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_register.h"
21 #include "hril_call_parcel.h"
22 #include "ims_control.h"
23 #include "securec.h"
24
25 namespace OHOS {
26 namespace Telephony {
27 using namespace testing::ext;
28 const int32_t SIM1_SLOTID = 0;
29 const int32_t SIM2_SLOTID = 1;
30 const int32_t INVALID_HANG_UP_TYPE = -1;
31 const int32_t RESULT = 1;
32 const std::string PHONE_NUMBER = "0000000";
33 const std::string PHONE_NUMBER_SECOND = "1111111";
34 const std::string PHONE_NUMBER_THIRD = "2222222";
35 const std::string PHONE_NUMBER_FOUR = "3333333";
36 const int32_t CELLULAR_CALL_SUCCESS = 0;
37
SetUpTestCase(void)38 void ImsTest::SetUpTestCase(void)
39 {
40 // step 3: Set Up Test Case
41 }
42
TearDownTestCase(void)43 void ImsTest::TearDownTestCase(void)
44 {
45 // step 3: Tear Down Test Case
46 }
47
SetUp(void)48 void ImsTest::SetUp(void)
49 {
50 // step 3: input testcase setup step
51 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_DOMAIN_PREFERENCE_MODE)] =
52 &ImsTest::SetDomainPreferenceMode;
53 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::GET_DOMAIN_PREFERENCE_MODE)] =
54 &ImsTest::GetDomainPreferenceMode;
55 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_IMS_SWITCH_STATUS)] =
56 &ImsTest::SetImsSwitchStatus;
57 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::GET_IMS_SWITCH_STATUS)] =
58 &ImsTest::GetImsSwitchStatus;
59 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_IMS_CONFIG_STRING)] =
60 &ImsTest::SetImsConfigString;
61 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_IMS_CONFIG_INT)] =
62 &ImsTest::SetImsConfigInt;
63 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::GET_IMS_CONFIG)] =
64 &ImsTest::GetImsConfig;
65 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_IMS_FEATURE)] =
66 &ImsTest::SetImsFeatureValue;
67 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::GET_IMS_FEATURE)] =
68 &ImsTest::GetImsFeatureValue;
69 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::CTRL_CAMERA)] = &ImsTest::CtrlCamera;
70 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_PREVIEW_WINDOW)] =
71 &ImsTest::SetPreviewWindow;
72 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_DISPLAY_WINDOW)] =
73 &ImsTest::SetDisplayWindow;
74 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_CAMERA_ZOOM)] =
75 &ImsTest::SetCameraZoom;
76 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_PAUSE_IMAGE)] =
77 &ImsTest::SetPauseImage;
78 requestFuncMap_[static_cast<int32_t>(CellularCallInterface::OperationType::SET_DEVICE_DIRECTION)] =
79 &ImsTest::SetDeviceDirection;
80 }
81
TearDown(void)82 void ImsTest::TearDown(void)
83 {
84 // step 3: input testcase teardown step
85 }
86
SetDomainPreferenceMode(const sptr<CellularCallInterface> & telephonyService) const87 int32_t ImsTest::SetDomainPreferenceMode(const sptr<CellularCallInterface> &telephonyService) const
88 {
89 std::cout << "test SetDomainPreferenceMode entry." << std::endl;
90 std::cout << "please enter the need mode:(1 - 4)";
91 int32_t mode;
92 std::cin >> mode;
93 int32_t slotId = 0;
94 std::cout << "please enter the slotId:(0 1)";
95 std::cin >> slotId;
96 return telephonyService->SetDomainPreferenceMode(slotId, mode);
97 }
98
GetDomainPreferenceMode(const sptr<CellularCallInterface> & telephonyService) const99 int32_t ImsTest::GetDomainPreferenceMode(const sptr<CellularCallInterface> &telephonyService) const
100 {
101 std::cout << "test GetDomainPreferenceMode entry." << std::endl;
102 int32_t slotId = 0;
103 std::cout << "please enter the slotId:(0 1)";
104 std::cin >> slotId;
105 return telephonyService->GetDomainPreferenceMode(slotId);
106 }
107
SetImsSwitchStatus(const sptr<CellularCallInterface> & telephonyService) const108 int32_t ImsTest::SetImsSwitchStatus(const sptr<CellularCallInterface> &telephonyService) const
109 {
110 std::cout << "test SetImsSwitchStatus entry." << std::endl;
111 std::cout << "please enter the switch state:";
112 bool active;
113 std::cin >> active;
114 int32_t slotId = 0;
115 std::cout << "please enter the slotId:(0 1)";
116 std::cin >> slotId;
117 return telephonyService->SetImsSwitchStatus(slotId, active);
118 }
119
GetImsSwitchStatus(const sptr<CellularCallInterface> & telephonyService) const120 int32_t ImsTest::GetImsSwitchStatus(const sptr<CellularCallInterface> &telephonyService) const
121 {
122 std::cout << "test GetImsSwitchStatus entry." << std::endl;
123 int32_t slotId = 0;
124 std::cout << "please enter the slotId:(0 1)";
125 std::cin >> slotId;
126 bool enabled;
127 return telephonyService->GetImsSwitchStatus(slotId, enabled);
128 }
129
SetImsConfigString(const sptr<CellularCallInterface> & telephonyService) const130 int32_t ImsTest::SetImsConfigString(const sptr<CellularCallInterface> &telephonyService) const
131 {
132 std::cout << "test SetImsConfigString entry." << std::endl;
133 std::cout << "please enter the item id:";
134 int32_t item = 0;
135 std::cin >> item;
136 std::cout << "please enter the item value:";
137 std::string value;
138 std::cin >> value;
139 int32_t slotId = 0;
140 return telephonyService->SetImsConfig(slotId, static_cast<ImsConfigItem>(item), value);
141 }
142
SetImsConfigInt(const sptr<CellularCallInterface> & telephonyService) const143 int32_t ImsTest::SetImsConfigInt(const sptr<CellularCallInterface> &telephonyService) const
144 {
145 std::cout << "test SetImsConfigInt entry." << std::endl;
146 std::cout << "please enter the item id:";
147 int32_t item = 0;
148 std::cin >> item;
149 std::cout << "please enter the item value:";
150 int32_t value = 0;
151 std::cin >> value;
152 int32_t slotId = 0;
153 return telephonyService->SetImsConfig(slotId, static_cast<ImsConfigItem>(item), value);
154 }
155
GetImsConfig(const sptr<CellularCallInterface> & telephonyService) const156 int32_t ImsTest::GetImsConfig(const sptr<CellularCallInterface> &telephonyService) const
157 {
158 std::cout << "test GetImsConfig entry." << std::endl;
159 std::cout << "please enter the item id:";
160 int32_t item = 0;
161 std::cin >> item;
162 int32_t slotId = 0;
163 return telephonyService->GetImsConfig(slotId, static_cast<ImsConfigItem>(item));
164 }
165
SetImsFeatureValue(const sptr<CellularCallInterface> & telephonyService) const166 int32_t ImsTest::SetImsFeatureValue(const sptr<CellularCallInterface> &telephonyService) const
167 {
168 std::cout << "test SetImsFeatureValue entry." << std::endl;
169 std::cout << "please enter the feature type:";
170 int32_t type = 0;
171 std::cin >> type;
172 std::cout << "please enter the feature value:";
173 int32_t value = 0;
174 std::cin >> value;
175 int32_t slotId = 0;
176 return telephonyService->SetImsFeatureValue(slotId, static_cast<FeatureType>(type), value);
177 }
178
GetImsFeatureValue(const sptr<CellularCallInterface> & telephonyService) const179 int32_t ImsTest::GetImsFeatureValue(const sptr<CellularCallInterface> &telephonyService) const
180 {
181 std::cout << "test GetImsFeatureValue entry." << std::endl;
182 std::cout << "please enter the feature type:";
183 int32_t type = 0;
184 std::cin >> type;
185 int32_t slotId = 0;
186 return telephonyService->GetImsFeatureValue(slotId, static_cast<FeatureType>(type));
187 }
188
CtrlCamera(const sptr<CellularCallInterface> & telephonyService) const189 int32_t ImsTest::CtrlCamera(const sptr<CellularCallInterface> &telephonyService) const
190 {
191 std::cout << "test CtrlCamera entry." << std::endl;
192 std::u16string cameraId = u"cameraId";
193 int32_t callingUid = 0;
194 int32_t callingPid = 0;
195 return telephonyService->CtrlCamera(cameraId, callingUid, callingPid);
196 }
197
SetPreviewWindow(const sptr<CellularCallInterface> & telephonyService) const198 int32_t ImsTest::SetPreviewWindow(const sptr<CellularCallInterface> &telephonyService) const
199 {
200 std::cout << "test SetPreviewWindow entry." << std::endl;
201 int32_t x = 0;
202 int32_t y = 0;
203 int32_t z = 0;
204 int32_t width = 0;
205 int32_t height = 0;
206 return telephonyService->SetPreviewWindow(x, y, z, width, height);
207 }
208
SetDisplayWindow(const sptr<CellularCallInterface> & telephonyService) const209 int32_t ImsTest::SetDisplayWindow(const sptr<CellularCallInterface> &telephonyService) const
210 {
211 std::cout << "test SetDisplayWindow entry." << std::endl;
212 int32_t x = 0;
213 int32_t y = 0;
214 int32_t z = 0;
215 int32_t width = 0;
216 int32_t height = 0;
217 return telephonyService->SetDisplayWindow(x, y, z, width, height);
218 }
219
SetCameraZoom(const sptr<CellularCallInterface> & telephonyService) const220 int32_t ImsTest::SetCameraZoom(const sptr<CellularCallInterface> &telephonyService) const
221 {
222 std::cout << "test SetCameraZoom entry." << std::endl;
223 float zoomRatio = 1.0;
224 return telephonyService->SetCameraZoom(zoomRatio);
225 }
226
SetPauseImage(const sptr<CellularCallInterface> & telephonyService) const227 int32_t ImsTest::SetPauseImage(const sptr<CellularCallInterface> &telephonyService) const
228 {
229 std::cout << "test SetPauseImage entry." << std::endl;
230 std::u16string path = u"path";
231 return telephonyService->SetPauseImage(path);
232 }
233
SetDeviceDirection(const sptr<CellularCallInterface> & telephonyService) const234 int32_t ImsTest::SetDeviceDirection(const sptr<CellularCallInterface> &telephonyService) const
235 {
236 std::cout << "test SetDeviceDirection entry." << std::endl;
237 int32_t rotation = 0;
238 return telephonyService->SetDeviceDirection(rotation);
239 }
240
InputNumForInterface(const sptr<CellularCallInterface> & telephonyService) const241 int32_t ImsTest::InputNumForInterface(const sptr<CellularCallInterface> &telephonyService) const
242 {
243 int32_t ret = -1;
244 bool loopFlag = true;
245 int32_t InputNum = 0;
246 int32_t returnNum = 1000; // end loop variable value
247 while (loopFlag) {
248 std::cout << "\n**********Unit Test Start**********\n"
249 "Usage: please input a cmd num:\n"
250 "300:SetCallPreferenceMode\n"
251 "301:GetCallPreferenceMode\n"
252 "302:SetImsSwitchStatus\n"
253 "303:GetImsSwitchStatus\n"
254 "304:SetImsConfigString\n"
255 "305:SetImsConfigInt\n"
256 "306:GetImsConfig\n"
257 "307:SetImsFeatureValue\n"
258 "308:GetImsFeatureValue\n"
259 "400:CtrlCamera\n"
260 "401:SetPreviewWindow\n"
261 "402:SetDisplayWindow\n"
262 "403:SetCameraZoom\n"
263 "404:SetPauseImage\n"
264 "405:SetDeviceDirection\n"
265 "1000:Exit\n"
266 "***********************************\n"
267 "Your choice: ";
268 std::cin >> InputNum;
269 if (InputNum == returnNum) {
270 std::cout << "exiting...\n";
271 break;
272 }
273 auto itFunc = requestFuncMap_.find(InputNum);
274 if (itFunc != requestFuncMap_.end()) {
275 auto requestFunc = itFunc->second;
276 if (requestFunc != nullptr) {
277 ret = (this->*requestFunc)(telephonyService);
278 }
279 }
280 if (ret != CELLULAR_CALL_SUCCESS) {
281 std::cout << "this execution did not return a successful value, please check.\n";
282 return ret;
283 }
284 }
285 return CELLULAR_CALL_SUCCESS;
286 }
287
288 /**
289 * @tc.number cellular_call_ims_test_001
290 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
291 * GetCallPreferenceMode, etc
292 * @tc.desc Function test
293 */
294 HWTEST_F(ImsTest, cellular_call_ims_test_001, Function | MediumTest | Level0)
295 {
296 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
297 ASSERT_TRUE(systemAbilityMgr != nullptr);
298 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
299 ASSERT_TRUE(remote != nullptr);
300 auto telephonyService = iface_cast<CellularCallInterface>(remote);
301 ASSERT_TRUE(telephonyService != nullptr);
302 std::cout << "HWTEST_F cellular_call_ims_test_001";
303 }
304
305 /**
306 * @tc.number cellular_call_ims_test_002
307 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
308 * GetCallPreferenceMode, etc
309 * @tc.desc Function test
310 */
311 HWTEST_F(ImsTest, cellular_call_ims_test_002, Function | MediumTest | Level1)
312 {
313 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
314 ASSERT_TRUE(systemAbilityMgr != nullptr);
315 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
316 ASSERT_TRUE(remote != nullptr);
317 auto telephonyService = iface_cast<CellularCallInterface>(remote);
318 ASSERT_TRUE(telephonyService != nullptr);
319 std::cout << "HWTEST_F cellular_call_ims_test_002";
320 }
321
322 /**
323 * @tc.number cellular_call_DialCall_0001
324 * @tc.name Test for SetClip function by ims
325 * @tc.desc Function test
326 */
327 HWTEST_F(ImsTest, cellular_call_DialCall_0001, Function | MediumTest | Level2)
328 {
329 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
330 return;
331 }
332 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
333 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*30#");
334 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
335 }
336 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
337 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*30#");
338 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
339 }
340 }
341
342 /**
343 * @tc.number cellular_call_DialCall_0002
344 * @tc.name Test for SetClip function by ims
345 * @tc.desc Function test
346 */
347 HWTEST_F(ImsTest, cellular_call_DialCall_0002, Function | MediumTest | Level2)
348 {
349 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
350 return;
351 }
352 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
353 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#30#");
354 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
355 }
356 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
357 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#30#");
358 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
359 }
360 }
361
362 /**
363 * @tc.number cellular_call_DialCall_0003
364 * @tc.name Test for getClip function by ims
365 * @tc.desc Function test
366 */
367 HWTEST_F(ImsTest, cellular_call_DialCall_0003, Function | MediumTest | Level2)
368 {
369 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
370 return;
371 }
372 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
373 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#30#");
374 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
375 }
376 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
377 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#30#");
378 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
379 }
380 }
381
382 /**
383 * @tc.number cellular_call_DialCall_0004
384 * @tc.name Test for SetClir function by ims
385 * @tc.desc Function test
386 */
387 HWTEST_F(ImsTest, cellular_call_DialCall_0004, Function | MediumTest | Level2)
388 {
389 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
390 return;
391 }
392 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
393 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*31#");
394 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
395 }
396 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
397 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*31#");
398 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
399 }
400 }
401
402 /**
403 * @tc.number cellular_call_DialCall_0005
404 * @tc.name Test for SetClir function by ims
405 * @tc.desc Function test
406 */
407 HWTEST_F(ImsTest, cellular_call_DialCall_0005, Function | MediumTest | Level2)
408 {
409 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
410 return;
411 }
412 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
413 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#31#");
414 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
415 }
416 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
417 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#31#");
418 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
419 }
420 }
421
422 /**
423 * @tc.number cellular_call_DialCall_0006
424 * @tc.name Test for GetClir function by ims
425 * @tc.desc Function test
426 */
427 HWTEST_F(ImsTest, cellular_call_DialCall_0006, Function | MediumTest | Level2)
428 {
429 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
430 return;
431 }
432 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
433 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#31#");
434 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
435 }
436 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
437 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#31#");
438 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
439 }
440 }
441
442 /**
443 * @tc.number cellular_call_DialCall_0007
444 * @tc.name Test for SetCallTransfer function by ims
445 * @tc.desc Function test
446 */
447 HWTEST_F(ImsTest, cellular_call_DialCall_0007, Function | MediumTest | Level2)
448 {
449 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
450 return;
451 }
452 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
453 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*21#");
454 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
455 }
456 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
457 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*21#");
458 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
459 }
460 }
461
462 /**
463 * @tc.number cellular_call_DialCall_0008
464 * @tc.name Test for SetCallTransfer function by ims
465 * @tc.desc Function test
466 */
467 HWTEST_F(ImsTest, cellular_call_DialCall_0008, Function | MediumTest | Level2)
468 {
469 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
470 return;
471 }
472 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
473 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#21#");
474 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
475 }
476 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
477 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#21#");
478 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
479 }
480 }
481
482 /**
483 * @tc.number cellular_call_DialCall_0009
484 * @tc.name Test for GetCallTransfer function by ims
485 * @tc.desc Function test
486 */
487 HWTEST_F(ImsTest, cellular_call_DialCall_0009, Function | MediumTest | Level2)
488 {
489 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
490 return;
491 }
492 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
493 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#21#");
494 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
495 }
496 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
497 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#21#");
498 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
499 }
500 }
501
502 /**
503 * @tc.number cellular_call_DialCall_0010
504 * @tc.name Test for SetCallRestriction function by ims
505 * @tc.desc Function test
506 */
507 HWTEST_F(ImsTest, cellular_call_DialCall_0010, Function | MediumTest | Level2)
508 {
509 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
510 return;
511 }
512 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
513 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*33#");
514 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
515 }
516 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
517 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*33#");
518 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
519 }
520 }
521
522 /**
523 * @tc.number cellular_call_DialCall_0011
524 * @tc.name Test for SetCallRestriction function by ims
525 * @tc.desc Function test
526 */
527 HWTEST_F(ImsTest, cellular_call_DialCall_0011, Function | MediumTest | Level2)
528 {
529 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
530 return;
531 }
532 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
533 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#33#");
534 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
535 }
536 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
537 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#33#");
538 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
539 }
540 }
541
542 /**
543 * @tc.number cellular_call_DialCall_0012
544 * @tc.name Test for GetCallRestriction function by ims
545 * @tc.desc Function test
546 */
547 HWTEST_F(ImsTest, cellular_call_DialCall_0012, Function | MediumTest | Level2)
548 {
549 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
550 return;
551 }
552 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
553 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#33#");
554 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
555 }
556 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
557 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#33#");
558 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
559 }
560 }
561
562 /**
563 * @tc.number cellular_call_DialCall_0013
564 * @tc.name Test for SetCallWaiting function by ims
565 * @tc.desc Function test
566 */
567 HWTEST_F(ImsTest, cellular_call_DialCall_0013, Function | MediumTest | Level2)
568 {
569 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
570 return;
571 }
572 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
573 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*43#");
574 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
575 }
576 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
577 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*43#");
578 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
579 }
580 }
581
582 /**
583 * @tc.number cellular_call_DialCall_0014
584 * @tc.name Test for SetCallWaiting function by ims
585 * @tc.desc Function test
586 */
587 HWTEST_F(ImsTest, cellular_call_DialCall_0014, Function | MediumTest | Level2)
588 {
589 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
590 return;
591 }
592 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
593 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#43#");
594 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
595 }
596 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
597 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#43#");
598 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
599 }
600 }
601
602 /**
603 * @tc.number cellular_call_DialCall_0015
604 * @tc.name Test for GetCallWaiting function by ims
605 * @tc.desc Function test
606 */
607 HWTEST_F(ImsTest, cellular_call_DialCall_0015, Function | MediumTest | Level2)
608 {
609 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
610 return;
611 }
612 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
613 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#43#");
614 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
615 ret = TestDialCallByIms(SIM1_SLOTID, "*#4@3#");
616 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
617 }
618 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
619 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#43#");
620 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
621 ret = TestDialCallByIms(SIM2_SLOTID, "*#4@3#");
622 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
623 }
624 }
625
626 /**
627 * @tc.number cellular_call_HangUpCall_0001
628 * @tc.name Test for HangUp function by ims
629 * @tc.desc Function test
630 */
631 HWTEST_F(ImsTest, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)
632 {
633 AccessToken token;
634 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
635 ASSERT_TRUE(systemAbilityMgr != nullptr);
636 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
637 ASSERT_TRUE(remote != nullptr);
638 auto telephonyService = iface_cast<CellularCallInterface>(remote);
639 ASSERT_TRUE(telephonyService != nullptr);
640 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
641 return;
642 }
643 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
644 CellularCallInfo callInfo;
645 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
646 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
647 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
648 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
649 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
650 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
651 }
652 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
653 CellularCallInfo callInfo;
654 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
655 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
656 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
657 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
658 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
659 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
660 }
661 }
662
663 /**
664 * @tc.number cellular_call_AnswerCall_0001
665 * @tc.name Test for answer function by ims
666 * @tc.desc Function test
667 */
668 HWTEST_F(ImsTest, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)
669 {
670 AccessToken token;
671 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
672 ASSERT_TRUE(systemAbilityMgr != nullptr);
673 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
674 ASSERT_TRUE(remote != nullptr);
675 auto telephonyService = iface_cast<CellularCallInterface>(remote);
676 ASSERT_TRUE(telephonyService != nullptr);
677 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
678 return;
679 }
680 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
681 CellularCallInfo callInfo;
682 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
683 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
684 ret = telephonyService->Answer(callInfo);
685 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
686 }
687 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
688 CellularCallInfo callInfo;
689 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
690 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
691 ret = telephonyService->Answer(callInfo);
692 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
693 }
694 }
695
696 /**
697 * @tc.number cellular_call_RejectCall_0001
698 * @tc.name Test for reject function by ims
699 * @tc.desc Function test
700 */
701 HWTEST_F(ImsTest, cellular_call_RejectCall_0001, Function | MediumTest | Level2)
702 {
703 AccessToken token;
704 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
705 ASSERT_TRUE(systemAbilityMgr != nullptr);
706 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
707 ASSERT_TRUE(remote != nullptr);
708 auto telephonyService = iface_cast<CellularCallInterface>(remote);
709 ASSERT_TRUE(telephonyService != nullptr);
710 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
711 return;
712 }
713 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
714 CellularCallInfo callInfo;
715 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
716 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
717 ret = telephonyService->Reject(callInfo);
718 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
719 }
720 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
721 CellularCallInfo callInfo;
722 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
723 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
724 ret = telephonyService->Reject(callInfo);
725 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
726 }
727 }
728
729 /**
730 * @tc.number cellular_call_HoldCall_0001
731 * @tc.name Test for hold call function by ims
732 * @tc.desc Function test
733 */
734 HWTEST_F(ImsTest, cellular_call_HoldCall_0001, Function | MediumTest | Level2)
735 {
736 AccessToken token;
737 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
738 ASSERT_TRUE(systemAbilityMgr != nullptr);
739 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
740 ASSERT_TRUE(remote != nullptr);
741 auto telephonyService = iface_cast<CellularCallInterface>(remote);
742 ASSERT_TRUE(telephonyService != nullptr);
743 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
744 return;
745 }
746 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
747 CellularCallInfo callInfo;
748 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
749 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
750 ret = telephonyService->HoldCall(callInfo);
751 EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
752 }
753 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
754 CellularCallInfo callInfo;
755 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
756 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
757 ret = telephonyService->HoldCall(callInfo);
758 EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
759 }
760 }
761
762 /**
763 * @tc.number cellular_call_UnHoldCall_0001
764 * @tc.name Test for unhold call function by ims
765 * @tc.desc Function test
766 */
767 HWTEST_F(ImsTest, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)
768 {
769 AccessToken token;
770 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
771 ASSERT_TRUE(systemAbilityMgr != nullptr);
772 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
773 ASSERT_TRUE(remote != nullptr);
774 auto telephonyService = iface_cast<CellularCallInterface>(remote);
775 ASSERT_TRUE(telephonyService != nullptr);
776 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
777 return;
778 }
779 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
780 CellularCallInfo callInfo;
781 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
782 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
783 ret = telephonyService->UnHoldCall(callInfo);
784 EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
785 }
786 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
787 CellularCallInfo callInfo;
788 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
789 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
790 ret = telephonyService->UnHoldCall(callInfo);
791 EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
792 }
793 }
794
795 /**
796 * @tc.number cellular_call_SwitchCall_0001
797 * @tc.name Test for switch call function by ims
798 * @tc.desc Function test
799 */
800 HWTEST_F(ImsTest, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)
801 {
802 AccessToken token;
803 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
804 ASSERT_TRUE(systemAbilityMgr != nullptr);
805 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
806 ASSERT_TRUE(remote != nullptr);
807 auto telephonyService = iface_cast<CellularCallInterface>(remote);
808 ASSERT_TRUE(telephonyService != nullptr);
809 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
810 return;
811 }
812 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
813 CellularCallInfo callInfo;
814 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
815 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
816 ret = telephonyService->SwitchCall(callInfo);
817 EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
818 }
819 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
820 CellularCallInfo callInfo;
821 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
822 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
823 ret = telephonyService->SwitchCall(callInfo);
824 EXPECT_EQ(ret, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
825 }
826 }
827
828 /**
829 * @tc.number cellular_call_CombineConference_0001
830 * @tc.name Test for combineConference function by ims
831 * @tc.desc Function test
832 */
833 HWTEST_F(ImsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)
834 {
835 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
836 ASSERT_TRUE(systemAbilityMgr != nullptr);
837 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
838 ASSERT_TRUE(remote != nullptr);
839 auto telephonyService = iface_cast<CellularCallInterface>(remote);
840 ASSERT_TRUE(telephonyService != nullptr);
841 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
842 return;
843 }
844 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
845 CellularCallInfo callInfo;
846 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
847 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
848 ret = telephonyService->CombineConference(callInfo);
849 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
850 }
851 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
852 CellularCallInfo callInfo;
853 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
854 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
855 ret = telephonyService->CombineConference(callInfo);
856 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
857 }
858 }
859
860 /**
861 * @tc.number cellular_call_SeparateConference_0001
862 * @tc.name Test for separateConference function by ims
863 * @tc.desc Function test
864 */
865 HWTEST_F(ImsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)
866 {
867 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
868 ASSERT_TRUE(systemAbilityMgr != nullptr);
869 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
870 ASSERT_TRUE(remote != nullptr);
871 auto telephonyService = iface_cast<CellularCallInterface>(remote);
872 ASSERT_TRUE(telephonyService != nullptr);
873 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
874 return;
875 }
876 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
877 CellularCallInfo callInfo;
878 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
879 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
880 ret = telephonyService->SeparateConference(callInfo);
881 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
882 }
883 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
884 CellularCallInfo callInfo;
885 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
886 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
887 ret = telephonyService->SeparateConference(callInfo);
888 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
889 }
890 }
891
892 /**
893 * @tc.number cellular_call_StartDtmf_0001
894 * @tc.name Test for startDtmf function by ims
895 * @tc.desc Function test
896 */
897 HWTEST_F(ImsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)
898 {
899 AccessToken token;
900 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
901 ASSERT_TRUE(systemAbilityMgr != nullptr);
902 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
903 ASSERT_TRUE(remote != nullptr);
904 auto telephonyService = iface_cast<CellularCallInterface>(remote);
905 ASSERT_TRUE(telephonyService != nullptr);
906 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
907 return;
908 }
909 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
910 CellularCallInfo callInfo;
911 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
912 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
913 char code = '1';
914 ret = telephonyService->StartDtmf(code, callInfo);
915 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
916 }
917 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
918 CellularCallInfo callInfo;
919 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
920 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
921 char code = '1';
922 ret = telephonyService->StartDtmf(code, callInfo);
923 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
924 }
925 }
926
927 /**
928 * @tc.number cellular_call_StopDtmf_0001
929 * @tc.name Test for stopDtmf function by ims
930 * @tc.desc Function test
931 */
932 HWTEST_F(ImsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)
933 {
934 AccessToken token;
935 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
936 ASSERT_TRUE(systemAbilityMgr != nullptr);
937 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
938 ASSERT_TRUE(remote != nullptr);
939 auto telephonyService = iface_cast<CellularCallInterface>(remote);
940 ASSERT_TRUE(telephonyService != nullptr);
941 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
942 return;
943 }
944 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
945 CellularCallInfo callInfo;
946 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
947 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
948 ret = telephonyService->StopDtmf(callInfo);
949 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
950 }
951 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
952 CellularCallInfo callInfo;
953 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
954 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
955 ret = telephonyService->StopDtmf(callInfo);
956 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
957 }
958 }
959
960 /**
961 * @tc.number cellular_call_SendDtmf_0001
962 * @tc.name Test for sendDtmf function by ims
963 * @tc.desc Function test
964 */
965 HWTEST_F(ImsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)
966 {
967 AccessToken token;
968 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
969 ASSERT_TRUE(systemAbilityMgr != nullptr);
970 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
971 ASSERT_TRUE(remote != nullptr);
972 auto telephonyService = iface_cast<CellularCallInterface>(remote);
973 ASSERT_TRUE(telephonyService != nullptr);
974 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
975 return;
976 }
977 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
978 CellularCallInfo callInfo;
979 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
980 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
981 char code = '1';
982 ret = telephonyService->SendDtmf(code, callInfo);
983 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
984 }
985 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
986 CellularCallInfo callInfo;
987 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
988 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
989 char code = '1';
990 ret = telephonyService->SendDtmf(code, callInfo);
991 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
992 }
993 }
994
995 /**
996 * @tc.number cellular_call_ImsControl_0001
997 * @tc.name Test for ImsControl
998 * @tc.desc Function test
999 */
1000 HWTEST_F(ImsTest, cellular_call_ImsControl_0001, Function | MediumTest | Level3)
1001 {
1002 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1003 ASSERT_TRUE(systemAbilityMgr != nullptr);
1004 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1005 ASSERT_TRUE(remote != nullptr);
1006 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1007 return;
1008 }
1009 auto imsControl = std::make_shared<IMSControl>();
1010 CellularCallInfo cellularCallInfo;
1011 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1012 if (!HasSimCard(slotId) || !CanUseImsService(slotId, ImsServiceType::TYPE_VOICE)) {
1013 continue;
1014 }
1015 EXPECT_EQ(imsControl->UpdateImsCallMode(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY),
1016 CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1017 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER, cellularCallInfo), TELEPHONY_SUCCESS);
1018 EXPECT_EQ(imsControl->Dial(cellularCallInfo), CALL_ERR_GET_RADIO_STATE_FAILED);
1019 ImsCurrentCallList callList;
1020 callList.callSize = 0;
1021 CallInfoList callInfoList;
1022 EXPECT_EQ(imsControl->ReportCallsData(slotId, callInfoList), TELEPHONY_ERROR);
1023 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_ERROR);
1024 ImsCurrentCall callInfo;
1025 callList.callSize = 1;
1026 callInfo.number = PHONE_NUMBER;
1027 callInfo.index = 1;
1028 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING);
1029 callList.calls.push_back(callInfo);
1030 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_SUCCESS);
1031 EXPECT_EQ(imsControl->Answer(cellularCallInfo), TELEPHONY_ERROR);
1032 EXPECT_EQ(imsControl->Reject(cellularCallInfo), TELEPHONY_ERROR);
1033 EXPECT_EQ(imsControl->HangUpAllConnection(slotId), TELEPHONY_ERROR);
1034 callList.callSize = 2;
1035 callInfo.index = 2;
1036 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_ACTIVE);
1037 callInfo.number = PHONE_NUMBER_SECOND;
1038 callList.calls.push_back(callInfo);
1039 callList.callSize = 3;
1040 callInfo.index = 3;
1041 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_WAITING);
1042 callInfo.number = PHONE_NUMBER_THIRD;
1043 callList.calls.push_back(callInfo);
1044 callList.callSize = 4;
1045 callInfo.index = 4;
1046 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_DISCONNECTED);
1047 callInfo.number = PHONE_NUMBER_FOUR;
1048 callList.calls.push_back(callInfo);
1049 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_SUCCESS);
1050 CLIRMode mode = CLIRMode::DEFAULT;
1051 EXPECT_EQ(imsControl->DialJudgment(slotId, PHONE_NUMBER_SECOND, mode, 0), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
1052 EXPECT_EQ(imsControl->DialJudgment(slotId, PHONE_NUMBER_THIRD, mode, 0), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
1053 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_SECOND, cellularCallInfo), TELEPHONY_SUCCESS);
1054 EXPECT_EQ(imsControl->Answer(cellularCallInfo), CALL_ERR_CALL_STATE);
1055 EXPECT_EQ(imsControl->UpdateImsCallMode(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY), TELEPHONY_ERROR);
1056 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_THIRD, cellularCallInfo), TELEPHONY_SUCCESS);
1057 EXPECT_EQ(imsControl->Answer(cellularCallInfo), TELEPHONY_ERROR);
1058 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_FOUR, cellularCallInfo), TELEPHONY_SUCCESS);
1059 EXPECT_EQ(imsControl->Answer(cellularCallInfo), CALL_ERR_CALL_STATE);
1060 EXPECT_EQ(imsControl->Reject(cellularCallInfo), CALL_ERR_CALL_STATE);
1061 EXPECT_EQ(imsControl->HoldCall(slotId), CALL_ERR_CALL_STATE);
1062 std::vector<std::string> numberList;
1063 EXPECT_EQ(imsControl->KickOutFromConference(slotId, numberList), TELEPHONY_ERROR);
1064 EXPECT_EQ(imsControl->InviteToConference(slotId, numberList), TELEPHONY_ERROR);
1065 EXPECT_EQ(imsControl->StartRtt(slotId, PHONE_NUMBER), TELEPHONY_ERROR);
1066 EXPECT_EQ(imsControl->StopRtt(slotId), TELEPHONY_ERROR);
1067 EXPECT_EQ(
1068 imsControl->UpdateImsCallMode(cellularCallInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY), CALL_ERR_CALL_STATE);
1069 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_DEFAULT), TELEPHONY_ERROR);
1070 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE),
1071 CALL_ERR_RESOURCE_UNAVAILABLE);
1072 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ALL), TELEPHONY_ERROR);
1073 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, static_cast<CallSupplementType>(INVALID_HANG_UP_TYPE)),
1074 TELEPHONY_ERR_ARGUMENT_INVALID);
1075 callList.callSize = 0;
1076 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_SUCCESS);
1077 }
1078 }
1079
1080 /**
1081 * @tc.number cellular_call_CellularCallConnectionIMS_0001
1082 * @tc.name Test for CellularCallConnectionIMS
1083 * @tc.desc Function test
1084 */
1085 HWTEST_F(ImsTest, cellular_call_CellularCallConnectionIMS_0001, Function | MediumTest | Level3)
1086 {
1087 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1088 ASSERT_TRUE(systemAbilityMgr != nullptr);
1089 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1090 ASSERT_TRUE(remote != nullptr);
1091 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1092 return;
1093 }
1094 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1095 if (!HasSimCard(slotId) || !CanUseImsService(slotId, ImsServiceType::TYPE_VOICE)) {
1096 continue;
1097 }
1098 CellularCallConnectionIMS imsConnection;
1099 EXPECT_EQ(imsConnection.SendDtmfRequest(slotId, '1', 1), TELEPHONY_ERROR);
1100 EXPECT_EQ(imsConnection.StartDtmfRequest(slotId, '1', 1), TELEPHONY_ERROR);
1101 EXPECT_EQ(imsConnection.StopDtmfRequest(slotId, 1), TELEPHONY_ERROR);
1102 EXPECT_EQ(imsConnection.GetImsCallsDataRequest(slotId, 1), TELEPHONY_ERROR);
1103 EXPECT_EQ(imsConnection.GetCallFailReasonRequest(slotId), TELEPHONY_ERROR);
1104 }
1105 }
1106
1107 /**
1108 * @tc.number cellular_call_CellularCallRegister_0001
1109 * @tc.name Test for CellularCallRegister
1110 * @tc.desc Function test
1111 */
1112 HWTEST_F(ImsTest, cellular_call_CellularCallRegister_0001, Function | MediumTest | Level3)
1113 {
1114 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1115 ASSERT_TRUE(systemAbilityMgr != nullptr);
1116 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1117 ASSERT_TRUE(remote != nullptr);
1118 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1119 return;
1120 }
1121 auto callRegister = DelayedSingleton<CellularCallRegister>::GetInstance();
1122 ASSERT_TRUE(callRegister != nullptr);
1123 GetImsConfigResponse imsConfigResponse;
1124 callRegister->ReportGetImsConfigResult(imsConfigResponse);
1125 callRegister->ReportSetImsConfigResult(RESULT);
1126 GetImsFeatureValueResponse imsFeatureValueResponse;
1127 callRegister->ReportGetImsFeatureResult(imsFeatureValueResponse);
1128 callRegister->ReportSetImsFeatureResult(RESULT);
1129 callRegister->ReportUpdateCallMediaModeResult(RESULT);
1130 }
1131 } // namespace Telephony
1132 } // namespace OHOS
1133