• 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 
InitCellularCallInfo(int32_t accountId,std::string phonenumber,CellularCallInfo & callInfo)54     int32_t InitCellularCallInfo(int32_t accountId, std::string phonenumber, CellularCallInfo &callInfo)
55     {
56         callInfo.accountId = accountId;
57         callInfo.slotId = accountId;
58         callInfo.index = 0;
59         callInfo.callType = CallType::TYPE_SATELLITE;
60         callInfo.videoState = 0; // 0 means audio
61         if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
62             return TELEPHONY_ERR_MEMSET_FAIL;
63         }
64         if (phonenumber.length() > static_cast<size_t>(kMaxNumberLen)) {
65             return CALL_ERR_NUMBER_OUT_OF_RANGE;
66         }
67         if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, phonenumber.c_str(), phonenumber.length()) != EOK) {
68             return TELEPHONY_ERR_MEMCPY_FAIL;
69         }
70         return TELEPHONY_SUCCESS;
71     };
72 
TestDialCallBySatellite(int32_t slotId,std::string code)73     int32_t TestDialCallBySatellite(int32_t slotId, std::string code)
74     {
75         AccessToken token;
76         auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
77         if (saMgr == nullptr) {
78             return TELEPHONY_ERR_FAIL;
79         }
80         auto remote = saMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
81         if (remote == nullptr) {
82             return TELEPHONY_ERR_FAIL;
83         }
84         auto telephonyService = iface_cast<CellularCallInterface>(remote);
85         if (telephonyService == nullptr) {
86             return TELEPHONY_ERR_FAIL;
87         }
88         CellularCallInfo SatelliteCellularCallInfo;
89         int32_t ret = TELEPHONY_SUCCESS;
90         ret = InitCellularCallInfo(slotId, code, SatelliteCellularCallInfo);
91         if (ret != TELEPHONY_SUCCESS) {
92             return ret;
93         }
94         ret = telephonyService->Dial(SatelliteCellularCallInfo);
95         return ret;
96     };
97 };
98 
SetUpTestCase(void)99 void SatelliteTest::SetUpTestCase(void)
100 {
101     // step 3: Set Up Test Case
102 }
103 
TearDownTestCase(void)104 void SatelliteTest::TearDownTestCase(void)
105 {
106     // step 3: Tear Down Test Case
107 }
108 
SetUp(void)109 void SatelliteTest::SetUp(void)
110 {
111     // step 3: input testcase setup step
112 }
113 
TearDown(void)114 void SatelliteTest::TearDown(void)
115 {
116     // step 3: input testcase teardown step
117 }
118 
119 /**
120  * @tc.number   Satellite_call_test_001
121  * @tc.name     Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
122  *              GetCallPreferenceMode, etc
123  * @tc.desc     Function test
124  */
125 HWTEST_F(SatelliteTest, Satellite_call_test_001, Function | MediumTest | Level0)
126 {
127     std::cout << "HWTEST_F Satellite_call_test_001";
128     AccessToken token;
129     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
130     ASSERT_TRUE(systemAbilityMgr != nullptr);
131     auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
132     ASSERT_TRUE(remote != nullptr);
133     auto telephonyService = iface_cast<CellularCallInterface>(remote);
134     ASSERT_TRUE(telephonyService != nullptr);
135 }
136 
137 /**
138  * @tc.number   Satellite_call_test_002
139  * @tc.name     Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
140  *              GetCallPreferenceMode, etc
141  * @tc.desc     Function test
142  */
143 HWTEST_F(SatelliteTest, Satellite_call_test_002, Function | MediumTest | Level1)
144 {
145     std::cout << "HWTEST_F Satellite_call_test_002";
146     AccessToken token;
147     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
148     ASSERT_TRUE(systemAbilityMgr != nullptr);
149     auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
150     ASSERT_TRUE(remote != nullptr);
151     auto telephonyService = iface_cast<CellularCallInterface>(remote);
152     ASSERT_TRUE(telephonyService != nullptr);
153 }
154 
155 /**
156  * @tc.number   Satellite_call_DialCall_0001
157  * @tc.name     Test for SetClip function by Satellite
158  * @tc.desc     Function test
159  */
160 HWTEST_F(SatelliteTest, Satellite_call_DialCall_0001, Function | MediumTest | Level2)
161 {
162     AccessToken token;
163     TELEPHONY_LOGI("Satellite_call_DialCall_0001 entry");
164     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
165     ASSERT_TRUE(systemAbilityMgr != nullptr);
166     auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
167     ASSERT_TRUE(hangUpCallRemote != nullptr);
168     auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
169     ASSERT_TRUE(telephonyService != nullptr);
170     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
171         return;
172     }
173     if (HasSimCard(SIM2_SLOTID)) {
174         int32_t ret = TestDialCallBySatellite(SIM2_SLOTID, PHONE_NUMBER);
175         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
176         ret = TestDialCallBySatellite(INVALID_SLOTID, PHONE_NUMBER);
177         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
178     }
179 }
180 
181 /**
182  * @tc.number   Satellite_call_HangUpCall_0001
183  * @tc.name     Test for HangUp function by Satellite
184  * @tc.desc     Function test
185  */
186 HWTEST_F(SatelliteTest, Satellite_call_HangUpCall_0001, Function | MediumTest | Level2)
187 {
188     AccessToken token;
189     TELEPHONY_LOGI("Satellite_call_HangUpCall_0001 entry");
190     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
191     ASSERT_TRUE(systemAbilityMgr != nullptr);
192     auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
193     ASSERT_TRUE(hangUpCallRemote != nullptr);
194     auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
195     ASSERT_TRUE(telephonyService != nullptr);
196     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
197         return;
198     }
199     if (HasSimCard(SIM1_SLOTID)) {
200         CellularCallInfo callInfo;
201         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
202         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
203         ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
204         EXPECT_GE(ret, TELEPHONY_SUCCESS);
205     }
206     if (HasSimCard(SIM2_SLOTID)) {
207         CellularCallInfo callInfo;
208         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
209         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
210         ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
211         EXPECT_GE(ret, TELEPHONY_SUCCESS);
212     }
213 }
214 
215 /**
216  * @tc.number   Satellite_call_AnswerCall_0001
217  * @tc.name     Test for answer function by Satellite
218  * @tc.desc     Function test
219  */
220 HWTEST_F(SatelliteTest, Satellite_call_AnswerCall_0001, Function | MediumTest | Level2)
221 {
222     AccessToken token;
223     TELEPHONY_LOGI("Satellite_call_AnswerCall_0001 entry");
224     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
225     ASSERT_TRUE(systemAbilityMgr != nullptr);
226     auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
227     ASSERT_TRUE(answerCallRemote != nullptr);
228     auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
229     ASSERT_TRUE(telephonyService != nullptr);
230     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
231         return;
232     }
233     if (HasSimCard(SIM1_SLOTID)) {
234         CellularCallInfo callInfo;
235         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
236         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
237         ret = telephonyService->Answer(callInfo);
238         EXPECT_GE(ret, TELEPHONY_SUCCESS);
239     }
240     if (HasSimCard(SIM2_SLOTID)) {
241         CellularCallInfo callInfo;
242         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
243         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
244         ret = telephonyService->Answer(callInfo);
245         EXPECT_GE(ret, TELEPHONY_SUCCESS);
246     }
247 }
248 
249 /**
250  * @tc.number   Satellite_call_RejectCall_0001
251  * @tc.name     Test for reject function by tatellite
252  * @tc.desc     Function test
253  */
254 HWTEST_F(SatelliteTest, Satellite_call_RejectCall_0001, Function | MediumTest | Level2)
255 {
256     AccessToken token;
257     TELEPHONY_LOGI("Satellite_call_RejectCall_0001 entry");
258     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
259     ASSERT_TRUE(systemAbilityMgr != nullptr);
260     auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
261     ASSERT_TRUE(rejectCallRemote != nullptr);
262     auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
263     ASSERT_TRUE(telephonyService != nullptr);
264     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
265         return;
266     }
267     if (HasSimCard(SIM1_SLOTID)) {
268         CellularCallInfo callInfo;
269         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
270         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
271         ret = telephonyService->Reject(callInfo);
272         EXPECT_GE(ret, TELEPHONY_SUCCESS);
273     }
274     if (HasSimCard(SIM2_SLOTID)) {
275         CellularCallInfo callInfo;
276         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
277         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
278         ret = telephonyService->Reject(callInfo);
279         EXPECT_GE(ret, TELEPHONY_SUCCESS);
280     }
281 }
282 /**
283  * @tc.number   Satellite_call_StartDtmf_0001
284  * @tc.name     Test for startDtmf function by satellite
285  * @tc.desc     Function test
286  */
287 HWTEST_F(SatelliteTest, Satellite_call_StartDtmf_0001, Function | MediumTest | Level2)
288 {
289     AccessToken token;
290     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
291     ASSERT_TRUE(systemAbilityMgr != nullptr);
292     auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
293     ASSERT_TRUE(startDtmfRemote != nullptr);
294     auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
295     ASSERT_TRUE(telephonyService != nullptr);
296     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
297         return;
298     }
299     if (HasSimCard(SIM1_SLOTID)) {
300         CellularCallInfo callInfo;
301         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
302         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
303     }
304     if (HasSimCard(SIM2_SLOTID)) {
305         CellularCallInfo callInfo;
306         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
307         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
308         char code = '1';
309         ret = telephonyService->StartDtmf(code, callInfo);
310         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
311     }
312 }
313 
314 /**
315  * @tc.number   Satellite_call_StartDtmf_0002
316  * @tc.name     Test for startDtmf function with invalid slot by satellite
317  * @tc.desc     Function test
318  */
319 HWTEST_F(SatelliteTest, Satellite_call_StartDtmf_0002, Function | MediumTest | Level2)
320 {
321     AccessToken token;
322     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
323         return;
324     }
325     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
326     ASSERT_TRUE(systemAbilityMgr != nullptr);
327     auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
328     ASSERT_TRUE(startDtmfRemote != nullptr);
329     auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
330     ASSERT_TRUE(telephonyService != nullptr);
331     CellularCallInfo callInfo;
332     if (HasSimCard(SIM1_SLOTID)) {
333         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
334         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
335         char code = '1';
336         ret = telephonyService->StartDtmf(code, callInfo);
337         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
338     }
339     if (HasSimCard(SIM2_SLOTID)) {
340         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, callInfo);
341         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
342         char code = '1';
343         ret = telephonyService->StartDtmf(code, callInfo);
344         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
345     }
346 }
347 
348 /**
349  * @tc.number   Satellite_call_StopDtmf_0001
350  * @tc.name     Test for stopDtmf function by satellite
351  * @tc.desc     Function test
352  */
353 HWTEST_F(SatelliteTest, Satellite_call_StopDtmf_0001, Function | MediumTest | Level2)
354 {
355     AccessToken token;
356     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
357     ASSERT_TRUE(systemAbilityMgr != nullptr);
358     auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
359     ASSERT_TRUE(stopDtmfRemote != nullptr);
360     auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
361     ASSERT_TRUE(telephonyService != nullptr);
362     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
363         return;
364     }
365     if (HasSimCard(SIM1_SLOTID)) {
366         CellularCallInfo callInfo;
367         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
368         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
369     }
370     if (HasSimCard(SIM2_SLOTID)) {
371         CellularCallInfo callInfo;
372         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
373         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
374         ret = telephonyService->StopDtmf(callInfo);
375         EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
376     }
377 }
378 
379 /**
380  * @tc.number   Satellite_call_StopDtmf_0002
381  * @tc.name     Test for stopDtmf function with invalid slot by satellite
382  * @tc.desc     Function test
383  */
384 HWTEST_F(SatelliteTest, Satellite_call_StopDtmf_0002, Function | MediumTest | Level2)
385 {
386     AccessToken token;
387     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
388         return;
389     }
390     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
391     ASSERT_TRUE(systemAbilityMgr != nullptr);
392     auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
393     ASSERT_TRUE(stopDtmfRemote != nullptr);
394     auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
395     ASSERT_TRUE(telephonyService != nullptr);
396     if (HasSimCard(SIM1_SLOTID)) {
397         CellularCallInfo stopDtmfCallInfo;
398         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
399         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
400         ret = telephonyService->StopDtmf(stopDtmfCallInfo);
401         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
402     }
403     if (HasSimCard(SIM2_SLOTID)) {
404         CellularCallInfo stopDtmfCallInfo;
405         int32_t ret = InitCellularCallInfo(INVALID_SLOTID, PHONE_NUMBER, stopDtmfCallInfo);
406         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
407         ret = telephonyService->StopDtmf(stopDtmfCallInfo);
408         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
409     }
410 }
411 
412 /**
413  * @tc.number   Satellite_call_SendDtmf_0001
414  * @tc.name     Test for sendDtmf function by satellite
415  * @tc.desc     Function test
416  */
417 HWTEST_F(SatelliteTest, Satellite_call_SendDtmf_0001, Function | MediumTest | Level2)
418 {
419     AccessToken token;
420     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
421     ASSERT_TRUE(systemAbilityMgr != nullptr);
422     auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
423     ASSERT_TRUE(sendDtmfRemote != nullptr);
424     auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
425     ASSERT_TRUE(telephonyService != nullptr);
426     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
427         return;
428     }
429     if (HasSimCard(SIM1_SLOTID)) {
430         CellularCallInfo sendDtmfCallInfo;
431         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, sendDtmfCallInfo);
432         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
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   Satellite_call_SendDtmf_0002
446  * @tc.name     Test for sendDtmf function with invalid slot by satellite
447  * @tc.desc     Function test
448  */
449 HWTEST_F(SatelliteTest, Satellite_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 } // namespace Telephony
479 } // namespace OHOS
480