• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 BASE_NOTIFICATION_CES_STANDARD_CESFWK_TOOLS_TEST_MOCK_MOCK_COMMON_EVENT_STUB_H
17 #define BASE_NOTIFICATION_CES_STANDARD_CESFWK_TOOLS_TEST_MOCK_MOCK_COMMON_EVENT_STUB_H
18 
19 #include "gmock/gmock.h"
20 
21 #include "common_event_stub.h"
22 #include "event_log_wrapper.h"
23 
24 namespace OHOS {
25 namespace EventFwk {
26 class MockCommonEventStub : public CommonEventStub {
27 public:
28     MOCK_METHOD4(FinishReceiver, bool(const sptr<IRemoteObject> &proxy, const int32_t &code,
29                                      const std::string &receiverData, const bool &abortEvent));
30 
31     /**
32      * Publishes a common event.
33      *
34      * @param event Indicates the common event data.
35      * @param publishInfo Indicates the publish info.
36      * @param commonEventListener Indicates the last subscriber to receive the ordered common event.
37      * @param userId Indicates the user ID.
38      * @return Returns true if success; false otherwise.
39      */
40     int32_t PublishCommonEvent(const CommonEventData &event, const CommonEventPublishInfo &publishinfo,
41         const sptr<IRemoteObject> &commonEventListener, const int32_t &userId) override;
42 
43     /**
44      * Subscribes to common events.
45      *
46      * @param subscribeInfo the subscribe information.
47      * @param commonEventListener the subscriber object.
48      * @return Returns true if success; false otherwise.
49      */
50     int32_t SubscribeCommonEvent(
51         const CommonEventSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &commonEventListener) override;
52 
53     /**
54      * Dumps the state for common event service.
55      *
56      * @param event the specified event.
57      * @param userId the user id.
58      * @param state the output result.
59      * @return Returns true if success; false otherwise.
60      */
61     bool DumpState(const uint8_t &dumpType, const std::string &event, const int32_t &userId,
62         std::vector<std::string> &state) override;
63 
64 private:
65     std::shared_ptr<CommonEventSubscribeInfo> subscribeInfoPtr;
66 };
67 }  // namespace EventFwk
68 }  // namespace OHOS
69 
70 #endif  // BASE_NOTIFICATION_CES_STANDARD_CESFWK_TOOLS_TEST_MOCK_MOCK_COMMON_EVENT_STUB_H
71