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 "i_net_conn_service.h"
17 #include "i_net_detection_callback.h"
18 #include "net_all_capabilities.h"
19 #include "net_conn_callback_stub.h"
20 #include "net_conn_service_proxy.h"
21 #include "net_manager_constants.h"
22 #include "net_supplier_callback_stub.h"
23 #include <gtest/gtest.h>
24 #include <iostream>
25 #include <memory>
26
27 namespace OHOS {
28 namespace NetManagerStandard {
29 using namespace testing::ext;
30 namespace {
31 constexpr int32_t TEST_UID = 1010;
32 constexpr const char *TEST_IDENT = "testIdent";
33 constexpr uint32_t TEST_TIMEOUTMS = 1000;
34 constexpr const char *TEST_HOST = "testHost";
35 constexpr int32_t TEST_NETID = 3;
36 constexpr int32_t TEST_SOCKETFD = 2;
37 constexpr int32_t TEST_SUPPLIERID = 1021;
38
39 uint32_t g_supplierId = 0;
40 class MockNetIRemoteObject : public IRemoteObject {
41 public:
MockNetIRemoteObject()42 MockNetIRemoteObject() : IRemoteObject(u"mock_i_remote_object") {}
~MockNetIRemoteObject()43 ~MockNetIRemoteObject() {}
44
GetObjectRefCount()45 int32_t GetObjectRefCount() override
46 {
47 return 0;
48 }
49
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)50 int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override
51 {
52 reply.WriteInt32(NETMANAGER_SUCCESS);
53 switch (code) {
54 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_IFACE_NAMES):
55 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_SPECIFIC_NET):
56 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_ALL_NETS):
57 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_ADDRESSES_BY_NAME):
58 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_NET_ID_BY_IDENTIFIER):
59 reply.WriteUint32(NETMANAGER_SUCCESS);
60 break;
61
62 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_IFACENAME_BY_TYPE):
63 reply.WriteString(TEST_HOST);
64 break;
65
66 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GETDEFAULTNETWORK):
67 reply.WriteInt32(TEST_NETID);
68 break;
69
70 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_HASDEFAULTNET):
71 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_IS_DEFAULT_NET_METERED):
72 reply.WriteBool(true);
73 break;
74
75 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_CONNECTION_PROPERTIES): {
76 NetLinkInfo linkInfo;
77 linkInfo.ifaceName_ = "ifacename_test";
78 linkInfo.Marshalling(reply);
79 break;
80 }
81
82 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_NET_CAPABILITIES): {
83 NetAllCapabilities netCap;
84 netCap.Marshalling(reply);
85 break;
86 }
87
88 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_ADDRESS_BY_NAME): {
89 INetAddr addr;
90 addr.Marshalling(reply);
91 break;
92 }
93
94 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_GLOBAL_HTTP_PROXY):
95 case static_cast<uint32_t>(ConnInterfaceCode::CMD_NM_GET_DEFAULT_HTTP_PROXY): {
96 HttpProxy httpProxy;
97 httpProxy.Marshalling(reply);
98 break;
99 }
100
101 default:
102 reply.WriteUint32(TEST_SUPPLIERID);
103 break;
104 }
105
106 return eCode;
107 }
108
IsProxyObject() const109 bool IsProxyObject() const override
110 {
111 return true;
112 }
113
CheckObjectLegality() const114 bool CheckObjectLegality() const override
115 {
116 return true;
117 }
118
AddDeathRecipient(const sptr<DeathRecipient> & recipient)119 bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override
120 {
121 return true;
122 }
123
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)124 bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override
125 {
126 return true;
127 }
128
Marshalling(Parcel & parcel) const129 bool Marshalling(Parcel &parcel) const override
130 {
131 return true;
132 }
133
AsInterface()134 sptr<IRemoteBroker> AsInterface() override
135 {
136 return nullptr;
137 }
138
Dump(int fd,const std::vector<std::u16string> & args)139 int Dump(int fd, const std::vector<std::u16string> &args) override
140 {
141 return 0;
142 }
143
GetObjectDescriptor() const144 std::u16string GetObjectDescriptor() const
145 {
146 std::u16string descriptor = std::u16string();
147 return descriptor;
148 }
149
SetErrorCode(int errorCode)150 void SetErrorCode(int errorCode)
151 {
152 eCode = errorCode;
153 }
154
155 private:
156 int eCode = NETMANAGER_SUCCESS;
157 };
158
159 class NetConnTestCallback : public NetConnCallbackStub {
160 public:
NetAvailable(sptr<NetHandle> & netHandle)161 inline int32_t NetAvailable(sptr<NetHandle> &netHandle) override
162 {
163 return 0;
164 }
NetCapabilitiesChange(sptr<NetHandle> & netHandle,const sptr<NetAllCapabilities> & netCap)165 inline int32_t NetCapabilitiesChange(sptr<NetHandle> &netHandle, const sptr<NetAllCapabilities> &netCap) override
166 {
167 return 0;
168 }
NetConnectionPropertiesChange(sptr<NetHandle> & netHandle,const sptr<NetLinkInfo> & info)169 inline int32_t NetConnectionPropertiesChange(sptr<NetHandle> &netHandle, const sptr<NetLinkInfo> &info) override
170 {
171 return 0;
172 }
NetLost(sptr<NetHandle> & netHandle)173 inline int32_t NetLost(sptr<NetHandle> &netHandle) override
174 {
175 return 0;
176 }
NetUnavailable()177 inline int32_t NetUnavailable() override
178 {
179 return 0;
180 }
NetBlockStatusChange(sptr<NetHandle> & netHandle,bool blocked)181 inline int32_t NetBlockStatusChange(sptr<NetHandle> &netHandle, bool blocked) override
182 {
183 return 0;
184 }
185 };
186
187 class NetDetectionTestCallback : public IRemoteStub<INetDetectionCallback> {
188 public:
OnNetDetectionResultChanged(NetDetectionResultCode resultCode,const std::string & urlRedirect)189 int32_t OnNetDetectionResultChanged(NetDetectionResultCode resultCode, const std::string &urlRedirect) override
190 {
191 return 0;
192 }
193 };
194
195 class NetConnServiceProxyTest : public testing::Test {
196 public:
197 static void SetUpTestCase();
198 static void TearDownTestCase();
199 void SetUp();
200 void TearDown();
201
202 static inline sptr<MockNetIRemoteObject> remoteObj_ = std::make_unique<MockNetIRemoteObject>().release();
203 static inline std::shared_ptr<NetConnServiceProxy> instance_ = std::make_shared<NetConnServiceProxy>(remoteObj_);
204 static inline sptr<INetSupplierCallback> supplierCallback_ = new (std::nothrow) NetSupplierCallbackStub();
205 static inline sptr<INetConnCallback> netConnCallback_ = new (std::nothrow) NetConnTestCallback();
206 static inline sptr<INetDetectionCallback> detectionCallback_ = new (std::nothrow) NetDetectionTestCallback();
207 };
208
SetUpTestCase()209 void NetConnServiceProxyTest::SetUpTestCase() {}
210
TearDownTestCase()211 void NetConnServiceProxyTest::TearDownTestCase() {}
212
SetUp()213 void NetConnServiceProxyTest::SetUp() {}
214
TearDown()215 void NetConnServiceProxyTest::TearDown() {}
216
217 /**
218 * @tc.name: SystemReadyTest001
219 * @tc.desc: Test NetConnServiceProxy SystemReady.
220 * @tc.type: FUNC
221 */
222 HWTEST_F(NetConnServiceProxyTest, SystemReadyTest001, TestSize.Level1)
223 {
224 int32_t ret = instance_->SystemReady();
225 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
226 }
227
228 /**
229 * @tc.name: SetInternetPermissionTest001
230 * @tc.desc: Test NetConnServiceProxy SetInternetPermission.
231 * @tc.type: FUNC
232 */
233 HWTEST_F(NetConnServiceProxyTest, SetInternetPermissionTest001, TestSize.Level1)
234 {
235 int32_t ret = instance_->SetInternetPermission(TEST_UID, true);
236 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
237 }
238
239 /**
240 * @tc.name: RegisterNetSupplierTest001
241 * @tc.desc: Test NetConnServiceProxy RegisterNetSupplier.
242 * @tc.type: FUNC
243 */
244 HWTEST_F(NetConnServiceProxyTest, RegisterNetSupplierTest001, TestSize.Level1)
245 {
246 std::set<NetCap> netCaps;
247 int32_t ret = instance_->RegisterNetSupplier(NetBearType::BEARER_ETHERNET, TEST_IDENT, netCaps, g_supplierId);
248 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
249 }
250
251 /**
252 * @tc.name: UnregisterNetSupplierTest001
253 * @tc.desc: Test NetConnServiceProxy UnregisterNetSupplier.
254 * @tc.type: FUNC
255 */
256 HWTEST_F(NetConnServiceProxyTest, UnregisterNetSupplierTest001, TestSize.Level1)
257 {
258 int32_t ret = instance_->UnregisterNetSupplier(g_supplierId);
259 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
260 }
261
262 /**
263 * @tc.name: RegisterNetSupplierCallbackTest001
264 * @tc.desc: Test NetConnServiceProxy RegisterNetSupplierCallback.
265 * @tc.type: FUNC
266 */
267 HWTEST_F(NetConnServiceProxyTest, RegisterNetSupplierCallbackTest001, TestSize.Level1)
268 {
269 int32_t ret = instance_->RegisterNetSupplierCallback(g_supplierId, supplierCallback_);
270 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
271 }
272
273 /**
274 * @tc.name: RegisterNetConnCallbackTest001
275 * @tc.desc: Test NetConnServiceProxy RegisterNetConnCallback.
276 * @tc.type: FUNC
277 */
278 HWTEST_F(NetConnServiceProxyTest, RegisterNetConnCallbackTest001, TestSize.Level1)
279 {
280 int32_t ret = instance_->RegisterNetConnCallback(netConnCallback_);
281 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
282 }
283
284 /**
285 * @tc.name: RegisterNetConnCallbackTest002
286 * @tc.desc: Test NetConnServiceProxy RegisterNetConnCallback.
287 * @tc.type: FUNC
288 */
289 HWTEST_F(NetConnServiceProxyTest, RegisterNetConnCallbackTest002, TestSize.Level1)
290 {
291 sptr<NetSpecifier> netSpecifier = new (std::nothrow) NetSpecifier();
292 int32_t ret = instance_->RegisterNetConnCallback(netSpecifier, netConnCallback_, TEST_TIMEOUTMS);
293 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
294 }
295
296 /**
297 * @tc.name: UnregisterNetConnCallbackTest001
298 * @tc.desc: Test NetConnServiceProxy UnregisterNetConnCallback.
299 * @tc.type: FUNC
300 */
301 HWTEST_F(NetConnServiceProxyTest, UnregisterNetConnCallbackTest001, TestSize.Level1)
302 {
303 int32_t ret = instance_->UnregisterNetConnCallback(netConnCallback_);
304 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
305 }
306
307 /**
308 * @tc.name: UpdateNetStateForTest001
309 * @tc.desc: Test NetConnServiceProxy UpdateNetStateForTest.
310 * @tc.type: FUNC
311 */
312 HWTEST_F(NetConnServiceProxyTest, UpdateNetStateForTest001, TestSize.Level1)
313 {
314 int32_t netState = 0;
315 sptr<NetSpecifier> netSpecifier = new (std::nothrow) NetSpecifier();
316 int32_t ret = instance_->UpdateNetStateForTest(netSpecifier, netState);
317 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
318 }
319
320 /**
321 * @tc.name: UpdateNetSupplierInfoTest001
322 * @tc.desc: Test NetConnServiceProxy UpdateNetSupplierInfo.
323 * @tc.type: FUNC
324 */
325 HWTEST_F(NetConnServiceProxyTest, UpdateNetSupplierInfoTest001, TestSize.Level1)
326 {
327 sptr<NetSupplierInfo> netSupplierInfo = new (std::nothrow) NetSupplierInfo();
328 int32_t ret = instance_->UpdateNetSupplierInfo(g_supplierId, netSupplierInfo);
329 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
330 }
331
332 /**
333 * @tc.name: UpdateNetLinkInfoTest001
334 * @tc.desc: Test NetConnServiceProxy UpdateNetLinkInfo.
335 * @tc.type: FUNC
336 */
337 HWTEST_F(NetConnServiceProxyTest, UpdateNetLinkInfoTest001, TestSize.Level1)
338 {
339 sptr<NetLinkInfo> netLinkInfo = new (std::nothrow) NetLinkInfo();
340 int32_t ret = instance_->UpdateNetLinkInfo(g_supplierId, netLinkInfo);
341 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
342 }
343
344 /**
345 * @tc.name: RegisterNetDetectionCallbackTest001
346 * @tc.desc: Test NetConnServiceProxy RegisterNetDetectionCallback.
347 * @tc.type: FUNC
348 */
349 HWTEST_F(NetConnServiceProxyTest, RegisterNetDetectionCallbackTest001, TestSize.Level1)
350 {
351 int32_t ret = instance_->RegisterNetDetectionCallback(TEST_NETID, detectionCallback_);
352 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
353 }
354
355 /**
356 * @tc.name: UnRegisterNetDetectionCallbackTest001
357 * @tc.desc: Test NetConnServiceProxy UnRegisterNetDetectionCallback.
358 * @tc.type: FUNC
359 */
360 HWTEST_F(NetConnServiceProxyTest, UnRegisterNetDetectionCallbackTest001, TestSize.Level1)
361 {
362 int32_t ret = instance_->UnRegisterNetDetectionCallback(TEST_NETID, detectionCallback_);
363 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
364 }
365
366 /**
367 * @tc.name: NetDetectionTest001
368 * @tc.desc: Test NetConnServiceProxy NetDetection.
369 * @tc.type: FUNC
370 */
371 HWTEST_F(NetConnServiceProxyTest, NetDetectionTest001, TestSize.Level1)
372 {
373 int32_t ret = instance_->NetDetection(TEST_NETID);
374 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
375 }
376
377 /**
378 * @tc.name: GetIfaceNamesTest001
379 * @tc.desc: Test NetConnServiceProxy GetIfaceNames.
380 * @tc.type: FUNC
381 */
382 HWTEST_F(NetConnServiceProxyTest, GetIfaceNamesTest001, TestSize.Level1)
383 {
384 std::list<std::string> ifaceNames;
385 int32_t ret = instance_->GetIfaceNames(NetBearType::BEARER_ETHERNET, ifaceNames);
386 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
387 }
388
389 /**
390 * @tc.name: GetIfaceNameByTypeTest001
391 * @tc.desc: Test NetConnServiceProxy GetIfaceNameByType.
392 * @tc.type: FUNC
393 */
394 HWTEST_F(NetConnServiceProxyTest, GetIfaceNameByTypeTest001, TestSize.Level1)
395 {
396 std::string ifaceName;
397 int32_t ret = instance_->GetIfaceNameByType(NetBearType::BEARER_ETHERNET, TEST_IDENT, ifaceName);
398 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
399 }
400
401 /**
402 * @tc.name: GetDefaultNetTest001
403 * @tc.desc: Test NetConnServiceProxy GetDefaultNet.
404 * @tc.type: FUNC
405 */
406 HWTEST_F(NetConnServiceProxyTest, GetDefaultNetTest001, TestSize.Level1)
407 {
408 int32_t netId = 0;
409 int32_t ret = instance_->GetDefaultNet(netId);
410 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
411 }
412
413 /**
414 * @tc.name: HasDefaultNetTest001
415 * @tc.desc: Test NetConnServiceProxy HasDefaultNet.
416 * @tc.type: FUNC
417 */
418 HWTEST_F(NetConnServiceProxyTest, HasDefaultNetTest001, TestSize.Level1)
419 {
420 bool hasDefaultNet = false;
421 int32_t ret = instance_->HasDefaultNet(hasDefaultNet);
422 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
423 EXPECT_EQ(hasDefaultNet, true);
424 }
425
426 /**
427 * @tc.name: GetSpecificNetTest001
428 * @tc.desc: Test NetConnServiceProxy GetSpecificNet.
429 * @tc.type: FUNC
430 */
431 HWTEST_F(NetConnServiceProxyTest, GetSpecificNetTest001, TestSize.Level1)
432 {
433 std::list<int32_t> netIdList;
434 int32_t ret = instance_->GetSpecificNet(NetBearType::BEARER_ETHERNET, netIdList);
435 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
436 }
437
438 /**
439 * @tc.name: GetAllNetsTest001
440 * @tc.desc: Test NetConnServiceProxy GetAllNets.
441 * @tc.type: FUNC
442 */
443 HWTEST_F(NetConnServiceProxyTest, GetAllNetsTest001, TestSize.Level1)
444 {
445 std::list<int32_t> netIdList;
446 int32_t ret = instance_->GetAllNets(netIdList);
447 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
448 }
449
450 /**
451 * @tc.name: GetSpecificUidNetTest001
452 * @tc.desc: Test NetConnServiceProxy GetSpecificUidNet.
453 * @tc.type: FUNC
454 */
455 HWTEST_F(NetConnServiceProxyTest, GetSpecificUidNetTest001, TestSize.Level1)
456 {
457 int32_t netId = 0;
458 int32_t ret = instance_->GetSpecificUidNet(TEST_UID, netId);
459 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
460 }
461
462 /**
463 * @tc.name: GetConnectionPropertiesTest001
464 * @tc.desc: Test NetConnServiceProxy GetConnectionProperties.
465 * @tc.type: FUNC
466 */
467 HWTEST_F(NetConnServiceProxyTest, GetConnectionPropertiesTest001, TestSize.Level1)
468 {
469 NetLinkInfo info;
470 int32_t ret = instance_->GetConnectionProperties(TEST_NETID, info);
471 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
472 }
473
474 /**
475 * @tc.name: GetNetCapabilitiesTest001
476 * @tc.desc: Test NetConnServiceProxy GetNetCapabilities.
477 * @tc.type: FUNC
478 */
479 HWTEST_F(NetConnServiceProxyTest, GetNetCapabilitiesTest001, TestSize.Level1)
480 {
481 NetAllCapabilities netAllCap;
482 int32_t ret = instance_->GetNetCapabilities(TEST_NETID, netAllCap);
483 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
484 }
485
486 /**
487 * @tc.name: GetAddressesByNameTest001
488 * @tc.desc: Test NetConnServiceProxy GetAddressesByName.
489 * @tc.type: FUNC
490 */
491 HWTEST_F(NetConnServiceProxyTest, GetAddressesByNameTest001, TestSize.Level1)
492 {
493 std::string host;
494 std::vector<INetAddr> addrList;
495 int32_t ret = instance_->GetAddressesByName(host, TEST_NETID, addrList);
496 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
497 }
498
499 /**
500 * @tc.name: GetAddressesByNameTest001
501 * @tc.desc: Test NetConnServiceProxy GetAddressesByName.
502 * @tc.type: FUNC
503 */
504 HWTEST_F(NetConnServiceProxyTest, GetAddresseByNameTest001, TestSize.Level1)
505 {
506 std::string host;
507 INetAddr addr;
508 int32_t ret = instance_->GetAddressByName(host, TEST_NETID, addr);
509 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
510 }
511
512 /**
513 * @tc.name: BindSocketTest001
514 * @tc.desc: Test NetConnServiceProxy BindSocket.
515 * @tc.type: FUNC
516 */
517 HWTEST_F(NetConnServiceProxyTest, BindSocketTest001, TestSize.Level1)
518 {
519 int32_t ret = instance_->BindSocket(TEST_SOCKETFD, TEST_NETID);
520 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
521 }
522
523 /**
524 * @tc.name: SetAirplaneModeTest001
525 * @tc.desc: Test NetConnServiceProxy SetAirplaneMode.
526 * @tc.type: FUNC
527 */
528 HWTEST_F(NetConnServiceProxyTest, SetAirplaneModeTest001, TestSize.Level1)
529 {
530 bool airplaneMode = true;
531 int32_t ret = instance_->SetAirplaneMode(airplaneMode);
532 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
533 }
534
535 /**
536 * @tc.name: IsDefaultNetMeteredTest001
537 * @tc.desc: Test NetConnServiceProxy IsDefaultNetMetered.
538 * @tc.type: FUNC
539 */
540 HWTEST_F(NetConnServiceProxyTest, IsDefaultNetMeteredTest001, TestSize.Level1)
541 {
542 bool isMetered;
543 int32_t ret = instance_->IsDefaultNetMetered(isMetered);
544 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
545 }
546
547 /**
548 * @tc.name: SetGlobalHttpProxyTest001
549 * @tc.desc: Test NetConnServiceProxy SetGlobalHttpProxy.
550 * @tc.type: FUNC
551 */
552 HWTEST_F(NetConnServiceProxyTest, SetGlobalHttpProxyTest001, TestSize.Level1)
553 {
554 HttpProxy proxy;
555 proxy.SetHost(TEST_HOST);
556 int32_t ret = instance_->SetGlobalHttpProxy(proxy);
557 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
558 }
559
560 /**
561 * @tc.name: GetGlobalHttpProxyTest001
562 * @tc.desc: Test NetConnServiceProxy GetGlobalHttpProxy.
563 * @tc.type: FUNC
564 */
565 HWTEST_F(NetConnServiceProxyTest, GetGlobalHttpProxyTest001, TestSize.Level1)
566 {
567 HttpProxy proxy;
568 int32_t ret = instance_->GetGlobalHttpProxy(proxy);
569 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
570 }
571
572 /**
573 * @tc.name: GetNetIdByIdentifierTest001
574 * @tc.desc: Test NetConnServiceProxy GetNetIdByIdentifier.
575 * @tc.type: FUNC
576 */
577 HWTEST_F(NetConnServiceProxyTest, GetNetIdByIdentifierTest001, TestSize.Level1)
578 {
579 std::list<int32_t> netIdList;
580 int32_t ret = instance_->GetNetIdByIdentifier(TEST_IDENT, netIdList);
581 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
582 }
583
584 /**
585 * @tc.name: SetAppNetTest001
586 * @tc.desc: Test NetConnServiceProxy SetAppNet.
587 * @tc.type: FUNC
588 */
589 HWTEST_F(NetConnServiceProxyTest, SetAppNetTest001, TestSize.Level1)
590 {
591 int32_t ret = instance_->SetAppNet(TEST_NETID);
592 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
593 }
594 }
595 } // namespace NetManagerStandard
596 } // namespace OHOS