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 #define protected public
19 #include "net_policy_base.h"
20 #undef protected
21 #include "net_mgr_log_wrapper.h"
22
23 namespace OHOS {
24 namespace NetManagerStandard {
25 namespace {
26 using namespace testing::ext;
27 constexpr int32_t EVENT_ID = 101;
28 constexpr int64_t DELAY_TIME = 10;
29 } // namespace
30
31 class NetPolicyBaseTest : public NetPolicyBase {
32 public:
Init()33 void Init() override {}
HandleEvent(int32_t eventId,const std::shared_ptr<PolicyEvent> & policyEvent)34 void HandleEvent(int32_t eventId, const std::shared_ptr<PolicyEvent> &policyEvent) override {}
35 };
36
37 class UtNetPolicyBase : public testing::Test {
38 public:
39 static void SetUpTestCase();
40 static void TearDownTestCase();
41 void SetUp();
42 void TearDown();
43 };
44
SetUpTestCase()45 void UtNetPolicyBase::SetUpTestCase() {}
46
TearDownTestCase()47 void UtNetPolicyBase::TearDownTestCase() {}
48
SetUp()49 void UtNetPolicyBase::SetUp() {}
50
TearDown()51 void UtNetPolicyBase::TearDown() {}
52
53 /**
54 * @tc.name: NetPolicyBaseTest001
55 * @tc.desc: Test FirewallRule NetpolicyBase->
56 * @tc.type: FUNC
57 */
58 HWTEST_F(UtNetPolicyBase, NetPolicyBaseTest001, TestSize.Level1)
59 {
60 auto policyBase = std::make_shared<NetPolicyBaseTest>();
61 EXPECT_TRUE(policyBase->GetCbInst() != nullptr);
62 EXPECT_TRUE(policyBase->GetFileInst() != nullptr);
63 EXPECT_TRUE(policyBase->GetNetsysInst() != nullptr);
64 policyBase->GetNetCenterInst();
65 policyBase->SendEvent(EVENT_ID, DELAY_TIME);
66 }
67 } // namespace NetManagerStandard
68 } // namespace OHOS