• 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 #ifndef COMMUNICATION_DSOFTBUS_HILOG_MOCK_H
17 #define COMMUNICATION_DSOFTBUS_HILOG_MOCK_H
18 
19 #include <atomic>
20 #include <cstdint>
21 #include <gmock/gmock.h>
22 
23 #include "hilog/log_c.h"
24 
25 class HilogInterface {
26 public:
27     virtual int HiLogPrint(
28         LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) = 0;
29 };
30 
31 class HilogMock : public HilogInterface {
32 public:
GetMock()33     static HilogMock *GetMock()
34     {
35         return mock.load();
36     }
37 
38     HilogMock();
39     ~HilogMock();
40 
41     int HiLogPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) override;
42 
43     MOCK_METHOD6(
44         HiLogPrint, int(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, char *));
45 
46 private:
47     static inline std::atomic<HilogMock *> mock = nullptr;
48 };
49 
50 #endif // COMMUNICATION_DSOFTBUS_HILOG_MOCK_H
51