• 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_mgr_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace NetManagerStandard {
22 namespace {
23 using namespace testing::ext;
24 } // namespace
25 
26 class NetMgrLogWrapperTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase()34 void NetMgrLogWrapperTest::SetUpTestCase() {}
35 
TearDownTestCase()36 void NetMgrLogWrapperTest::TearDownTestCase() {}
37 
SetUp()38 void NetMgrLogWrapperTest::SetUp() {}
39 
TearDown()40 void NetMgrLogWrapperTest::TearDown() {}
41 
42 HWTEST_F(NetMgrLogWrapperTest, JudgeLevelTest001, TestSize.Level1)
43 {
44     auto ret = NetMgrLogWrapper::JudgeLevel(NetMgrLogLevel::INFO);
45     ASSERT_TRUE(ret);
46     NetMgrLogWrapper::SetLogLevel(NetMgrLogLevel::FATAL);
47     auto level = NetMgrLogWrapper::GetLogLevel();
48     ASSERT_EQ(level, NetMgrLogLevel::FATAL);
49     ret = NetMgrLogWrapper::JudgeLevel(NetMgrLogLevel::INFO);
50     ASSERT_FALSE(ret);
51 }
52 
53 HWTEST_F(NetMgrLogWrapperTest, GetBriefFileNameTest001, TestSize.Level1)
54 {
55     const std::string testFile = "testFile";
56     auto ret = NetMgrLogWrapper::GetBriefFileName(testFile);
57     EXPECT_EQ(ret, testFile);
58 }
59 
60 HWTEST_F(NetMgrLogWrapperTest, GetBriefFileNameTest002, TestSize.Level1)
61 {
62     const std::string testPath = "test";
63     const std::string testFileName = "testFile";
64     auto ret = NetMgrLogWrapper::GetBriefFileName(testPath + "/" + testFileName);
65     EXPECT_EQ(ret, testFileName);
66 }
67 
68 HWTEST_F(NetMgrLogWrapperTest, GetBriefFileNameTest003, TestSize.Level1)
69 {
70     const std::string testPath = "test";
71     const std::string testFileName = "testFile";
72     auto ret = NetMgrLogWrapper::GetBriefFileName(testPath + "\\" + testFileName);
73     EXPECT_EQ(ret, testFileName);
74 }
75 } // namespace NetManagerStandard
76 } // namespace OHOS