14faa1673Sopenharmony_ci/* 24faa1673Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 34faa1673Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44faa1673Sopenharmony_ci * you may not use this file except in compliance with the License. 54faa1673Sopenharmony_ci * You may obtain a copy of the License at 64faa1673Sopenharmony_ci * 74faa1673Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84faa1673Sopenharmony_ci * 94faa1673Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104faa1673Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114faa1673Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124faa1673Sopenharmony_ci * See the License for the specific language governing permissions and 134faa1673Sopenharmony_ci * limitations under the License. 144faa1673Sopenharmony_ci */ 154faa1673Sopenharmony_ci 164faa1673Sopenharmony_ci#ifndef SANDBOX_MANAGER_EVENT_HANDLER_MOCK_H 174faa1673Sopenharmony_ci#define SANDBOX_MANAGER_EVENT_HANDLER_MOCK_H 184faa1673Sopenharmony_ci#include <cstdint> 194faa1673Sopenharmony_ci#include <string> 204faa1673Sopenharmony_ci 214faa1673Sopenharmony_cinamespace OHOS { 224faa1673Sopenharmony_cinamespace AppExecFwk { 234faa1673Sopenharmony_cienum class ThreadMode: uint32_t { 244faa1673Sopenharmony_ci NEW_THREAD = 0, // for new thread mode, event handler create thread 254faa1673Sopenharmony_ci FFRT, // for new thread mode, use ffrt 264faa1673Sopenharmony_ci}; 274faa1673Sopenharmony_ci 284faa1673Sopenharmony_ciclass EventRunner final { 294faa1673Sopenharmony_cipublic: 304faa1673Sopenharmony_ci EventRunner() = default; 314faa1673Sopenharmony_ci ~EventRunner() = default; 324faa1673Sopenharmony_ci 334faa1673Sopenharmony_ci static std::shared_ptr<EventRunner> Create(bool inNewThread, ThreadMode mode) 344faa1673Sopenharmony_ci { 354faa1673Sopenharmony_ci return std::make_shared<EventRunner>(); 364faa1673Sopenharmony_ci } 374faa1673Sopenharmony_ci}; 384faa1673Sopenharmony_ci 394faa1673Sopenharmony_ciclass EventHandler { 404faa1673Sopenharmony_cipublic: 414faa1673Sopenharmony_ci using Callback = std::function<void()>; 424faa1673Sopenharmony_ci 434faa1673Sopenharmony_ci explicit EventHandler(const std::shared_ptr<EventRunner> &runner = nullptr) : runner_(runner) {}; 444faa1673Sopenharmony_ci 454faa1673Sopenharmony_ci void RemoveTask(const std::string &name) {}; 464faa1673Sopenharmony_ci 474faa1673Sopenharmony_ci bool PostTask(const Callback &callback, const std::string &name = std::string(), 484faa1673Sopenharmony_ci int64_t delayTime = 0) 494faa1673Sopenharmony_ci { 504faa1673Sopenharmony_ci return true; 514faa1673Sopenharmony_ci }; 524faa1673Sopenharmony_ci 534faa1673Sopenharmony_ciprivate: 544faa1673Sopenharmony_ci std::shared_ptr<EventRunner> runner_; 554faa1673Sopenharmony_ci}; 564faa1673Sopenharmony_ci} // AppExecFwk 574faa1673Sopenharmony_ci} // OHOS 584faa1673Sopenharmony_ci#endif // SANDBOX_MANAGER_EVENT_HANDLER_MOCK_H