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_MANAGER_IMPL_H 17 #define OHOS_ACE_COMPONENT_TEST_MANAGER_IMPL_H 18 19 #include <mutex> 20 #include <shared_mutex> 21 #include <unordered_map> 22 23 #include "component_test/component_test_manager.h" 24 #include "component_test/test_config.h" 25 26 #include "base/thread/task_executor.h" 27 28 namespace OHOS::Ace::ComponentTest { 29 30 class ComponentTestManagerImpl : public ComponentTestManager { 31 public: 32 static RefPtr<ComponentTestManagerImpl> Get(); 33 static RefPtr<ComponentTestManagerImpl> GetInitialized(); 34 void Destroy(); 35 void PostUITask(std::function<void(void*)>&& task, std::function<void(void*)>&& onFinish, void* data = nullptr, 36 uint32_t delay = 0) override; 37 void PostJSTask(std::function<void(void*)>&& task, std::function<void(void*)>&& onFinish, void* data = nullptr, 38 uint32_t delay = 0) override; 39 void SetTestCaseAttribute(TestCaseAttribute attribute) override; 40 void Record(std::string info, std::string position, Result result) override; 41 void Finish() override; 42 void ClaimLongOperation() override; 43 void LongOperationComplete() override; 44 void RequestContinuousIdleStatusNotification(IdleNotifycallback&& notifycallback) override; 45 ~ComponentTestManagerImpl() override 46 { 47 Destroy(); 48 } 49 50 PipelineStatusHolder pipelineStatusHolder; 51 TestConfig testConfig; 52 53 private: 54 static std::mutex mtx_; 55 ComponentTestManagerImpl(); 56 void Initialize(RefPtr<TaskExecutor> taskExecutor); 57 static RefPtr<ComponentTestManagerImpl> instance; 58 RefPtr<IdleWatcher> idleWatcher_; 59 TestTaskScheduler testTaskScheduler_; 60 RefPtr<TaskExecutor> taskExecutor_; 61 TestResultRecorder testResultRecorder_; 62 bool initialized_; 63 }; 64 } // namespace OHOS::Ace::ComponentTest 65 66 #endif // OHOS_ACE_COMPONENT_TEST_MANAGER_IMPL_H 67