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 #include "component_test/component_test_proxy.h"
17
18 #include "component_test/test_config.h"
19
20 #include "adapter/preview/entrance/ace_container.h"
21 #include "base/memory/referenced.h"
22
23 namespace OHOS::Ace::ComponentTest {
24
GetCurrentComponentTestManager()25 RefPtr<ComponentTestManager> ComponentTestManagerProxy::GetCurrentComponentTestManager()
26 {
27 return ComponentTestManagerImpl::GetInitialized();
28 }
29
PostUITask(std::function<void (void *)> && task,std::function<void (void *)> && onFinish,void * data,uint32_t delay)30 void ComponentTestManagerProxy::PostUITask(
31 std::function<void(void*)>&& task, std::function<void(void*)>&& onFinish, void* data, uint32_t delay)
32 {
33 return GetCurrentComponentTestManager()->PostUITask(std::move(task), std::move(onFinish), data, delay);
34 }
35
PostJSTask(std::function<void (void *)> && task,std::function<void (void *)> && onFinish,void * data,uint32_t delay)36 void ComponentTestManagerProxy::PostJSTask(
37 std::function<void(void*)>&& task, std::function<void(void*)>&& onFinish, void* data, uint32_t delay)
38 {
39 return GetCurrentComponentTestManager()->PostJSTask(std::move(task), std::move(onFinish), data, delay);
40 }
41
SetTestCaseAttribute(TestCaseAttribute attribute)42 void ComponentTestManagerProxy::SetTestCaseAttribute(TestCaseAttribute attribute)
43 {
44 return ComponentTestManagerImpl::Get()->SetTestCaseAttribute(attribute);
45 }
46
Record(std::string info,std::string position,Result result)47 void ComponentTestManagerProxy::Record(std::string info, std::string position, Result result)
48 {
49 GetCurrentComponentTestManager()->Record(info, position, result);
50 }
51
Finish()52 void ComponentTestManagerProxy::Finish()
53 {
54 GetCurrentComponentTestManager()->Finish();
55 }
56
ClaimLongOperation()57 void ComponentTestManagerProxy::ClaimLongOperation()
58 {
59 GetCurrentComponentTestManager()->ClaimLongOperation();
60 }
61
LongOperationComplete()62 void ComponentTestManagerProxy::LongOperationComplete()
63 {
64 GetCurrentComponentTestManager()->LongOperationComplete();
65 }
66
RequestContinuousIdleStatusNotification(IdleNotifycallback && notifycallback)67 void ComponentTestManagerProxy::RequestContinuousIdleStatusNotification(IdleNotifycallback&& notifycallback)
68 {
69 GetCurrentComponentTestManager()->RequestContinuousIdleStatusNotification(std::move(notifycallback));
70 }
71
GetTestConfigPage()72 std::string ComponentTestManagerProxy::GetTestConfigPage()
73 {
74 return ComponentTestManagerImpl::Get()->testConfig.GetPage();
75 }
76
IsComponentTestEnabled()77 bool ComponentTestManagerProxy::IsComponentTestEnabled()
78 {
79 return ComponentTestManagerImpl::Get()->testConfig.IsComponentTestEnabled();
80 }
81 } // namespace OHOS::Ace::ComponentTest
82