1 /*
2 * Copyright (C) 2021 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 <cstdint>
17 #include <string>
18
19 #define private public
20 #include <gtest/gtest.h>
21
22 #include "cellular_data_client.h"
23 #include "cellular_data_controller.h"
24 #include "cellular_data_error.h"
25 #include "cellular_data_net_agent.h"
26 #include "cellular_data_service.h"
27 #include "cellular_data_types.h"
28 #include "core_service_client.h"
29 #include "data_access_token.h"
30 #include "gtest/gtest-message.h"
31 #include "gtest/gtest-test-part.h"
32 #include "gtest/gtest_pred_impl.h"
33 #include "gtest/hwext/gtest-tag.h"
34 #include "hap_token_info.h"
35 #include "i_cellular_data_manager.h"
36 #include "iosfwd"
37 #include "iostream"
38 #include "net_conn_callback_stub.h"
39 #include "net_supplier_callback_base.h"
40 #include "net_conn_client.h"
41 #include "net_handle.h"
42 #include "net_specifier.h"
43 #include "ostream"
44 #include "permission_def.h"
45 #include "permission_state_full.h"
46 #include "refbase.h"
47 #include "telephony_ext_wrapper.h"
48 #include "telephony_types.h"
49 #include "token_setproc.h"
50 #include "unistd.h"
51 #include "apn_item.h"
52 #include "cellular_data_constant.h"
53 #include "common_event_manager.h"
54 #include "common_event_support.h"
55
56 namespace OHOS {
57 namespace Telephony {
58 using namespace testing::ext;
59 using namespace OHOS::NetManagerStandard;
60
61 static const int32_t SLEEP_TIME = 1;
62 static const int32_t SIM_SLOT_ID_1 = DEFAULT_SIM_SLOT_ID + 1;
63 static const int32_t DATA_SLOT_ID_INVALID = DEFAULT_SIM_SLOT_ID + 10;
64 static const int32_t PING_CHECK_SUCCESS = 0;
65 static const int32_t PING_CHECK_FAIL = 1;
66 static const int32_t MAX_TIMES = 60;
67 static const int32_t CMD_BUF_SIZE = 10240;
68 static const int32_t NET_REGISTER_TIMEOUT_MS = 20000;
69 static const int32_t SLEEP_TIME_SECONDS = 3;
70
71 class TestCallback : public NetManagerStandard::NetConnCallbackStub {
NetAvailable(sptr<NetManagerStandard::NetHandle> & netHandle)72 int32_t NetAvailable(sptr<NetManagerStandard::NetHandle> &netHandle) override
73 {
74 isCallback_ = true;
75 std::cout << "TestCallback::NetAvailable" << std::endl;
76 return 0;
77 }
78
NetCapabilitiesChange(sptr<NetManagerStandard::NetHandle> & netHandle,const sptr<NetManagerStandard::NetAllCapabilities> & netAllCap)79 int32_t NetCapabilitiesChange(sptr<NetManagerStandard::NetHandle> &netHandle,
80 const sptr<NetManagerStandard::NetAllCapabilities> &netAllCap) override
81 {
82 isCallback_ = true;
83 std::cout << "TestCallback::NetCapabilitiesChange" << std::endl;
84 return 0;
85 }
86
NetConnectionPropertiesChange(sptr<NetManagerStandard::NetHandle> & netHandle,const sptr<NetManagerStandard::NetLinkInfo> & info)87 int32_t NetConnectionPropertiesChange(
88 sptr<NetManagerStandard::NetHandle> &netHandle, const sptr<NetManagerStandard::NetLinkInfo> &info) override
89 {
90 isCallback_ = true;
91 std::cout << "TestCallback::NetConnectionPropertiesChange" << std::endl;
92 return 0;
93 }
94
NetLost(sptr<NetManagerStandard::NetHandle> & netHandle)95 int32_t NetLost(sptr<NetManagerStandard::NetHandle> &netHandle) override
96 {
97 isCallback_ = true;
98 std::cout << "TestCallback::NetLost" << std::endl;
99 return 0;
100 }
101
NetUnavailable()102 int32_t NetUnavailable() override
103 {
104 isCallback_ = true;
105 std::cout << "TestCallback::NetUnavailable" << std::endl;
106 return 0;
107 }
108
NetBlockStatusChange(sptr<NetManagerStandard::NetHandle> & netHandle,bool blocked)109 int32_t NetBlockStatusChange(sptr<NetManagerStandard::NetHandle> &netHandle, bool blocked) override
110 {
111 isCallback_ = true;
112 std::cout << "TestCallback::NetBlockStatusChange" << std::endl;
113 return 0;
114 }
115
116 public:
117 bool isCallback_ = false;
118 };
119
120 class CellularDataTest : public testing::Test {
121 public:
122 static void SetUpTestCase();
123 static void TearDownTestCase();
124 virtual void SetUp();
125 virtual void TearDown();
126 static bool HasSimCard(const int32_t slotId);
127 static int32_t IsCellularDataEnabledTest(bool &dataEnabled);
128 static int32_t EnableCellularDataTest(bool enable);
129 static int32_t EnableIntelligenceSwitchTest(bool enable);
130 static int32_t GetCellularDataStateTest();
131 static int32_t IsCellularDataRoamingEnabledTest(int32_t slotId, bool &dataRoamingEnabled);
132 static int32_t EnableCellularDataRoamingTest(int32_t slotId, bool enable);
133 static int32_t GetDefaultCellularDataSlotIdTest();
134 static int32_t GetDefaultCellularDataSimIdTest();
135 static int32_t SetDefaultCellularDataSlotIdTest(int32_t slotId);
136 static int32_t GetCellularDataFlowTypeTest();
137 static void WaitTestTimeout(const int32_t status);
138 static sptr<ICellularDataManager> GetProxy();
139 static string GetCmdResult();
140 static int32_t PingTest();
141 static int32_t HasInternetCapability(int32_t slotId, int32_t cid);
142 static int32_t ClearCellularDataConnections(int32_t slotId);
143 static int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason);
144 static int32_t GetApnState(int32_t slotId, const std::string &apnTyp);
145 static int32_t GetDataRecoveryState();
146 static int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr);
147 static int32_t GetDataConnIpType(int32_t slotId, std::string &ipType);
148 static int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery);
149 static int32_t InitCellularDataController(int32_t slotId);
150 static int32_t GetIntelligenceSwitchStateTest(bool &state);
151 static int32_t GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId);
152 static int32_t CorrectNetSupplierNoAvailable(int32_t slotid);
153 static int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t ®State);
154 CellularDataNetAgent &netAgent = CellularDataNetAgent::GetInstance();
155 };
156
HasSimCard(const int32_t slotId)157 bool CellularDataTest::HasSimCard(const int32_t slotId)
158 {
159 bool hasSimCard = false;
160 DelayedRefSingleton<CoreServiceClient>::GetInstance().HasSimCard(slotId, hasSimCard);
161 return hasSimCard;
162 }
163
TearDownTestCase()164 void CellularDataTest::TearDownTestCase()
165 {
166 if (CoreServiceClient::GetInstance().GetProxy() == nullptr) {
167 std::cout << "connect coreService server failed!" << std::endl;
168 return;
169 }
170 DataAccessToken token;
171 int32_t slotId = DATA_SLOT_ID_INVALID;
172 if (HasSimCard(DEFAULT_SIM_SLOT_ID)) {
173 slotId = DEFAULT_SIM_SLOT_ID;
174 } else if (HasSimCard(SIM_SLOT_ID_1)) {
175 slotId = SIM_SLOT_ID_1;
176 }
177 if (slotId == DATA_SLOT_ID_INVALID) {
178 return;
179 }
180 // Set the default slot
181 int32_t result = CellularDataClient::GetInstance().SetDefaultCellularDataSlotId(slotId);
182 if (result != TELEPHONY_ERR_SUCCESS) {
183 return;
184 }
185 int32_t enable = CellularDataClient::GetInstance().EnableCellularData(true);
186 ASSERT_TRUE(enable == TELEPHONY_ERR_SUCCESS);
187 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
188 sleep(SLEEP_TIME_SECONDS);
189 }
190
SetUp()191 void CellularDataTest::SetUp() {}
192
TearDown()193 void CellularDataTest::TearDown() {}
194
SetUpTestCase()195 void CellularDataTest::SetUpTestCase()
196 {
197 if (CoreServiceClient::GetInstance().GetProxy() == nullptr) {
198 std::cout << "connect coreService server failed!" << std::endl;
199 return;
200 }
201 DataAccessToken token;
202 int32_t slotId = DATA_SLOT_ID_INVALID;
203 if (HasSimCard(DEFAULT_SIM_SLOT_ID)) {
204 slotId = DEFAULT_SIM_SLOT_ID;
205 } else if (HasSimCard(SIM_SLOT_ID_1)) {
206 slotId = SIM_SLOT_ID_1;
207 }
208 if (slotId == DATA_SLOT_ID_INVALID) {
209 return;
210 }
211 // Set the default slot
212 int32_t result = CellularDataClient::GetInstance().SetDefaultCellularDataSlotId(slotId);
213 if (result != TELEPHONY_ERR_SUCCESS) {
214 return;
215 }
216 int32_t enable = CellularDataClient::GetInstance().EnableCellularData(true);
217 ASSERT_TRUE(enable == TELEPHONY_ERR_SUCCESS);
218 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
219 }
220
WaitTestTimeout(const int32_t status)221 void CellularDataTest::WaitTestTimeout(const int32_t status)
222 {
223 int32_t count = 0;
224 while (count < MAX_TIMES) {
225 sleep(SLEEP_TIME);
226 if (CellularDataClient::GetInstance().GetCellularDataState() == status) {
227 return;
228 }
229 count++;
230 }
231 }
232
GetCmdResult()233 string CellularDataTest::GetCmdResult()
234 {
235 string strCmd = "ping -c3 www.openharmony.cn";
236 char buf[CMD_BUF_SIZE] = { 0 };
237 FILE *pf;
238
239 if ((pf = popen(strCmd.c_str(), "r")) == nullptr) {
240 return "";
241 }
242 string strResult;
243 while (fgets(buf, sizeof(buf), pf) != nullptr) {
244 strResult += buf;
245 }
246 pclose(pf);
247 unsigned int iSize = strResult.size();
248 if (iSize > 0 && strResult[iSize - 1] == '\n') {
249 strResult = strResult.substr(0, iSize - 1);
250 }
251 return strResult;
252 }
253
PingTest()254 int32_t CellularDataTest::PingTest()
255 {
256 string strRe = GetCmdResult();
257 std::cout << strRe << std::endl;
258
259 // if ping succeed, the result should contains something like:
260 // 3 packets transmitted, 3 received, 0% packet loss, time 5440ms
261 if (strRe.find("3 packets") != string::npos) {
262 return PING_CHECK_SUCCESS;
263 } else {
264 return PING_CHECK_FAIL;
265 }
266 }
267
IsCellularDataRoamingEnabledTest(int32_t slotId,bool & dataRoamingEnabled)268 int32_t CellularDataTest::IsCellularDataRoamingEnabledTest(int32_t slotId, bool &dataRoamingEnabled)
269 {
270 return CellularDataClient::GetInstance().IsCellularDataRoamingEnabled(slotId, dataRoamingEnabled);
271 }
272
IsCellularDataEnabledTest(bool & dataEnabled)273 int32_t CellularDataTest::IsCellularDataEnabledTest(bool &dataEnabled)
274 {
275 return CellularDataClient::GetInstance().IsCellularDataEnabled(dataEnabled);
276 }
277
EnableCellularDataTest(bool enable)278 int32_t CellularDataTest::EnableCellularDataTest(bool enable)
279 {
280 return CellularDataClient::GetInstance().EnableCellularData(enable);
281 }
282
EnableIntelligenceSwitchTest(bool enable)283 int32_t CellularDataTest::EnableIntelligenceSwitchTest(bool enable)
284 {
285 return CellularDataClient::GetInstance().EnableIntelligenceSwitch(enable);
286 }
287
GetCellularDataStateTest()288 int32_t CellularDataTest::GetCellularDataStateTest()
289 {
290 return CellularDataClient::GetInstance().GetCellularDataState();
291 }
292
GetIntelligenceSwitchStateTest(bool & state)293 int32_t CellularDataTest::GetIntelligenceSwitchStateTest(bool &state)
294 {
295 return CellularDataClient::GetInstance().GetIntelligenceSwitchState(state);
296 }
297
EnableCellularDataRoamingTest(int32_t slotId,bool enable)298 int32_t CellularDataTest::EnableCellularDataRoamingTest(int32_t slotId, bool enable)
299 {
300 return CellularDataClient::GetInstance().EnableCellularDataRoaming(slotId, enable);
301 }
302
GetDefaultCellularDataSlotIdTest()303 int32_t CellularDataTest::GetDefaultCellularDataSlotIdTest()
304 {
305 return CellularDataClient::GetInstance().GetDefaultCellularDataSlotId();
306 }
307
GetDefaultCellularDataSimIdTest()308 int32_t CellularDataTest::GetDefaultCellularDataSimIdTest()
309 {
310 int32_t simId = 0;
311 return CellularDataClient::GetInstance().GetDefaultCellularDataSimId(simId);
312 }
313
SetDefaultCellularDataSlotIdTest(int32_t slotId)314 int32_t CellularDataTest::SetDefaultCellularDataSlotIdTest(int32_t slotId)
315 {
316 return CellularDataClient::GetInstance().SetDefaultCellularDataSlotId(slotId);
317 }
318
GetCellularDataFlowTypeTest()319 int32_t CellularDataTest::GetCellularDataFlowTypeTest()
320 {
321 return CellularDataClient::GetInstance().GetCellularDataFlowType();
322 }
323
HasInternetCapability(int32_t slotId,int32_t cid)324 int32_t CellularDataTest::HasInternetCapability(int32_t slotId, int32_t cid)
325 {
326 CellularDataClient::GetInstance().IsConnect();
327 return CellularDataClient::GetInstance().HasInternetCapability(slotId, cid);
328 }
329
ClearCellularDataConnections(int32_t slotId)330 int32_t CellularDataTest::ClearCellularDataConnections(int32_t slotId)
331 {
332 CellularDataClient::GetInstance().IsConnect();
333 return CellularDataClient::GetInstance().ClearCellularDataConnections(slotId);
334 }
335
ClearAllConnections(int32_t slotId,DisConnectionReason reason)336 int32_t CellularDataTest::ClearAllConnections(int32_t slotId, DisConnectionReason reason)
337 {
338 return CellularDataClient::GetInstance().ClearAllConnections(slotId, reason);
339 }
340
GetApnState(int32_t slotId,const std::string & apnTyp)341 int32_t CellularDataTest::GetApnState(int32_t slotId, const std::string &apnTyp)
342 {
343 return CellularDataClient::GetInstance().GetApnState(slotId, apnTyp);
344 }
345
GetDataRecoveryState()346 int32_t CellularDataTest::GetDataRecoveryState()
347 {
348 return CellularDataClient::GetInstance().GetDataRecoveryState();
349 }
350
GetDataConnApnAttr(int32_t slotId,ApnItem::Attribute & apnAttr)351 int32_t CellularDataTest::GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr)
352 {
353 return CellularDataClient::GetInstance().GetDataConnApnAttr(slotId, apnAttr);
354 }
355
GetDataConnIpType(int32_t slotId,std::string & ipType)356 int32_t CellularDataTest::GetDataConnIpType(int32_t slotId, std::string &ipType)
357 {
358 return CellularDataClient::GetInstance().GetDataConnIpType(slotId, ipType);
359 }
360
IsNeedDoRecovery(int32_t slotId,bool needDoRecovery)361 int32_t CellularDataTest::IsNeedDoRecovery(int32_t slotId, bool needDoRecovery)
362 {
363 return CellularDataClient::GetInstance().IsNeedDoRecovery(slotId, needDoRecovery);
364 }
365
InitCellularDataController(int32_t slotId)366 int32_t CellularDataTest::InitCellularDataController(int32_t slotId)
367 {
368 return CellularDataClient::GetInstance().InitCellularDataController(slotId);
369 }
370
GetCellularDataSupplierId(int32_t slotId,uint64_t capability,uint32_t & supplierId)371 int32_t CellularDataTest::GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId)
372 {
373 return CellularDataClient::GetInstance().GetCellularDataSupplierId(slotId, capability, supplierId);
374 }
375
CorrectNetSupplierNoAvailable(int32_t slotId)376 int32_t CellularDataTest::CorrectNetSupplierNoAvailable(int32_t slotId)
377 {
378 return CellularDataClient::GetInstance().CorrectNetSupplierNoAvailable(slotId);
379 }
380
GetSupplierRegisterState(uint32_t supplierId,int32_t & regState)381 int32_t CellularDataTest::GetSupplierRegisterState(uint32_t supplierId, int32_t ®State)
382 {
383 return CellularDataClient::GetInstance().GetSupplierRegisterState(supplierId, regState);
384 }
385 #ifndef TEL_TEST_UNSUPPORT
386 /**
387 * @tc.number IsCellularDataEnabled_Test
388 * @tc.name Test cellular data switch status(enabled or disabled)
389 * @tc.desc Function test
390 */
391 HWTEST_F(CellularDataTest, IsCellularDataEnabled_Test, TestSize.Level1)
392 {
393 DataAccessToken token;
394 bool dataEnabled = false;
395 CellularDataTest::IsCellularDataEnabledTest(dataEnabled);
396 ASSERT_TRUE(dataEnabled >= static_cast<int32_t>(DataSwitchCode::CELLULAR_DATA_DISABLED));
397 }
398
399 /**
400 * @tc.number DefaultCellularDataSlotId_Test
401 * @tc.name Test set default data card slot
402 * @tc.desc Function test
403 */
404 HWTEST_F(CellularDataTest, DefaultCellularDataSlotId_Test, TestSize.Level2)
405 {
406 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
407 return;
408 }
409 DataAccessToken token;
410 int32_t result = CellularDataTest::GetDefaultCellularDataSlotIdTest();
411 if (result < DEFAULT_SIM_SLOT_ID_REMOVE) {
412 return;
413 }
414 result = CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
415 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
416 // Multiple cards will need to be optimized again
417 result = CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID - 1);
418 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
419 result = CellularDataTest::SetDefaultCellularDataSlotIdTest(DATA_SLOT_ID_INVALID);
420 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
421 }
422
423 /**
424 * @tc.number GetDefaultCellularDataSimId
425 * @tc.name Test get default data sim id
426 * @tc.desc Function test
427 */
428 HWTEST_F(CellularDataTest, DefaultCellularDataSimId_Test, TestSize.Level2)
429 {
430 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
431 return;
432 }
433 int32_t result = CellularDataTest::GetDefaultCellularDataSimIdTest();
434 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
435 }
436
437 /**
438 * @tc.number DefaultCellularDataSlotId_Test_01
439 * @tc.name Test set default data card slot
440 * @tc.desc Function test
441 */
442 HWTEST_F(CellularDataTest, DefaultCellularDataSlotId_Test_01, TestSize.Level2)
443 {
444 if (!HasSimCard(SIM_SLOT_ID_1)) {
445 return;
446 }
447 DataAccessToken token;
448 int32_t result = CellularDataTest::GetDefaultCellularDataSlotIdTest();
449 if (result < DEFAULT_SIM_SLOT_ID_REMOVE) {
450 return;
451 }
452 result = CellularDataTest::SetDefaultCellularDataSlotIdTest(SIM_SLOT_ID_1);
453 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
454 result = CellularDataTest::SetDefaultCellularDataSlotIdTest(DATA_SLOT_ID_INVALID);
455 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
456 }
457
458 /**
459 * @tc.number EnableCellularData_Test_01
460 * @tc.name Test cellular data switch
461 * @tc.desc Function test
462 */
463 HWTEST_F(CellularDataTest, EnableCellularData_Test_01, TestSize.Level2)
464 {
465 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
466 return;
467 }
468 DataAccessToken token;
469 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
470 CellularDataTest::EnableCellularDataTest(false);
471 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
472 sleep(SLEEP_TIME);
473 int32_t result = CellularDataTest::EnableCellularDataTest(true);
474 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
475 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
476 sleep(SLEEP_TIME);
477 std::cout << "Cellular Data Connected Ping..." << std::endl;
478 int32_t pingResult = CellularDataTest::PingTest();
479 ASSERT_TRUE(pingResult >= PING_CHECK_SUCCESS);
480 CellularDataTest::EnableCellularDataTest(false);
481 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
482 sleep(SLEEP_TIME);
483 std::cout << "Cellular Data Disconnected Ping..." << std::endl;
484 pingResult = CellularDataTest::PingTest();
485 ASSERT_TRUE(pingResult == PING_CHECK_FAIL);
486 }
487
488 /**
489 * @tc.number EnableCellularData_Test_02
490 * @tc.name Test cellular data switch
491 * @tc.desc Function test
492 */
493 HWTEST_F(CellularDataTest, EnableCellularData_Test_02, TestSize.Level2)
494 {
495 if (!HasSimCard(SIM_SLOT_ID_1)) {
496 return;
497 }
498 DataAccessToken token;
499 CellularDataTest::SetDefaultCellularDataSlotIdTest(SIM_SLOT_ID_1);
500 CellularDataTest::EnableCellularDataTest(false);
501 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
502 sleep(SLEEP_TIME);
503 int32_t result = CellularDataTest::EnableCellularDataTest(true);
504 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
505 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
506 sleep(SLEEP_TIME);
507 std::cout << "Cellular Data Connected Ping..." << std::endl;
508 int32_t pingResult = CellularDataTest::PingTest();
509 ASSERT_TRUE(pingResult >= PING_CHECK_SUCCESS);
510 CellularDataTest::EnableCellularDataTest(false);
511 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
512 sleep(SLEEP_TIME);
513 std::cout << "Cellular Data Disconnected Ping..." << std::endl;
514 pingResult = CellularDataTest::PingTest();
515 ASSERT_TRUE(pingResult == PING_CHECK_FAIL);
516 }
517
518 /**
519 * @tc.number DataRoamingState_ValidSlot_Test_01
520 * @tc.name Test the cellular data roaming switch with a slot id
521 * @tc.desc Function test
522 */
523 HWTEST_F(CellularDataTest, DataRoamingState_ValidSlot_Test_01, TestSize.Level3)
524 {
525 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
526 return;
527 }
528 DataAccessToken token;
529 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
530 int32_t disabled = CellularDataTest::EnableCellularDataTest(false);
531 ASSERT_TRUE(disabled == TELEPHONY_ERR_SUCCESS);
532 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
533
534 // slot0 enable data roaming
535 int32_t enabled = CellularDataTest::EnableCellularDataRoamingTest(DEFAULT_SIM_SLOT_ID, true);
536 ASSERT_TRUE(enabled != TELEPHONY_ERR_SUCCESS);
537 bool dataRoamingEnabled = false;
538 CellularDataTest::IsCellularDataRoamingEnabledTest(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled);
539 ASSERT_FALSE(dataRoamingEnabled);
540 }
541
542 /**
543 * @tc.number DataRoamingState_ValidSlot_Test_02
544 * @tc.name Test the cellular data roaming switch with a slot id
545 * @tc.desc Function test
546 */
547 HWTEST_F(CellularDataTest, DataRoamingState_ValidSlot_Test_02, TestSize.Level3)
548 {
549 if (!HasSimCard(SIM_SLOT_ID_1)) {
550 return;
551 }
552 DataAccessToken token;
553 CellularDataTest::SetDefaultCellularDataSlotIdTest(SIM_SLOT_ID_1);
554 int32_t disabled = CellularDataTest::EnableCellularDataTest(false);
555 ASSERT_TRUE(disabled == TELEPHONY_ERR_SUCCESS);
556 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
557
558 // slot1 enable data roaming
559 int32_t enabled = CellularDataTest::EnableCellularDataRoamingTest(SIM_SLOT_ID_1, true);
560 ASSERT_TRUE(enabled == TELEPHONY_ERR_SUCCESS);
561 bool dataRoamingEnabled = false;
562 CellularDataTest::IsCellularDataRoamingEnabledTest(SIM_SLOT_ID_1, dataRoamingEnabled);
563 ASSERT_TRUE(dataRoamingEnabled);
564 // slot1 close
565 int32_t enable = CellularDataTest::EnableCellularDataRoamingTest(SIM_SLOT_ID_1, false);
566 ASSERT_TRUE(enable == TELEPHONY_ERR_SUCCESS);
567 CellularDataTest::IsCellularDataRoamingEnabledTest(SIM_SLOT_ID_1, dataRoamingEnabled);
568 ASSERT_TRUE(!dataRoamingEnabled);
569
570 // At present, multiple card problems, the subsequent need to continue to deal with
571 enable = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, true);
572 ASSERT_TRUE(enable != TELEPHONY_ERR_SUCCESS);
573 int32_t result = CellularDataTest::IsCellularDataRoamingEnabledTest(DATA_SLOT_ID_INVALID, dataRoamingEnabled);
574 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
575 enable = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, false);
576 // At present, multiple card problems, the subsequent need to continue to deal with
577 ASSERT_TRUE(enable != TELEPHONY_ERR_SUCCESS);
578 result = CellularDataTest::IsCellularDataRoamingEnabledTest(DATA_SLOT_ID_INVALID, dataRoamingEnabled);
579 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
580 }
581
582 /**
583 * @tc.number EnableCellularDataRoaming_ValidSlot_Test_01
584 * @tc.name Test the cellular data roaming switch with a slot id
585 * @tc.desc Function test
586 */
587 HWTEST_F(CellularDataTest, EnableCellularDataRoaming_ValidSlot_Test_01, TestSize.Level3)
588 {
589 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
590 return;
591 }
592 DataAccessToken token;
593 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
594 int32_t disabled = CellularDataTest::EnableCellularDataTest(false);
595 ASSERT_TRUE(disabled == TELEPHONY_ERR_SUCCESS);
596 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
597
598 bool dataRoamingEnabled = false;
599 CellularDataTest::IsCellularDataRoamingEnabledTest(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled);
600 if (dataRoamingEnabled) {
601 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(DEFAULT_SIM_SLOT_ID, false);
602 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
603 } else {
604 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(DEFAULT_SIM_SLOT_ID, true);
605 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
606 }
607 // At present, multiple card problems, the subsequent need to continue to deal with
608 CellularDataTest::IsCellularDataRoamingEnabledTest(DEFAULT_SIM_SLOT_ID, dataRoamingEnabled);
609 if (dataRoamingEnabled) {
610 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, false);
611 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
612 } else {
613 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, true);
614 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
615 }
616 }
617
618 /**
619 * @tc.number EnableCellularDataRoaming_ValidSlot_Test_02
620 * @tc.name Test the cellular data roaming switch with a slot id
621 * @tc.desc Function test
622 */
623 HWTEST_F(CellularDataTest, EnableCellularDataRoaming_ValidSlot_Test_02, TestSize.Level3)
624 {
625 if (!HasSimCard(SIM_SLOT_ID_1)) {
626 return;
627 }
628 DataAccessToken token;
629 CellularDataTest::SetDefaultCellularDataSlotIdTest(SIM_SLOT_ID_1);
630 int32_t disabled = CellularDataTest::EnableCellularDataTest(false);
631 ASSERT_TRUE(disabled == TELEPHONY_ERR_SUCCESS);
632 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
633
634 bool dataRoamingEnabled = false;
635 CellularDataTest::IsCellularDataRoamingEnabledTest(SIM_SLOT_ID_1, dataRoamingEnabled);
636 if (dataRoamingEnabled) {
637 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(SIM_SLOT_ID_1, false);
638 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
639 } else {
640 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(SIM_SLOT_ID_1, true);
641 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
642 }
643 // At present, multiple card problems, the subsequent need to continue to deal with
644 CellularDataTest::IsCellularDataRoamingEnabledTest(SIM_SLOT_ID_1, dataRoamingEnabled);
645 if (dataRoamingEnabled) {
646 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, false);
647 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
648 } else {
649 int32_t result = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, true);
650 ASSERT_TRUE(result != TELEPHONY_ERR_SUCCESS);
651 }
652 }
653
654 /**
655 * @tc.number GetCellularDataState_ValidityTest_01
656 * @tc.name Test the GetCellularDataState function
657 * @tc.desc Function test
658 */
659 HWTEST_F(CellularDataTest, GetCellularDataState_ValidityTest_01, TestSize.Level3)
660 {
661 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
662 return;
663 }
664 DataAccessToken token;
665 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
666 bool dataEnabled = false;
667 CellularDataTest::IsCellularDataEnabledTest(dataEnabled);
668 if (dataEnabled) {
669 CellularDataTest::EnableCellularDataTest(false);
670 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
671 sleep(SLEEP_TIME);
672 CellularDataTest::EnableCellularDataTest(true);
673 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
674 int32_t result = CellularDataTest::GetCellularDataStateTest();
675 ASSERT_TRUE(result == static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
676 } else {
677 CellularDataTest::EnableCellularDataTest(true);
678 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
679 sleep(SLEEP_TIME);
680 CellularDataTest::EnableCellularDataTest(false);
681 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
682 int32_t result = CellularDataTest::GetCellularDataStateTest();
683 ASSERT_TRUE(result == static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
684 }
685 CellularDataTest::EnableCellularDataTest(false);
686 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
687 }
688
689 /**
690 * @tc.number GetCellularDataState_ValidityTest_02
691 * @tc.name Test the GetCellularDataState function
692 * @tc.desc Function test
693 */
694 HWTEST_F(CellularDataTest, GetCellularDataState_ValidityTest_02, TestSize.Level3)
695 {
696 if (!HasSimCard(SIM_SLOT_ID_1)) {
697 return;
698 }
699 DataAccessToken token;
700 CellularDataTest::SetDefaultCellularDataSlotIdTest(SIM_SLOT_ID_1);
701 bool dataEnabled = false;
702 CellularDataTest::IsCellularDataEnabledTest(dataEnabled);
703 if (dataEnabled) {
704 CellularDataTest::EnableCellularDataTest(false);
705 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
706 sleep(SLEEP_TIME);
707 CellularDataTest::EnableCellularDataTest(true);
708 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
709 int32_t result = CellularDataTest::GetCellularDataStateTest();
710 ASSERT_TRUE(result == static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
711 } else {
712 CellularDataTest::EnableCellularDataTest(true);
713 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
714 sleep(SLEEP_TIME);
715 CellularDataTest::EnableCellularDataTest(false);
716 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
717 int32_t result = CellularDataTest::GetCellularDataStateTest();
718 ASSERT_TRUE(result == static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
719 }
720 CellularDataTest::EnableCellularDataTest(false);
721 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
722 }
723
724 /**
725 * @tc.number DataRoamingState_InValidSlot_Test_01
726 * @tc.name Test the EnableCellularDataRoaming function with a invalid slot id
727 * @tc.desc Function test
728 */
729 HWTEST_F(CellularDataTest, DataRoamingState_InValidSlot_Test_01, TestSize.Level3)
730 {
731 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
732 return;
733 }
734 DataAccessToken token;
735 // invalid slot turn on data roaming
736 int32_t enable = CellularDataTest::EnableCellularDataRoamingTest(DEFAULT_SIM_SLOT_ID - 1, true);
737 ASSERT_TRUE(enable != TELEPHONY_ERR_SUCCESS);
738 bool dataRoamingEnabled = false;
739 int32_t result = CellularDataTest::IsCellularDataRoamingEnabledTest(DEFAULT_SIM_SLOT_ID - 1, dataRoamingEnabled);
740 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
741 enable = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, true);
742 ASSERT_TRUE(enable != TELEPHONY_ERR_SUCCESS);
743 result = CellularDataTest::IsCellularDataRoamingEnabledTest(DATA_SLOT_ID_INVALID, dataRoamingEnabled);
744 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
745 // invalid slot disable roaming
746 enable = CellularDataTest::EnableCellularDataRoamingTest(DEFAULT_SIM_SLOT_ID - 1, false);
747 ASSERT_TRUE(enable != TELEPHONY_ERR_SUCCESS);
748 result = CellularDataTest::IsCellularDataRoamingEnabledTest(DEFAULT_SIM_SLOT_ID - 1, dataRoamingEnabled);
749 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
750 enable = CellularDataTest::EnableCellularDataRoamingTest(DATA_SLOT_ID_INVALID, false);
751 ASSERT_TRUE(enable != TELEPHONY_ERR_SUCCESS);
752 result = CellularDataTest::IsCellularDataRoamingEnabledTest(DATA_SLOT_ID_INVALID, dataRoamingEnabled);
753 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
754 }
755
756 /**
757 * @tc.number DataFlowType_Test_01
758 * @tc.name Test the GetCellularDataFlowType function
759 * @tc.desc Function test
760 */
761 HWTEST_F(CellularDataTest, DataFlowType_Test_01, TestSize.Level3)
762 {
763 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
764 return;
765 }
766 DataAccessToken token;
767 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
768 CellularDataTest::EnableCellularDataTest(false);
769 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
770 sleep(SLEEP_TIME);
771
772 CellularDataTest::EnableCellularDataTest(true);
773 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
774 sleep(SLEEP_TIME);
775 std::cout << "Cellular Data Connected Ping..." << std::endl;
776 int32_t pingResult = CellularDataTest::PingTest();
777 ASSERT_TRUE(pingResult >= PING_CHECK_SUCCESS);
778 int32_t dataFlowType = CellularDataTest::GetCellularDataFlowTypeTest();
779 ASSERT_TRUE(dataFlowType >= 0);
780
781 CellularDataTest::EnableCellularDataTest(false);
782 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
783 sleep(SLEEP_TIME);
784 std::cout << "Cellular Data Disconnected Ping..." << std::endl;
785 pingResult = CellularDataTest::PingTest();
786 ASSERT_TRUE(pingResult == PING_CHECK_FAIL);
787 dataFlowType = CellularDataTest::GetCellularDataFlowTypeTest();
788 ASSERT_TRUE(dataFlowType == 0);
789 }
790
791 /**
792 * @tc.number DataFlowType_Test_02
793 * @tc.name Test the GetCellularDataFlowType function
794 * @tc.desc Function test
795 */
796 HWTEST_F(CellularDataTest, DataFlowType_Test_02, TestSize.Level3)
797 {
798 if (!HasSimCard(SIM_SLOT_ID_1)) {
799 return;
800 }
801 DataAccessToken token;
802 CellularDataTest::SetDefaultCellularDataSlotIdTest(SIM_SLOT_ID_1);
803 CellularDataTest::EnableCellularDataTest(false);
804 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
805 sleep(SLEEP_TIME);
806
807 CellularDataTest::EnableCellularDataTest(true);
808 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED));
809 sleep(SLEEP_TIME);
810 std::cout << "Cellular Data Connected Ping..." << std::endl;
811 int32_t pingResult = CellularDataTest::PingTest();
812 ASSERT_TRUE(pingResult >= PING_CHECK_SUCCESS);
813 int32_t dataFlowType = CellularDataTest::GetCellularDataFlowTypeTest();
814 ASSERT_TRUE(dataFlowType >= 0);
815
816 CellularDataTest::EnableCellularDataTest(false);
817 WaitTestTimeout(static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED));
818 sleep(SLEEP_TIME);
819 std::cout << "Cellular Data Disconnected Ping..." << std::endl;
820 pingResult = CellularDataTest::PingTest();
821 ASSERT_TRUE(pingResult == PING_CHECK_FAIL);
822 dataFlowType = CellularDataTest::GetCellularDataFlowTypeTest();
823 ASSERT_TRUE(dataFlowType == 0);
824 }
825
826 /**
827 * @tc.number MmsApn_Test_01
828 * @tc.name Test the Mms apn function
829 * @tc.desc Function test
830 */
831 HWTEST_F(CellularDataTest, MmsApn_Test_01, TestSize.Level3)
832 {
833 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
834 return;
835 }
836 DataAccessToken token;
837 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
838 if (callback == nullptr) {
839 std::cout << "callback is null" << std::endl;
840 return;
841 }
842 NetSpecifier netSpecifier;
843 NetAllCapabilities netAllCapabilities;
844 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_MMS);
845 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
846 int32_t simId = CoreServiceClient::GetInstance().GetSimId(DEFAULT_SIM_SLOT_ID);
847 netSpecifier.ident_ = "simId" + std::to_string(simId);
848 netSpecifier.netCapabilities_ = netAllCapabilities;
849 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
850 if (specifier == nullptr) {
851 std::cout << "specifier is null" << std::endl;
852 return;
853 }
854 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
855 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
856 auto mmsCallback = static_cast<TestCallback *>(callback.GetRefPtr());
857 if (mmsCallback == nullptr) {
858 std::cout << "mmsCallback is null" << std::endl;
859 return;
860 }
861 int32_t count = 0;
862 while (count < MAX_TIMES) {
863 sleep(SLEEP_TIME);
864 if (mmsCallback->isCallback_ == true) {
865 break;
866 }
867 count++;
868 }
869 ASSERT_TRUE(mmsCallback->isCallback_);
870 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
871 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
872 }
873
874 /**
875 * @tc.number MmsApn_Test_02
876 * @tc.name Test the Mms apn function
877 * @tc.desc Function test
878 */
879 HWTEST_F(CellularDataTest, MmsApn_Test_02, TestSize.Level3)
880 {
881 if (!HasSimCard(SIM_SLOT_ID_1)) {
882 return;
883 }
884 DataAccessToken token;
885 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
886 if (callback == nullptr) {
887 std::cout << "callback is null" << std::endl;
888 return;
889 }
890 NetSpecifier netSpecifier;
891 NetAllCapabilities netAllCapabilities;
892 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_MMS);
893 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
894 int32_t simId = CoreServiceClient::GetInstance().GetSimId(SIM_SLOT_ID_1);
895 netSpecifier.ident_ = "simId" + std::to_string(simId);
896 netSpecifier.netCapabilities_ = netAllCapabilities;
897 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
898 if (specifier == nullptr) {
899 std::cout << "specifier is null" << std::endl;
900 return;
901 }
902 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
903 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
904 auto mmsCallback = static_cast<TestCallback *>(callback.GetRefPtr());
905 if (mmsCallback == nullptr) {
906 std::cout << "mmsCallback is null" << std::endl;
907 return;
908 }
909 int32_t count = 0;
910 while (count < MAX_TIMES) {
911 sleep(SLEEP_TIME);
912 if (mmsCallback->isCallback_ == true) {
913 break;
914 }
915 count++;
916 }
917 ASSERT_TRUE(mmsCallback->isCallback_);
918 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
919 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
920 }
921
922 /**
923 * @tc.number HasInternetCapability_Test_01
924 * @tc.name Test the HasInternetCapability function
925 * @tc.desc Function test
926 */
927 HWTEST_F(CellularDataTest, HasInternetCapability_Test_01, TestSize.Level3)
928 {
929 if (!HasSimCard(SIM_SLOT_ID_1)) {
930 return;
931 }
932
933 int32_t cid = 1;
934 int32_t result = CellularDataTest::HasInternetCapability(SIM_SLOT_ID_1, cid);
935 ASSERT_TRUE(result == static_cast<int32_t>(RequestNetCode::REQUEST_FAILED));
936 }
937
938 /**
939 * @tc.number HasInternetCapability_Test_02
940 * @tc.name Test the HasInternetCapability function
941 * @tc.desc Function test
942 */
943 HWTEST_F(CellularDataTest, HasInternetCapability_Test_02, TestSize.Level3)
944 {
945 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
946 return;
947 }
948
949 int32_t cid = 1;
950 int32_t result = CellularDataTest::HasInternetCapability(DEFAULT_SIM_SLOT_ID, cid);
951 ASSERT_TRUE(result == static_cast<int32_t>(RequestNetCode::REQUEST_FAILED));
952 }
953
954 /**
955 * @tc.number ClearCellularDataConnections_Test_01
956 * @tc.name Test the ClearCellularDataConnections function
957 * @tc.desc Function test
958 */
959 HWTEST_F(CellularDataTest, ClearCellularDataConnections_Test_01, TestSize.Level3)
960 {
961 if (!HasSimCard(SIM_SLOT_ID_1)) {
962 return;
963 }
964 DataAccessToken token;
965 int32_t result = CellularDataTest::ClearCellularDataConnections(SIM_SLOT_ID_1);
966 ASSERT_TRUE(result == static_cast<int32_t>(RequestNetCode::REQUEST_SUCCESS));
967 }
968
969 /**
970 * @tc.number ClearCellularDataConnections_Test_02
971 * @tc.name Test the ClearCellularDataConnections function
972 * @tc.desc Function test
973 */
974 HWTEST_F(CellularDataTest, ClearCellularDataConnections_Test_02, TestSize.Level3)
975 {
976 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
977 return;
978 }
979 DataAccessToken token;
980 int32_t result = CellularDataTest::ClearCellularDataConnections(DEFAULT_SIM_SLOT_ID);
981 ASSERT_TRUE(result == static_cast<int32_t>(RequestNetCode::REQUEST_SUCCESS));
982 }
983
984 /**
985 * @tc.number ClearAllConnections
986 * @tc.name Test the ClearAllConnections function
987 * @tc.desc Function test
988 */
989 HWTEST_F(CellularDataTest, ClearAllConnections_Test_01, TestSize.Level3)
990 {
991 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
992 return;
993 }
994 DataAccessToken token;
995 int32_t result = CellularDataTest::ClearAllConnections(
996 DEFAULT_SIM_SLOT_ID, DisConnectionReason::REASON_RETRY_CONNECTION);
997 ASSERT_TRUE(result == static_cast<int32_t>(RequestNetCode::REQUEST_SUCCESS));
998 }
999
1000 /**
1001 * @tc.number GetApnState
1002 * @tc.name Test the GetApnState function
1003 * @tc.desc Function test
1004 */
1005 HWTEST_F(CellularDataTest, GetApnState_Test_01, TestSize.Level3)
1006 {
1007 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1008 return;
1009 }
1010 DataAccessToken token;
1011 int32_t result = CellularDataTest::GetApnState(DEFAULT_SIM_SLOT_ID, "default");
1012 ASSERT_TRUE(result >= 0 && result <= 5);
1013 }
1014
1015 /**
1016 * @tc.number GetDataRecoveryState
1017 * @tc.name Test the GetDataRecoveryState function
1018 * @tc.desc Function test
1019 */
1020 HWTEST_F(CellularDataTest, GetDataRecoveryState_Test_01, TestSize.Level3)
1021 {
1022 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1023 return;
1024 }
1025 DataAccessToken token;
1026 int32_t result = CellularDataTest::GetDataRecoveryState();
1027 ASSERT_TRUE(result >= 0 && result <= 3);
1028 }
1029
1030 /**
1031 * @tc.number CellularDataDump_Test_01
1032 * @tc.name TestDump
1033 * @tc.desc Function test
1034 */
1035 HWTEST_F(CellularDataTest, CellularDataDump_Test_01, Function | MediumTest | Level3)
1036 {
1037 std::vector<std::u16string> emptyArgs = {};
1038 std::vector<std::u16string> args = { u"test", u"test1" };
1039 EXPECT_GE(DelayedSingleton<CellularDataService>::GetInstance()->Dump(-1, args), 0);
1040 EXPECT_GE(DelayedSingleton<CellularDataService>::GetInstance()->Dump(0, emptyArgs), 0);
1041 EXPECT_GE(DelayedSingleton<CellularDataService>::GetInstance()->Dump(0, args), 0);
1042 }
1043
1044 /**
1045 * @tc.number Telephony_Cellulardata_InitTelephonyExtService_0100
1046 * @tc.name Init Telephony Ext Service.
1047 * @tc.desc Function test
1048 */
1049 HWTEST_F(CellularDataTest, Telephony_Cellulardata_InitTelephonyExtService_0100, Function | MediumTest | Level1)
1050 {
1051 DataAccessToken token;
1052 TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapper();
1053 if (TELEPHONY_EXT_WRAPPER.telephonyExtWrapperHandle_ == nullptr) {
1054 TELEPHONY_LOGI("telephonyExtWrapperHandle_ null");
1055 } else {
1056 TELEPHONY_LOGI("telephonyExtWrapperHandle_ not null");
1057 EXPECT_EQ(TELEPHONY_EXT_WRAPPER.dataEndSelfCure_ != nullptr, true);
1058 }
1059 }
1060
1061 /**
1062 * @tc.number GetDataConnApnAttr_Test_01
1063 * @tc.name Test the GetDataConnApnAttr function
1064 * @tc.desc Function test
1065 */
1066 HWTEST_F(CellularDataTest, GetDataConnApnAttr_Test_01, TestSize.Level3)
1067 {
1068 if (!HasSimCard(SIM_SLOT_ID_1)) {
1069 return;
1070 }
1071 DataAccessToken token;
1072 ApnItem::Attribute apnAttr;
1073 int32_t result = CellularDataTest::GetDataConnApnAttr(SIM_SLOT_ID_1, apnAttr);
1074 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1075 }
1076
1077 /**
1078 * @tc.number GetDataConnApnAttr_Test_02
1079 * @tc.name Test the GetDataConnApnAttr function
1080 * @tc.desc Function test
1081 */
1082 HWTEST_F(CellularDataTest, GetDataConnApnAttr_Test_02, TestSize.Level3)
1083 {
1084 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1085 return;
1086 }
1087 DataAccessToken token;
1088 ApnItem::Attribute apnAttr;
1089 int32_t result = CellularDataTest::GetDataConnApnAttr(DEFAULT_SIM_SLOT_ID, apnAttr);
1090 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1091 }
1092
1093 /**
1094 * @tc.number GetDataConnIpType_Test_01
1095 * @tc.name Test the GetDataConnIpType function
1096 * @tc.desc Function test
1097 */
1098 HWTEST_F(CellularDataTest, GetDataConnIpType_Test_01, TestSize.Level3)
1099 {
1100 if (!HasSimCard(SIM_SLOT_ID_1)) {
1101 return;
1102 }
1103 DataAccessToken token;
1104 std::string ipType;
1105 int32_t result = CellularDataTest::GetDataConnIpType(SIM_SLOT_ID_1, ipType);
1106 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1107 }
1108
1109 /**
1110 * @tc.number GetDataConnIpType_Test_02
1111 * @tc.name Test the GetDataConnIpType function
1112 * @tc.desc Function test
1113 */
1114 HWTEST_F(CellularDataTest, GetDataConnIpType_Test_02, TestSize.Level3)
1115 {
1116 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1117 return;
1118 }
1119 DataAccessToken token;
1120 std::string ipType;
1121 int32_t result = CellularDataTest::GetDataConnIpType(DEFAULT_SIM_SLOT_ID, ipType);
1122 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1123 }
1124
1125 /**
1126 * @tc.number IsNeedDoRecovery_Test_01
1127 * @tc.name Test the IsNeedDoRecovery function
1128 * @tc.desc Function test
1129 */
1130 HWTEST_F(CellularDataTest, IsNeedDoRecovery_Test_01, TestSize.Level3)
1131 {
1132 if (!HasSimCard(SIM_SLOT_ID_1)) {
1133 return;
1134 }
1135 DataAccessToken token;
1136 bool needDoRecovery = true;
1137 int32_t result = CellularDataTest::IsNeedDoRecovery(SIM_SLOT_ID_1, needDoRecovery);
1138 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1139 }
1140
1141 /**
1142 * @tc.number IsNeedDoRecovery_Test_02
1143 * @tc.name Test the IsNeedDoRecovery function
1144 * @tc.desc Function test
1145 */
1146 HWTEST_F(CellularDataTest, IsNeedDoRecovery_Test_02, TestSize.Level3)
1147 {
1148 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1149 return;
1150 }
1151 DataAccessToken token;
1152 bool needDoRecovery = true;
1153 int32_t result = CellularDataTest::IsNeedDoRecovery(DEFAULT_SIM_SLOT_ID, needDoRecovery);
1154 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1155 }
1156
1157 /**
1158 * @tc.number GetCellularDataSupplierId_Test_01
1159 * @tc.name Test the function
1160 * @tc.desc Function test
1161 */
1162 HWTEST_F(CellularDataTest, GetCellularDataSupplierId_Test_01, TestSize.Level3)
1163 {
1164 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1165 return;
1166 }
1167 DataAccessToken token;
1168 uint32_t supplierId = 0;
1169 uint64_t capabilityInvalid = NetCap::NET_CAPABILITY_END;
1170 int32_t result = CellularDataTest::GetCellularDataSupplierId(DEFAULT_SIM_SLOT_ID, capabilityInvalid, supplierId);
1171 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
1172
1173 result =
1174 CellularDataTest::GetCellularDataSupplierId(DEFAULT_SIM_SLOT_ID, NetCap::NET_CAPABILITY_INTERNET, supplierId);
1175 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1176 }
1177
1178 /**
1179 * @tc.number CorrectNetSupplierNoAvailable_Test_01
1180 * @tc.name Test the function
1181 * @tc.desc Function test
1182 */
1183 HWTEST_F(CellularDataTest, CorrectNetSupplierNoAvailable_Test_01, TestSize.Level3)
1184 {
1185 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1186 return;
1187 }
1188 DataAccessToken token;
1189 int32_t result = CellularDataTest::CorrectNetSupplierNoAvailable(DEFAULT_SIM_SLOT_ID);
1190 int32_t apnState = CellularDataTest::GetApnState(DEFAULT_SIM_SLOT_ID, "default");
1191 if (apnState == ApnProfileState::PROFILE_STATE_CONNECTED) {
1192 ASSERT_TRUE(result == TELEPHONY_ERR_FAIL);
1193 } else {
1194 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1195 }
1196 }
1197
1198 /**
1199 * @tc.number GetSupplierRegisterState_Test_01
1200 * @tc.name Test the function
1201 * @tc.desc Function test
1202 */
1203 HWTEST_F(CellularDataTest, GetSupplierRegisterState_Test_01, TestSize.Level3)
1204 {
1205 DataAccessToken token;
1206 int32_t regState = -1;
1207 uint32_t supplierId = 1;
1208 int32_t result = CellularDataTest::GetSupplierRegisterState(supplierId, regState);
1209 ASSERT_TRUE(result == TELEPHONY_ERR_FAIL);
1210
1211 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1212 return;
1213 }
1214 int32_t getSupplierIdRet =
1215 CellularDataTest::GetCellularDataSupplierId(DEFAULT_SIM_SLOT_ID, NetCap::NET_CAPABILITY_INTERNET, supplierId);
1216 if (getSupplierIdRet == TELEPHONY_ERR_SUCCESS) {
1217 result = CellularDataTest::GetSupplierRegisterState(supplierId, regState);
1218 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1219 }
1220 }
1221
1222 /**
1223 * @tc.number EnableIntelligenceSwitch_Test_01
1224 * @tc.name Test Intelligence switch
1225 * @tc.desc Function test
1226 */
1227 HWTEST_F(CellularDataTest, EnableIntelligenceSwitch_Test_01, TestSize.Level2)
1228 {
1229 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1230 return;
1231 }
1232 DataAccessToken token;
1233 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
1234 int32_t result1 = CellularDataTest::EnableIntelligenceSwitchTest(true);
1235 ASSERT_TRUE(result1 == TELEPHONY_ERR_SUCCESS);
1236 sleep(SLEEP_TIME);
1237 std::cout << "EnableIntelligenceSwitch ..." << std::endl;
1238 int32_t result2 = CellularDataTest::EnableIntelligenceSwitchTest(false);
1239 ASSERT_TRUE(result2 == TELEPHONY_ERR_SUCCESS);
1240 sleep(SLEEP_TIME);
1241 std::cout << "DisableIntelligenceSwitch ..." << std::endl;
1242 }
1243
1244 /**
1245 * @tc.number GetIntelligenceSwitchState_Test_01
1246 * @tc.name Test Intelligence switch
1247 * @tc.desc Function test
1248 */
1249 HWTEST_F(CellularDataTest, GetIntelligenceSwitchState_Test_01, TestSize.Level2)
1250 {
1251 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1252 return;
1253 }
1254 DataAccessToken token;
1255 CellularDataTest::SetDefaultCellularDataSlotIdTest(DEFAULT_SIM_SLOT_ID);
1256 int32_t result1 = CellularDataTest::EnableIntelligenceSwitchTest(true);
1257 ASSERT_TRUE(result1 == TELEPHONY_ERR_SUCCESS);
1258 bool res1 = false;
1259 CellularDataTest::GetIntelligenceSwitchStateTest(res1);
1260 ASSERT_TRUE(res1 == true);
1261 std::cout << "Test GetIntelligenceSwitchState Of True..." << std::endl;
1262 int32_t result2 = CellularDataTest::EnableIntelligenceSwitchTest(false);
1263 ASSERT_TRUE(result2 == TELEPHONY_ERR_SUCCESS);
1264 bool res2 = true;
1265 CellularDataTest::GetIntelligenceSwitchStateTest(res2);
1266 ASSERT_TRUE(res2 == false);
1267 std::cout << "Test GetIntelligenceSwitchState Of False..." << std::endl;
1268 }
1269
1270 /**
1271 * @tc.number InitCellularDataController_Test_01
1272 * @tc.name Test the InitCellularDataController function
1273 * @tc.desc Function test
1274 */
1275 HWTEST_F(CellularDataTest, InitCellularDataController_Test_01, TestSize.Level3)
1276 {
1277 if (!HasSimCard(SIM_SLOT_ID_1)) {
1278 return;
1279 }
1280 DataAccessToken token;
1281 int32_t result = CellularDataTest::InitCellularDataController(SIM_SLOT_ID_1);
1282 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
1283 }
1284
1285 /**
1286 * @tc.number InitCellularDataController_Test_02
1287 * @tc.name Test the InitCellularDataController function
1288 * @tc.desc Function test
1289 */
1290 HWTEST_F(CellularDataTest, InitCellularDataController_Test_02, TestSize.Level3)
1291 {
1292 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1293 return;
1294 }
1295 DataAccessToken token;
1296 int32_t result = CellularDataTest::InitCellularDataController(DEFAULT_SIM_SLOT_ID);
1297 ASSERT_TRUE(result == CELLULAR_DATA_INVALID_PARAM);
1298 }
1299
1300 /**
1301 * @tc.number InitCellularDataController_Test_03
1302 * @tc.name Test the InitCellularDataController function
1303 * @tc.desc Function test
1304 */
1305 HWTEST_F(CellularDataTest, InitCellularDataController_Test_03, TestSize.Level3)
1306 {
1307 DataAccessToken token;
1308 int32_t result = CellularDataTest::InitCellularDataController(CELLULAR_DATA_VSIM_SLOT_ID);
1309 ASSERT_TRUE(result == TELEPHONY_ERR_SUCCESS);
1310 }
1311
1312 /**
1313 * @tc.number SUPL_Apn_Test_01
1314 * @tc.name Test the SUPL apn function
1315 * @tc.desc Function test
1316 */
1317 HWTEST_F(CellularDataTest, SUPL_Apn_Test_01, TestSize.Level3)
1318 {
1319 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1320 return;
1321 }
1322 DataAccessToken token;
1323 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1324 if (callback == nullptr) {
1325 std::cout << "callback is null" << std::endl;
1326 return;
1327 }
1328 NetSpecifier netSpecifier;
1329 NetAllCapabilities netAllCapabilities;
1330 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_SUPL);
1331 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1332 int32_t simId = CoreServiceClient::GetInstance().GetSimId(DEFAULT_SIM_SLOT_ID);
1333 netSpecifier.ident_ = "simId" + std::to_string(simId);
1334 netSpecifier.netCapabilities_ = netAllCapabilities;
1335 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1336 if (specifier == nullptr) {
1337 std::cout << "specifier is null" << std::endl;
1338 return;
1339 }
1340 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1341 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1342 auto suplCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1343 if (suplCallback == nullptr) {
1344 std::cout << "suplCallback is null" << std::endl;
1345 return;
1346 }
1347 int32_t count = 0;
1348 while (count < MAX_TIMES) {
1349 sleep(SLEEP_TIME);
1350 if (suplCallback->isCallback_ == true) {
1351 break;
1352 }
1353 count++;
1354 }
1355 ASSERT_TRUE(suplCallback->isCallback_);
1356 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1357 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1358 }
1359
1360 /**
1361 * @tc.number SUPL_Apn_Test_02
1362 * @tc.name Test the SUPL apn function
1363 * @tc.desc Function test
1364 */
1365 HWTEST_F(CellularDataTest, SUPL_Apn_Test_02, TestSize.Level3)
1366 {
1367 if (!HasSimCard(SIM_SLOT_ID_1)) {
1368 return;
1369 }
1370 DataAccessToken token;
1371 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1372 if (callback == nullptr) {
1373 std::cout << "callback is null" << std::endl;
1374 return;
1375 }
1376 NetSpecifier netSpecifier;
1377 NetAllCapabilities netAllCapabilities;
1378 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_SUPL);
1379 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1380 int32_t simId = CoreServiceClient::GetInstance().GetSimId(SIM_SLOT_ID_1);
1381 netSpecifier.ident_ = "simId" + std::to_string(simId);
1382 netSpecifier.netCapabilities_ = netAllCapabilities;
1383 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1384 if (specifier == nullptr) {
1385 std::cout << "specifier is null" << std::endl;
1386 return;
1387 }
1388 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1389 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1390 auto suplCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1391 if (suplCallback == nullptr) {
1392 std::cout << "suplCallback is null" << std::endl;
1393 return;
1394 }
1395 int32_t count = 0;
1396 while (count < MAX_TIMES) {
1397 sleep(SLEEP_TIME);
1398 if (suplCallback->isCallback_ == true) {
1399 break;
1400 }
1401 count++;
1402 }
1403 ASSERT_TRUE(suplCallback->isCallback_);
1404 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1405 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1406 }
1407
1408 /**
1409 * @tc.number DUN_Apn_Test_01
1410 * @tc.name Test the DUN apn function
1411 * @tc.desc Function test
1412 */
1413 HWTEST_F(CellularDataTest, DUN_Apn_Test_01, TestSize.Level3)
1414 {
1415 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1416 return;
1417 }
1418 DataAccessToken token;
1419 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1420 if (callback == nullptr) {
1421 std::cout << "callback is null" << std::endl;
1422 return;
1423 }
1424 NetSpecifier netSpecifier;
1425 NetAllCapabilities netAllCapabilities;
1426 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_DUN);
1427 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1428 int32_t simId = CoreServiceClient::GetInstance().GetSimId(DEFAULT_SIM_SLOT_ID);
1429 netSpecifier.ident_ = "simId" + std::to_string(simId);
1430 netSpecifier.netCapabilities_ = netAllCapabilities;
1431 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1432 if (specifier == nullptr) {
1433 std::cout << "specifier is null" << std::endl;
1434 return;
1435 }
1436 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1437 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1438 auto dunCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1439 if (dunCallback == nullptr) {
1440 std::cout << "dunCallback is null" << std::endl;
1441 return;
1442 }
1443 int32_t count = 0;
1444 while (count < MAX_TIMES) {
1445 sleep(SLEEP_TIME);
1446 if (dunCallback->isCallback_ == true) {
1447 break;
1448 }
1449 count++;
1450 }
1451 ASSERT_TRUE(dunCallback->isCallback_);
1452 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1453 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1454 }
1455
1456 /**
1457 * @tc.number DUN_Apn_Test_02
1458 * @tc.name Test the DUN apn function
1459 * @tc.desc Function test
1460 */
1461 HWTEST_F(CellularDataTest, DUN_Apn_Test_02, TestSize.Level3)
1462 {
1463 if (!HasSimCard(SIM_SLOT_ID_1)) {
1464 return;
1465 }
1466 DataAccessToken token;
1467 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1468 if (callback == nullptr) {
1469 std::cout << "callback is null" << std::endl;
1470 return;
1471 }
1472 NetSpecifier netSpecifier;
1473 NetAllCapabilities netAllCapabilities;
1474 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_DUN);
1475 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1476 int32_t simId = CoreServiceClient::GetInstance().GetSimId(SIM_SLOT_ID_1);
1477 netSpecifier.ident_ = "simId" + std::to_string(simId);
1478 netSpecifier.netCapabilities_ = netAllCapabilities;
1479 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1480 if (specifier == nullptr) {
1481 std::cout << "specifier is null" << std::endl;
1482 return;
1483 }
1484 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1485 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1486 auto dunCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1487 if (dunCallback == nullptr) {
1488 std::cout << "dunCallback is null" << std::endl;
1489 return;
1490 }
1491 int32_t count = 0;
1492 while (count < MAX_TIMES) {
1493 sleep(SLEEP_TIME);
1494 if (dunCallback->isCallback_ == true) {
1495 break;
1496 }
1497 count++;
1498 }
1499 ASSERT_TRUE(dunCallback->isCallback_);
1500 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1501 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1502 }
1503
1504 /**
1505 * @tc.number IA_Apn_Test_01
1506 * @tc.name Test the IA apn function
1507 * @tc.desc Function test
1508 */
1509 HWTEST_F(CellularDataTest, IA_Apn_Test_01, TestSize.Level3)
1510 {
1511 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1512 return;
1513 }
1514 DataAccessToken token;
1515 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1516 if (callback == nullptr) {
1517 std::cout << "callback is null" << std::endl;
1518 return;
1519 }
1520 NetSpecifier netSpecifier;
1521 NetAllCapabilities netAllCapabilities;
1522 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_IA);
1523 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1524 int32_t simId = CoreServiceClient::GetInstance().GetSimId(DEFAULT_SIM_SLOT_ID);
1525 netSpecifier.ident_ = "simId" + std::to_string(simId);
1526 netSpecifier.netCapabilities_ = netAllCapabilities;
1527 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1528 if (specifier == nullptr) {
1529 std::cout << "specifier is null" << std::endl;
1530 return;
1531 }
1532 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1533 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1534 auto iaCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1535 if (iaCallback == nullptr) {
1536 std::cout << "iaCallback is null" << std::endl;
1537 return;
1538 }
1539 int32_t count = 0;
1540 while (count < MAX_TIMES) {
1541 sleep(SLEEP_TIME);
1542 if (iaCallback->isCallback_ == true) {
1543 break;
1544 }
1545 count++;
1546 }
1547 ASSERT_TRUE(iaCallback->isCallback_);
1548 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1549 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1550 }
1551
1552 /**
1553 * @tc.number IA_Apn_Test_02
1554 * @tc.name Test the IA apn function
1555 * @tc.desc Function test
1556 */
1557 HWTEST_F(CellularDataTest, IA_Apn_Test_02, TestSize.Level3)
1558 {
1559 if (!HasSimCard(SIM_SLOT_ID_1)) {
1560 return;
1561 }
1562 DataAccessToken token;
1563 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1564 if (callback == nullptr) {
1565 std::cout << "callback is null" << std::endl;
1566 return;
1567 }
1568 NetSpecifier netSpecifier;
1569 NetAllCapabilities netAllCapabilities;
1570 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_IA);
1571 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1572 int32_t simId = CoreServiceClient::GetInstance().GetSimId(SIM_SLOT_ID_1);
1573 netSpecifier.ident_ = "simId" + std::to_string(simId);
1574 netSpecifier.netCapabilities_ = netAllCapabilities;
1575 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1576 if (specifier == nullptr) {
1577 std::cout << "specifier is null" << std::endl;
1578 return;
1579 }
1580 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1581 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1582 auto iaCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1583 if (iaCallback == nullptr) {
1584 std::cout << "iaCallback is null" << std::endl;
1585 return;
1586 }
1587 int32_t count = 0;
1588 while (count < MAX_TIMES) {
1589 sleep(SLEEP_TIME);
1590 if (iaCallback->isCallback_ == true) {
1591 break;
1592 }
1593 count++;
1594 }
1595 ASSERT_TRUE(iaCallback->isCallback_);
1596 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1597 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1598 }
1599
1600 /**
1601 * @tc.number XCAP_Apn_Test_01
1602 * @tc.name Test the XCAP apn function
1603 * @tc.desc Function test
1604 */
1605 HWTEST_F(CellularDataTest, XCAP_Apn_Test_01, TestSize.Level3)
1606 {
1607 if (!HasSimCard(DEFAULT_SIM_SLOT_ID)) {
1608 return;
1609 }
1610 DataAccessToken token;
1611 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1612 if (callback == nullptr) {
1613 std::cout << "callback is null" << std::endl;
1614 return;
1615 }
1616 NetSpecifier netSpecifier;
1617 NetAllCapabilities netAllCapabilities;
1618 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_XCAP);
1619 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1620 int32_t simId = CoreServiceClient::GetInstance().GetSimId(DEFAULT_SIM_SLOT_ID);
1621 netSpecifier.ident_ = "simId" + std::to_string(simId);
1622 netSpecifier.netCapabilities_ = netAllCapabilities;
1623 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1624 if (specifier == nullptr) {
1625 std::cout << "specifier is null" << std::endl;
1626 return;
1627 }
1628 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1629 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1630 auto xcapCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1631 if (xcapCallback == nullptr) {
1632 std::cout << "xcapCallback is null" << std::endl;
1633 return;
1634 }
1635 int32_t count = 0;
1636 while (count < MAX_TIMES) {
1637 sleep(SLEEP_TIME);
1638 if (xcapCallback->isCallback_ == true) {
1639 break;
1640 }
1641 count++;
1642 }
1643 ASSERT_TRUE(xcapCallback->isCallback_);
1644 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1645 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1646 }
1647
1648 /**
1649 * @tc.number XCAP_Apn_Test_02
1650 * @tc.name Test the XCAP apn function
1651 * @tc.desc Function test
1652 */
1653 HWTEST_F(CellularDataTest, XCAP_Apn_Test_02, TestSize.Level3)
1654 {
1655 if (!HasSimCard(SIM_SLOT_ID_1)) {
1656 return;
1657 }
1658 DataAccessToken token;
1659 sptr<INetConnCallback> callback = new (std::nothrow) TestCallback();
1660 if (callback == nullptr) {
1661 std::cout << "callback is null" << std::endl;
1662 return;
1663 }
1664 NetSpecifier netSpecifier;
1665 NetAllCapabilities netAllCapabilities;
1666 netAllCapabilities.netCaps_.insert(NetCap::NET_CAPABILITY_XCAP);
1667 netAllCapabilities.bearerTypes_.insert(NetBearType::BEARER_CELLULAR);
1668 int32_t simId = CoreServiceClient::GetInstance().GetSimId(SIM_SLOT_ID_1);
1669 netSpecifier.ident_ = "simId" + std::to_string(simId);
1670 netSpecifier.netCapabilities_ = netAllCapabilities;
1671 sptr<NetSpecifier> specifier = new (std::nothrow) NetSpecifier(netSpecifier);
1672 if (specifier == nullptr) {
1673 std::cout << "specifier is null" << std::endl;
1674 return;
1675 }
1676 int32_t result = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, callback, NET_REGISTER_TIMEOUT_MS);
1677 std::cout << "RegisterNetConnCallback result [" << result << "]" << std::endl;
1678 auto xcapCallback = static_cast<TestCallback *>(callback.GetRefPtr());
1679 if (xcapCallback == nullptr) {
1680 std::cout << "xcapCallback is null" << std::endl;
1681 return;
1682 }
1683 int32_t count = 0;
1684 while (count < MAX_TIMES) {
1685 sleep(SLEEP_TIME);
1686 if (xcapCallback->isCallback_ == true) {
1687 break;
1688 }
1689 count++;
1690 }
1691 ASSERT_TRUE(xcapCallback->isCallback_);
1692 result = NetConnClient::GetInstance().UnregisterNetConnCallback(callback);
1693 std::cout << "UnregisterNetConnCallback result [" << result << "]" << std::endl;
1694 }
1695
1696 /**
1697 * @tc.number RequestNetwork_001
1698 * @tc.name Test the function
1699 * @tc.desc Function test
1700 */
1701 HWTEST_F(CellularDataTest, RequestNetwork_001, TestSize.Level3)
1702 {
1703 std::string ident = "testIdent";
1704 std::set<NetCap> netCaps;
1705 NetManagerStandard::NetRequest netrequest;
1706 int32_t result = netAgent.callBack_->RequestNetwork(ident, netCaps, netrequest);
1707 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1708 }
1709
1710 /**
1711 * @tc.number RequestNetwork_002
1712 * @tc.name Test the function
1713 * @tc.desc Function test
1714 */
1715 HWTEST_F(CellularDataTest, RequestNetwork_002, TestSize.Level3)
1716 {
1717 std::string ident = "testIdent";
1718 std::set<NetCap> netCaps = { NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET };
1719 NetManagerStandard::NetRequest netrequest;
1720 int32_t result = netAgent.callBack_->RequestNetwork(ident, netCaps, netrequest);
1721 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1722 }
1723
1724 /**
1725 * @tc.number ReleaseNetwork_001
1726 * @tc.name Test the function
1727 * @tc.desc Function test
1728 */
1729 HWTEST_F(CellularDataTest, ReleaseNetwork_001, TestSize.Level3)
1730 {
1731 std::string ident = "testIdent";
1732 std::set<NetCap> netCaps;
1733 int32_t result = netAgent.callBack_->ReleaseNetwork(ident, netCaps);
1734 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1735 }
1736
1737 /**
1738 * @tc.number ReleaseNetwork_002
1739 * @tc.name Test the function
1740 * @tc.desc Function test
1741 */
1742 HWTEST_F(CellularDataTest, ReleaseNetwork_002, TestSize.Level3)
1743 {
1744 std::string ident = "testIdent";
1745 std::set<NetCap> netCaps = { NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET };
1746 int32_t result = netAgent.callBack_->ReleaseNetwork(ident, netCaps);
1747 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1748 }
1749
1750 /**
1751 * @tc.number NetStrategySwitch_001
1752 * @tc.name Test the function
1753 * @tc.desc Function test
1754 */
1755 HWTEST_F(CellularDataTest, NetStrategySwitch_001, TestSize.Level3)
1756 {
1757 int32_t result = netAgent.tacticsCallBack_->NetStrategySwitch("", true);
1758 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1759 }
1760
1761 /**
1762 * @tc.number NetStrategySwitch_002
1763 * @tc.name Test the function
1764 * @tc.desc Function test
1765 */
1766 HWTEST_F(CellularDataTest, NetStrategySwitch_002, TestSize.Level3)
1767 {
1768 int32_t result = netAgent.tacticsCallBack_->NetStrategySwitch("abc", true);
1769 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1770 }
1771
1772 /**
1773 * @tc.number NetStrategySwitch_003
1774 * @tc.name Test the function
1775 * @tc.desc Function test
1776 */
1777 HWTEST_F(CellularDataTest, NetStrategySwitch_003, TestSize.Level3)
1778 {
1779 int32_t result = netAgent.tacticsCallBack_->NetStrategySwitch("123", true);
1780 ASSERT_EQ(result, CELLULAR_DATA_INVALID_PARAM);
1781 }
1782
1783 /**
1784 * @tc.number GetSupplierRegState_001
1785 * @tc.name Test the function
1786 * @tc.desc Function test
1787 */
1788 HWTEST_F(CellularDataTest, GetSupplierRegState_001, TestSize.Level3)
1789 {
1790 int32_t regState = 0;
1791 int32_t result = netAgent.GetSupplierRegState(0, regState);
1792 EXPECT_TRUE(result);
1793
1794 NetSupplier netSupplier = { 0 };
1795 netSupplier.supplierId = 1000;
1796 netSupplier.slotId = 0;
1797 netAgent.AddNetSupplier(netSupplier);
1798 result = netAgent.GetSupplierRegState(1000, regState);
1799 EXPECT_TRUE(result);
1800
1801 sptr<NetSupplierInfo> netSupplierInfo = new (std::nothrow) NetSupplierInfo();
1802 result = netAgent.UpdateNetSupplierInfo(1000, netSupplierInfo);
1803 EXPECT_NE(result, 0);
1804 }
1805
1806 /**
1807 * @tc.number RdbUpdate_001
1808 * @tc.name Test the function
1809 * @tc.desc Function test
1810 */
1811 HWTEST_F(CellularDataTest, RdbUpdate_001, TestSize.Level3)
1812 {
1813 DataShare::DataShareValuesBucket values;
1814 DataShare::DataSharePredicates predicates;
1815 CellularDataRdbHelper cellularDataRdbHelper;
1816 int result = cellularDataRdbHelper.Update(values, predicates);
1817 ASSERT_EQ(result, NULL_POINTER_EXCEPTION);
1818 }
1819
1820 /**
1821 * @tc.number RdbInsert_001
1822 * @tc.name Test the function
1823 * @tc.desc Function test
1824 */
1825 HWTEST_F(CellularDataTest, RdbInsert_001, TestSize.Level3)
1826 {
1827 DataShare::DataShareValuesBucket values;
1828 CellularDataRdbHelper cellularDataRdbHelper;
1829 int result = cellularDataRdbHelper.Insert(values);
1830 ASSERT_EQ(result, NULL_POINTER_EXCEPTION);
1831 }
1832
1833 /**
1834 * @tc.number QueryApns_001
1835 * @tc.name Test the function
1836 * @tc.desc Function test
1837 */
1838 HWTEST_F(CellularDataTest, QueryApns_001, TestSize.Level3)
1839 {
1840 std::string mcc = "123";
1841 std::string mnc = "456";
1842 std::vector<PdpProfile> apnVec;
1843 int32_t slotId = 0;
1844 CellularDataRdbHelper cellularDataRdbHelper;
1845 bool result = cellularDataRdbHelper.QueryApns(mcc, mnc, apnVec, slotId);
1846 ASSERT_FALSE(result);
1847 }
1848
1849
1850 /**
1851 * @tc.number QueryMvnoApnsByType_001
1852 * @tc.name Test the function
1853 * @tc.desc Function test
1854 */
1855 HWTEST_F(CellularDataTest, QueryMvnoApnsByType_001, TestSize.Level3)
1856 {
1857 std::string mcc = "123";
1858 std::string mnc = "456";
1859 std::string mvnoType = "789";
1860 std::string mvnoDataFromSim = "";
1861 std::vector<PdpProfile> mvnoApnVec;
1862 int32_t slotId = 0;
1863 CellularDataRdbHelper cellularDataRdbHelper;
1864 bool result = cellularDataRdbHelper.QueryMvnoApnsByType(mcc, mnc, mvnoType, mvnoDataFromSim, mvnoApnVec, slotId);
1865 ASSERT_TRUE(result);
1866 }
1867
1868 /**
1869 * @tc.number QueryMvnoApnsByType_002
1870 * @tc.name Test the function
1871 * @tc.desc Function test
1872 */
1873 HWTEST_F(CellularDataTest, QueryMvnoApnsByType_002, TestSize.Level3)
1874 {
1875 std::string mcc = "123";
1876 std::string mnc = "456";
1877 std::string mvnoType = "789";
1878 std::string mvnoDataFromSim = "012";
1879 std::vector<PdpProfile> mvnoApnVec;
1880 int32_t slotId = 0;
1881 CellularDataRdbHelper cellularDataRdbHelper;
1882 bool result = cellularDataRdbHelper.QueryMvnoApnsByType(mcc, mnc, mvnoType, mvnoDataFromSim, mvnoApnVec, slotId);
1883 ASSERT_FALSE(result);
1884 }
1885
1886 /**
1887 * @tc.number ReadApnResult_001
1888 * @tc.name Test the function
1889 * @tc.desc Function test
1890 */
1891 HWTEST_F(CellularDataTest, ReadApnResult_001, TestSize.Level3)
1892 {
1893 std::shared_ptr<DataShare::DataShareResultSet> result = nullptr;
1894 std::vector<PdpProfile> apnVec;
1895 CellularDataRdbHelper cellularDataRdbHelper;
1896 cellularDataRdbHelper.ReadApnResult(nullptr, apnVec);
1897 ASSERT_TRUE(apnVec.empty());
1898 }
1899
1900 /**
1901 * @tc.number ReadApnResult_002
1902 * @tc.name Test the function
1903 * @tc.desc Function test
1904 */
1905 HWTEST_F(CellularDataTest, ReadApnResult_002, TestSize.Level3)
1906 {
1907 std::shared_ptr<DataShare::DataShareResultSet> result = std::make_shared<DataShare::DataShareResultSet>();
1908 std::vector<PdpProfile> apnVec;
1909 CellularDataRdbHelper cellularDataRdbHelper;
1910 cellularDataRdbHelper.ReadApnResult(nullptr, apnVec);
1911 ASSERT_TRUE(apnVec.empty());
1912 }
1913
1914 #else // TEL_TEST_UNSUPPORT
1915 /**
1916 * @tc.number DataMock_Test_01
1917 * @tc.name Test for unsupport platform
1918 * @tc.desc Function test
1919 */
1920 HWTEST_F(CellularDataTest, DataMock_Test_01, TestSize.Level3)
1921 {
1922 EXPECT_TRUE(true);
1923 }
1924 #endif // TEL_TEST_UNSUPPORT
1925 /**
1926 * @tc.number CellularDataControllerAddUid_Test_01
1927 * @tc.name Test the CellularDataControllerAddUid function
1928 * @tc.desc Function test
1929 */
1930 HWTEST_F(CellularDataTest, CellularDataControllerAddUid_Test_01, TestSize.Level3)
1931 {
1932 auto controller = std::make_shared<CellularDataController>(DEFAULT_SIM_SLOT_ID);
1933 controller->cellularDataHandler_ = nullptr;
1934 NetRequest request;
1935 request.uid = 0;
1936 ASSERT_FALSE(controller->AddUid(request));
1937 }
1938
1939 /**
1940 * @tc.number CellularDataControllerRemoveUid_Test_01
1941 * @tc.name Test the CellularDataControllerRemoveUid function
1942 * @tc.desc Function test
1943 */
1944 HWTEST_F(CellularDataTest, CellularDataControllerRemoveUid_Test_1, TestSize.Level3)
1945 {
1946 auto controller = std::make_shared<CellularDataController>(DEFAULT_SIM_SLOT_ID);
1947 controller->cellularDataHandler_ = nullptr;
1948 NetRequest request;
1949 request.uid = 0;
1950 ASSERT_FALSE(controller->RemoveUid(request));
1951 }
1952
1953 /**
1954 * @tc.number ControllerReleaseCellularDataConnection_Test_01
1955 * @tc.name Test the Controlle ReleaseCellularDataConnection function
1956 * @tc.desc Function test
1957 */
1958 HWTEST_F(CellularDataTest, ControllerReleaseCellularDataConnection_Test_1, TestSize.Level3)
1959 {
1960 auto controller = std::make_shared<CellularDataController>(DEFAULT_SIM_SLOT_ID);
1961 controller->cellularDataHandler_ = nullptr;
1962 ASSERT_FALSE(controller->ReleaseCellularDataConnection());
1963 }
1964 /**
1965 * @tc.number ControllerReleaseCellularDataConnection_Test_02
1966 * @tc.name Test the Controller ReleaseCellularDataConnection function
1967 * @tc.desc Function test
1968 */
1969 HWTEST_F(CellularDataTest, ControllerReleaseCellularDataConnection_Test_2, TestSize.Level3)
1970 {
1971 auto controller = std::make_shared<CellularDataController>(DEFAULT_SIM_SLOT_ID);
1972 controller->Init();
1973 ASSERT_TRUE(controller->cellularDataHandler_ != nullptr);
1974 NetRequest request;
1975 ASSERT_TRUE(controller->ReleaseCellularDataConnection());
1976 }
1977
1978 /**
1979 * @tc.number ControllerUpdateNetworkInfo_Test_01
1980 * @tc.name Test the Controller UpdateNetworkInfo function
1981 * @tc.desc Function test
1982 */
1983 HWTEST_F(CellularDataTest, ControllerUpdateNetworkInfo_Test_01, TestSize.Level3)
1984 {
1985 auto controller = std::make_shared<CellularDataController>(DEFAULT_SIM_SLOT_ID);
1986 ASSERT_TRUE(controller->cellularDataHandler_ == nullptr);
1987 ASSERT_FALSE(controller->UpdateNetworkInfo());
1988 }
1989
1990 /**
1991 * @tc.number ControllerUpdateNetworkInfo_Test_02
1992 * @tc.name Test the Controller UpdateNetworkInfo function
1993 * @tc.desc Function test
1994 */
1995 HWTEST_F(CellularDataTest, ControllerUpdateNetworkInfo_Test_02, TestSize.Level3)
1996 {
1997 auto controller = std::make_shared<CellularDataController>(DEFAULT_SIM_SLOT_ID);
1998 EventFwk::MatchingSkills matchingSkills;
1999 matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED);
2000 EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
2001 auto cellularDataHandler = std::make_shared<CellularDataHandler>(subscriberInfo, 0);
2002 cellularDataHandler->Init();
2003 controller->cellularDataHandler_ = cellularDataHandler;
2004 ASSERT_TRUE(controller->cellularDataHandler_ != nullptr);
2005 ASSERT_TRUE(controller->UpdateNetworkInfo());
2006 }
2007
2008 } // namespace Telephony
2009 } // namespace OHOS
2010