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 "hril_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 int32_t INVALID_SLOTID = -1;
39 const int32_t INVALID_HANG_UP_TYPE = -1;
40 const int32_t RESULT = 1;
41 const std::string PHONE_NUMBER = "0000000";
42 const std::string PHONE_NUMBER_SECOND = "1111111";
43 const std::string PHONE_NUMBER_THIRD = "2222222";
44 const std::string PHONE_NUMBER_FOUR = "3333333";
45 const int32_t CELLULAR_CALL_SUCCESS = 0;
46 const int32_t DEFAULT_INDEX = 1;
47
SetUpTestCase(void)48 void ImsTest::SetUpTestCase(void)
49 {
50 // step 3: Set Up Test Case
51 std::cout << "---------- ImsCoreServiceClient start ------------" << std::endl;
52 DelayedSingleton<ImsCoreServiceClient>::GetInstance()->Init();
53 }
54
TearDownTestCase(void)55 void ImsTest::TearDownTestCase(void)
56 {
57 // step 3: Tear Down Test Case
58 }
59
SetUp(void)60 void ImsTest::SetUp(void)
61 {
62 // step 3: input testcase setup step
63 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_DOMAIN_PREFERENCE_MODE)] =
64 &ImsTest::SetDomainPreferenceMode;
65 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_DOMAIN_PREFERENCE_MODE)] =
66 &ImsTest::GetDomainPreferenceMode;
67 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_SWITCH_STATUS)] =
68 &ImsTest::SetImsSwitchStatus;
69 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_IMS_SWITCH_STATUS)] =
70 &ImsTest::GetImsSwitchStatus;
71 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_STRING)] =
72 &ImsTest::SetImsConfigString;
73 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_INT)] = &ImsTest::SetImsConfigInt;
74 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_IMS_CONFIG)] = &ImsTest::GetImsConfig;
75 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_FEATURE)] = &ImsTest::SetImsFeatureValue;
76 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_IMS_FEATURE)] = &ImsTest::GetImsFeatureValue;
77 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::CTRL_CAMERA)] = &ImsTest::ControlCamera;
78 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_PREVIEW_WINDOW)] = &ImsTest::SetPreviewWindow;
79 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_DISPLAY_WINDOW)] = &ImsTest::SetDisplayWindow;
80 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_CAMERA_ZOOM)] = &ImsTest::SetCameraZoom;
81 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_PAUSE_IMAGE)] = &ImsTest::SetPausePicture;
82 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_DEVICE_DIRECTION)] =
83 &ImsTest::SetDeviceDirection;
84 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_REQUEST)] =
85 &ImsTest::SendUpdateCallMediaModeRequest;
86 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_RESPONSE)] =
87 &ImsTest::SendUpdateCallMediaModeResponse;
88 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::CANCEL_CALL_UPGRADE)] =
89 &ImsTest::CancelCallUpgrade;
90 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::REQUEST_CAMERA_CAPABILITY)] =
91 &ImsTest::RequestCameraCapabilities;
92 }
93
TearDown(void)94 void ImsTest::TearDown(void)
95 {
96 // step 3: input testcase teardown step
97 }
98
SetDomainPreferenceMode(const sptr<CellularCallInterface> & telephonyService) const99 int32_t ImsTest::SetDomainPreferenceMode(const sptr<CellularCallInterface> &telephonyService) const
100 {
101 std::cout << "test SetDomainPreferenceMode entry." << std::endl;
102 std::cout << "please enter the need mode:(1 - 4)";
103 int32_t mode;
104 std::cin >> mode;
105 int32_t slotId = 0;
106 std::cout << "please enter the slotId:(0 1)";
107 std::cin >> slotId;
108 return telephonyService->SetDomainPreferenceMode(slotId, mode);
109 }
110
GetDomainPreferenceMode(const sptr<CellularCallInterface> & telephonyService) const111 int32_t ImsTest::GetDomainPreferenceMode(const sptr<CellularCallInterface> &telephonyService) const
112 {
113 std::cout << "test GetDomainPreferenceMode entry." << std::endl;
114 int32_t slotId = 0;
115 std::cout << "please enter the slotId:(0 1)";
116 std::cin >> slotId;
117 return telephonyService->GetDomainPreferenceMode(slotId);
118 }
119
SetImsSwitchStatus(const sptr<CellularCallInterface> & telephonyService) const120 int32_t ImsTest::SetImsSwitchStatus(const sptr<CellularCallInterface> &telephonyService) const
121 {
122 std::cout << "test SetImsSwitchStatus entry." << std::endl;
123 std::cout << "please enter the switch state:";
124 bool active;
125 std::cin >> active;
126 int32_t slotId = 0;
127 std::cout << "please enter the slotId:(0 1)";
128 std::cin >> slotId;
129 return telephonyService->SetImsSwitchStatus(slotId, active);
130 }
131
GetImsSwitchStatus(const sptr<CellularCallInterface> & telephonyService) const132 int32_t ImsTest::GetImsSwitchStatus(const sptr<CellularCallInterface> &telephonyService) const
133 {
134 std::cout << "test GetImsSwitchStatus entry." << std::endl;
135 int32_t slotId = 0;
136 std::cout << "please enter the slotId:(0 1)";
137 std::cin >> slotId;
138 bool enabled;
139 return telephonyService->GetImsSwitchStatus(slotId, enabled);
140 }
141
SetImsConfigString(const sptr<CellularCallInterface> & telephonyService) const142 int32_t ImsTest::SetImsConfigString(const sptr<CellularCallInterface> &telephonyService) const
143 {
144 std::cout << "test SetImsConfigString entry." << std::endl;
145 std::cout << "please enter the item id:";
146 int32_t item = 0;
147 std::cin >> item;
148 std::cout << "please enter the item value:";
149 std::string value;
150 std::cin >> value;
151 int32_t slotId = 0;
152 return telephonyService->SetImsConfig(slotId, static_cast<ImsConfigItem>(item), value);
153 }
154
SetImsConfigInt(const sptr<CellularCallInterface> & telephonyService) const155 int32_t ImsTest::SetImsConfigInt(const sptr<CellularCallInterface> &telephonyService) const
156 {
157 std::cout << "test SetImsConfigInt entry." << std::endl;
158 std::cout << "please enter the item id:";
159 int32_t item = 0;
160 std::cin >> item;
161 std::cout << "please enter the item value:";
162 int32_t value = 0;
163 std::cin >> value;
164 int32_t slotId = 0;
165 return telephonyService->SetImsConfig(slotId, static_cast<ImsConfigItem>(item), value);
166 }
167
GetImsConfig(const sptr<CellularCallInterface> & telephonyService) const168 int32_t ImsTest::GetImsConfig(const sptr<CellularCallInterface> &telephonyService) const
169 {
170 std::cout << "test GetImsConfig entry." << std::endl;
171 std::cout << "please enter the item id:";
172 int32_t item = 0;
173 std::cin >> item;
174 int32_t slotId = 0;
175 return telephonyService->GetImsConfig(slotId, static_cast<ImsConfigItem>(item));
176 }
177
SetImsFeatureValue(const sptr<CellularCallInterface> & telephonyService) const178 int32_t ImsTest::SetImsFeatureValue(const sptr<CellularCallInterface> &telephonyService) const
179 {
180 std::cout << "test SetImsFeatureValue entry." << std::endl;
181 std::cout << "please enter the feature type:";
182 int32_t type = 0;
183 std::cin >> type;
184 std::cout << "please enter the feature value:";
185 int32_t value = 0;
186 std::cin >> value;
187 int32_t slotId = 0;
188 return telephonyService->SetImsFeatureValue(slotId, static_cast<FeatureType>(type), value);
189 }
190
GetImsFeatureValue(const sptr<CellularCallInterface> & telephonyService) const191 int32_t ImsTest::GetImsFeatureValue(const sptr<CellularCallInterface> &telephonyService) const
192 {
193 std::cout << "test GetImsFeatureValue entry." << std::endl;
194 std::cout << "please enter the feature type:";
195 int32_t type = 0;
196 std::cin >> type;
197 int32_t slotId = 0;
198 return telephonyService->GetImsFeatureValue(slotId, static_cast<FeatureType>(type));
199 }
200
ControlCamera(const sptr<CellularCallInterface> & telephonyService) const201 int32_t ImsTest::ControlCamera(const sptr<CellularCallInterface> &telephonyService) const
202 {
203 std::cout << "test ControlCamera entry." << std::endl;
204 int32_t slotId = SIM1_SLOTID;
205 int32_t callIndex = DEFAULT_INDEX;
206 std::string cameraId = "cameraId";
207 return telephonyService->ControlCamera(slotId, callIndex, cameraId);
208 }
209
SetPreviewWindow(const sptr<CellularCallInterface> & telephonyService) const210 int32_t ImsTest::SetPreviewWindow(const sptr<CellularCallInterface> &telephonyService) const
211 {
212 std::cout << "test SetPreviewWindow entry." << std::endl;
213 int32_t slotId = SIM1_SLOTID;
214 int32_t callIndex = DEFAULT_INDEX;
215 std::string surfaceId = "123";
216 std::string subSurfaceId = surfaceId.substr(0, 1);
217 uint64_t tmpSurfaceId = std::stoull(subSurfaceId);
218 auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId);
219 if (surface == nullptr) {
220 surfaceId = "";
221 }
222 return telephonyService->SetPreviewWindow(slotId, callIndex, subSurfaceId, surface);
223 }
224
SetDisplayWindow(const sptr<CellularCallInterface> & telephonyService) const225 int32_t ImsTest::SetDisplayWindow(const sptr<CellularCallInterface> &telephonyService) const
226 {
227 std::cout << "test SetDisplayWindow entry." << std::endl;
228 int32_t slotId = SIM1_SLOTID;
229 int32_t callIndex = DEFAULT_INDEX;
230 std::string surfaceId = "123";
231 std::string subSurfaceId = surfaceId.substr(0, 1);
232 uint64_t tmpSurfaceId = std::stoull(subSurfaceId);
233 auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId);
234 if (surface == nullptr) {
235 surfaceId = "";
236 }
237 return telephonyService->SetDisplayWindow(slotId, callIndex, subSurfaceId, surface);
238 }
239
SetCameraZoom(const sptr<CellularCallInterface> & telephonyService) const240 int32_t ImsTest::SetCameraZoom(const sptr<CellularCallInterface> &telephonyService) const
241 {
242 std::cout << "test SetCameraZoom entry." << std::endl;
243 float zoomRatio = 1.0;
244 return telephonyService->SetCameraZoom(zoomRatio);
245 }
246
SetPausePicture(const sptr<CellularCallInterface> & telephonyService) const247 int32_t ImsTest::SetPausePicture(const sptr<CellularCallInterface> &telephonyService) const
248 {
249 std::cout << "test SetPausePicture entry." << std::endl;
250 int32_t slotId = SIM1_SLOTID;
251 int32_t callIndex = DEFAULT_INDEX;
252 std::string path = "path";
253 return telephonyService->SetPausePicture(slotId, callIndex, path);
254 }
255
SetDeviceDirection(const sptr<CellularCallInterface> & telephonyService) const256 int32_t ImsTest::SetDeviceDirection(const sptr<CellularCallInterface> &telephonyService) const
257 {
258 std::cout << "test SetDeviceDirection entry." << std::endl;
259 int32_t slotId = SIM1_SLOTID;
260 int32_t callIndex = DEFAULT_INDEX;
261 int32_t rotation = 0;
262 return telephonyService->SetDeviceDirection(slotId, callIndex, rotation);
263 }
264
SendUpdateCallMediaModeRequest(const sptr<CellularCallInterface> & telephonyService) const265 int32_t ImsTest::SendUpdateCallMediaModeRequest(const sptr<CellularCallInterface> &telephonyService) const
266 {
267 std::cout << "test SendUpdateCallMediaModeRequest entry." << std::endl;
268 CellularCallInfo callInfo;
269 callInfo.accountId = SIM1_SLOTID;
270 callInfo.slotId = SIM1_SLOTID;
271 callInfo.index = DEFAULT_INDEX;
272 callInfo.callType = CallType::TYPE_IMS;
273 callInfo.videoState = 0; // 0 means audio
274 if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
275 return TELEPHONY_ERR_MEMSET_FAIL;
276 }
277 if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, PHONE_NUMBER.c_str(), PHONE_NUMBER.length()) != EOK) {
278 return TELEPHONY_ERR_MEMCPY_FAIL;
279 }
280 std::cout << "please enter the ims call mode:";
281 std::cout << "0:audio_only, 1:send_only, 2:receive_only, 3:send_receive, 4:video_paused";
282 ImsCallMode callMode = ImsCallMode::CALL_MODE_AUDIO_ONLY;
283 int32_t input = 0;
284 std::cin >> input;
285 callMode = static_cast<ImsCallMode>(input);
286 return telephonyService->SendUpdateCallMediaModeRequest(callInfo, callMode);
287 }
288
SendUpdateCallMediaModeResponse(const sptr<CellularCallInterface> & telephonyService) const289 int32_t ImsTest::SendUpdateCallMediaModeResponse(const sptr<CellularCallInterface> &telephonyService) const
290 {
291 std::cout << "test SendUpdateCallMediaModeResponse entry." << std::endl;
292 CellularCallInfo callInfo;
293 callInfo.accountId = SIM1_SLOTID;
294 callInfo.slotId = SIM1_SLOTID;
295 callInfo.index = DEFAULT_INDEX;
296 callInfo.callType = CallType::TYPE_IMS;
297 callInfo.videoState = 0; // 0 means audio
298 if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
299 return TELEPHONY_ERR_MEMSET_FAIL;
300 }
301 if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, PHONE_NUMBER.c_str(), PHONE_NUMBER.length()) != EOK) {
302 return TELEPHONY_ERR_MEMCPY_FAIL;
303 }
304 std::cout << "please enter the ims call mode:";
305 std::cout << "0:audio_only, 1:send_only, 2:receive_only, 3:send_receive, 4:video_paused";
306 ImsCallMode callMode = ImsCallMode::CALL_MODE_AUDIO_ONLY;
307 int32_t input = 0;
308 std::cin >> input;
309 callMode = static_cast<ImsCallMode>(input);
310 return telephonyService->SendUpdateCallMediaModeResponse(callInfo, callMode);
311 }
312
CancelCallUpgrade(const sptr<CellularCallInterface> & telephonyService) const313 int32_t ImsTest::CancelCallUpgrade(const sptr<CellularCallInterface> &telephonyService) const
314 {
315 std::cout << "test CancelCallUpgrade entry." << std::endl;
316 int32_t slotId = SIM1_SLOTID;
317 int32_t callIndex = DEFAULT_INDEX;
318 return telephonyService->CancelCallUpgrade(slotId, callIndex);
319 }
320
RequestCameraCapabilities(const sptr<CellularCallInterface> & telephonyService) const321 int32_t ImsTest::RequestCameraCapabilities(const sptr<CellularCallInterface> &telephonyService) const
322 {
323 std::cout << "test RequestCameraCapabilities entry." << std::endl;
324 int32_t slotId = SIM1_SLOTID;
325 int32_t callIndex = DEFAULT_INDEX;
326 return telephonyService->RequestCameraCapabilities(slotId, callIndex);
327 }
328
InputNumForInterface(const sptr<CellularCallInterface> & telephonyService) const329 int32_t ImsTest::InputNumForInterface(const sptr<CellularCallInterface> &telephonyService) const
330 {
331 int32_t ret = -1;
332 bool loopFlag = true;
333 int32_t inputNumber = 0;
334 int32_t returnNum = 1000; // end loop variable value
335 while (loopFlag) {
336 std::cout << "\n**********Unit Test Start**********\n"
337 "Usage: please input a cmd num:\n"
338 "300:SetCallPreferenceMode\n"
339 "301:GetCallPreferenceMode\n"
340 "302:SetImsSwitchStatus\n"
341 "303:GetImsSwitchStatus\n"
342 "304:SetImsConfigString\n"
343 "305:SetImsConfigInt\n"
344 "306:GetImsConfig\n"
345 "307:SetImsFeatureValue\n"
346 "308:GetImsFeatureValue\n"
347 "400:ControlCamera\n"
348 "401:SetPreviewWindow\n"
349 "402:SetDisplayWindow\n"
350 "403:SetCameraZoom\n"
351 "404:SetPausePicture\n"
352 "405:SetDeviceDirection\n"
353 "406:SendUpdateCallMediaModeRequest\n"
354 "407:SendUpdateCallMediaModeResponse\n"
355 "408:CancelCallUpgrade\n"
356 "409:RequestCameraCapabilities\n"
357 "1000:Exit\n"
358 "***********************************\n"
359 "Your choice: ";
360 std::cin >> inputNumber;
361 if (inputNumber == returnNum) {
362 std::cout << "exiting...\n";
363 break;
364 }
365 auto itFunction = requestFuncMap_.find(inputNumber);
366 if (itFunction != requestFuncMap_.end()) {
367 auto requestFunction = itFunction->second;
368 if (requestFunction != nullptr) {
369 ret = (this->*requestFunction)(telephonyService);
370 }
371 }
372 if (ret != CELLULAR_CALL_SUCCESS) {
373 std::cout << "this execution did not return a successful value, please check.\n";
374 return ret;
375 }
376 }
377 return CELLULAR_CALL_SUCCESS;
378 }
379
380 /**
381 * @tc.number cellular_call_ims_test_001
382 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
383 * GetCallPreferenceMode, etc
384 * @tc.desc Function test
385 */
386 HWTEST_F(ImsTest, cellular_call_ims_test_001, Function | MediumTest | Level0)
387 {
388 AccessToken token;
389 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
390 ASSERT_TRUE(systemAbilityMgr != nullptr);
391 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
392 ASSERT_TRUE(remote != nullptr);
393 auto telephonyService = iface_cast<CellularCallInterface>(remote);
394 ASSERT_TRUE(telephonyService != nullptr);
395 std::cout << "HWTEST_F cellular_call_ims_test_001";
396 }
397
398 /**
399 * @tc.number cellular_call_ims_test_002
400 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
401 * GetCallPreferenceMode, etc
402 * @tc.desc Function test
403 */
404 HWTEST_F(ImsTest, cellular_call_ims_test_002, Function | MediumTest | Level1)
405 {
406 AccessToken token;
407 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
408 ASSERT_TRUE(systemAbilityMgr != nullptr);
409 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
410 ASSERT_TRUE(remote != nullptr);
411 auto telephonyService = iface_cast<CellularCallInterface>(remote);
412 ASSERT_TRUE(telephonyService != nullptr);
413 std::cout << "HWTEST_F cellular_call_ims_test_002";
414 }
415
416 /**
417 * @tc.number cellular_call_DialCall_0001
418 * @tc.name Test for SetClip function by ims
419 * @tc.desc Function test
420 */
421 HWTEST_F(ImsTest, cellular_call_DialCall_0001, Function | MediumTest | Level2)
422 {
423 AccessToken token;
424 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
425 return;
426 }
427 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
428 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*30#");
429 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
430 }
431 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
432 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*30#");
433 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
434 }
435 }
436
437 /**
438 * @tc.number cellular_call_DialCall_0002
439 * @tc.name Test for SetClip function by ims
440 * @tc.desc Function test
441 */
442 HWTEST_F(ImsTest, cellular_call_DialCall_0002, Function | MediumTest | Level2)
443 {
444 AccessToken token;
445 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
446 return;
447 }
448 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
449 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#30#");
450 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
451 }
452 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
453 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#30#");
454 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
455 }
456 }
457
458 /**
459 * @tc.number cellular_call_DialCall_0003
460 * @tc.name Test for getClip function by ims
461 * @tc.desc Function test
462 */
463 HWTEST_F(ImsTest, cellular_call_DialCall_0003, Function | MediumTest | Level2)
464 {
465 AccessToken token;
466 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
467 return;
468 }
469 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
470 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#30#");
471 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
472 }
473 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
474 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#30#");
475 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
476 }
477 }
478
479 /**
480 * @tc.number cellular_call_DialCall_0004
481 * @tc.name Test for SetClir function by ims
482 * @tc.desc Function test
483 */
484 HWTEST_F(ImsTest, cellular_call_DialCall_0004, Function | MediumTest | Level2)
485 {
486 AccessToken token;
487 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
488 return;
489 }
490 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
491 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*31#");
492 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
493 }
494 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
495 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*31#");
496 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
497 }
498 }
499
500 /**
501 * @tc.number cellular_call_DialCall_0005
502 * @tc.name Test for SetClir function by ims
503 * @tc.desc Function test
504 */
505 HWTEST_F(ImsTest, cellular_call_DialCall_0005, Function | MediumTest | Level2)
506 {
507 AccessToken token;
508 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
509 return;
510 }
511 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
512 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#31#");
513 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
514 }
515 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
516 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#31#");
517 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
518 }
519 }
520
521 /**
522 * @tc.number cellular_call_DialCall_0006
523 * @tc.name Test for GetClir function by ims
524 * @tc.desc Function test
525 */
526 HWTEST_F(ImsTest, cellular_call_DialCall_0006, Function | MediumTest | Level2)
527 {
528 AccessToken token;
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, "*#31#");
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, "*#31#");
538 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
539 }
540 }
541
542 /**
543 * @tc.number cellular_call_DialCall_0007
544 * @tc.name Test for SetCallTransfer function by ims
545 * @tc.desc Function test
546 */
547 HWTEST_F(ImsTest, cellular_call_DialCall_0007, Function | MediumTest | Level2)
548 {
549 AccessToken token;
550 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
551 return;
552 }
553 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
554 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*21#");
555 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
556 }
557 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
558 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*21#");
559 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
560 }
561 }
562
563 /**
564 * @tc.number cellular_call_DialCall_0008
565 * @tc.name Test for SetCallTransfer function by ims
566 * @tc.desc Function test
567 */
568 HWTEST_F(ImsTest, cellular_call_DialCall_0008, Function | MediumTest | Level2)
569 {
570 AccessToken token;
571 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
572 return;
573 }
574 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
575 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#21#");
576 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
577 }
578 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
579 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#21#");
580 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
581 }
582 }
583
584 /**
585 * @tc.number cellular_call_DialCall_0009
586 * @tc.name Test for GetCallTransfer function by ims
587 * @tc.desc Function test
588 */
589 HWTEST_F(ImsTest, cellular_call_DialCall_0009, Function | MediumTest | Level2)
590 {
591 AccessToken token;
592 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
593 return;
594 }
595 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
596 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#21#");
597 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
598 }
599 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
600 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#21#");
601 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
602 }
603 }
604
605 /**
606 * @tc.number cellular_call_DialCall_0010
607 * @tc.name Test for SetCallRestriction function by ims
608 * @tc.desc Function test
609 */
610 HWTEST_F(ImsTest, cellular_call_DialCall_0010, Function | MediumTest | Level2)
611 {
612 AccessToken token;
613 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
614 return;
615 }
616 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
617 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*33#");
618 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
619 }
620 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
621 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*33#");
622 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
623 }
624 }
625
626 /**
627 * @tc.number cellular_call_DialCall_0011
628 * @tc.name Test for SetCallRestriction function by ims
629 * @tc.desc Function test
630 */
631 HWTEST_F(ImsTest, cellular_call_DialCall_0011, Function | MediumTest | Level2)
632 {
633 AccessToken token;
634 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
635 return;
636 }
637 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
638 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#33#");
639 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
640 }
641 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
642 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#33#");
643 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
644 }
645 }
646
647 /**
648 * @tc.number cellular_call_DialCall_0012
649 * @tc.name Test for GetCallRestriction function by ims
650 * @tc.desc Function test
651 */
652 HWTEST_F(ImsTest, cellular_call_DialCall_0012, Function | MediumTest | Level2)
653 {
654 AccessToken token;
655 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
656 return;
657 }
658 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
659 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#33#");
660 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
661 }
662 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
663 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#33#");
664 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
665 }
666 }
667
668 /**
669 * @tc.number cellular_call_DialCall_0013
670 * @tc.name Test for SetCallWaiting function by ims
671 * @tc.desc Function test
672 */
673 HWTEST_F(ImsTest, cellular_call_DialCall_0013, Function | MediumTest | Level2)
674 {
675 AccessToken token;
676 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
677 return;
678 }
679 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
680 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*43#");
681 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
682 }
683 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
684 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*43#");
685 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
686 }
687 }
688
689 /**
690 * @tc.number cellular_call_DialCall_0014
691 * @tc.name Test for SetCallWaiting function by ims
692 * @tc.desc Function test
693 */
694 HWTEST_F(ImsTest, cellular_call_DialCall_0014, Function | MediumTest | Level2)
695 {
696 AccessToken token;
697 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
698 return;
699 }
700 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
701 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#43#");
702 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
703 }
704 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
705 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#43#");
706 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
707 }
708 }
709
710 /**
711 * @tc.number cellular_call_DialCall_0015
712 * @tc.name Test for GetCallWaiting function by ims
713 * @tc.desc Function test
714 */
715 HWTEST_F(ImsTest, cellular_call_DialCall_0015, Function | MediumTest | Level2)
716 {
717 AccessToken token;
718 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
719 return;
720 }
721 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
722 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#43#");
723 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
724 ret = TestDialCallByIms(SIM1_SLOTID, "*#4@3#");
725 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
726 }
727 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
728 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#43#");
729 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
730 ret = TestDialCallByIms(SIM2_SLOTID, "*#4@3#");
731 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
732 }
733 }
734
735 /**
736 * @tc.number cellular_call_HangUpCall_0001
737 * @tc.name Test for HangUp function by ims
738 * @tc.desc Function test
739 */
740 HWTEST_F(ImsTest, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)
741 {
742 AccessToken token;
743 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
744 ASSERT_TRUE(systemAbilityMgr != nullptr);
745 auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
746 ASSERT_TRUE(hangUpCallRemote != nullptr);
747 auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
748 ASSERT_TRUE(telephonyService != nullptr);
749 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
750 return;
751 }
752 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
753 CellularCallInfo callInfo;
754 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
755 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
756 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
757 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
758 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
759 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
760 }
761 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
762 CellularCallInfo callInfo;
763 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
764 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
765 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
766 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
767 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
768 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
769 }
770 }
771
772 /**
773 * @tc.number cellular_call_AnswerCall_0001
774 * @tc.name Test for answer function by ims
775 * @tc.desc Function test
776 */
777 HWTEST_F(ImsTest, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)
778 {
779 AccessToken token;
780 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
781 ASSERT_TRUE(systemAbilityMgr != nullptr);
782 auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
783 ASSERT_TRUE(answerCallRemote != nullptr);
784 auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
785 ASSERT_TRUE(telephonyService != nullptr);
786 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
787 return;
788 }
789 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
790 CellularCallInfo callInfo;
791 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
792 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
793 ret = telephonyService->Answer(callInfo);
794 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
795 }
796 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
797 CellularCallInfo callInfo;
798 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
799 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
800 ret = telephonyService->Answer(callInfo);
801 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
802 }
803 }
804
805 /**
806 * @tc.number cellular_call_RejectCall_0001
807 * @tc.name Test for reject function by ims
808 * @tc.desc Function test
809 */
810 HWTEST_F(ImsTest, cellular_call_RejectCall_0001, Function | MediumTest | Level2)
811 {
812 AccessToken token;
813 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
814 ASSERT_TRUE(systemAbilityMgr != nullptr);
815 auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
816 ASSERT_TRUE(rejectCallRemote != nullptr);
817 auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
818 ASSERT_TRUE(telephonyService != nullptr);
819 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
820 return;
821 }
822 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
823 CellularCallInfo callInfo;
824 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
825 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
826 ret = telephonyService->Reject(callInfo);
827 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
828 }
829 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
830 CellularCallInfo callInfo;
831 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
832 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
833 ret = telephonyService->Reject(callInfo);
834 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
835 }
836 }
837
838 /**
839 * @tc.number cellular_call_HoldCall_0001
840 * @tc.name Test for hold call function by ims
841 * @tc.desc Function test
842 */
843 HWTEST_F(ImsTest, cellular_call_HoldCall_0001, Function | MediumTest | Level2)
844 {
845 AccessToken token;
846 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
847 ASSERT_TRUE(systemAbilityMgr != nullptr);
848 auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
849 ASSERT_TRUE(holdCallRemote != nullptr);
850 auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
851 ASSERT_TRUE(telephonyService != nullptr);
852 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
853 return;
854 }
855 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
856 CellularCallInfo callInfo;
857 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
858 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
859 ret = telephonyService->HoldCall(callInfo);
860 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
861 }
862 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
863 CellularCallInfo callInfo;
864 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
865 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
866 ret = telephonyService->HoldCall(callInfo);
867 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
868 }
869 }
870
871 /**
872 * @tc.number cellular_call_UnHoldCall_0001
873 * @tc.name Test for unhold call function by ims
874 * @tc.desc Function test
875 */
876 HWTEST_F(ImsTest, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)
877 {
878 AccessToken token;
879 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
880 ASSERT_TRUE(systemAbilityMgr != nullptr);
881 auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
882 ASSERT_TRUE(unHoldCallRemote != nullptr);
883 auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
884 ASSERT_TRUE(telephonyService != nullptr);
885 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
886 return;
887 }
888 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
889 CellularCallInfo callInfo;
890 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
891 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
892 ret = telephonyService->UnHoldCall(callInfo);
893 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
894 }
895 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
896 CellularCallInfo callInfo;
897 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
898 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
899 ret = telephonyService->UnHoldCall(callInfo);
900 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
901 }
902 }
903
904 /**
905 * @tc.number cellular_call_SwitchCall_0001
906 * @tc.name Test for switch call function by ims
907 * @tc.desc Function test
908 */
909 HWTEST_F(ImsTest, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)
910 {
911 AccessToken token;
912 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
913 ASSERT_TRUE(systemAbilityMgr != nullptr);
914 auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
915 ASSERT_TRUE(switchCallRemote != nullptr);
916 auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
917 ASSERT_TRUE(telephonyService != nullptr);
918 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
919 return;
920 }
921 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
922 CellularCallInfo callInfo;
923 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
924 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
925 ret = telephonyService->SwitchCall(callInfo);
926 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
927 }
928 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
929 CellularCallInfo callInfo;
930 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
931 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
932 ret = telephonyService->SwitchCall(callInfo);
933 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
934 }
935 }
936
937 /**
938 * @tc.number cellular_call_CombineConference_0001
939 * @tc.name Test for combineConference function by ims
940 * @tc.desc Function test
941 */
942 HWTEST_F(ImsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)
943 {
944 AccessToken token;
945 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
946 ASSERT_TRUE(systemAbilityMgr != nullptr);
947 auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
948 ASSERT_TRUE(combineRemote != nullptr);
949 auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
950 ASSERT_TRUE(telephonyService != nullptr);
951 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
952 return;
953 }
954 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
955 CellularCallInfo callInfo;
956 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
957 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
958 ret = telephonyService->CombineConference(callInfo);
959 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
960 }
961 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
962 CellularCallInfo callInfo;
963 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
964 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
965 ret = telephonyService->CombineConference(callInfo);
966 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
967 }
968 }
969
970 /**
971 * @tc.number cellular_call_SeparateConference_0001
972 * @tc.name Test for separateConference function by ims
973 * @tc.desc Function test
974 */
975 HWTEST_F(ImsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)
976 {
977 AccessToken token;
978 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
979 ASSERT_TRUE(systemAbilityMgr != nullptr);
980 auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
981 ASSERT_TRUE(separateRemote != nullptr);
982 auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
983 ASSERT_TRUE(telephonyService != nullptr);
984 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
985 return;
986 }
987 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
988 CellularCallInfo callInfo;
989 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
990 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
991 ret = telephonyService->SeparateConference(callInfo);
992 EXPECT_EQ(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
993 }
994 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
995 CellularCallInfo callInfo;
996 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
997 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
998 ret = telephonyService->SeparateConference(callInfo);
999 EXPECT_EQ(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
1000 }
1001 }
1002
1003 /**
1004 * @tc.number cellular_call_KickOutFromConference_0001
1005 * @tc.name Test for KickOutFromConference function by ims
1006 * @tc.desc Function test
1007 */
1008 HWTEST_F(ImsTest, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)
1009 {
1010 AccessToken token;
1011 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1012 ASSERT_TRUE(systemAbilityMgr != nullptr);
1013 auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1014 ASSERT_TRUE(kickOutRemote != nullptr);
1015 auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
1016 ASSERT_TRUE(telephonyService != nullptr);
1017 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1018 return;
1019 }
1020 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
1021 CellularCallInfo callInfo;
1022 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
1023 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1024 ret = telephonyService->KickOutFromConference(callInfo);
1025 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1026 }
1027 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1028 CellularCallInfo callInfo;
1029 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
1030 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1031 ret = telephonyService->KickOutFromConference(callInfo);
1032 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1033 }
1034 }
1035
1036 /**
1037 * @tc.number cellular_call_StartDtmf_0001
1038 * @tc.name Test for startDtmf function by ims
1039 * @tc.desc Function test
1040 */
1041 HWTEST_F(ImsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)
1042 {
1043 AccessToken token;
1044 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1045 ASSERT_TRUE(systemAbilityMgr != nullptr);
1046 auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1047 ASSERT_TRUE(startDtmfRemote != nullptr);
1048 auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
1049 ASSERT_TRUE(telephonyService != nullptr);
1050 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1051 return;
1052 }
1053 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
1054 CellularCallInfo callInfo;
1055 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
1056 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1057 char code = '1';
1058 ret = telephonyService->StartDtmf(code, callInfo);
1059 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1060 }
1061 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1062 CellularCallInfo callInfo;
1063 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
1064 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1065 char code = '1';
1066 ret = telephonyService->StartDtmf(code, callInfo);
1067 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1068 }
1069 }
1070
1071 /**
1072 * @tc.number cellular_call_StopDtmf_0001
1073 * @tc.name Test for stopDtmf function by ims
1074 * @tc.desc Function test
1075 */
1076 HWTEST_F(ImsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)
1077 {
1078 AccessToken token;
1079 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1080 ASSERT_TRUE(systemAbilityMgr != nullptr);
1081 auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1082 ASSERT_TRUE(stopDtmfRemote != nullptr);
1083 auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
1084 ASSERT_TRUE(telephonyService != nullptr);
1085 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1086 return;
1087 }
1088 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
1089 CellularCallInfo callInfo;
1090 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
1091 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1092 ret = telephonyService->StopDtmf(callInfo);
1093 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1094 }
1095 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1096 CellularCallInfo callInfo;
1097 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
1098 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1099 ret = telephonyService->StopDtmf(callInfo);
1100 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1101 }
1102 }
1103
1104 /**
1105 * @tc.number cellular_call_SendDtmf_0001
1106 * @tc.name Test for sendDtmf function by ims
1107 * @tc.desc Function test
1108 */
1109 HWTEST_F(ImsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)
1110 {
1111 AccessToken token;
1112 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1113 ASSERT_TRUE(systemAbilityMgr != nullptr);
1114 auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1115 ASSERT_TRUE(sendDtmfRemote != nullptr);
1116 auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
1117 ASSERT_TRUE(telephonyService != nullptr);
1118 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1119 return;
1120 }
1121 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
1122 CellularCallInfo callInfo;
1123 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
1124 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1125 char code = '1';
1126 ret = telephonyService->SendDtmf(code, callInfo);
1127 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1128 }
1129 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1130 CellularCallInfo callInfo;
1131 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
1132 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1133 char code = '1';
1134 ret = telephonyService->SendDtmf(code, callInfo);
1135 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
1136 }
1137 }
1138
1139 /**
1140 * @tc.number cellular_call_CanSetCallTransferTime_0001
1141 * @tc.name Test for CanSetCallTransferTime function by ims
1142 * @tc.desc Function test
1143 */
1144 HWTEST_F(ImsTest, cellular_call_CanSetCallTransferTime_0001, Function | MediumTest | Level2)
1145 {
1146 AccessToken token;
1147 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1148 ASSERT_TRUE(systemAbilityMgr != nullptr);
1149 auto transferRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1150 ASSERT_TRUE(transferRemote != nullptr);
1151 auto telephonyService = iface_cast<CellularCallInterface>(transferRemote);
1152 ASSERT_TRUE(telephonyService != nullptr);
1153 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1154 return;
1155 }
1156 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
1157 bool result;
1158 int32_t ret = telephonyService->CanSetCallTransferTime(SIM1_SLOTID, result);
1159 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1160 }
1161 if (HasSimCard(SIM2_SLOTID)) {
1162 bool result;
1163 int32_t ret = telephonyService->CanSetCallTransferTime(SIM2_SLOTID, result);
1164 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1165 }
1166 }
1167
1168
1169 /**
1170 * @tc.number cellular_call_SetVoNRState_0001
1171 * @tc.name Test for SetVoNRState function
1172 * @tc.desc Function test
1173 */
1174 HWTEST_F(ImsTest, cellular_call_SetVoNRState_0001, Function | MediumTest | Level2)
1175 {
1176 AccessToken token;
1177 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1178 ASSERT_TRUE(systemAbilityMgr != nullptr);
1179 auto setVoNRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1180 ASSERT_TRUE(setVoNRRemote != nullptr);
1181 auto telephonyService = iface_cast<CellularCallInterface>(setVoNRRemote);
1182 ASSERT_TRUE(telephonyService != nullptr);
1183 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1184 return;
1185 }
1186 if (HasSimCard(SIM1_SLOTID)) {
1187 int32_t ret = telephonyService->SetVoNRState(SIM1_SLOTID, 1);
1188 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1189 }
1190 if (HasSimCard(SIM2_SLOTID)) {
1191 int32_t ret = telephonyService->SetVoNRState(SIM2_SLOTID, 1);
1192 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1193 }
1194 }
1195
1196 /**
1197 * @tc.number cellular_call_SetVoNRState_0002
1198 * @tc.name Test for SetVoNRState function
1199 * @tc.desc Function test
1200 */
1201 HWTEST_F(ImsTest, cellular_call_SetVoNRState_0002, Function | MediumTest | Level2)
1202 {
1203 AccessToken token;
1204 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1205 return;
1206 }
1207 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1208 ASSERT_TRUE(systemAbilityMgr != nullptr);
1209 auto setVoNRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1210 ASSERT_TRUE(setVoNRRemote != nullptr);
1211 auto telephonyService = iface_cast<CellularCallInterface>(setVoNRRemote);
1212 ASSERT_TRUE(telephonyService != nullptr);
1213 if (HasSimCard(SIM1_SLOTID)) {
1214 int32_t ret = telephonyService->SetVoNRState(SIM1_SLOTID, 0);
1215 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1216 }
1217 if (HasSimCard(SIM2_SLOTID)) {
1218 int32_t ret = telephonyService->SetVoNRState(SIM2_SLOTID, 0);
1219 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1220 }
1221 }
1222
1223 /**
1224 * @tc.number cellular_call_GetVoNRState_0001
1225 * @tc.name Test for GetVoNRState function
1226 * @tc.desc Function test
1227 */
1228 HWTEST_F(ImsTest, cellular_call_GetVoNRState_0001, Function | MediumTest | Level2)
1229 {
1230 AccessToken token;
1231 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1232 ASSERT_TRUE(systemAbilityMgr != nullptr);
1233 auto getVoNRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1234 ASSERT_TRUE(getVoNRRemote != nullptr);
1235 auto telephonyService = iface_cast<CellularCallInterface>(getVoNRRemote);
1236 ASSERT_TRUE(telephonyService != nullptr);
1237 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1238 return;
1239 }
1240 if (HasSimCard(SIM1_SLOTID)) {
1241 int32_t result;
1242 int32_t ret = telephonyService->GetVoNRState(SIM1_SLOTID, result);
1243 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1244 }
1245 if (HasSimCard(SIM2_SLOTID)) {
1246 int32_t result;
1247 int32_t ret = telephonyService->GetVoNRState(SIM2_SLOTID, result);
1248 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1249 }
1250 }
1251
1252 /**
1253 * @tc.number cellular_call_StartRtt_0001
1254 * @tc.name Test for StartRtt function
1255 * @tc.desc Function test
1256 */
1257 HWTEST_F(ImsTest, cellular_call_StartRtt_0001, Function | MediumTest | Level2)
1258 {
1259 AccessToken token;
1260 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1261 ASSERT_TRUE(systemAbilityMgr != nullptr);
1262 auto startRttRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1263 ASSERT_TRUE(startRttRemote != nullptr);
1264 auto telephonyService = iface_cast<CellularCallInterface>(startRttRemote);
1265 ASSERT_TRUE(telephonyService != nullptr);
1266 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1267 return;
1268 }
1269 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1270 int32_t ret = telephonyService->StartRtt(SIM1_SLOTID, PHONE_NUMBER);
1271 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1272 }
1273 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1274 int32_t ret = telephonyService->StartRtt(SIM2_SLOTID, PHONE_NUMBER);
1275 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1276 }
1277 }
1278
1279 /**
1280 * @tc.number cellular_call_StopRtt_0001
1281 * @tc.name Test for StopRtt function
1282 * @tc.desc Function test
1283 */
1284 HWTEST_F(ImsTest, cellular_call_StopRtt_0001, Function | MediumTest | Level2)
1285 {
1286 AccessToken token;
1287 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1288 ASSERT_TRUE(systemAbilityMgr != nullptr);
1289 auto stopRttRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1290 ASSERT_TRUE(stopRttRemote != nullptr);
1291 auto telephonyService = iface_cast<CellularCallInterface>(stopRttRemote);
1292 ASSERT_TRUE(telephonyService != nullptr);
1293 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1294 return;
1295 }
1296 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1297 int32_t ret = telephonyService->StopRtt(SIM1_SLOTID);
1298 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1299 }
1300 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1301 int32_t ret = telephonyService->StopRtt(SIM2_SLOTID);
1302 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1303 }
1304 }
1305
1306 /**
1307 * @tc.number cellular_call_SetDomainPreferenceMode_0001
1308 * @tc.name Test for SetDomainPreferenceMode function
1309 * @tc.desc Function test
1310 */
1311 HWTEST_F(ImsTest, cellular_call_SetDomainPreferenceMode_0001, Function | MediumTest | Level2)
1312 {
1313 AccessToken token;
1314 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1315 ASSERT_TRUE(systemAbilityMgr != nullptr);
1316 auto domainPrefModeRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1317 ASSERT_TRUE(domainPrefModeRemote != nullptr);
1318 auto telephonyService = iface_cast<CellularCallInterface>(domainPrefModeRemote);
1319 ASSERT_TRUE(telephonyService != nullptr);
1320 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1321 return;
1322 }
1323 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1324 int32_t mode = -1;
1325 int32_t ret = telephonyService->SetDomainPreferenceMode(SIM1_SLOTID, mode);
1326 EXPECT_EQ(ret, CALL_ERR_PARAMETER_OUT_OF_RANGE);
1327 }
1328 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1329 int32_t mode = -1;
1330 int32_t ret = telephonyService->SetDomainPreferenceMode(SIM2_SLOTID, mode);
1331 EXPECT_EQ(ret, CALL_ERR_PARAMETER_OUT_OF_RANGE);
1332 }
1333 }
1334
1335 /**
1336 * @tc.number cellular_call_GetImsConfig_0001
1337 * @tc.name Test for GetImsConfig function
1338 * @tc.desc Function test
1339 */
1340 HWTEST_F(ImsTest, cellular_call_GetImsConfig_0001, Function | MediumTest | Level2)
1341 {
1342 AccessToken token;
1343 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1344 ASSERT_TRUE(systemAbilityMgr != nullptr);
1345 auto getImsConfigRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1346 ASSERT_TRUE(getImsConfigRemote != nullptr);
1347 auto telephonyService = iface_cast<CellularCallInterface>(getImsConfigRemote);
1348 ASSERT_TRUE(telephonyService != nullptr);
1349 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1350 return;
1351 }
1352 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1353 ImsConfigItem mode = ITEM_IMS_SWITCH_STATUS;
1354 int32_t ret = telephonyService->GetImsConfig(SIM1_SLOTID, mode);
1355 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1356 }
1357 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1358 ImsConfigItem mode = ITEM_IMS_SWITCH_STATUS;
1359 int32_t ret = telephonyService->GetImsConfig(SIM2_SLOTID, mode);
1360 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1361 }
1362 }
1363
1364 /**
1365 * @tc.number cellular_call_GetImsFeatureValue_0001
1366 * @tc.name Test for GetImsFeatureValue function
1367 * @tc.desc Function test
1368 */
1369 HWTEST_F(ImsTest, cellular_call_GetImsFeatureValue_0001, Function | MediumTest | Level2)
1370 {
1371 AccessToken token;
1372 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1373 ASSERT_TRUE(systemAbilityMgr != nullptr);
1374 auto getImsFeatureRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1375 ASSERT_TRUE(getImsFeatureRemote != nullptr);
1376 auto telephonyService = iface_cast<CellularCallInterface>(getImsFeatureRemote);
1377 ASSERT_TRUE(telephonyService != nullptr);
1378 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1379 return;
1380 }
1381 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1382 FeatureType mode = TYPE_VOICE_OVER_LTE;
1383 int32_t ret = telephonyService->GetImsFeatureValue(SIM1_SLOTID, mode);
1384 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1385 }
1386 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1387 FeatureType mode = TYPE_VOICE_OVER_LTE;
1388 int32_t ret = telephonyService->GetImsFeatureValue(SIM2_SLOTID, mode);
1389 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1390 }
1391 }
1392
1393 /**
1394 * @tc.number cellular_call_SetMute_0001
1395 * @tc.name Test for SetMute function
1396 * @tc.desc Function test
1397 */
1398 HWTEST_F(ImsTest, cellular_call_SetMute_0001, Function | MediumTest | Level2)
1399 {
1400 AccessToken token;
1401 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1402 ASSERT_TRUE(systemAbilityMgr != nullptr);
1403 auto setMuteRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1404 ASSERT_TRUE(setMuteRemote != nullptr);
1405 auto telephonyService = iface_cast<CellularCallInterface>(setMuteRemote);
1406 ASSERT_TRUE(telephonyService != nullptr);
1407 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1408 return;
1409 }
1410 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1411 int32_t mode = 0;
1412 int32_t ret = telephonyService->SetMute(SIM1_SLOTID, mode);
1413 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1414 }
1415 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
1416 int32_t mode = 0;
1417 int32_t ret = telephonyService->SetMute(SIM2_SLOTID, mode);
1418 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1419 }
1420 }
1421
1422 /**
1423 * @tc.number cellular_call_SetCallWaiting_0001
1424 * @tc.name Test for SetCallWaiting function
1425 * @tc.desc Function test
1426 */
1427 HWTEST_F(ImsTest, cellular_call_SetCallWaiting_0001, Function | MediumTest | Level2)
1428 {
1429 AccessToken token;
1430 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1431 ASSERT_TRUE(systemAbilityMgr != nullptr);
1432 auto SetCWRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1433 ASSERT_TRUE(SetCWRemote != nullptr);
1434 auto telephonyService = iface_cast<CellularCallInterface>(SetCWRemote);
1435 ASSERT_TRUE(telephonyService != nullptr);
1436 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1437 return;
1438 }
1439 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1440 bool act = true;
1441 int32_t ret = telephonyService->SetCallWaiting(SIM1_SLOTID, act);
1442 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1443 }
1444 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1445 bool act = true;
1446 int32_t ret = telephonyService->SetCallWaiting(SIM2_SLOTID, act);
1447 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1448 }
1449 }
1450
1451 /**
1452 * @tc.number cellular_call_GetCallWaiting_0001
1453 * @tc.name Test for GetCallWaiting function
1454 * @tc.desc Function test
1455 */
1456 HWTEST_F(ImsTest, cellular_call_GetCallWaiting_0001, Function | MediumTest | Level2)
1457 {
1458 AccessToken token;
1459 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1460 ASSERT_TRUE(systemAbilityMgr != nullptr);
1461 auto getCWRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1462 ASSERT_TRUE(getCWRemote != nullptr);
1463 auto telephonyService = iface_cast<CellularCallInterface>(getCWRemote);
1464 ASSERT_TRUE(telephonyService != nullptr);
1465 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1466 return;
1467 }
1468 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1469 int32_t ret = telephonyService->GetCallWaiting(SIM1_SLOTID);
1470 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1471 }
1472 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1473 int32_t ret = telephonyService->GetCallWaiting(SIM2_SLOTID);
1474 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
1475 }
1476 }
1477
1478 /**
1479 * @tc.number cellular_call_SetCallRestriction_0001
1480 * @tc.name Test for SetCallRestriction function
1481 * @tc.desc Function test
1482 */
1483 HWTEST_F(ImsTest, cellular_call_SetCallRestriction_0001, Function | MediumTest | Level2)
1484 {
1485 AccessToken token;
1486 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1487 ASSERT_TRUE(systemAbilityMgr != nullptr);
1488 auto setCRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1489 ASSERT_TRUE(setCRRemote != nullptr);
1490 auto telephonyService = iface_cast<CellularCallInterface>(setCRRemote);
1491 ASSERT_TRUE(telephonyService != nullptr);
1492 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1493 return;
1494 }
1495 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1496 CallRestrictionInfo crInfo;
1497 int32_t ret = telephonyService->SetCallRestriction(SIM1_SLOTID, crInfo);
1498 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1499 }
1500 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1501 CallRestrictionInfo crInfo;
1502 int32_t ret = telephonyService->SetCallRestriction(SIM2_SLOTID, crInfo);
1503 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1504 }
1505 }
1506
1507 /**
1508 * @tc.number cellular_call_GetCallRestriction_0001
1509 * @tc.name Test for GetCallRestriction function
1510 * @tc.desc Function test
1511 */
1512 HWTEST_F(ImsTest, cellular_call_GetCallRestriction_0001, Function | MediumTest | Level2)
1513 {
1514 AccessToken token;
1515 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1516 ASSERT_TRUE(systemAbilityMgr != nullptr);
1517 auto getCRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1518 ASSERT_TRUE(getCRRemote != nullptr);
1519 auto telephonyService = iface_cast<CellularCallInterface>(getCRRemote);
1520 ASSERT_TRUE(telephonyService != nullptr);
1521 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1522 return;
1523 }
1524 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1525 CallRestrictionType facType = CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING;
1526 int32_t ret = telephonyService->GetCallRestriction(SIM1_SLOTID, facType);
1527 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1528 }
1529 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1530 CallRestrictionType facType = CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING;
1531 int32_t ret = telephonyService->GetCallRestriction(SIM2_SLOTID, facType);
1532 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1533 }
1534 }
1535
1536 /**
1537 * @tc.number cellular_call_SetCallTransferInfo_0001
1538 * @tc.name Test for SetCallTransferInfo function
1539 * @tc.desc Function test
1540 */
1541 HWTEST_F(ImsTest, cellular_call_SetCallTransferInfo_0001, Function | MediumTest | Level2)
1542 {
1543 AccessToken token;
1544 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1545 ASSERT_TRUE(systemAbilityMgr != nullptr);
1546 auto setTransferRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1547 ASSERT_TRUE(setTransferRemote != nullptr);
1548 auto telephonyService = iface_cast<CellularCallInterface>(setTransferRemote);
1549 ASSERT_TRUE(telephonyService != nullptr);
1550 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1551 return;
1552 }
1553 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1554 CallTransferInfo ctInfo;
1555 int32_t ret = telephonyService->SetCallTransferInfo(SIM1_SLOTID, ctInfo);
1556 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1557 }
1558 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1559 CallTransferInfo ctInfo;
1560 int32_t ret = telephonyService->SetCallTransferInfo(SIM2_SLOTID, ctInfo);
1561 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1562 }
1563 }
1564
1565 /**
1566 * @tc.number cellular_call_GetCallTransferInfo_0001
1567 * @tc.name Test for GetCallTransferInfo function
1568 * @tc.desc Function test
1569 */
1570 HWTEST_F(ImsTest, cellular_call_GetCallTransferInfo_0001, Function | MediumTest | Level2)
1571 {
1572 AccessToken token;
1573 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1574 ASSERT_TRUE(systemAbilityMgr != nullptr);
1575 auto getTransferRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1576 ASSERT_TRUE(getTransferRemote != nullptr);
1577 auto telephonyService = iface_cast<CellularCallInterface>(getTransferRemote);
1578 ASSERT_TRUE(telephonyService != nullptr);
1579 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1580 return;
1581 }
1582 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1583 CallTransferType type = CallTransferType::TRANSFER_TYPE_UNCONDITIONAL;
1584 int32_t ret = telephonyService->GetCallTransferInfo(SIM1_SLOTID, type);
1585 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1586 }
1587 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
1588 CallTransferType type = CallTransferType::TRANSFER_TYPE_UNCONDITIONAL;
1589 int32_t ret = telephonyService->GetCallTransferInfo(SIM2_SLOTID, type);
1590 EXPECT_NE(ret, TELEPHONY_SUCCESS);
1591 }
1592 }
1593
1594 /**
1595 * @tc.number cellular_call_ImsControl_0001
1596 * @tc.name Test for ImsControl
1597 * @tc.desc Function test
1598 */
1599 HWTEST_F(ImsTest, cellular_call_ImsControl_0001, Function | MediumTest | Level3)
1600 {
1601 AccessToken token;
1602 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1603 ASSERT_TRUE(systemAbilityMgr != nullptr);
1604 auto imsControlRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1605 ASSERT_TRUE(imsControlRemote != nullptr);
1606 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1607 return;
1608 }
1609 auto imsControl = std::make_shared<IMSControl>();
1610 CellularCallInfo cellularCallInfo;
1611 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1612 if (!HasSimCard(slotId) || !CanUseImsService(slotId, ImsServiceType::TYPE_VOICE)) {
1613 continue;
1614 }
1615 EXPECT_NE(imsControl->Answer(cellularCallInfo), TELEPHONY_SUCCESS);
1616 EXPECT_NE(imsControl->Reject(cellularCallInfo), TELEPHONY_SUCCESS);
1617 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER, cellularCallInfo), TELEPHONY_SUCCESS);
1618 bool enabled = false;
1619 EXPECT_EQ(imsControl->Dial(cellularCallInfo, enabled), CALL_ERR_GET_RADIO_STATE_FAILED);
1620 CLIRMode mode = CLIRMode::DEFAULT;
1621 EXPECT_EQ(imsControl->DialJudgment(slotId, PHONE_NUMBER_SECOND, mode, 0), TELEPHONY_SUCCESS);
1622 EXPECT_EQ(imsControl->DialJudgment(slotId, PHONE_NUMBER_THIRD, mode, 0), TELEPHONY_SUCCESS);
1623 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_SECOND, cellularCallInfo), TELEPHONY_SUCCESS);
1624 EXPECT_NE(imsControl->Answer(cellularCallInfo), TELEPHONY_SUCCESS);
1625 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_THIRD, cellularCallInfo), TELEPHONY_SUCCESS);
1626 EXPECT_NE(imsControl->Answer(cellularCallInfo), TELEPHONY_SUCCESS);
1627 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_FOUR, cellularCallInfo), TELEPHONY_SUCCESS);
1628 EXPECT_NE(imsControl->Answer(cellularCallInfo), TELEPHONY_SUCCESS);
1629 EXPECT_NE(imsControl->Reject(cellularCallInfo), TELEPHONY_SUCCESS);
1630 EXPECT_EQ(imsControl->HoldCall(slotId), TELEPHONY_SUCCESS);
1631 std::vector<std::string> numberList;
1632 EXPECT_EQ(imsControl->KickOutFromConference(slotId, PHONE_NUMBER, cellularCallInfo.index), TELEPHONY_SUCCESS);
1633 EXPECT_EQ(imsControl->InviteToConference(slotId, numberList), TELEPHONY_SUCCESS);
1634 EXPECT_EQ(imsControl->StartRtt(slotId, PHONE_NUMBER), TELEPHONY_SUCCESS);
1635 EXPECT_EQ(imsControl->StopRtt(slotId), TELEPHONY_SUCCESS);
1636 EXPECT_NE(imsControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_DEFAULT), TELEPHONY_SUCCESS);
1637 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE),
1638 CALL_ERR_RESOURCE_UNAVAILABLE);
1639 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ALL), TELEPHONY_SUCCESS);
1640 EXPECT_EQ(imsControl->HangUp(cellularCallInfo, static_cast<CallSupplementType>(INVALID_HANG_UP_TYPE)),
1641 TELEPHONY_ERR_ARGUMENT_INVALID);
1642 }
1643 }
1644
1645 /**
1646 * @tc.number cellular_call_ImsControl_0002
1647 * @tc.name Test for ImsControl
1648 * @tc.desc Function test
1649 */
1650 HWTEST_F(ImsTest, cellular_call_ImsControl_0002, Function | MediumTest | Level3)
1651 {
1652 AccessToken token;
1653 auto imsControl = std::make_shared<IMSControl>();
1654 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1655 if (!HasSimCard(slotId) || !CanUseImsService(slotId, ImsServiceType::TYPE_VOICE)) {
1656 continue;
1657 }
1658 ImsCurrentCallList callList;
1659 callList.callSize = 0;
1660 CallInfoList callInfoList;
1661 EXPECT_EQ(imsControl->ReportCallsData(slotId, callInfoList), TELEPHONY_ERROR);
1662 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_ERROR);
1663 EXPECT_NE(imsControl->ReportUpdateInfo(slotId, callList), TELEPHONY_SUCCESS);
1664 ImsCurrentCall callInfo;
1665 callList.callSize = 1;
1666 callInfo.number = PHONE_NUMBER;
1667 callInfo.index = 1;
1668 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING);
1669 callList.calls.push_back(callInfo);
1670 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_SUCCESS);
1671 EXPECT_EQ(imsControl->HangUpAllConnection(slotId), TELEPHONY_SUCCESS);
1672 callList.callSize = 2;
1673 callInfo.index = 2;
1674 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_ACTIVE);
1675 callInfo.number = PHONE_NUMBER_SECOND;
1676 callList.calls.push_back(callInfo);
1677 callList.callSize = 3;
1678 callInfo.index = 3;
1679 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_WAITING);
1680 callInfo.number = PHONE_NUMBER_THIRD;
1681 callList.calls.push_back(callInfo);
1682 callList.callSize = 4;
1683 callInfo.index = 4;
1684 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_DISCONNECTED);
1685 callInfo.number = PHONE_NUMBER_FOUR;
1686 callList.calls.push_back(callInfo);
1687 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_SUCCESS);
1688 callList.callSize = 0;
1689 EXPECT_EQ(imsControl->ReportImsCallsData(slotId, callList), TELEPHONY_SUCCESS);
1690 }
1691 }
1692
1693 /**
1694 * @tc.number cellular_call_CellularCallConnectionIMS_0001
1695 * @tc.name Test for CellularCallConnectionIMS
1696 * @tc.desc Function test
1697 */
1698 HWTEST_F(ImsTest, cellular_call_CellularCallConnectionIMS_0001, Function | MediumTest | Level3)
1699 {
1700 AccessToken token;
1701 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1702 ASSERT_TRUE(systemAbilityMgr != nullptr);
1703 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1704 ASSERT_TRUE(remote != nullptr);
1705 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1706 return;
1707 }
1708 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1709 if (!HasSimCard(slotId) || !CanUseImsService(slotId, ImsServiceType::TYPE_VOICE)) {
1710 continue;
1711 }
1712 CellularCallConnectionIMS imsConnection;
1713 EXPECT_EQ(imsConnection.SendDtmfRequest(slotId, '1', 1), TELEPHONY_SUCCESS);
1714 EXPECT_EQ(imsConnection.StartDtmfRequest(slotId, '1', 1), TELEPHONY_SUCCESS);
1715 EXPECT_EQ(imsConnection.StopDtmfRequest(slotId, 1), TELEPHONY_SUCCESS);
1716 EXPECT_EQ(imsConnection.GetImsCallsDataRequest(slotId, 1), TELEPHONY_SUCCESS);
1717 EXPECT_EQ(imsConnection.GetCallFailReasonRequest(slotId), TELEPHONY_SUCCESS);
1718 EXPECT_EQ(imsConnection.AnswerRequest(slotId, PHONE_NUMBER, 0, slotId), TELEPHONY_SUCCESS);
1719 ImsDialInfoStruct imsDialInfo;
1720 imsDialInfo.phoneNum = PHONE_NUMBER_SECOND;
1721 EXPECT_EQ(imsConnection.DialRequest(slotId, imsDialInfo), TELEPHONY_SUCCESS);
1722 EXPECT_EQ(imsConnection.HangUpRequest(slotId, PHONE_NUMBER_SECOND, slotId), TELEPHONY_SUCCESS);
1723 EXPECT_EQ(imsConnection.StartRttRequest(slotId, PHONE_NUMBER_THIRD), TELEPHONY_SUCCESS);
1724 EXPECT_EQ(imsConnection.StopRttRequest(slotId), TELEPHONY_SUCCESS);
1725 }
1726 }
1727
1728 /**
1729 * @tc.number cellular_call_CellularCallRegister_0001
1730 * @tc.name Test for CellularCallRegister
1731 * @tc.desc Function test
1732 */
1733 HWTEST_F(ImsTest, cellular_call_CellularCallRegister_0001, Function | MediumTest | Level3)
1734 {
1735 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1736 ASSERT_TRUE(systemAbilityMgr != nullptr);
1737 auto registerRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
1738 ASSERT_TRUE(registerRemote != nullptr);
1739 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1740 return;
1741 }
1742 auto callRegister = DelayedSingleton<CellularCallRegister>::GetInstance();
1743 ASSERT_TRUE(callRegister != nullptr);
1744 GetImsConfigResponse imsConfigResponse;
1745 callRegister->ReportGetImsConfigResult(imsConfigResponse);
1746 callRegister->ReportSetImsConfigResult(RESULT);
1747 GetImsFeatureValueResponse imsFeatureValueResponse;
1748 callRegister->ReportGetImsFeatureResult(imsFeatureValueResponse);
1749 callRegister->ReportSetImsFeatureResult(RESULT);
1750 ImsCallModeReceiveInfo callModeInfo;
1751 callRegister->ReceiveUpdateCallMediaModeRequest(callModeInfo);
1752 callRegister->ReceiveUpdateCallMediaModeResponse(callModeInfo);
1753 ImsCallSessionEventInfo callSessionEventInfo;
1754 callRegister->HandleCallSessionEventChanged(callSessionEventInfo);
1755 ImsCallPeerDimensionsInfo callPeerDimensionsInfo;
1756 callRegister->HandlePeerDimensionsChanged(callPeerDimensionsInfo);
1757 ImsCallDataUsageInfo callDataUsageInfo;
1758 callRegister->HandleCallDataUsageChanged(callDataUsageInfo);
1759 CameraCapabilitiesInfo cameraCapabilitiesInfo;
1760 callRegister->HandleCameraCapabilitiesChanged(cameraCapabilitiesInfo);
1761 }
1762
1763 /**
1764 * @tc.number cellular_call_CellularCallConfig_0001
1765 * @tc.name Test for CellularCallConfig
1766 * @tc.desc Function test
1767 */
1768 HWTEST_F(ImsTest, cellular_call_CellularCallConfig_0001, Function | MediumTest | Level3)
1769 {
1770 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1771 return;
1772 }
1773
1774 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1775 if (!HasSimCard(slotId)) {
1776 continue;
1777 }
1778 CellularCallConfig cellularCallConfig;
1779 ASSERT_TRUE(cellularCallConfig.GetImsSwitchOnByDefaultConfig(INVALID_SLOTID));
1780 ASSERT_TRUE(cellularCallConfig.GetImsSwitchOnByDefaultConfig(slotId));
1781 ASSERT_FALSE(cellularCallConfig.GethideImsSwitchConfig(INVALID_SLOTID));
1782 ASSERT_FALSE(cellularCallConfig.GethideImsSwitchConfig(slotId));
1783 ASSERT_FALSE(cellularCallConfig.GetvolteSupportedConfig(INVALID_SLOTID));
1784 ASSERT_FALSE(cellularCallConfig.GetvolteSupportedConfig(slotId));
1785 cellularCallConfig.GetNrModeSupportedListConfig(INVALID_SLOTID);
1786 cellularCallConfig.GetNrModeSupportedListConfig(slotId);
1787 ASSERT_FALSE(cellularCallConfig.GetVolteProvisioningSupportedConfig(INVALID_SLOTID));
1788 ASSERT_FALSE(cellularCallConfig.GetVolteProvisioningSupportedConfig(slotId));
1789 ASSERT_FALSE(cellularCallConfig.GetSsOverUtSupportedConfig(INVALID_SLOTID));
1790 ASSERT_FALSE(cellularCallConfig.GetSsOverUtSupportedConfig(slotId));
1791 ASSERT_FALSE(cellularCallConfig.GetImsGbaRequiredConfig(INVALID_SLOTID));
1792 ASSERT_FALSE(cellularCallConfig.GetImsGbaRequiredConfig(slotId));
1793 ASSERT_FALSE(cellularCallConfig.GetUtProvisioningSupportedConfig(INVALID_SLOTID));
1794 ASSERT_FALSE(cellularCallConfig.GetUtProvisioningSupportedConfig(slotId));
1795 ASSERT_TRUE(cellularCallConfig.GetImsPreferForEmergencyConfig(INVALID_SLOTID));
1796 ASSERT_TRUE(cellularCallConfig.GetImsPreferForEmergencyConfig(slotId));
1797 cellularCallConfig.GetCallWaitingServiceClassConfig(INVALID_SLOTID);
1798 cellularCallConfig.GetCallWaitingServiceClassConfig(slotId);
1799 cellularCallConfig.GetImsCallDisconnectResoninfoMappingConfig(INVALID_SLOTID);
1800 cellularCallConfig.GetImsCallDisconnectResoninfoMappingConfig(slotId);
1801 ASSERT_FALSE(cellularCallConfig.GetForceVolteSwitchOnConfig(INVALID_SLOTID));
1802 ASSERT_FALSE(cellularCallConfig.GetForceVolteSwitchOnConfig(slotId));
1803 }
1804 }
1805
1806 /**
1807 * @tc.number cellular_call_CellularCallHandler_0001
1808 * @tc.name Test for CellularCallHandler
1809 * @tc.desc Function test
1810 */
1811 HWTEST_F(ImsTest, cellular_call_CellularCallHandler_0001, Function | MediumTest | Level3)
1812 {
1813 EventFwk::MatchingSkills matchingSkills;
1814 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
1815 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1816 CellularCallHandler handler { subscriberInfo };
1817 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1818 return;
1819 }
1820 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1821 if (!HasSimCard(slotId)) {
1822 continue;
1823 }
1824 handler.SetSlotId(slotId);
1825 auto event = AppExecFwk::InnerEvent::Get(0);
1826 handler.GetImsCallsDataResponse(event);
1827 handler.GetImsCallsDataRequest(event);
1828 auto rilRadioResponse = std::make_shared<HRilRadioResponseInfo>();
1829 rilRadioResponse->error = HRilErrType::HRIL_ERR_GENERIC_FAILURE;
1830 auto responseEvent = AppExecFwk::InnerEvent::Get(0, rilRadioResponse);
1831 handler.SetDomainPreferenceModeResponse(responseEvent);
1832 handler.GetDomainPreferenceModeResponse(event);
1833 handler.SetDomainPreferenceModeResponse(event);
1834 handler.SetVoNRSwitchStatusResponse(responseEvent);
1835 ASSERT_EQ(handler.GetSlotId(), slotId);
1836 handler.OnRilAdapterHostDied(event);
1837 auto serviceInstance = DelayedSingleton<CellularCallService>::GetInstance();
1838 if (serviceInstance != nullptr) {
1839 std::shared_ptr<CSControl> csControl;
1840 serviceInstance->SetCsControl(slotId, csControl);
1841 std::shared_ptr<IMSControl> imsControl;
1842 serviceInstance->SetImsControl(slotId, imsControl);
1843 handler.OnRilAdapterHostDied(event);
1844 ASSERT_TRUE(serviceInstance->GetCsControl(slotId) == nullptr);
1845 ASSERT_TRUE(serviceInstance->GetCsControl(slotId) == nullptr);
1846 }
1847 }
1848 }
1849
1850 /**
1851 * @tc.number cellular_call_CellularCallHandler_0002
1852 * @tc.name Test for CellularCallHandler
1853 * @tc.desc Function test
1854 */
1855 HWTEST_F(ImsTest, cellular_call_CellularCallHandler_0002, Function | MediumTest | Level3)
1856 {
1857 EventFwk::MatchingSkills matchingSkills;
1858 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
1859 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1860 CellularCallHandler handler { subscriberInfo };
1861 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1862 return;
1863 }
1864 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1865 if (!HasSimCard(slotId)) {
1866 continue;
1867 }
1868 handler.SetSlotId(slotId);
1869 auto event = AppExecFwk::InnerEvent::Get(0);
1870 handler.ReceiveUpdateCallMediaModeRequest(event);
1871 handler.ReceiveUpdateCallMediaModeResponse(event);
1872 handler.HandleCallSessionEventChanged(event);
1873 handler.HandlePeerDimensionsChanged(event);
1874 handler.HandleCallDataUsageChanged(event);
1875 handler.HandleCameraCapabilitiesChanged(event);
1876 }
1877 }
1878
1879 /**
1880 * @tc.number cellular_call_ImsCallClient_0001
1881 * @tc.name test for ImsCallClient
1882 * @tc.desc Function test
1883 */
1884 HWTEST_F(ImsTest, cellular_call_ImsCallClient_0001, Function | MediumTest | Level3)
1885 {
1886 ImsCallClient::SystemAbilityListener listen;
1887 int32_t systemAbilityId = 1;
1888 std::string deviceId = "123";
1889 listen.OnAddSystemAbility(systemAbilityId, deviceId);
1890 listen.OnRemoveSystemAbility(systemAbilityId, deviceId);
1891 listen.OnAddSystemAbility(COMMON_EVENT_SERVICE_ID, deviceId);
1892 listen.OnRemoveSystemAbility(COMMON_EVENT_SERVICE_ID, deviceId);
1893 }
1894 } // namespace Telephony
1895 } // namespace OHOS
1896