1 /*
2 * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "cs_test.h"
17
18 #define private public
19 #define protected public
20 #include "cellular_call_callback.h"
21 #include "cellular_call_handler.h"
22 #include "cellular_call_proxy.h"
23 #include "cellular_call_register.h"
24 #include "cellular_call_service.h"
25 #include "cellular_call_supplement.h"
26 #include "config_request.h"
27 #include "core_service_client.h"
28 #include "cs_control.h"
29 #include "tel_ril_call_parcel.h"
30 #include "operator_config_types.h"
31 #include "radio_event.h"
32 #include "securec.h"
33 #include "sim_state_type.h"
34
35 namespace OHOS {
36 namespace Telephony {
37 using namespace testing::ext;
38 const int32_t SIM1_SLOTID = 0;
39 const int32_t SIM2_SLOTID = 1;
40 const int32_t INVALID_SLOTID = 0xFF;
41 const int32_t INVALID_HANG_UP_TYPE = -1;
42 const int32_t SUCCESS_RESULT = 0;
43 const int32_t ERROR_RESULT = 1;
44 const int32_t USSD_MODE_NOTIFY = 0;
45 const std::string PHONE_NUMBER = "0000000";
46 const std::string PHONE_NUMBER_SECOND = "1111111";
47 const std::string PHONE_NUMBER_THIRD = "2222222";
48
49 /**
50 * @tc.number cellular_call_CombineConference_0001
51 * @tc.name Test for combineConference function by cs
52 * @tc.desc Function test
53 */
HWTEST_F(CsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)54 HWTEST_F(CsTest, cellular_call_CombineConference_0001, Function | MediumTest | Level2)
55 {
56 AccessToken token;
57 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
58 ASSERT_TRUE(systemAbilityMgr != nullptr);
59 auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
60 ASSERT_TRUE(combineRemote != nullptr);
61 auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
62 ASSERT_TRUE(telephonyService != nullptr);
63 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
64 return;
65 }
66 if (HasSimCard(SIM1_SLOTID)) {
67 CellularCallInfo conferenceCallInfo;
68 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, conferenceCallInfo);
69 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
70 ret = telephonyService->CombineConference(conferenceCallInfo);
71 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
72 }
73 if (HasSimCard(SIM2_SLOTID)) {
74 CellularCallInfo conferenceCallInfo;
75 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, conferenceCallInfo);
76 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
77 ret = telephonyService->CombineConference(conferenceCallInfo);
78 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
79 }
80 }
81
82 /**
83 * @tc.number cellular_call_CombineConference_0002
84 * @tc.name Test for combineConference function with invalid slot by cs
85 * @tc.desc Function test
86 */
HWTEST_F(CsTest, cellular_call_CombineConference_0002, Function | MediumTest | Level2)87 HWTEST_F(CsTest, cellular_call_CombineConference_0002, Function | MediumTest | Level2)
88 {
89 AccessToken token;
90 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
91 return;
92 }
93 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
94 ASSERT_TRUE(systemAbilityMgr != nullptr);
95 auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
96 ASSERT_TRUE(combineRemote != nullptr);
97 auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
98 ASSERT_TRUE(telephonyService != nullptr);
99 if (HasSimCard(SIM1_SLOTID)) {
100 CellularCallInfo conferenceCallInfo;
101 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, conferenceCallInfo);
102 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
103 ret = telephonyService->CombineConference(conferenceCallInfo);
104 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
105 }
106 if (HasSimCard(SIM2_SLOTID)) {
107 CellularCallInfo conferenceCallInfo;
108 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, conferenceCallInfo);
109 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
110 ret = telephonyService->CombineConference(conferenceCallInfo);
111 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
112 }
113 }
114
115 /**
116 * @tc.number cellular_call_SeparateConference_0001
117 * @tc.name Test for separateConference function by cs
118 * @tc.desc Function test
119 */
HWTEST_F(CsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)120 HWTEST_F(CsTest, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)
121 {
122 AccessToken token;
123 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
124 ASSERT_TRUE(systemAbilityMgr != nullptr);
125 auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
126 ASSERT_TRUE(separateRemote != nullptr);
127 auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
128 ASSERT_TRUE(telephonyService != nullptr);
129 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
130 return;
131 }
132 if (HasSimCard(SIM1_SLOTID)) {
133 CellularCallInfo callInfo;
134 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
135 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
136 ret = telephonyService->SeparateConference(callInfo);
137 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
138 }
139 if (HasSimCard(SIM2_SLOTID)) {
140 CellularCallInfo callInfo;
141 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
142 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
143 ret = telephonyService->SeparateConference(callInfo);
144 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
145 }
146 }
147
148 /**
149 * @tc.number cellular_call_SeparateConference_0002
150 * @tc.name Test for separateConference function with invalid slot by cs
151 * @tc.desc Function test
152 */
HWTEST_F(CsTest, cellular_call_SeparateConference_0002, Function | MediumTest | Level2)153 HWTEST_F(CsTest, cellular_call_SeparateConference_0002, Function | MediumTest | Level2)
154 {
155 AccessToken token;
156 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
157 return;
158 }
159 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
160 ASSERT_TRUE(systemAbilityMgr != nullptr);
161 auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
162 ASSERT_TRUE(separateRemote != nullptr);
163 auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
164 ASSERT_TRUE(telephonyService != nullptr);
165 if (HasSimCard(SIM1_SLOTID)) {
166 CellularCallInfo separateCallInfo;
167 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, separateCallInfo);
168 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
169 ret = telephonyService->SeparateConference(separateCallInfo);
170 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
171 }
172 if (HasSimCard(SIM2_SLOTID)) {
173 CellularCallInfo separateCallInfo;
174 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, separateCallInfo);
175 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
176 ret = telephonyService->SeparateConference(separateCallInfo);
177 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
178 }
179 }
180
181 /**
182 * @tc.number cellular_call_KickOutFromConference_0001
183 * @tc.name Test for separateConference function by cs
184 * @tc.desc Function test
185 */
HWTEST_F(CsTest, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)186 HWTEST_F(CsTest, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)
187 {
188 AccessToken token;
189 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
190 ASSERT_TRUE(systemAbilityMgr != nullptr);
191 auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
192 ASSERT_TRUE(kickOutRemote != nullptr);
193 auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
194 ASSERT_TRUE(telephonyService != nullptr);
195 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
196 return;
197 }
198 if (HasSimCard(SIM1_SLOTID)) {
199 CellularCallInfo kickOutCallInfo;
200 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, kickOutCallInfo);
201 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
202 ret = telephonyService->KickOutFromConference(kickOutCallInfo);
203 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
204 }
205 if (HasSimCard(SIM2_SLOTID)) {
206 CellularCallInfo kickOutCallInfo;
207 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, kickOutCallInfo);
208 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
209 ret = telephonyService->KickOutFromConference(kickOutCallInfo);
210 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
211 }
212 }
213
214 /**
215 * @tc.number cellular_call_KickOutFromConference_0002
216 * @tc.name Test for KickOutFromConference function with invalid slot by cs
217 * @tc.desc Function test
218 */
HWTEST_F(CsTest, cellular_call_KickOutFromConference_0002, Function | MediumTest | Level2)219 HWTEST_F(CsTest, cellular_call_KickOutFromConference_0002, Function | MediumTest | Level2)
220 {
221 AccessToken token;
222 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
223 return;
224 }
225 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
226 ASSERT_TRUE(systemAbilityMgr != nullptr);
227 auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
228 ASSERT_TRUE(kickOutRemote != nullptr);
229 auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
230 ASSERT_TRUE(telephonyService != nullptr);
231 if (HasSimCard(SIM1_SLOTID)) {
232 CellularCallInfo kickOutCallInfo;
233 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, kickOutCallInfo);
234 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
235 ret = telephonyService->KickOutFromConference(kickOutCallInfo);
236 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
237 }
238 if (HasSimCard(SIM2_SLOTID)) {
239 CellularCallInfo kickOutCallInfo;
240 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, kickOutCallInfo);
241 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
242 ret = telephonyService->KickOutFromConference(kickOutCallInfo);
243 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
244 }
245 }
246
247 /**
248 * @tc.number cellular_call_HangUpAllConnection_0001
249 * @tc.name Test for hangup all connection function by cs
250 * @tc.desc Function test
251 */
HWTEST_F(CsTest, cellular_call_HangUpAllConnection_0001, Function | MediumTest | Level2)252 HWTEST_F(CsTest, cellular_call_HangUpAllConnection_0001, Function | MediumTest | Level2)
253 {
254 AccessToken token;
255 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
256 ASSERT_TRUE(systemAbilityMgr != nullptr);
257 auto hangUpAllConRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
258 ASSERT_TRUE(hangUpAllConRemote != nullptr);
259 auto telephonyService = iface_cast<CellularCallInterface>(hangUpAllConRemote);
260 ASSERT_TRUE(telephonyService != nullptr);
261 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
262 return;
263 }
264 if (HasSimCard(SIM1_SLOTID)) {
265 int32_t ret = telephonyService->HangUpAllConnection();
266 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
267 }
268 if (HasSimCard(SIM2_SLOTID)) {
269 int32_t ret = telephonyService->HangUpAllConnection();
270 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
271 }
272 }
273
274 /**
275 * @tc.number cellular_call_StartDtmf_0001
276 * @tc.name Test for startDtmf function by cs
277 * @tc.desc Function test
278 */
HWTEST_F(CsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)279 HWTEST_F(CsTest, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)
280 {
281 AccessToken token;
282 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
283 ASSERT_TRUE(systemAbilityMgr != nullptr);
284 auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
285 ASSERT_TRUE(startDtmfRemote != nullptr);
286 auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
287 ASSERT_TRUE(telephonyService != nullptr);
288 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
289 return;
290 }
291 if (HasSimCard(SIM1_SLOTID)) {
292 CellularCallInfo callInfo;
293 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
294 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
295 char code = '1';
296 ret = telephonyService->StartDtmf(code, callInfo);
297 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
298 }
299 if (HasSimCard(SIM2_SLOTID)) {
300 CellularCallInfo callInfo;
301 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
302 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
303 char code = '1';
304 ret = telephonyService->StartDtmf(code, callInfo);
305 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
306 }
307 }
308
309 /**
310 * @tc.number cellular_call_StartDtmf_0002
311 * @tc.name Test for startDtmf function with invalid slot by cs
312 * @tc.desc Function test
313 */
HWTEST_F(CsTest, cellular_call_StartDtmf_0002, Function | MediumTest | Level2)314 HWTEST_F(CsTest, cellular_call_StartDtmf_0002, Function | MediumTest | Level2)
315 {
316 AccessToken token;
317 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
318 return;
319 }
320 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
321 ASSERT_TRUE(systemAbilityMgr != nullptr);
322 auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
323 ASSERT_TRUE(startDtmfRemote != nullptr);
324 auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
325 ASSERT_TRUE(telephonyService != nullptr);
326 CellularCallInfo callInfo;
327 if (HasSimCard(SIM1_SLOTID)) {
328 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
329 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
330 char code = '1';
331 ret = telephonyService->StartDtmf(code, callInfo);
332 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
333 }
334 if (HasSimCard(SIM2_SLOTID)) {
335 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
336 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
337 char code = '1';
338 ret = telephonyService->StartDtmf(code, callInfo);
339 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
340 }
341 }
342
343 /**
344 * @tc.number cellular_call_StopDtmf_0001
345 * @tc.name Test for stopDtmf function by cs
346 * @tc.desc Function test
347 */
HWTEST_F(CsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)348 HWTEST_F(CsTest, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)
349 {
350 AccessToken token;
351 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
352 ASSERT_TRUE(systemAbilityMgr != nullptr);
353 auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
354 ASSERT_TRUE(stopDtmfRemote != nullptr);
355 auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
356 ASSERT_TRUE(telephonyService != nullptr);
357 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
358 return;
359 }
360 if (HasSimCard(SIM1_SLOTID)) {
361 CellularCallInfo callInfo;
362 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
363 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
364 ret = telephonyService->StopDtmf(callInfo);
365 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
366 }
367 if (HasSimCard(SIM2_SLOTID)) {
368 CellularCallInfo callInfo;
369 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
370 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
371 ret = telephonyService->StopDtmf(callInfo);
372 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
373 }
374 }
375
376 /**
377 * @tc.number cellular_call_StopDtmf_0002
378 * @tc.name Test for stopDtmf function with invalid slot by cs
379 * @tc.desc Function test
380 */
HWTEST_F(CsTest, cellular_call_StopDtmf_0002, Function | MediumTest | Level2)381 HWTEST_F(CsTest, cellular_call_StopDtmf_0002, Function | MediumTest | Level2)
382 {
383 AccessToken token;
384 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
385 return;
386 }
387 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
388 ASSERT_TRUE(systemAbilityMgr != nullptr);
389 auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
390 ASSERT_TRUE(stopDtmfRemote != nullptr);
391 auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
392 ASSERT_TRUE(telephonyService != nullptr);
393 if (HasSimCard(SIM1_SLOTID)) {
394 CellularCallInfo stopDtmfCallInfo;
395 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
396 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
397 ret = telephonyService->StopDtmf(stopDtmfCallInfo);
398 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
399 }
400 if (HasSimCard(SIM2_SLOTID)) {
401 CellularCallInfo stopDtmfCallInfo;
402 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
403 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
404 ret = telephonyService->StopDtmf(stopDtmfCallInfo);
405 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
406 }
407 }
408
409 /**
410 * @tc.number cellular_call_SendDtmf_0001
411 * @tc.name Test for sendDtmf function by cs
412 * @tc.desc Function test
413 */
HWTEST_F(CsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)414 HWTEST_F(CsTest, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)
415 {
416 AccessToken token;
417 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
418 ASSERT_TRUE(systemAbilityMgr != nullptr);
419 auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
420 ASSERT_TRUE(sendDtmfRemote != nullptr);
421 auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
422 ASSERT_TRUE(telephonyService != nullptr);
423 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
424 return;
425 }
426 if (HasSimCard(SIM1_SLOTID)) {
427 CellularCallInfo sendDtmfCallInfo;
428 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
429 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
430 char code = '1';
431 ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
432 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
433 }
434 if (HasSimCard(SIM2_SLOTID)) {
435 CellularCallInfo sendDtmfCallInfo;
436 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
437 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
438 char code = '1';
439 ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
440 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
441 }
442 }
443
444 /**
445 * @tc.number cellular_call_SendDtmf_0002
446 * @tc.name Test for sendDtmf function with invalid slot by cs
447 * @tc.desc Function test
448 */
HWTEST_F(CsTest, cellular_call_SendDtmf_0002, Function | MediumTest | Level2)449 HWTEST_F(CsTest, cellular_call_SendDtmf_0002, Function | MediumTest | Level2)
450 {
451 AccessToken token;
452 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
453 return;
454 }
455 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
456 ASSERT_TRUE(systemAbilityMgr != nullptr);
457 auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
458 ASSERT_TRUE(sendDtmfRemote != nullptr);
459 auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
460 ASSERT_TRUE(telephonyService != nullptr);
461 if (HasSimCard(SIM1_SLOTID)) {
462 CellularCallInfo sendDtmfCallInfo;
463 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
464 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
465 char code = '1';
466 ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
467 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
468 }
469 if (HasSimCard(SIM2_SLOTID)) {
470 CellularCallInfo sendDtmfCallInfo;
471 int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
472 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
473 char code = '1';
474 ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
475 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
476 }
477 }
478
479 /**
480 * @tc.number cellular_call_GetDomainPreferenceMode_0001
481 * @tc.name Test for GetDomainPreferenceMode function by invalid slotId
482 * @tc.desc Function test
483 */
HWTEST_F(CsTest, cellular_call_GetDomainPreferenceMode_0001, Function | MediumTest | Level3)484 HWTEST_F(CsTest, cellular_call_GetDomainPreferenceMode_0001, Function | MediumTest | Level3)
485 {
486 AccessToken token;
487 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
488 ASSERT_TRUE(systemAbilityMgr != nullptr);
489 auto domainPrefModeRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
490 ASSERT_TRUE(domainPrefModeRemote != nullptr);
491 auto telephonyService = iface_cast<CellularCallInterface>(domainPrefModeRemote);
492 ASSERT_TRUE(telephonyService != nullptr);
493 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
494 return;
495 }
496 if (HasSimCard(SIM1_SLOTID)) {
497 int32_t ret = telephonyService->GetDomainPreferenceMode(INVALID_SLOTID);
498 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
499 }
500 if (HasSimCard(SIM2_SLOTID)) {
501 int32_t ret = telephonyService->GetDomainPreferenceMode(INVALID_SLOTID);
502 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
503 }
504 }
505
506 /**
507 * @tc.number cellular_call_GetDomainPreferenceMode_0002
508 * @tc.name Test for GetDomainPreferenceMode function by valid slotId
509 * @tc.desc Function test
510 */
HWTEST_F(CsTest, cellular_call_GetDomainPreferenceMode_0002, Function | MediumTest | Level3)511 HWTEST_F(CsTest, cellular_call_GetDomainPreferenceMode_0002, Function | MediumTest | Level3)
512 {
513 AccessToken token;
514 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
515 return;
516 }
517 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
518 ASSERT_TRUE(systemAbilityMgr != nullptr);
519 auto domainPrefModeRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
520 ASSERT_TRUE(domainPrefModeRemote != nullptr);
521 auto telephonyService = iface_cast<CellularCallInterface>(domainPrefModeRemote);
522 ASSERT_TRUE(telephonyService != nullptr);
523 if (HasSimCard(SIM1_SLOTID)) {
524 int32_t ret = telephonyService->GetDomainPreferenceMode(SIM1_SLOTID);
525 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
526 }
527 if (HasSimCard(SIM2_SLOTID)) {
528 int32_t ret = telephonyService->GetDomainPreferenceMode(SIM2_SLOTID);
529 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
530 }
531 }
532
533 /**
534 * @tc.number cellular_call_GetMute_0001
535 * @tc.name Test for GetMute function by invalid slotId
536 * @tc.desc Function test
537 */
HWTEST_F(CsTest, cellular_call_GetMute_0001, Function | MediumTest | Level3)538 HWTEST_F(CsTest, cellular_call_GetMute_0001, Function | MediumTest | Level3)
539 {
540 AccessToken token;
541 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
542 ASSERT_TRUE(systemAbilityMgr != nullptr);
543 auto getMuteRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
544 ASSERT_TRUE(getMuteRemote != nullptr);
545 auto telephonyService = iface_cast<CellularCallInterface>(getMuteRemote);
546 ASSERT_TRUE(telephonyService != nullptr);
547 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
548 return;
549 }
550 if (HasSimCard(SIM1_SLOTID)) {
551 int32_t ret = telephonyService->GetMute(INVALID_SLOTID);
552 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
553 }
554 if (HasSimCard(SIM2_SLOTID)) {
555 int32_t ret = telephonyService->GetMute(INVALID_SLOTID);
556 EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
557 }
558 }
559
560 /**
561 * @tc.number cellular_call_GetMute_0002
562 * @tc.name Test for GetMute function by valid slotId
563 * @tc.desc Function test
564 */
HWTEST_F(CsTest, cellular_call_GetMute_0002, Function | MediumTest | Level3)565 HWTEST_F(CsTest, cellular_call_GetMute_0002, Function | MediumTest | Level3)
566 {
567 AccessToken token;
568 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
569 return;
570 }
571 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
572 ASSERT_TRUE(systemAbilityMgr != nullptr);
573 auto getMuteRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
574 ASSERT_TRUE(getMuteRemote != nullptr);
575 auto telephonyService = iface_cast<CellularCallInterface>(getMuteRemote);
576 ASSERT_TRUE(telephonyService != nullptr);
577 if (HasSimCard(SIM1_SLOTID)) {
578 int32_t ret = telephonyService->GetMute(SIM1_SLOTID);
579 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
580 }
581 if (HasSimCard(SIM2_SLOTID)) {
582 int32_t ret = telephonyService->GetMute(SIM2_SLOTID);
583 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
584 }
585 }
586
587 /**
588 * @tc.number cellular_call_CsControl_0001
589 * @tc.name Test for CsControl
590 * @tc.desc Function test
591 */
HWTEST_F(CsTest, cellular_call_CsControl_0001, Function | MediumTest | Level3)592 HWTEST_F(CsTest, cellular_call_CsControl_0001, Function | MediumTest | Level3)
593 {
594 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
595 ASSERT_TRUE(systemAbilityMgr != nullptr);
596 auto csControlRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
597 ASSERT_TRUE(csControlRemote != nullptr);
598 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
599 return;
600 }
601 auto csControl = std::make_shared<CSControl>();
602 CellularCallInfo cellularCallInfo;
603 bool enabled = false;
604 EXPECT_EQ(InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, cellularCallInfo), TELEPHONY_SUCCESS);
605 EXPECT_EQ(csControl->Dial(cellularCallInfo, enabled), CALL_ERR_GET_RADIO_STATE_FAILED);
606 EXPECT_EQ(InitCellularCallInfo(INVALID_SLOTID, "", cellularCallInfo), TELEPHONY_SUCCESS);
607 EXPECT_EQ(csControl->Dial(cellularCallInfo, enabled), CALL_ERR_PHONE_NUMBER_EMPTY);
608 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
609 if (!HasSimCard(slotId)) {
610 continue;
611 }
612 EXPECT_EQ(InitCellularCallInfo(slotId, "*30#", cellularCallInfo), TELEPHONY_SUCCESS);
613 EXPECT_EQ(csControl->DialCdma(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
614 EXPECT_EQ(csControl->DialGsm(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
615 EXPECT_EQ(InitCellularCallInfo(slotId, "#30#", cellularCallInfo), TELEPHONY_SUCCESS);
616 EXPECT_EQ(csControl->DialGsm(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
617 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER, cellularCallInfo), TELEPHONY_SUCCESS);
618 EXPECT_EQ(csControl->DialCdma(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
619 EXPECT_EQ(csControl->Dial(cellularCallInfo, enabled), CALL_ERR_GET_RADIO_STATE_FAILED);
620 ASSERT_FALSE(csControl->CalculateInternationalRoaming(slotId));
621 EXPECT_NE(csControl->DialCdma(cellularCallInfo), TELEPHONY_SUCCESS);
622 EXPECT_EQ(csControl->DialGsm(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
623 EXPECT_NE(csControl->Answer(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
624 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_SECOND, cellularCallInfo), TELEPHONY_SUCCESS);
625 EXPECT_NE(csControl->Answer(cellularCallInfo), CALL_ERR_CALL_STATE);
626 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER_THIRD, cellularCallInfo), TELEPHONY_SUCCESS);
627 EXPECT_NE(csControl->Answer(cellularCallInfo), CALL_ERR_CALL_STATE);
628 EXPECT_NE(csControl->Reject(cellularCallInfo), CALL_ERR_CALL_STATE);
629 EXPECT_EQ(InitCellularCallInfo(slotId, PHONE_NUMBER, cellularCallInfo), TELEPHONY_SUCCESS);
630 EXPECT_EQ(csControl->SeparateConference(slotId, PHONE_NUMBER, 1), CALL_ERR_RESOURCE_UNAVAILABLE);
631 EXPECT_EQ(csControl->SeparateConference(slotId, "", 1), CALL_ERR_RESOURCE_UNAVAILABLE);
632 EXPECT_NE(csControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_DEFAULT), CALL_ERR_RESOURCE_UNAVAILABLE);
633 EXPECT_EQ(csControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE),
634 CALL_ERR_RESOURCE_UNAVAILABLE);
635 EXPECT_EQ(
636 csControl->HangUp(cellularCallInfo, CallSupplementType::TYPE_HANG_UP_ALL), CALL_ERR_RESOURCE_UNAVAILABLE);
637 EXPECT_EQ(csControl->HangUp(cellularCallInfo, static_cast<CallSupplementType>(INVALID_HANG_UP_TYPE)),
638 TELEPHONY_ERR_ARGUMENT_INVALID);
639 }
640 }
641
642 /**
643 * @tc.number cellular_call_CsControl_0002
644 * @tc.name Test for CsControl
645 * @tc.desc Function test
646 */
HWTEST_F(CsTest, cellular_call_CsControl_0002, Function | MediumTest | Level3)647 HWTEST_F(CsTest, cellular_call_CsControl_0002, Function | MediumTest | Level3)
648 {
649 auto csControl = std::make_shared<CSControl>();
650 CellularCallInfo cellularCallInfo;
651 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
652 if (!HasSimCard(slotId)) {
653 continue;
654 }
655 CallInfoList callList;
656 callList.callSize = 0;
657 EXPECT_EQ(csControl->ReportCallsData(slotId, callList), TELEPHONY_ERROR);
658 EXPECT_NE(csControl->ReportUpdateInfo(slotId, callList), TELEPHONY_SUCCESS);
659 CallInfo callInfo;
660 callList.callSize = 1;
661 callInfo.number = PHONE_NUMBER;
662 callInfo.index = 1;
663 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING);
664 callList.calls.push_back(callInfo);
665 EXPECT_EQ(csControl->ReportCallsData(slotId, callList), TELEPHONY_SUCCESS);
666 callList.callSize = 2;
667 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_ACTIVE);
668 callInfo.number = PHONE_NUMBER_SECOND;
669 callInfo.index = 2;
670 callList.calls.push_back(callInfo);
671 callList.callSize = 3;
672 callInfo.state = static_cast<int32_t>(TelCallState::CALL_STATUS_DISCONNECTED);
673 callInfo.number = PHONE_NUMBER_THIRD;
674 callInfo.index = 3;
675 callList.calls.push_back(callInfo);
676 callList.callSize = 0;
677 EXPECT_EQ(csControl->ReportCallsData(slotId, callList), TELEPHONY_SUCCESS);
678 EXPECT_NE(csControl->ReportCallsData(slotId, callList), TELEPHONY_SUCCESS);
679 EXPECT_NE(csControl->Reject(cellularCallInfo), CALL_ERR_RESOURCE_UNAVAILABLE);
680 EXPECT_NE(csControl->HoldCall(slotId), CALL_ERR_CALL_STATE);
681 EXPECT_NE(csControl->UnHoldCall(slotId), CALL_ERR_CALL_STATE);
682 EXPECT_NE(csControl->SwitchCall(slotId), CALL_ERR_CALL_STATE);
683 }
684 }
685
686 /**
687 * @tc.number cellular_call_CellularCallConnectionCS_0001
688 * @tc.name Test for CellularCallConnectionCS
689 * @tc.desc Function test
690 */
HWTEST_F(CsTest, cellular_call_CellularCallConnectionCS_0001, Function | MediumTest | Level3)691 HWTEST_F(CsTest, cellular_call_CellularCallConnectionCS_0001, Function | MediumTest | Level3)
692 {
693 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
694 ASSERT_TRUE(systemAbilityMgr != nullptr);
695 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
696 ASSERT_TRUE(remote != nullptr);
697 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
698 return;
699 }
700
701 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
702 if (!HasSimCard(slotId)) {
703 continue;
704 }
705 CellularCallConnectionCS csConnection;
706 EXPECT_EQ(csConnection.SendDtmfRequest(slotId, '1', 1), CALL_ERR_RESOURCE_UNAVAILABLE);
707 EXPECT_EQ(csConnection.StartDtmfRequest(slotId, '1', 1), CALL_ERR_RESOURCE_UNAVAILABLE);
708 EXPECT_EQ(csConnection.StopDtmfRequest(slotId, 1), CALL_ERR_RESOURCE_UNAVAILABLE);
709 EXPECT_EQ(csConnection.GetCsCallsDataRequest(slotId, 1), CALL_ERR_RESOURCE_UNAVAILABLE);
710 EXPECT_EQ(csConnection.GetCallFailReasonRequest(slotId), CALL_ERR_RESOURCE_UNAVAILABLE);
711 MMICodeUtils utils;
712 ASSERT_FALSE(utils.IsNeedExecuteMmi("", false));
713 ASSERT_FALSE(utils.ExecuteMmiCode(slotId));
714 }
715 }
716
717 /**
718 * @tc.number cellular_call_CellularCallRegister_0001
719 * @tc.name Test for CellularCallRegister
720 * @tc.desc Function test
721 */
HWTEST_F(CsTest, cellular_call_CellularCallRegister_0001, Function | MediumTest | Level3)722 HWTEST_F(CsTest, cellular_call_CellularCallRegister_0001, Function | MediumTest | Level3)
723 {
724 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
725 ASSERT_TRUE(systemAbilityMgr != nullptr);
726 auto cellularCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
727 ASSERT_TRUE(cellularCallRemote != nullptr);
728 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
729 return;
730 }
731 auto callRegister = DelayedSingleton<CellularCallRegister>::GetInstance();
732 ASSERT_TRUE(callRegister != nullptr);
733 CellularCallEventInfo callEvent;
734 callRegister->ReportEventResultInfo(callEvent);
735 CallWaitResponse waitResponse;
736 callRegister->ReportGetWaitingResult(waitResponse);
737 callRegister->ReportSetWaitingResult(ERROR_RESULT);
738 CallRestrictionResponse restrictionResponse;
739 callRegister->ReportGetRestrictionResult(restrictionResponse);
740 callRegister->ReportSetRestrictionResult(ERROR_RESULT);
741 callRegister->ReportSetBarringPasswordResult(ERROR_RESULT);
742 CallTransferResponse transferResponse;
743 callRegister->ReportGetTransferResult(transferResponse);
744 callRegister->ReportSetTransferResult(ERROR_RESULT);
745 ClipResponse clipResponse;
746 callRegister->ReportGetClipResult(clipResponse);
747 ClirResponse clirResponse;
748 callRegister->ReportGetClirResult(clirResponse);
749 callRegister->ReportSetClirResult(ERROR_RESULT);
750 callRegister->ReportCallRingBackResult(ERROR_RESULT);
751 DisconnectedDetails details;
752 callRegister->ReportCallFailReason(details);
753 MuteControlResponse muteResponse;
754 callRegister->ReportSetMuteResult(muteResponse);
755 callRegister->ReportGetMuteResult(muteResponse);
756 callRegister->ReportInviteToConferenceResult(ERROR_RESULT);
757 callRegister->ReportGetCallDataResult(ERROR_RESULT);
758 callRegister->ReportStartDtmfResult(ERROR_RESULT);
759 callRegister->ReportStopDtmfResult(ERROR_RESULT);
760 callRegister->ReportStartRttResult(ERROR_RESULT);
761 callRegister->ReportStopRttResult(ERROR_RESULT);
762 callRegister->ReportSendUssdResult(ERROR_RESULT);
763 SetEccListResponse eccListResponse;
764 callRegister->ReportSetEmergencyCallListResponse(eccListResponse);
765 MmiCodeInfo mmiInfo;
766 callRegister->ReportMmiCodeResult(mmiInfo);
767 ASSERT_FALSE(callRegister->IsCallManagerCallBackRegistered());
768 }
769
770 /**
771 * @tc.number cellular_call_CellularCallRegister_0002
772 * @tc.name Test for CellularCallRegister
773 * @tc.desc Function test
774 */
HWTEST_F(CsTest, cellular_call_CellularCallRegister_0002, Function | MediumTest | Level3)775 HWTEST_F(CsTest, cellular_call_CellularCallRegister_0002, Function | MediumTest | Level3)
776 {
777 auto callRegister = DelayedSingleton<CellularCallRegister>::GetInstance();
778 CallReportInfo callRepotInfo;
779 callRepotInfo.callType = CallType::TYPE_CS;
780 callRepotInfo.accountId = INVALID_SLOTID;
781 callRepotInfo.state = TelCallState::CALL_STATUS_INCOMING;
782 callRepotInfo.callMode = VideoStateType::TYPE_VOICE;
783 CallsReportInfo calls;
784 calls.slotId = INVALID_SLOTID;
785 calls.callVec.push_back(callRepotInfo);
786 callRegister->ReportCallsInfo(calls);
787 callRegister->ReportSingleCallInfo(callRepotInfo, TelCallState::CALL_STATUS_INCOMING);
788 EXPECT_EQ(callRegister->RegisterCallManagerCallBack(nullptr), TELEPHONY_SUCCESS);
789 EXPECT_EQ(callRegister->UnRegisterCallManagerCallBack(), TELEPHONY_SUCCESS);
790 }
791
792 /**
793 * @tc.number cellular_call_SupplementRequestCs_0001
794 * @tc.name Test for SupplementRequestCs
795 * @tc.desc Function test
796 */
HWTEST_F(CsTest, cellular_call_SupplementRequestCs_0001, Function | MediumTest | Level3)797 HWTEST_F(CsTest, cellular_call_SupplementRequestCs_0001, Function | MediumTest | Level3)
798 {
799 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
800 return;
801 }
802
803 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
804 if (!HasSimCard(slotId)) {
805 continue;
806 }
807 SupplementRequestCs request;
808 std::string fac = "fac";
809 std::string pw = "test";
810 int32_t index = 1;
811 int32_t mode = 1;
812 int32_t classType = 1;
813 const char *oldPassword = "oldpwd";
814 const char *newPassword = "newpwd";
815 bool active = true;
816 CallTransferParam param;
817 EXPECT_NE(request.GetCallRestrictionRequest(slotId, fac, index), TELEPHONY_SUCCESS);
818 EXPECT_NE(request.SetCallRestrictionRequest(slotId, fac, mode, pw, index), TELEPHONY_SUCCESS);
819 EXPECT_NE(request.SetBarringPasswordRequest(slotId, fac, index, oldPassword, newPassword), TELEPHONY_SUCCESS);
820 EXPECT_NE(request.GetCallWaitingRequest(slotId, index), TELEPHONY_SUCCESS);
821 EXPECT_NE(request.SetCallWaitingRequest(slotId, active, classType, index), TELEPHONY_SUCCESS);
822 EXPECT_NE(request.GetClipRequest(slotId, index), TELEPHONY_SUCCESS);
823 EXPECT_NE(request.GetClirRequest(slotId, index), TELEPHONY_SUCCESS);
824 EXPECT_NE(request.SetClirRequest(slotId, mode, index), TELEPHONY_SUCCESS);
825 EXPECT_NE(request.GetCallTransferRequest(slotId, mode, index), TELEPHONY_SUCCESS);
826 EXPECT_NE(request.SetCallTransferRequest(slotId, param, index), TELEPHONY_SUCCESS);
827 }
828 }
829
830 /**
831 * @tc.number cellular_call_ConfigRequest_0001
832 * @tc.name Test for ConfigRequest
833 * @tc.desc Function test
834 */
HWTEST_F(CsTest, cellular_call_ConfigRequest_0001, Function | MediumTest | Level3)835 HWTEST_F(CsTest, cellular_call_ConfigRequest_0001, Function | MediumTest | Level3)
836 {
837 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
838 return;
839 }
840
841 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
842 if (!HasSimCard(slotId)) {
843 continue;
844 }
845 ConfigRequest config;
846 int32_t mode = 1;
847 EXPECT_NE(config.SetDomainPreferenceModeRequest(slotId, mode), TELEPHONY_SUCCESS);
848 EXPECT_NE(config.GetDomainPreferenceModeRequest(slotId), TELEPHONY_SUCCESS);
849 EXPECT_NE(config.SetMuteRequest(slotId, mode), TELEPHONY_SUCCESS);
850 EXPECT_NE(config.GetMuteRequest(slotId), TELEPHONY_SUCCESS);
851 }
852 }
853
854 /**
855 * @tc.number cellular_call_CellularCallSupplement_0001
856 * @tc.name Test for CellularCallSupplement
857 * @tc.desc Function test
858 */
HWTEST_F(CsTest, cellular_call_CellularCallSupplement_0001, Function | MediumTest | Level3)859 HWTEST_F(CsTest, cellular_call_CellularCallSupplement_0001, Function | MediumTest | Level3)
860 {
861 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
862 return;
863 }
864
865 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
866 if (!HasSimCard(slotId)) {
867 continue;
868 }
869 MMIData mmiData;
870 CellularCallSupplement supplement;
871 mmiData.actionString = "";
872 supplement.AlterPinPassword(slotId, mmiData);
873 supplement.AlterPin2Password(slotId, mmiData);
874 supplement.UnlockPuk(slotId, mmiData);
875 supplement.UnlockPuk2(slotId, mmiData);
876 mmiData.actionString = "test";
877 mmiData.serviceInfoA = "infoA";
878 mmiData.serviceInfoB = "infoB";
879 mmiData.serviceInfoC = "infoC";
880 supplement.AlterPinPassword(slotId, mmiData);
881 supplement.AlterPin2Password(slotId, mmiData);
882 supplement.UnlockPuk(slotId, mmiData);
883 supplement.UnlockPuk2(slotId, mmiData);
884 mmiData.serviceInfoC = "infoB";
885 supplement.AlterPinPassword(slotId, mmiData);
886 supplement.AlterPin2Password(slotId, mmiData);
887 supplement.UnlockPuk(slotId, mmiData);
888 supplement.UnlockPuk2(slotId, mmiData);
889 ASSERT_FALSE(supplement.IsVaildPinOrPuk("B", "B"));
890 EXPECT_NE(supplement.SendUssd(slotId, "test"), TELEPHONY_SUCCESS);
891 }
892 }
893
894 /**
895 * @tc.number cellular_call_CellularCallSupplement_0002
896 * @tc.name Test for CellularCallSupplement
897 * @tc.desc Function test
898 */
HWTEST_F(CsTest, cellular_call_CellularCallSupplement_0002, Function | MediumTest | Level3)899 HWTEST_F(CsTest, cellular_call_CellularCallSupplement_0002, Function | MediumTest | Level3)
900 {
901 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
902 return;
903 }
904
905 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
906 if (!HasSimCard(slotId)) {
907 continue;
908 }
909 CellularCallSupplement supplement;
910 supplement.ObtainBarringInstallation("33");
911 supplement.ObtainBarringInstallation("331");
912 supplement.ObtainBarringInstallation("332");
913 supplement.ObtainBarringInstallation("351");
914 supplement.ObtainBarringInstallation("35");
915 supplement.ObtainBarringInstallation("330");
916 supplement.ObtainBarringInstallation("333");
917 supplement.ObtainBarringInstallation("353");
918 supplement.ObtainBarringInstallation("1000");
919
920 EXPECT_NE(supplement.ObtainServiceCode("10"), TELEPHONY_SUCCESS);
921 EXPECT_NE(supplement.ObtainServiceCode("11"), TELEPHONY_SUCCESS);
922 EXPECT_NE(supplement.ObtainServiceCode("12"), TELEPHONY_SUCCESS);
923 EXPECT_NE(supplement.ObtainServiceCode("13"), TELEPHONY_SUCCESS);
924 EXPECT_NE(supplement.ObtainServiceCode("16"), TELEPHONY_SUCCESS);
925 EXPECT_NE(supplement.ObtainServiceCode("19"), TELEPHONY_SUCCESS);
926 EXPECT_NE(supplement.ObtainServiceCode("20"), TELEPHONY_SUCCESS);
927 EXPECT_NE(supplement.ObtainServiceCode("21"), TELEPHONY_SUCCESS);
928 EXPECT_NE(supplement.ObtainServiceCode("22"), TELEPHONY_SUCCESS);
929 EXPECT_NE(supplement.ObtainServiceCode("24"), TELEPHONY_SUCCESS);
930 EXPECT_NE(supplement.ObtainServiceCode("25"), TELEPHONY_SUCCESS);
931 EXPECT_NE(supplement.ObtainServiceCode("99"), TELEPHONY_SUCCESS);
932 EXPECT_EQ(supplement.ObtainServiceCode("100"), TELEPHONY_SUCCESS);
933
934 EXPECT_EQ(supplement.ObtainCause("21"), TELEPHONY_SUCCESS);
935 EXPECT_NE(supplement.ObtainCause("61"), TELEPHONY_SUCCESS);
936 EXPECT_NE(supplement.ObtainCause("62"), TELEPHONY_SUCCESS);
937 EXPECT_NE(supplement.ObtainCause("67"), TELEPHONY_SUCCESS);
938 EXPECT_EQ(supplement.ObtainCause("99"), TELEPHONY_ERROR);
939 }
940 }
941
942 /**
943 * @tc.number cellular_call_CellularCallSupplement_0003
944 * @tc.name Test for CellularCallSupplement
945 * @tc.desc Function test
946 */
HWTEST_F(CsTest, cellular_call_CellularCallSupplement_0003, Function | MediumTest | Level3)947 HWTEST_F(CsTest, cellular_call_CellularCallSupplement_0003, Function | MediumTest | Level3)
948 {
949 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
950 return;
951 }
952
953 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
954 if (!HasSimCard(slotId)) {
955 continue;
956 }
957 CellularCallSupplement supplement;
958 std::string action = "*";
959 std::string number = "";
960 CallTransferSettingType type;
961 EXPECT_EQ(supplement.ObtainCallTrasferAction(action.c_str(), number, type), TELEPHONY_SUCCESS);
962 EXPECT_EQ(supplement.ObtainCallTrasferAction(action.c_str(), PHONE_NUMBER, type), TELEPHONY_SUCCESS);
963 action = "#";
964 EXPECT_EQ(supplement.ObtainCallTrasferAction(action.c_str(), number, type), TELEPHONY_SUCCESS);
965 action = "**";
966 EXPECT_EQ(supplement.ObtainCallTrasferAction(action.c_str(), number, type), TELEPHONY_SUCCESS);
967 action = "##";
968 EXPECT_EQ(supplement.ObtainCallTrasferAction(action.c_str(), number, type), TELEPHONY_SUCCESS);
969 action = "*#";
970 EXPECT_NE(supplement.ObtainCallTrasferAction(action.c_str(), number, type), TELEPHONY_SUCCESS);
971 }
972 }
973
974 /**
975 * @tc.number cellular_call_CellularCallHandler_0001
976 * @tc.name Test for CellularCallHandler
977 * @tc.desc Function test
978 */
HWTEST_F(CsTest, cellular_call_CellularCallHandler_0001, Function | MediumTest | Level3)979 HWTEST_F(CsTest, cellular_call_CellularCallHandler_0001, Function | MediumTest | Level3)
980 {
981 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
982 return;
983 }
984
985 EventFwk::MatchingSkills matchingSkills;
986 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
987 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
988 CellularCallHandler firstHandler { subscriberInfo };
989 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
990 if (!HasSimCard(slotId)) {
991 continue;
992 }
993 firstHandler.SetSlotId(slotId);
994 auto event = AppExecFwk::InnerEvent::Get(0);
995 auto rilRadioResponse = std::make_shared<RadioResponseInfo>();
996 rilRadioResponse->error = ErrType::ERR_GENERIC_FAILURE;
997 firstHandler.CellularCallIncomingStartTrace(static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING));
998 firstHandler.CellularCallIncomingFinishTrace(static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING));
999 firstHandler.GetCsCallsDataResponse(event);
1000 firstHandler.GetCsCallsDataRequest(event);
1001 firstHandler.GetMMIResponse(event);
1002 auto ringbackResponse = std::make_shared<RingbackVoice>();
1003 ringbackResponse->status = ERROR_RESULT;
1004 auto ringbackEvent = AppExecFwk::InnerEvent::Get(0, ringbackResponse);
1005 firstHandler.CallRingBackVoiceResponse(event);
1006 firstHandler.CallRingBackVoiceResponse(ringbackEvent);
1007 auto srvccStatus = std::make_shared<SrvccStatus>();
1008 srvccStatus->status = SrvccState::SRVCC_NONE;
1009 auto srvccEvent1 = AppExecFwk::InnerEvent::Get(0, srvccStatus);
1010 firstHandler.UpdateSrvccStateReport(event);
1011 firstHandler.UpdateSrvccStateReport(srvccEvent1);
1012 srvccStatus->status = SrvccState::COMPLETED;
1013 auto srvccEvent2 = AppExecFwk::InnerEvent::Get(0, srvccStatus);
1014 firstHandler.UpdateSrvccStateReport(srvccEvent2);
1015 firstHandler.UpdateRsrvccStateReport(event);
1016 firstHandler.GetCallFailReasonResponse(event);
1017 firstHandler.GetEmergencyCallListResponse(event);
1018 firstHandler.ReportEccChanged(event);
1019 firstHandler.SetEmergencyCallListResponse(event);
1020 firstHandler.SendUssdResponse(event);
1021 ASSERT_EQ(firstHandler.GetSlotId(), slotId);
1022 }
1023 }
1024
1025 /**
1026 * @tc.number cellular_call_CellularCallHandler_0002
1027 * @tc.name Test for CellularCallHandler
1028 * @tc.desc Function test
1029 */
HWTEST_F(CsTest, cellular_call_CellularCallHandler_0002, Function | MediumTest | Level3)1030 HWTEST_F(CsTest, cellular_call_CellularCallHandler_0002, Function | MediumTest | Level3)
1031 {
1032 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1033 return;
1034 }
1035
1036 EventFwk::MatchingSkills matchingSkills;
1037 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
1038 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1039 CellularCallHandler secondHandler { subscriberInfo };
1040 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1041 if (!HasSimCard(slotId)) {
1042 continue;
1043 }
1044 secondHandler.SetSlotId(slotId);
1045 auto event = AppExecFwk::InnerEvent::Get(0);
1046 auto rilRadioResponse = std::make_shared<RadioResponseInfo>();
1047 rilRadioResponse->error = ErrType::ERR_GENERIC_FAILURE;
1048 secondHandler.CommonResultResponse(event);
1049 auto rejectEvent = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_REJECT_CALL, rilRadioResponse);
1050 secondHandler.CommonResultResponse(rejectEvent);
1051 auto supplementEvent = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_CALL_SUPPLEMENT, rilRadioResponse);
1052 secondHandler.CommonResultResponse(supplementEvent);
1053
1054 rilRadioResponse->error = ErrType::NONE;
1055 auto hangupConnectEvent = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_HANGUP_CONNECT, rilRadioResponse);
1056 secondHandler.CommonResultResponse(hangupConnectEvent);
1057 auto acceptEvent = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_ACCEPT_CALL, rilRadioResponse);
1058 secondHandler.CommonResultResponse(acceptEvent);
1059 auto splitNoErrorEvent = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SPLIT_CALL, rilRadioResponse);
1060 secondHandler.CommonResultResponse(splitNoErrorEvent);
1061
1062 auto ssResult = std::make_shared<SsBaseResult>();
1063 ssResult->index = INVALID_INDEX;
1064 ssResult->result = SUCCESS_RESULT;
1065 auto errorEvent = AppExecFwk::InnerEvent::Get(0, ssResult);
1066 secondHandler.SetCallRestrictionResponse(event);
1067 secondHandler.SetCallRestrictionResponse(errorEvent);
1068 secondHandler.SetBarringPasswordResponse(event);
1069 secondHandler.SetCallTransferInfoResponse(event);
1070 secondHandler.SetCallWaitingResponse(event);
1071 secondHandler.SetClipResponse(event);
1072 secondHandler.SetClirResponse(event);
1073 secondHandler.SetColpResponse(event);
1074 secondHandler.SetColrResponse(event);
1075
1076 auto responseEvent = AppExecFwk::InnerEvent::Get(0, rilRadioResponse);
1077 secondHandler.SetMuteResponse(event);
1078 secondHandler.SetMuteResponse(responseEvent);
1079 secondHandler.GetMuteResponse(event);
1080 secondHandler.GetMuteResponse(responseEvent);
1081 ASSERT_EQ(secondHandler.GetSlotId(), slotId);
1082 }
1083 }
1084
1085 /**
1086 * @tc.number cellular_call_CellularCallHandler_0003
1087 * @tc.name Test for CellularCallHandler
1088 * @tc.desc Function test
1089 */
HWTEST_F(CsTest, cellular_call_CellularCallHandler_0003, Function | MediumTest | Level3)1090 HWTEST_F(CsTest, cellular_call_CellularCallHandler_0003, Function | MediumTest | Level3)
1091 {
1092 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
1093 return;
1094 }
1095 EventFwk::MatchingSkills matchingSkills;
1096 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
1097 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1098 CellularCallHandler thirdhandler { subscriberInfo };
1099 for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) {
1100 if (!HasSimCard(slotId)) {
1101 continue;
1102 }
1103 thirdhandler.SetSlotId(slotId);
1104 auto event = AppExecFwk::InnerEvent::Get(0);
1105 auto ussdNoticeResponse = std::make_shared<UssdNoticeInfo>();
1106 ussdNoticeResponse->m = USSD_MODE_NOTIFY;
1107 ussdNoticeResponse->str = "tdd test";
1108 auto successEvent = AppExecFwk::InnerEvent::Get(0, ussdNoticeResponse);
1109 thirdhandler.UssdNotifyResponse(event);
1110 thirdhandler.UssdNotifyResponse(successEvent);
1111 ussdNoticeResponse->str = "";
1112 auto errorEvent = AppExecFwk::InnerEvent::Get(0, ussdNoticeResponse);
1113 thirdhandler.UssdNotifyResponse(errorEvent);
1114
1115 auto ssNoticeResponse = std::make_shared<SsNoticeInfo>();
1116 ssNoticeResponse->result = ERROR_RESULT;
1117 auto defaultEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1118 thirdhandler.SsNotifyResponse(event);
1119 thirdhandler.SsNotifyResponse(defaultEvent);
1120 ssNoticeResponse->requestType = SUCCESS_RESULT;
1121 auto noticeErrorEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1122 thirdhandler.SsNotifyResponse(noticeErrorEvent);
1123 ssNoticeResponse->result = SUCCESS_RESULT;
1124 auto noticeDefaultEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1125 thirdhandler.SsNotifyResponse(noticeDefaultEvent);
1126 ssNoticeResponse->serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_UNCONDITIONAL);
1127 auto noticeUnconditinalEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1128 thirdhandler.SsNotifyResponse(noticeUnconditinalEvent);
1129 ssNoticeResponse->serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_BUSY);
1130 auto noticeBusyEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1131 thirdhandler.SsNotifyResponse(noticeBusyEvent);
1132 ssNoticeResponse->serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_NO_REPLY);
1133 auto noticeNoReplyEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1134 thirdhandler.SsNotifyResponse(noticeNoReplyEvent);
1135 ssNoticeResponse->serviceType = static_cast<int32_t>(CallTransferType::TRANSFER_TYPE_NOT_REACHABLE);
1136 auto noticeNotReachableEvent = AppExecFwk::InnerEvent::Get(0, ssNoticeResponse);
1137 thirdhandler.SsNotifyResponse(noticeNotReachableEvent);
1138 ASSERT_EQ(thirdhandler.GetSlotId(), slotId);
1139 }
1140 }
1141
1142 /**
1143 * @tc.number cellular_call_CellularCallHandler_0004
1144 * @tc.name Test for CellularCallHandler
1145 * @tc.desc Function test
1146 */
HWTEST_F(CsTest, cellular_call_CellularCallHandler_0004, Function | MediumTest | Level3)1147 HWTEST_F(CsTest, cellular_call_CellularCallHandler_0004, Function | MediumTest | Level3)
1148 {
1149 EventFwk::MatchingSkills matchingSkills;
1150 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
1151 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1152 CellularCallHandler fourthHandler { subscriberInfo };
1153 auto callInfoList = std::make_shared<CallInfoList>();
1154 callInfoList->callSize = 1;
1155 std::string expectedPhoneNumber = "+861565910xxxx";
1156 std::string unexpectedPhoneNumber = "00861565910xxxx";
1157 std::vector<CallInfo> callInfoLists;
1158 CallInfo callInfo;
1159 callInfo.number = unexpectedPhoneNumber;
1160 callInfoLists.push_back(callInfo);
1161 callInfoList->calls = callInfoLists;
1162 fourthHandler.ProcessCsPhoneNumber(*callInfoList);
1163 EXPECT_EQ(callInfoList->calls[0].number, expectedPhoneNumber);
1164 auto callInfoListFirst = std::make_shared<CallInfoList>();
1165 callInfoListFirst->callSize = 0;
1166 callInfoLists.clear();
1167 callInfo.number = unexpectedPhoneNumber;
1168 callInfoLists.push_back(callInfo);
1169 callInfoListFirst->calls = callInfoLists;
1170 fourthHandler.ProcessCsPhoneNumber(*callInfoListFirst);
1171 EXPECT_EQ(callInfoListFirst->calls[0].number, unexpectedPhoneNumber);
1172 auto callInfoListSecond = std::make_shared<CallInfoList>();
1173 callInfoListSecond->callSize = 1;
1174 fourthHandler.ProcessCsPhoneNumber(*callInfoListSecond);
1175 EXPECT_EQ(callInfoListSecond->callSize, 1);
1176 auto callInfoListThird = std::make_shared<CallInfoList>();
1177 callInfoListThird->callSize = 1;
1178 expectedPhoneNumber = "+861565910xxxx";
1179 unexpectedPhoneNumber = "123";
1180 callInfoLists.clear();
1181 callInfo.number = unexpectedPhoneNumber;
1182 callInfoLists.push_back(callInfo);
1183 callInfoListThird->calls = callInfoLists;
1184 fourthHandler.ProcessCsPhoneNumber(*callInfoListThird);
1185 EXPECT_EQ(callInfoListThird->calls[0].number, unexpectedPhoneNumber);
1186 callInfoLists.clear();
1187 unexpectedPhoneNumber = "0861565910xxxx";
1188 callInfo.number = unexpectedPhoneNumber;
1189 callInfoLists.push_back(callInfo);
1190 callInfoListThird->calls = callInfoLists;
1191 fourthHandler.ProcessCsPhoneNumber(*callInfoListThird);
1192 EXPECT_EQ(callInfoListThird->calls[0].number, unexpectedPhoneNumber);
1193 }
1194
1195 /**
1196 * @tc.number cellular_call_CellularCallHandler_0005
1197 * @tc.name Test for CellularCallHandler
1198 * @tc.desc Function test
1199 */
HWTEST_F(CsTest, cellular_call_CellularCallHandler_0005, Function | MediumTest | Level3)1200 HWTEST_F(CsTest, cellular_call_CellularCallHandler_0005, Function | MediumTest | Level3)
1201 {
1202 EventFwk::MatchingSkills matchingSkills;
1203 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
1204 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1205 CellularCallHandler fifthHandler { subscriberInfo };
1206 auto callInfoList = std::make_shared<CallInfoList>();
1207 callInfoList->callSize = 1;
1208 std::random_device rd;
1209 std::mt19937 gen(rd());
1210 std::uniform_int_distribution<> distrib(0, 9);
1211 int randomNumber = 0;
1212 int phonenumberLength = 8;
1213 for (int i = 0; i < phonenumberLength; i++) {
1214 randomNumber = randomNumber * 10 + distrib(gen);
1215 }
1216 std::string expectedPhoneNumber = "+86156" + std::to_string(randomNumber);
1217 std::string unexpectedPhoneNumber = "+8686156" + std::to_string(randomNumber);
1218 CallInfo callInfo;
1219 callInfo.number = unexpectedPhoneNumber;
1220 callInfo.type = 145;
1221 callInfoList->calls.push_back(callInfo);
1222 fifthHandler.ProcessRedundantCode(*callInfoList);
1223 EXPECT_EQ(callInfoList->calls[0].number, expectedPhoneNumber);
1224 callInfoList->callSize = 0;
1225 fifthHandler.ProcessRedundantCode(*callInfoList);
1226 EXPECT_EQ(callInfoList->calls[0].number, expectedPhoneNumber);
1227 callInfoList->callSize = 1;
1228 callInfoList->calls.clear();
1229 fifthHandler.ProcessRedundantCode(*callInfoList);
1230 EXPECT_EQ(callInfoList->callSize, 1);
1231 callInfo.number = unexpectedPhoneNumber;
1232 callInfo.type = 136;
1233 callInfoList->calls.push_back(callInfo);
1234 fifthHandler.ProcessRedundantCode(*callInfoList);
1235 EXPECT_EQ(callInfoList->calls[0].number, unexpectedPhoneNumber);
1236 unexpectedPhoneNumber = "+561565910xxxx";
1237 callInfo.number = unexpectedPhoneNumber;
1238 callInfo.type = 145;
1239 callInfoList->calls.clear();
1240 callInfoList->calls.push_back(callInfo);
1241 fifthHandler.ProcessRedundantCode(*callInfoList);
1242 EXPECT_EQ(callInfoList->calls[0].number, unexpectedPhoneNumber);
1243 unexpectedPhoneNumber = "+861565910";
1244 callInfo.number = unexpectedPhoneNumber;
1245 callInfoList->calls.clear();
1246 callInfoList->calls.push_back(callInfo);
1247 fifthHandler.ProcessRedundantCode(*callInfoList);
1248 EXPECT_EQ(callInfoList->calls[0].number, unexpectedPhoneNumber);
1249 }
1250
1251 /**
1252 * @tc.number cellular_call_TestDump_0001
1253 * @tc.name TestDump
1254 * @tc.desc Function test
1255 */
HWTEST_F(CsTest, cellular_call_TestDump_0001, Function | MediumTest | Level3)1256 HWTEST_F(CsTest, cellular_call_TestDump_0001, Function | MediumTest | Level3)
1257 {
1258 std::vector<std::u16string> emptyArgs = {};
1259 std::vector<std::u16string> args = { u"test", u"test1" };
1260 EXPECT_GE(DelayedSingleton<CellularCallService>::GetInstance()->Dump(-1, args), 0);
1261 EXPECT_GE(DelayedSingleton<CellularCallService>::GetInstance()->Dump(0, emptyArgs), 0);
1262 EXPECT_GE(DelayedSingleton<CellularCallService>::GetInstance()->Dump(0, args), 0);
1263 }
1264
1265 /**
1266 * @tc.number cellular_call_ModuleServiceUtils_0001
1267 * @tc.name ModuleServiceUtils
1268 * @tc.desc Function test
1269 */
HWTEST_F(CsTest, cellular_call_ModuleServiceUtils_0001, Function | MediumTest | Level3)1270 HWTEST_F(CsTest, cellular_call_ModuleServiceUtils_0001, Function | MediumTest | Level3)
1271 {
1272 ModuleServiceUtils moduleServiceUtils;
1273 bool airplaneModeOn = false;
1274 moduleServiceUtils.GetCsRegState(SIM1_SLOTID);
1275 moduleServiceUtils.GetPsRegState(SIM1_SLOTID);
1276 moduleServiceUtils.GetRadioState(SIM1_SLOTID);
1277 moduleServiceUtils.GetNetworkStatus(SIM1_SLOTID);
1278 moduleServiceUtils.GetIsoCountryCode(SIM1_SLOTID);
1279 moduleServiceUtils.GetNetworkCountryCode(SIM1_SLOTID);
1280 moduleServiceUtils.GetImsRegistrationState(SIM1_SLOTID);
1281 moduleServiceUtils.GetImsUtSupportState(SIM1_SLOTID);
1282 moduleServiceUtils.GetSatelliteStatus();
1283 moduleServiceUtils.GetSlotInfo();
1284 moduleServiceUtils.NeedCallImsService();
1285 moduleServiceUtils.GetImsServiceRemoteObject();
1286 EXPECT_NE(moduleServiceUtils.GetAirplaneMode(airplaneModeOn), TELEPHONY_SUCCESS);
1287 EXPECT_NE(moduleServiceUtils.UpdateRadioOn(SIM1_SLOTID), TELEPHONY_SUCCESS);
1288 }
1289
1290 /**
1291 * @tc.number cellular_call_CellularCallConfig_0001
1292 * @tc.name CellularCallConfig
1293 * @tc.desc Function test
1294 */
HWTEST_F(CsTest, cellular_call_CellularCallConfig_0001, Function | MediumTest | Level3)1295 HWTEST_F(CsTest, cellular_call_CellularCallConfig_0001, Function | MediumTest | Level3)
1296 {
1297 CellularCallConfig CellularCallConfig;
1298 bool isReadyToCall = false;
1299 bool csType = 0;
1300 CellularCallConfig.SetReadyToCall(SIM1_SLOTID, isReadyToCall);
1301 CellularCallCallback cellularCallCallback;
1302 cellularCallCallback.SetReadyToCall(SIM1_SLOTID, csType, isReadyToCall);
1303 EXPECT_EQ(CellularCallConfig.IsReadyToCall(SIM1_SLOTID), TELEPHONY_SUCCESS);
1304 }
1305 } // namespace Telephony
1306 } // namespace OHOS
1307