• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <gmock/gmock-matchers.h>
17 #include <gmock/gmock.h>
18 #include <gtest/gtest.h>
19 #include <string>
20 
21 #include "hilog_mock.h"
22 #include "softbus_log.h"
23 
24 using namespace std;
25 using namespace testing;
26 using namespace testing::ext;
27 
28 namespace {
29 const char *TEST_LOG_DETAIL = "softbus test log";
30 } // namespace
31 
32 namespace OHOS {
33 class SoftBusLogTest : public testing::Test { };
34 /**
35  * @tc.name: SoftBusLogTest001
36  * @tc.desc: Test SOFTBUS_LOG_INNER macro
37  * @tc.type: FUNC
38  * @tc.require: I8DW1W
39  */
40 HWTEST_F(SoftBusLogTest, SoftBusLogTest001, TestSize.Level0)
41 {
42     LogLevel level = LOG_INFO;
43     SoftBusLogLabel label = {
44         .domain = DOMAIN_ID_TEST,
45         .tag = "SoftBusTest",
46     };
47 
48     HilogMock mock;
49     EXPECT_CALL(mock, HiLogPrint(Eq(LOG_CORE), Eq(level), Eq(label.domain), StrEq(label.tag), _, _)).Times(1);
50     SOFTBUS_LOG_INNER(level, label, "%{public}s", TEST_LOG_DETAIL);
51 }
52 } // namespace OHOS
53