1 /* 2 * Copyright (C) 2024 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 OHOS_ACE_COMPONENT_TEST_TASK_SCHEDULER_H 17 #define OHOS_ACE_COMPONENT_TEST_TASK_SCHEDULER_H 18 19 #include <functional> 20 #include <mutex> 21 22 #include "component_test/idle_watcher.h" 23 24 #include "base/memory/ace_type.h" 25 #include "base/memory/referenced.h" 26 27 namespace OHOS::Ace::ComponentTest { 28 29 class TestTaskScheduler { 30 private: 31 RefPtr<IdleWatcher> idleWatcher_; 32 RefPtr<TaskExecutor> taskExecutor_; 33 RefPtr<TaskRunnerAdapter> testTaskSchedulerThread_; 34 TestTaskScheduler() = default; 35 void Initialize(RefPtr<IdleWatcher>, RefPtr<TaskExecutor>); 36 void Destroy(); 37 void PushTask(std::function<void(void*)>&& task, std::function<void(void*)>&& onFinish, 38 TaskExecutor::TaskType taskType, void* data, uint32_t delay); 39 friend class ComponentTestManagerImpl; 40 }; 41 } // namespace OHOS::Ace::ComponentTest 42 43 #endif // OHOS_ACE_COMPONENT_TEST_TASK_SCHEDULER_H 44