• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.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 "core_service_client.h"
26 #include "tel_ril_call_parcel.h"
27 #include "satellite_call_client.h"
28 #include "securec.h"
29 #include "system_ability_definition.h"
30 #include "token.h"
31 
32 namespace OHOS {
33 namespace Telephony {
34 using namespace testing::ext;
35 const int32_t SIM1_SLOTID = 0;
36 const int32_t SIM2_SLOTID = 1;
37 const int32_t INVALID_SLOTID = 10;
38 const std::string PHONE_NUMBER = "0000000";
39 
40 class SatelliteTest : public testing::Test {
41 public:
42     static void SetUpTestCase();
43     static void TearDownTestCase();
44     void SetUp();
45     void TearDown();
46 
HasSimCard(int32_t slotId)47     bool HasSimCard(int32_t slotId)
48     {
49         bool hasSimCard = false;
50         DelayedRefSingleton<CoreServiceClient>::GetInstance().HasSimCard(slotId, hasSimCard);
51         return hasSimCard;
52     }
53 
CanUseImsService(int32_t slotId,ImsServiceType type)54     bool CanUseImsService(int32_t slotId, ImsServiceType type)
55     {
56         ImsRegInfo info;
57         CoreServiceClient::GetInstance().GetImsRegStatus(slotId, type, info);
58         bool imsReg = info.imsRegState == ImsRegState::IMS_REGISTERED;
59         return imsReg;
60     }
61 
InitCellularCallInfo(int32_t accountId,std::string phonenumber,CellularCallInfo & callInfo)62     int32_t InitCellularCallInfo(int32_t accountId, std::string phonenumber, CellularCallInfo &callInfo)
63     {
64         callInfo.accountId = accountId;
65         callInfo.slotId = accountId;
66         callInfo.index = 0;
67         callInfo.callType = CallType::TYPE_SATELLITE;
68         callInfo.videoState = 0; // 0 means audio
69         if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
70             return TELEPHONY_ERR_MEMSET_FAIL;
71         }
72         if (phonenumber.length() > static_cast<size_t>(kMaxNumberLen)) {
73             return CALL_ERR_NUMBER_OUT_OF_RANGE;
74         }
75         if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, phonenumber.c_str(), phonenumber.length()) != EOK) {
76             return TELEPHONY_ERR_MEMCPY_FAIL;
77         }
78         return TELEPHONY_SUCCESS;
79     };
80 
TestDialCallBySatellite(int32_t slotId,std::string code)81     int32_t TestDialCallBySatellite(int32_t slotId, std::string code)
82     {
83         AccessToken token;
84         auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
85         if (saMgr == nullptr) {
86             return TELEPHONY_ERR_FAIL;
87         }
88         auto remote = saMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
89         if (remote == nullptr) {
90             return TELEPHONY_ERR_FAIL;
91         }
92         auto telephonyService = iface_cast<CellularCallInterface>(remote);
93         if (telephonyService == nullptr) {
94             return TELEPHONY_ERR_FAIL;
95         }
96         CellularCallInfo SatelliteCellularCallInfo;
97         int32_t ret = TELEPHONY_SUCCESS;
98         ret = InitCellularCallInfo(slotId, code, SatelliteCellularCallInfo);
99         if (ret != TELEPHONY_SUCCESS) {
100             return ret;
101         }
102         ret = telephonyService->Dial(SatelliteCellularCallInfo);
103         return ret;
104     };
105 };
106 
SetUpTestCase(void)107 void SatelliteTest::SetUpTestCase(void)
108 {
109     // step 3: Set Up Test Case
110 }
111 
TearDownTestCase(void)112 void SatelliteTest::TearDownTestCase(void)
113 {
114     // step 3: Tear Down Test Case
115 }
116 
SetUp(void)117 void SatelliteTest::SetUp(void)
118 {
119     // step 3: input testcase setup step
120 }
121 
TearDown(void)122 void SatelliteTest::TearDown(void)
123 {
124     // step 3: input testcase teardown step
125 }
126 
127 /**
128  * @tc.number   Satellite_call_test_001
129  * @tc.name     Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
130  *              GetCallPreferenceMode, etc
131  * @tc.desc     Function test
132  */
133 HWTEST_F(SatelliteTest, Satellite_call_test_001, Function | MediumTest | Level0)
134 {
135     std::cout << "HWTEST_F Satellite_call_test_001";
136     AccessToken token;
137     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
138     ASSERT_TRUE(systemAbilityMgr != nullptr);
139     auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
140     ASSERT_TRUE(remote != nullptr);
141     auto telephonyService = iface_cast<CellularCallInterface>(remote);
142     ASSERT_TRUE(telephonyService != nullptr);
143 }
144 
145 /**
146  * @tc.number   Satellite_call_test_002
147  * @tc.name     Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
148  *              GetCallPreferenceMode, etc
149  * @tc.desc     Function test
150  */
151 HWTEST_F(SatelliteTest, Satellite_call_test_002, Function | MediumTest | Level1)
152 {
153     std::cout << "HWTEST_F Satellite_call_test_002";
154     AccessToken token;
155     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
156     ASSERT_TRUE(systemAbilityMgr != nullptr);
157     auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
158     ASSERT_TRUE(remote != nullptr);
159     auto telephonyService = iface_cast<CellularCallInterface>(remote);
160     ASSERT_TRUE(telephonyService != nullptr);
161 }
162 
163 /**
164  * @tc.number   Satellite_call_DialCall_0001
165  * @tc.name     Test for SetClip function by Satellite
166  * @tc.desc     Function test
167  */
168 HWTEST_F(SatelliteTest, Satellite_call_DialCall_0001, Function | MediumTest | Level2)
169 {
170     AccessToken token;
171     TELEPHONY_LOGI("Satellite_call_DialCall_0001 entry");
172     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
173     ASSERT_TRUE(systemAbilityMgr != nullptr);
174     auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
175     ASSERT_TRUE(hangUpCallRemote != nullptr);
176     auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
177     ASSERT_TRUE(telephonyService != nullptr);
178     if (HasSimCard(SIM1_SLOTID)) {
179         int32_t ret = TestDialCallBySatellite(SIM1_SLOTID, PHONE_NUMBER);
180         EXPECT_NE(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
181         ret = TestDialCallBySatellite(INVALID_SLOTID, PHONE_NUMBER);
182         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
183     }
184     if (HasSimCard(SIM2_SLOTID)) {
185         int32_t ret = TestDialCallBySatellite(SIM2_SLOTID, PHONE_NUMBER);
186         EXPECT_NE(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
187         ret = TestDialCallBySatellite(INVALID_SLOTID, PHONE_NUMBER);
188         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
189     }
190 }
191 
192 /**
193  * @tc.number   Satellite_call_HangUpCall_0001
194  * @tc.name     Test for HangUp function by Satellite
195  * @tc.desc     Function test
196  */
197 HWTEST_F(SatelliteTest, Satellite_call_HangUpCall_0001, Function | MediumTest | Level2)
198 {
199     AccessToken token;
200     TELEPHONY_LOGI("Satellite_call_HangUpCall_0001 entry");
201     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
202     ASSERT_TRUE(systemAbilityMgr != nullptr);
203     auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
204     ASSERT_TRUE(hangUpCallRemote != nullptr);
205     auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
206     ASSERT_TRUE(telephonyService != nullptr);
207     if (HasSimCard(SIM1_SLOTID)) {
208         CellularCallInfo callInfo;
209         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
210         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
211         ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
212         EXPECT_GE(ret, TELEPHONY_SUCCESS);
213     }
214     if (HasSimCard(SIM2_SLOTID)) {
215         CellularCallInfo callInfo;
216         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
217         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
218         ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
219         EXPECT_GE(ret, TELEPHONY_SUCCESS);
220     }
221 }
222 
223 /**
224  * @tc.number   Satellite_call_AnswerCall_0001
225  * @tc.name     Test for answer function by Satellite
226  * @tc.desc     Function test
227  */
228 HWTEST_F(SatelliteTest, Satellite_call_AnswerCall_0001, Function | MediumTest | Level2)
229 {
230     AccessToken token;
231     TELEPHONY_LOGI("Satellite_call_AnswerCall_0001 entry");
232     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
233     ASSERT_TRUE(systemAbilityMgr != nullptr);
234     auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
235     ASSERT_TRUE(answerCallRemote != nullptr);
236     auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
237     ASSERT_TRUE(telephonyService != nullptr);
238     if (HasSimCard(SIM1_SLOTID)) {
239         CellularCallInfo callInfo;
240         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
241         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
242         ret = telephonyService->Answer(callInfo);
243         EXPECT_GE(ret, TELEPHONY_SUCCESS);
244     }
245     if (HasSimCard(SIM2_SLOTID)) {
246         CellularCallInfo callInfo;
247         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
248         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
249         ret = telephonyService->Answer(callInfo);
250         EXPECT_GE(ret, TELEPHONY_SUCCESS);
251     }
252 }
253 
254 /**
255  * @tc.number   Satellite_call_RejectCall_0001
256  * @tc.name     Test for reject function by tatellite
257  * @tc.desc     Function test
258  */
259 HWTEST_F(SatelliteTest, Satellite_call_RejectCall_0001, Function | MediumTest | Level2)
260 {
261     AccessToken token;
262     TELEPHONY_LOGI("Satellite_call_RejectCall_0001 entry");
263     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
264     ASSERT_TRUE(systemAbilityMgr != nullptr);
265     auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
266     ASSERT_TRUE(rejectCallRemote != nullptr);
267     auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
268     ASSERT_TRUE(telephonyService != nullptr);
269     if (HasSimCard(SIM1_SLOTID)) {
270         CellularCallInfo callInfo;
271         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
272         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
273         ret = telephonyService->Reject(callInfo);
274         EXPECT_GE(ret, TELEPHONY_SUCCESS);
275     }
276     if (HasSimCard(SIM2_SLOTID)) {
277         CellularCallInfo callInfo;
278         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
279         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
280         ret = telephonyService->Reject(callInfo);
281         EXPECT_GE(ret, TELEPHONY_SUCCESS);
282     }
283 }
284 /**
285  * @tc.number   Satellite_call_StartDtmf_0001
286  * @tc.name     Test for startDtmf function by satellite
287  * @tc.desc     Function test
288  */
289 HWTEST_F(SatelliteTest, Satellite_call_StartDtmf_0001, Function | MediumTest | Level2)
290 {
291     AccessToken token;
292     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
293     ASSERT_TRUE(systemAbilityMgr != nullptr);
294     auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
295     ASSERT_TRUE(startDtmfRemote != nullptr);
296     auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
297     ASSERT_TRUE(telephonyService != nullptr);
298     if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
299         CellularCallInfo callInfo;
300         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
301         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
302         char code = '1';
303         ret = telephonyService->StartDtmf(code, callInfo);
304         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
305     }
306     if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
307         CellularCallInfo callInfo;
308         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
309         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
310         char code = '1';
311         ret = telephonyService->StartDtmf(code, callInfo);
312         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
313     }
314 }
315 
316 /**
317  * @tc.number   Satellite_call_StartDtmf_0002
318  * @tc.name     Test for startDtmf function with invalid slot by satellite
319  * @tc.desc     Function test
320  */
321 HWTEST_F(SatelliteTest, Satellite_call_StartDtmf_0002, Function | MediumTest | Level2)
322 {
323     AccessToken token;
324     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
325     ASSERT_TRUE(systemAbilityMgr != nullptr);
326     auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
327     ASSERT_TRUE(startDtmfRemote != nullptr);
328     auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
329     ASSERT_TRUE(telephonyService != nullptr);
330     CellularCallInfo callInfo;
331     if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
332         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
333         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
334         char code = '1';
335         ret = telephonyService->StartDtmf(code, callInfo);
336         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
337     }
338     if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
339         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
340         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
341         char code = '1';
342         ret = telephonyService->StartDtmf(code, callInfo);
343         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
344     }
345 }
346 
347 /**
348  * @tc.number   Satellite_call_StopDtmf_0001
349  * @tc.name     Test for stopDtmf function by satellite
350  * @tc.desc     Function test
351  */
352 HWTEST_F(SatelliteTest, Satellite_call_StopDtmf_0001, Function | MediumTest | Level2)
353 {
354     AccessToken token;
355     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
356     ASSERT_TRUE(systemAbilityMgr != nullptr);
357     auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
358     ASSERT_TRUE(stopDtmfRemote != nullptr);
359     auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
360     ASSERT_TRUE(telephonyService != nullptr);
361     if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
362         CellularCallInfo callInfo;
363         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
364         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
365         ret = telephonyService->StopDtmf(callInfo);
366         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
367     }
368     if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
369         CellularCallInfo callInfo;
370         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
371         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
372         ret = telephonyService->StopDtmf(callInfo);
373         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
374     }
375 }
376 
377 /**
378  * @tc.number   Satellite_call_StopDtmf_0002
379  * @tc.name     Test for stopDtmf function with invalid slot by satellite
380  * @tc.desc     Function test
381  */
382 HWTEST_F(SatelliteTest, Satellite_call_StopDtmf_0002, Function | MediumTest | Level2)
383 {
384     AccessToken token;
385     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
386     ASSERT_TRUE(systemAbilityMgr != nullptr);
387     auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
388     ASSERT_TRUE(stopDtmfRemote != nullptr);
389     auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
390     ASSERT_TRUE(telephonyService != nullptr);
391     if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
392         CellularCallInfo stopDtmfCallInfo;
393         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
394         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
395         ret = telephonyService->StopDtmf(stopDtmfCallInfo);
396         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
397     }
398     if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
399         CellularCallInfo stopDtmfCallInfo;
400         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
401         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
402         ret = telephonyService->StopDtmf(stopDtmfCallInfo);
403         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
404     }
405 }
406 
407 /**
408  * @tc.number   Satellite_call_SendDtmf_0001
409  * @tc.name     Test for sendDtmf function by satellite
410  * @tc.desc     Function test
411  */
412 HWTEST_F(SatelliteTest, Satellite_call_SendDtmf_0001, Function | MediumTest | Level2)
413 {
414     AccessToken token;
415     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
416     ASSERT_TRUE(systemAbilityMgr != nullptr);
417     auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
418     ASSERT_TRUE(sendDtmfRemote != nullptr);
419     auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
420     ASSERT_TRUE(telephonyService != nullptr);
421     if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
422         CellularCallInfo sendDtmfCallInfo;
423         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
424         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
425         char code = '1';
426         ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
427         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
428     }
429     if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
430         CellularCallInfo sendDtmfCallInfo;
431         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
432         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
433         char code = '1';
434         ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
435         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
436     }
437 }
438 
439 /**
440  * @tc.number   Satellite_call_SendDtmf_0002
441  * @tc.name     Test for sendDtmf function with invalid slot by satellite
442  * @tc.desc     Function test
443  */
444 HWTEST_F(SatelliteTest, Satellite_call_SendDtmf_0002, Function | MediumTest | Level2)
445 {
446     AccessToken token;
447     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
448     ASSERT_TRUE(systemAbilityMgr != nullptr);
449     auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
450     ASSERT_TRUE(sendDtmfRemote != nullptr);
451     auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
452     ASSERT_TRUE(telephonyService != nullptr);
453     if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
454         CellularCallInfo sendDtmfCallInfo;
455         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
456         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
457         char code = '1';
458         ret = telephonyService->SendDtmf(code, sendDtmfCallInfo);
459         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
460     }
461     if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
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 }
470 } // namespace Telephony
471 } // namespace OHOS
472