• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_NAPI_ACE_COMPONENT_TEST_COMPONENT_H
17 #define OHOS_NAPI_ACE_COMPONENT_TEST_COMPONENT_H
18 
19 #include "component_test/core/component_test_component_impl.h"
20 #include "js_component_test_utils.h"
21 #include "napi/native_api.h"
22 #include "napi/native_node_api.h"
23 
24 namespace OHOS::Ace::Napi {
25 
26 ComponentTestAsyncCtx* CreateComponentAsyncContext(napi_env env, napi_value thisVar);
27 
28 class ComponentTestComponent final {
29 public:
30     ComponentTestComponent() = default;
31     ~ComponentTestComponent() = default;
32 
33     static napi_status DefineComponentTestComponent(napi_env env, napi_value exports);
34     static napi_value Constructor(napi_env env, napi_callback_info info);
35     static void Destructor(napi_env env, void* nativeObject, void* finalize);
36     static napi_value JSTap(napi_env env, napi_callback_info info);
37     static napi_value JSDoubleTap(napi_env env, napi_callback_info info);
38     static napi_value JSPress(napi_env env, napi_callback_info info);
39     static napi_value JSPinchOut(napi_env env, napi_callback_info info);
40     static napi_value JSPinchIn(napi_env env, napi_callback_info info);
41     static napi_value JSInputText(napi_env env, napi_callback_info info);
42     static napi_value JSClearText(napi_env env, napi_callback_info info);
43     static napi_value JSScrollToTop(napi_env env, napi_callback_info info);
44     static napi_value JSScrollToBottom(napi_env env, napi_callback_info info);
45     static napi_value JSGetId(napi_env env, napi_callback_info info);
46     static napi_value JSGetText(napi_env env, napi_callback_info info);
47     static napi_value JSGetType(napi_env env, napi_callback_info info);
48     static napi_value GenericBoolCallback(napi_env env, napi_callback_info info);
49     static napi_value JSGetInspectorInfo(napi_env env, napi_callback_info info);
50     static napi_value JSGetInspectorTree(napi_env env, napi_callback_info info);
51     static napi_value JSGetChildCount(napi_env env, napi_callback_info info);
52     static napi_value JSGetBounds(napi_env env, napi_callback_info info);
53     static void CreateJsComponent(
54         napi_env env, napi_value* result, ComponentTest::ComponentTestComponentImpl* componentImpl);
55 
56 private:
57     static thread_local napi_ref constructorRef_;
58     static void AsyncCompleteWork(void* data);
59     static const napi_property_descriptor componentDesc_[];
60 };
61 } // namespace OHOS::Ace::Napi
62 
63 #endif // OHOS_NAPI_ACE_COMPONENT_TEST_COMPONENT_H
64