• 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 "satellite_test.h"
17 
18 #define private public
19 #define protected public
20 #include "cellular_call_config.h"
21 #include "cellular_call_handler.h"
22 #include "cellular_call_proxy.h"
23 #include "cellular_call_register.h"
24 #include "cellular_call_service.h"
25 #include "hril_call_parcel.h"
26 #include "satellite_call_client.h"
27 #include "securec.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 using namespace testing::ext;
32 const int32_t SIM1_SLOTID = 0;
33 const int32_t SIM2_SLOTID = 1;
34 const int32_t INVALID_SLOTID = 10;
35 const std::string PHONE_NUMBER = "0000000";
36 
SetUpTestCase(void)37 void SatelliteTest::SetUpTestCase(void)
38 {
39     // step 3: Set Up Test Case
40 }
41 
TearDownTestCase(void)42 void SatelliteTest::TearDownTestCase(void)
43 {
44     // step 3: Tear Down Test Case
45 }
46 
SetUp(void)47 void SatelliteTest::SetUp(void)
48 {
49     // step 3: input testcase setup step
50 }
51 
TearDown(void)52 void SatelliteTest::TearDown(void)
53 {
54     // step 3: input testcase teardown step
55 }
56 
57 /**
58  * @tc.number   Satellite_call_test_001
59  * @tc.name     Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
60  *              GetCallPreferenceMode, etc
61  * @tc.desc     Function test
62  */
63 HWTEST_F(SatelliteTest, Satellite_call_test_001, Function | MediumTest | Level0)
64 {
65     std::cout << "HWTEST_F Satellite_call_test_001";
66     AccessToken token;
67     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
68     ASSERT_TRUE(systemAbilityMgr != nullptr);
69     auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
70     ASSERT_TRUE(remote != nullptr);
71     auto telephonyService = iface_cast<CellularCallInterface>(remote);
72     ASSERT_TRUE(telephonyService != nullptr);
73 }
74 
75 /**
76  * @tc.number   Satellite_call_test_002
77  * @tc.name     Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
78  *              GetCallPreferenceMode, etc
79  * @tc.desc     Function test
80  */
81 HWTEST_F(SatelliteTest, Satellite_call_test_002, Function | MediumTest | Level1)
82 {
83     std::cout << "HWTEST_F Satellite_call_test_002";
84     AccessToken token;
85     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
86     ASSERT_TRUE(systemAbilityMgr != nullptr);
87     auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
88     ASSERT_TRUE(remote != nullptr);
89     auto telephonyService = iface_cast<CellularCallInterface>(remote);
90     ASSERT_TRUE(telephonyService != nullptr);
91 }
92 
93 /**
94  * @tc.number   Satellite_call_DialCall_0001
95  * @tc.name     Test for SetClip function by Satellite
96  * @tc.desc     Function test
97  */
98 HWTEST_F(SatelliteTest, Satellite_call_DialCall_0001, Function | MediumTest | Level2)
99 {
100     AccessToken token;
101     TELEPHONY_LOGI("Satellite_call_DialCall_0001 entry");
102     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
103     ASSERT_TRUE(systemAbilityMgr != nullptr);
104     auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
105     ASSERT_TRUE(hangUpCallRemote != nullptr);
106     auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
107     ASSERT_TRUE(telephonyService != nullptr);
108     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
109         return;
110     }
111     if (HasSimCard(SIM1_SLOTID)) {
112         int32_t ret = TestDialCallBySatellite(SIM1_SLOTID, PHONE_NUMBER);
113         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
114         ret = TestDialCallBySatellite(INVALID_SLOTID, PHONE_NUMBER);
115         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
116     }
117     if (HasSimCard(SIM2_SLOTID)) {
118         int32_t ret = TestDialCallBySatellite(SIM2_SLOTID, PHONE_NUMBER);
119         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
120         ret = TestDialCallBySatellite(INVALID_SLOTID, PHONE_NUMBER);
121         EXPECT_EQ(ret, CALL_ERR_INVALID_SLOT_ID);
122     }
123 }
124 
125 /**
126  * @tc.number   Satellite_call_HangUpCall_0001
127  * @tc.name     Test for HangUp function by Satellite
128  * @tc.desc     Function test
129  */
130 HWTEST_F(SatelliteTest, Satellite_call_HangUpCall_0001, Function | MediumTest | Level2)
131 {
132     AccessToken token;
133     TELEPHONY_LOGI("Satellite_call_HangUpCall_0001 entry");
134     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
135     ASSERT_TRUE(systemAbilityMgr != nullptr);
136     auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
137     ASSERT_TRUE(hangUpCallRemote != nullptr);
138     auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
139     ASSERT_TRUE(telephonyService != nullptr);
140     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
141         return;
142     }
143     if (HasSimCard(SIM1_SLOTID)) {
144         CellularCallInfo callInfo;
145         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
146         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
147         ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
148         EXPECT_GE(ret, TELEPHONY_SUCCESS);
149     }
150     if (HasSimCard(SIM2_SLOTID)) {
151         CellularCallInfo callInfo;
152         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
153         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
154         ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
155         EXPECT_GE(ret, TELEPHONY_SUCCESS);
156     }
157 }
158 
159 /**
160  * @tc.number   Satellite_call_AnswerCall_0001
161  * @tc.name     Test for answer function by Satellite
162  * @tc.desc     Function test
163  */
164 HWTEST_F(SatelliteTest, Satellite_call_AnswerCall_0001, Function | MediumTest | Level2)
165 {
166     AccessToken token;
167     TELEPHONY_LOGI("Satellite_call_AnswerCall_0001 entry");
168     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
169     ASSERT_TRUE(systemAbilityMgr != nullptr);
170     auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
171     ASSERT_TRUE(answerCallRemote != nullptr);
172     auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
173     ASSERT_TRUE(telephonyService != nullptr);
174     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
175         return;
176     }
177     if (HasSimCard(SIM1_SLOTID)) {
178         CellularCallInfo callInfo;
179         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
180         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
181         ret = telephonyService->Answer(callInfo);
182         EXPECT_GE(ret, TELEPHONY_SUCCESS);
183     }
184     if (HasSimCard(SIM2_SLOTID)) {
185         CellularCallInfo callInfo;
186         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
187         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
188         ret = telephonyService->Answer(callInfo);
189         EXPECT_GE(ret, TELEPHONY_SUCCESS);
190     }
191 }
192 
193 /**
194  * @tc.number   Satellite_call_RejectCall_0001
195  * @tc.name     Test for reject function by tatellite
196  * @tc.desc     Function test
197  */
198 HWTEST_F(SatelliteTest, Satellite_call_RejectCall_0001, Function | MediumTest | Level2)
199 {
200     AccessToken token;
201     TELEPHONY_LOGI("Satellite_call_RejectCall_0001 entry");
202     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
203     ASSERT_TRUE(systemAbilityMgr != nullptr);
204     auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
205     ASSERT_TRUE(rejectCallRemote != nullptr);
206     auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
207     ASSERT_TRUE(telephonyService != nullptr);
208     if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
209         return;
210     }
211     if (HasSimCard(SIM1_SLOTID)) {
212         CellularCallInfo callInfo;
213         int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
214         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
215         ret = telephonyService->Reject(callInfo);
216         EXPECT_GE(ret, TELEPHONY_SUCCESS);
217     }
218     if (HasSimCard(SIM2_SLOTID)) {
219         CellularCallInfo callInfo;
220         int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
221         EXPECT_EQ(ret, TELEPHONY_SUCCESS);
222         ret = telephonyService->Reject(callInfo);
223         EXPECT_GE(ret, TELEPHONY_SUCCESS);
224     }
225 }
226 } // namespace Telephony
227 } // namespace OHOS
228