• 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_stats_wrapper.h"
19 
20 namespace OHOS {
21 namespace NetManagerStandard {
22 namespace {
23 using namespace testing::ext;
24 constexpr uint32_t TEST_UID = 1454;
25 constexpr const char *TEST_IFACE = "test_iface";
26 } // namespace
27 
28 class NetStatsWrapperTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp();
33     void TearDown();
34     static inline NetStatsWrapper &instance_ = NetStatsWrapper::GetInstance();
35 };
36 
SetUpTestCase()37 void NetStatsWrapperTest::SetUpTestCase() {}
38 
TearDownTestCase()39 void NetStatsWrapperTest::TearDownTestCase() {}
40 
SetUp()41 void NetStatsWrapperTest::SetUp() {}
42 
TearDown()43 void NetStatsWrapperTest::TearDown() {}
44 
45 HWTEST_F(NetStatsWrapperTest, GetTotalStatsTest001, TestSize.Level1)
46 {
47     auto result = instance_.GetTotalStats(StatsType::STATS_TYPE_RX_BYTES);
48     ASSERT_GE(result, -1);
49 }
50 
51 HWTEST_F(NetStatsWrapperTest, GetUidStatsTest001, TestSize.Level1)
52 {
53     auto result = instance_.GetUidStats(StatsType::STATS_TYPE_RX_BYTES, TEST_UID);
54     ASSERT_GE(result, -1);
55 }
56 
57 HWTEST_F(NetStatsWrapperTest, GetIfaceStatsTest001, TestSize.Level1)
58 {
59     auto result = instance_.GetIfaceStats(StatsType::STATS_TYPE_RX_BYTES, TEST_IFACE);
60     ASSERT_GE(result, -1);
61 }
62 } // namespace NetManagerStandard
63 } // namespace OHOS