• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_manager_constants.h"
19 #include "netnative_log_wrapper.h"
20 
21 #define private public
22 #define protected public
23 #include "local_network.h"
24 #undef protected
25 #undef private
26 
27 namespace OHOS {
28 namespace NetsysNative {
29 using namespace testing::ext;
30 using namespace OHOS::nmd;
31 class LocalNetworkTest : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp();
36     void TearDown();
37 };
38 
SetUpTestCase()39 void LocalNetworkTest::SetUpTestCase() {}
40 
TearDownTestCase()41 void LocalNetworkTest::TearDownTestCase() {}
42 
SetUp()43 void LocalNetworkTest::SetUp() {}
44 
TearDown()45 void LocalNetworkTest::TearDown() {}
46 
47 HWTEST_F(LocalNetworkTest, AddInterfaceTest001, TestSize.Level1)
48 {
49     NETNATIVE_LOGI("AddInterfaceTest001 enter");
50     LocalNetwork localNetwork(1);
51     std::string interfaceName = "waln0";
52     int32_t ret = localNetwork.AddInterface(interfaceName);
53     EXPECT_EQ(ret, NetManagerStandard::NETMANAGER_SUCCESS);
54     localNetwork.interfaces_.insert(interfaceName);
55     ret = localNetwork.AddInterface(interfaceName);
56     EXPECT_EQ(ret, NetManagerStandard::NETMANAGER_SUCCESS);
57     ret = localNetwork.RemoveInterface(interfaceName);
58     EXPECT_NE(ret, NetManagerStandard::NETMANAGER_SUCCESS);
59     localNetwork.interfaces_.clear();
60     ret = localNetwork.RemoveInterface(interfaceName);
61     EXPECT_EQ(ret, NetManagerStandard::NETMANAGER_SUCCESS);
62 }
63 } // namespace NetsysNative
64 } // namespace OHOS
65