• 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 "netsys_network.h"
19 #include "net_manager_constants.h"
20 #include "network_permission.h"
21 #include "physical_network.h"
22 
23 namespace OHOS {
24 namespace nmd {
25 namespace {
26 using namespace NetManagerStandard;
27 using namespace testing::ext;
28 std::string INTERFACE_NAME = "interface_name";
29 const uint16_t NET_ID = 2;
30 } // namespace
31 
32 class NetsysNetworkTest : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp();
37     void TearDown();
38 };
39 
SetUpTestCase()40 void NetsysNetworkTest::SetUpTestCase() {}
41 
TearDownTestCase()42 void NetsysNetworkTest::TearDownTestCase() {}
43 
SetUp()44 void NetsysNetworkTest::SetUp() {}
45 
TearDown()46 void NetsysNetworkTest::TearDown() {}
47 
48 HWTEST_F(NetsysNetworkTest, InterfaceTest001, TestSize.Level1)
49 {
50     PhysicalNetwork physicNetwork(NET_ID, NetworkPermission::PERMISSION_NETWORK);
51     NetsysNetwork *netsysNetwork = &physicNetwork;
52     bool isExisted = netsysNetwork->ExistInterface(INTERFACE_NAME);
53     EXPECT_FALSE(isExisted);
54 
55     int32_t ret = netsysNetwork->ClearInterfaces();
56     EXPECT_EQ(ret, NETMANAGER_SUCCESS);
57 }
58 
59 HWTEST_F(NetsysNetworkTest, InterfaceTest002, TestSize.Level1)
60 {
61     PhysicalNetwork physicNetwork(NET_ID, NetworkPermission::PERMISSION_SYSTEM);
62     NetsysNetwork *netsysNetwork = &physicNetwork;
63     bool isExisted = netsysNetwork->ExistInterface(INTERFACE_NAME);
64     EXPECT_FALSE(isExisted);
65 
66     int32_t ret = netsysNetwork->ClearInterfaces();
67     EXPECT_EQ(ret, NETMANAGER_SUCCESS);
68 }
69 } // namespace nmd
70 } // namespace OHOS
71