1 /*
2 * Copyright (C) 2024 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 #define private public
16 #define protected public
17
18 #include "cellular_data_client.h"
19 #include "cellular_data_constant.h"
20 #include "data_access_token.h"
21 #include "gtest/gtest.h"
22 #include "telephony_errors.h"
23
24 namespace OHOS {
25 namespace Telephony {
26 using namespace testing::ext;
27
28 class CellularDataClientTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp();
33 void TearDown();
34 };
SetUpTestCase()35 void CellularDataClientTest::SetUpTestCase() {}
36
TearDownTestCase()37 void CellularDataClientTest::TearDownTestCase() {}
38
SetUp()39 void CellularDataClientTest::SetUp() {}
40
TearDown()41 void CellularDataClientTest::TearDown() {}
42
43 /**
44 * @tc.number CellularDataServiceValidTest_001
45 * @tc.name test function branch
46 * @tc.desc Function test
47 */
48 HWTEST_F(CellularDataClientTest, CellularDataServiceValidTest_001, TestSize.Level0)
49 {
50 auto proxy = CellularDataClient::GetInstance().GetProxy();
51 EXPECT_TRUE(proxy != nullptr);
52 }
53
54 /**
55 * @tc.number EnableIntelligenceSwitch_001
56 * @tc.name test function branch
57 * @tc.desc Function test
58 */
59 HWTEST_F(CellularDataClientTest, EnableIntelligenceSwitch_001, TestSize.Level0)
60 {
61 int32_t result = CellularDataClient::GetInstance().EnableIntelligenceSwitch(false);
62 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
63 }
64
65 /**
66 * @tc.number GetApnState_001
67 * @tc.name test function branch
68 * @tc.desc Function test
69 */
70 HWTEST_F(CellularDataClientTest, GetApnState_001, TestSize.Level0)
71 {
72 std::string str;
73 int32_t result = CellularDataClient::GetInstance().GetApnState(0, str);
74 EXPECT_EQ(result, 0);
75 }
76
77 /**
78 * @tc.number GetDataRecoveryState_001
79 * @tc.name test function branch
80 * @tc.desc Function test
81 */
82 HWTEST_F(CellularDataClientTest, GetDataRecoveryState_001, TestSize.Level0)
83 {
84 int32_t result = CellularDataClient::GetInstance().GetDataRecoveryState();
85 EXPECT_EQ(result, 0);
86 }
87
88 /**
89 * @tc.number IsCellularDataRoamingEnabled_001
90 * @tc.name test function branch
91 * @tc.desc Function test
92 */
93 HWTEST_F(CellularDataClientTest, IsCellularDataRoamingEnabled_001, TestSize.Level0)
94 {
95 bool dataRoamingEnabled = false;
96 CellularDataClient::GetInstance().IsCellularDataRoamingEnabled(0, dataRoamingEnabled);
97 EXPECT_EQ(dataRoamingEnabled, false);
98 }
99
100 /**
101 * @tc.number ClearCellularDataConnections_001
102 * @tc.name test function branch
103 * @tc.desc Function test
104 */
105 HWTEST_F(CellularDataClientTest, ClearCellularDataConnections_001, TestSize.Level0)
106 {
107 int32_t result = CellularDataClient::GetInstance().ClearCellularDataConnections(0);
108 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
109 }
110
111 /**
112 * @tc.number GetDataConnApnAttr_001
113 * @tc.name test function branch
114 * @tc.desc Function test
115 */
116 HWTEST_F(CellularDataClientTest, GetDataConnApnAttr_001, TestSize.Level0)
117 {
118 ApnItem::Attribute apnAttr;
119 int32_t result = CellularDataClient::GetInstance().GetDataConnApnAttr(0, apnAttr);
120 EXPECT_EQ(result, 0);
121 }
122
123 /**
124 * @tc.number GetDataConnIpType_001
125 * @tc.name test function branch
126 * @tc.desc Function test
127 */
128 HWTEST_F(CellularDataClientTest, GetDataConnIpType_001, TestSize.Level0)
129 {
130 std::string ipType;
131 int32_t result = CellularDataClient::GetInstance().GetDataConnIpType(0, ipType);
132 EXPECT_EQ(result, 0);
133 }
134
135 /**
136 * @tc.number ClearAllConnections_001
137 * @tc.name test function branch
138 * @tc.desc Function test
139 */
140 HWTEST_F(CellularDataClientTest, ClearAllConnections_001, TestSize.Level0)
141 {
142 int32_t result = CellularDataClient::GetInstance().ClearAllConnections(0, DisConnectionReason::REASON_NORMAL);
143 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
144 }
145
146 /**
147 * @tc.number IsNeedDoRecovery_001
148 * @tc.name test function branch
149 * @tc.desc Function test
150 */
151 HWTEST_F(CellularDataClientTest, IsNeedDoRecovery_001, TestSize.Level0)
152 {
153 bool needDoRecovery = false;
154 CellularDataClient::GetInstance().IsNeedDoRecovery(0, needDoRecovery);
155 EXPECT_EQ(needDoRecovery, false);
156 }
157
158 /**
159 * @tc.number SetDefaultCellularDataSlotId_001
160 * @tc.name test function branch
161 * @tc.desc Function test
162 */
163 HWTEST_F(CellularDataClientTest, SetDefaultCellularDataSlotId_001, TestSize.Level0)
164 {
165 int32_t result = CellularDataClient::GetInstance().SetDefaultCellularDataSlotId(0);
166 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
167 }
168
169 /**
170 * @tc.number SetDefaultCellularDataSlotId_002
171 * @tc.name test function branch
172 * @tc.desc Function test
173 */
174 HWTEST_F(CellularDataClientTest, SetDefaultCellularDataSlotId_002, TestSize.Level0)
175 {
176 DataAccessToken token;
177 int32_t result = CellularDataClient::GetInstance().SetDefaultCellularDataSlotId(0);
178 EXPECT_NE(result, 0);
179 }
180
181 /**
182 * @tc.number EstablishAllApnsIfConnectable_001
183 * @tc.name test function branch
184 * @tc.desc Function test
185 */
186 HWTEST_F(CellularDataClientTest, EstablishAllApnsIfConnectable_001, TestSize.Level0)
187 {
188 int32_t result = CellularDataClient::GetInstance().EstablishAllApnsIfConnectable(0);
189 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
190 }
191
192 /**
193 * @tc.number ReleaseCellularDataConnection_001
194 * @tc.name test function branch
195 * @tc.desc Function test
196 */
197 HWTEST_F(CellularDataClientTest, ReleaseCellularDataConnection_001, TestSize.Level0)
198 {
199 int32_t result = CellularDataClient::GetInstance().ReleaseCellularDataConnection(0);
200 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
201 }
202
203 /**
204 * @tc.number GetCellularDataSupplierId_001
205 * @tc.name test function branch
206 * @tc.desc Function test
207 */
208 HWTEST_F(CellularDataClientTest, GetCellularDataSupplierId_001, TestSize.Level0)
209 {
210 uint32_t supplierId = 0;
211 int32_t result = CellularDataClient::GetInstance().GetCellularDataSupplierId(0, 0, supplierId);
212 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
213 }
214
215 /**
216 * @tc.number CorrectNetSupplierNoAvailable_001
217 * @tc.name test function branch
218 * @tc.desc Function test
219 */
220 HWTEST_F(CellularDataClientTest, CorrectNetSupplierNoAvailable_001, TestSize.Level0)
221 {
222 int32_t result = CellularDataClient::GetInstance().CorrectNetSupplierNoAvailable(0);
223 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
224 }
225
226 /**
227 * @tc.number GetSupplierRegisterState_001
228 * @tc.name test function branch
229 * @tc.desc Function test
230 */
231 HWTEST_F(CellularDataClientTest, GetSupplierRegisterState_001, TestSize.Level0)
232 {
233 int32_t regState = 0;
234 int32_t result = CellularDataClient::GetInstance().GetSupplierRegisterState(0, regState);
235 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
236 }
237
238 /**
239 * @tc.number OnInitCellularDataController_001
240 * @tc.name test function branch
241 * @tc.desc Function test
242 */
243 HWTEST_F(CellularDataClientTest, OnInitCellularDataController_001, TestSize.Level0)
244 {
245 int32_t result = CellularDataClient::GetInstance().InitCellularDataController(0);
246 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
247 }
248
249 /**
250 * @tc.number GetIfSupportDunApn_001
251 * @tc.name test function branch
252 * @tc.desc Function test
253 */
254 HWTEST_F(CellularDataClientTest, GetIfSupportDunApn_001, TestSize.Level0)
255 {
256 bool isSupportDun = false;
257 int32_t result = CellularDataClient::GetInstance().GetIfSupportDunApn(isSupportDun);
258 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
259 }
260
261 /**
262 * @tc.number GetSupplierRegisterState_001
263 * @tc.name test function branch
264 * @tc.desc Function test
265 */
266 HWTEST_F(CellularDataClientTest, GetDefaultActReportInfo_001, TestSize.Level0)
267 {
268 ApnActivateReportInfo info;
269 int32_t result = CellularDataClient::GetInstance().GetDefaultActReportInfo(0, info);
270 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
271 }
272
273 /**
274 * @tc.number GetSupplierRegisterState_001
275 * @tc.name test function branch
276 * @tc.desc Function test
277 */
278 HWTEST_F(CellularDataClientTest, GetInternalActReportInfo_001, TestSize.Level0)
279 {
280 ApnActivateReportInfo info;
281 int32_t result = CellularDataClient::GetInstance().GetInternalActReportInfo(0, info);
282 EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR);
283 }
284 } // namespace Telephony
285 } // namespace OHOS