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 "net_policy_service_common.h"
20 #include "net_settings.h"
21
22 namespace OHOS {
23 namespace NetManagerStandard {
24 namespace {
25 using namespace testing::ext;
26 } // namespace
27
28 class UtNetPolicyServiceCommonTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp();
33 void TearDown();
34 static inline auto instance_ = std::make_shared<NetPolicyServiceCommon>();
35 };
36
SetUpTestCase()37 void UtNetPolicyServiceCommonTest::SetUpTestCase() {}
38
TearDownTestCase()39 void UtNetPolicyServiceCommonTest::TearDownTestCase() {}
40
SetUp()41 void UtNetPolicyServiceCommonTest::SetUp() {}
42
TearDown()43 void UtNetPolicyServiceCommonTest::TearDown() {}
44
45 HWTEST_F(UtNetPolicyServiceCommonTest, ResetPoliciesTest001, TestSize.Level1)
46 {
47 auto ret = instance_->ResetPolicies();
48 EXPECT_EQ(ret, NETMANAGER_ERR_LOCAL_PTR_NULL);
49 }
50
51 HWTEST_F(UtNetPolicyServiceCommonTest, IsUidNetAllowedTest001, TestSize.Level1)
52 {
53 uint32_t uid = 1251;
54 bool metered = true;
55 NetSettings::GetInstance().AddSystemUid(uid);
56 auto ret = instance_->IsUidNetAllowed(uid, metered);
57 EXPECT_TRUE(ret);
58 }
59 } // namespace NetManagerStandard
60 } // namespace OHOS
61