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 <gtest/gtest.h>
17
18 #include "traffic_manager.h"
19
20 namespace OHOS {
21 namespace nmd {
22 namespace {
23 using namespace testing::ext;
24 } // namespace
25
26 class TrafficManagerTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase()34 void TrafficManagerTest::SetUpTestCase() {}
35
TearDownTestCase()36 void TrafficManagerTest::TearDownTestCase() {}
37
SetUp()38 void TrafficManagerTest::SetUp() {}
39
TearDown()40 void TrafficManagerTest::TearDown() {}
41
42 HWTEST_F(TrafficManagerTest, GetInterfaceTraffic001, TestSize.Level1)
43 {
44 std::string ifName = "test0";
45 TrafficStatsParcel tmpData = TrafficManager::GetInterfaceTraffic(ifName);
46 EXPECT_EQ(tmpData.rxBytes, 0);
47 }
48
49 HWTEST_F(TrafficManagerTest, GetInterfaceTraffic002, TestSize.Level1)
50 {
51 std::string ifName = "eth0";
52 TrafficStatsParcel tmpData = TrafficManager::GetInterfaceTraffic(ifName);
53 EXPECT_GE(tmpData.rxBytes, 0);
54 }
55
56 HWTEST_F(TrafficManagerTest, GetAllTxTraffic001, TestSize.Level1)
57 {
58 long allTxBytes = TrafficManager::GetAllTxTraffic();
59 EXPECT_GE(allTxBytes, 0);
60 }
61
62 HWTEST_F(TrafficManagerTest, GetAllRxTraffic001, TestSize.Level1)
63 {
64 long allRxBytes = TrafficManager::GetAllRxTraffic();
65 EXPECT_GE(allRxBytes, 0);
66 }
67 } // namespace nmd
68 } // namespace OHOS