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 <gtest/gtest.h>
17
18 #include "net_mgr_log_wrapper.h"
19 #include "net_handle.h"
20 #include "net_conn_types.h"
21 #include "net_conn_constants.h"
22
23 namespace OHOS {
24 namespace NetManagerStandard {
25 using namespace testing::ext;
26 class NetHandleTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase()34 void NetHandleTest::SetUpTestCase() {}
35
TearDownTestCase()36 void NetHandleTest::TearDownTestCase() {}
37
SetUp()38 void NetHandleTest::SetUp() {}
39
TearDown()40 void NetHandleTest::TearDown() {}
41
42 HWTEST_F(NetHandleTest, BindSocket, TestSize.Level1)
43 {
44 int32_t socket_fd = 1;
45 int32_t netId = 5;
46 auto handler = DelayedSingleton<NetHandle>::GetInstance();
47 handler->SetNetId(netId);
48 int32_t result = handler->BindSocket(socket_fd);
49 ASSERT_TRUE(result != NETMANAGER_SUCCESS);
50 }
51
52 HWTEST_F(NetHandleTest, GetAddressesByName, TestSize.Level1)
53 {
54 std::string host = "www.baidu.com";
55 std::vector<INetAddr> addrList;
56 int32_t netId = 5;
57 auto handler = DelayedSingleton<NetHandle>::GetInstance();
58 handler->SetNetId(netId);
59 handler->GetAddressesByName(host, addrList);
60 }
61
62 HWTEST_F(NetHandleTest, GetAddressByName, TestSize.Level1)
63 {
64 std::string host = "www.baidu.com";
65 INetAddr addr;
66 int32_t netId = 5;
67 auto handler = DelayedSingleton<NetHandle>::GetInstance();
68 handler->SetNetId(netId);
69 handler->GetAddressByName(host, addr);
70 }
71 } // namespace NetManagerStandard
72 } // namespace OHOS
73