1 /* 2 * Copyright (c) 2025 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_POWERMGR_BATTERY_MOCK_COMMON_EVENT_MANAGER 17 #define BASE_POWERMGR_BATTERY_MOCK_COMMON_EVENT_MANAGER 18 #include "common_event_data.h" 19 #include "common_event_manager.h" 20 #include "common_event_publish_info.h" 21 #include "common_event_support.h" 22 23 namespace OHOS { 24 namespace PowerMgr { 25 class MockBatteryCommonEventManager { 26 public: 27 /** 28 * Publishes a standard common event. 29 * 30 * @param data Indicates the common event data. 31 * @return Returns true if success; false otherwise. 32 */ 33 static bool PublishCommonEvent(const EventFwk::CommonEventData &data); 34 35 /** 36 * Publishes a standard common event. 37 * 38 * @param data Indicates the common event data. 39 * @param userId Indicates the user ID. 40 * @return Returns true if success; false otherwise. 41 */ 42 static bool PublishCommonEventAsUser(const EventFwk::CommonEventData &data, const int32_t &userId); 43 44 /** 45 * Publishes a common event. 46 * 47 * @param data Indicates the common event data. 48 * @param publishInfo Indicates the publish info. 49 * @return Returns true if success; false otherwise. 50 */ 51 static bool PublishCommonEvent( 52 const EventFwk::CommonEventData &data, const EventFwk::CommonEventPublishInfo &publishInfo); 53 54 /** 55 * Publishes a common event. 56 * 57 * @param data Indicates the common event data. 58 * @param publishInfo Indicates the publish info. 59 * @return Returns ERR_OK if success; otherwise failed. 60 */ 61 static int32_t NewPublishCommonEvent( 62 const EventFwk::CommonEventData &data, const EventFwk::CommonEventPublishInfo &publishInfo); 63 64 /** 65 * Publishes a common event. 66 * 67 * @param data Indicates the common event data. 68 * @param publishInfo Indicates the publish info. 69 * @param userId Indicates the user ID. 70 * @return Returns true if success; false otherwise. 71 */ 72 static bool PublishCommonEventAsUser( 73 const EventFwk::CommonEventData &data, 74 const EventFwk::CommonEventPublishInfo &publishInfo, 75 const int32_t &userId); 76 77 /** 78 * Publishes a common event. 79 * 80 * @param data Indicates the common event data. 81 * @param publishInfo Indicates the publish info. 82 * @param userId Indicates the user ID. 83 * @return Returns ERR_OK if success; otherwise failed. 84 */ 85 static int32_t NewPublishCommonEventAsUser( 86 const EventFwk::CommonEventData &data, 87 const EventFwk::CommonEventPublishInfo &publishInfo, 88 const int32_t &userId); 89 SetBoolReturnValue(const bool value)90 static void SetBoolReturnValue(const bool value) 91 { 92 boolReturnValue_ = value; 93 } SetInt32ReturnValue(const int32_t value)94 static void SetInt32ReturnValue(const int32_t value) 95 { 96 int32ReturnValue_ = value; 97 } 98 private: 99 static bool boolReturnValue_; 100 static int32_t int32ReturnValue_; 101 }; 102 } 103 } 104 #endif