diff --git a/OAT.xml b/OAT.xml index e6b5b947bba36fe1ac1eb390307a3738babad273..ab126dd796c160990049a79dbcd8b53acaa0c712 100644 --- a/OAT.xml +++ b/OAT.xml @@ -115,6 +115,7 @@ Note:If the text contains special characters, please escape them according to th + diff --git a/function/ui_compare/capidemo/.gitignore b/function/ui_compare/capidemo/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9d39b1d41632e78835ce53b0c8b1f744eb54e920 --- /dev/null +++ b/function/ui_compare/capidemo/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +oh-package-lock.json5 \ No newline at end of file diff --git a/function/ui_compare/capidemo/AppScope/app.json5 b/function/ui_compare/capidemo/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..bdeacd6a46704a05cf2586f111fbfcc269897a2e --- /dev/null +++ b/function/ui_compare/capidemo/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.openharmony.capi_demo", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/function/ui_compare/capidemo/AppScope/resources/base/element/string.json b/function/ui_compare/capidemo/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..91869016027e18ce9274bfcc018e4a6a618aa07c --- /dev/null +++ b/function/ui_compare/capidemo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "CAPI_Demo" + } + ] +} diff --git a/function/ui_compare/capidemo/AppScope/resources/base/media/app_icon.png b/function/ui_compare/capidemo/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/function/ui_compare/capidemo/AppScope/resources/base/media/app_icon.png differ diff --git a/function/ui_compare/capidemo/README.md b/function/ui_compare/capidemo/README.md new file mode 100644 index 0000000000000000000000000000000000000000..80a5141f789450de473ca5924a703b02c8652799 --- /dev/null +++ b/function/ui_compare/capidemo/README.md @@ -0,0 +1,3 @@ +# capidemo + +c api demo project \ No newline at end of file diff --git a/function/ui_compare/capidemo/build-profile.json5 b/function/ui_compare/capidemo/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e86339faf41569133d6b49ff859b7c7f8bbb6932 --- /dev/null +++ b/function/ui_compare/capidemo/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/code-linter.json5 b/function/ui_compare/capidemo/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..95fce531ca2df66e9e28ad1fb183730472234fc7 --- /dev/null +++ b/function/ui_compare/capidemo/code-linter.json5 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/.gitignore b/function/ui_compare/capidemo/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3c3507dc214954779585317366bd9263c3519bb0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/.gitignore @@ -0,0 +1,7 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test +oh-package-lock.json5 \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/build-profile.json5 b/function/ui_compare/capidemo/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..781009cfcd4f093281a7b298cb05371fc1d560c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/build-profile.json5 @@ -0,0 +1,20 @@ +{ + "apiType": 'stageMode', + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "armeabi-v7a", "x86_64"], + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/hvigorfile.ts b/function/ui_compare/capidemo/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c57c77181d0d36beb49c897ff3fc1ad92f7eaa7c --- /dev/null +++ b/function/ui_compare/capidemo/entry/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/function/ui_compare/capidemo/entry/oh-package.json5 b/function/ui_compare/capidemo/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7d6ab2164afcb6febf05fd7f955b67cc3a807a3e --- /dev/null +++ b/function/ui_compare/capidemo/entry/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "license": "", + "devDependencies": { + "@types/libnativerender.so": "file:./src/main/cpp/types/libnativerender" + }, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/CMakeLists.txt b/function/ui_compare/capidemo/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a09128ba4acf72041c16c0a4354389a5bcd533cb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,99 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(XComponent) + +# Automatically refresh source files +file(GLOB_RECURSE ALL_CPP_FILES ${PROJECT_SOURCE_DIR}/*.cpp) +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +add_definitions(-DOHOS_PLATFORM) + + +function(getAllCpp path parentDir exclude) + set(LOCAL_LIST) + file(GLOB ALL_DIR RELATIVE ${parentDir} ${parentDir}/*) + foreach(ITEM ${ALL_DIR}) + set(ITEM_DIR ${parentDir}/${ITEM}) + set(FIND_BOOL FALSE) + foreach(dir ${exclude}) + if("${dir}" STREQUAL "${ITEM}") + set(FIND_BOOL TRUE) + break() + endif() + endforeach() + if ("${FIND_BOOL}" STREQUAL "FALSE") + if(EXISTS ${ITEM_DIR}) + file(GLOB ALL_FILE ${ITEM_DIR}/*.cpp) + list(APPEND LOCAL_LIST ${ALL_FILE}) + endif() + endif () + endforeach() + set(path ${LOCAL_LIST} PARENT_SCOPE) +endfunction() + +set(path) +set(exclude "types") +set(CMAKE_CXX_STANDARD 17) +getAllCpp("${path}" ${PROJECT_SOURCE_DIR} "${exclude}") + +add_library(nativerender SHARED + napi_init.cpp + ${path} +) +find_library( + # Sets the name of the path variable. + hilog-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + hilog_ndk.z +) + +find_library( + # Sets the name of the path variable. + libace-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + ace_ndk.z +) + +find_library( + # Sets the name of the path variable. + libnapi-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + ace_napi.z +) + +find_library( + # Sets the name of the path variable. + libuv-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + uv +) + +find_library( + # Sets the name of the path variable. + EGL-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + EGL +) + +find_library( + # Sets the name of the path variable. + GLES-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + GLESv3 +) + +target_include_directories(nativerender PUBLIC + ${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include + PUBLIC component +) + +target_link_libraries(nativerender PUBLIC + libnative_drawing.so ${EGL-lib} ${GLES-lib} ${hilog-lib} ${libace-lib} ${libnapi-lib} ${libuv-lib}) +target_link_libraries(nativerender PUBLIC libhilog_ndk.z.so libpixelmap.so libudmf.so) + diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animateoption_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animateoption_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..50feef4206caf3ba7c5638d307dd6b60b7671b3f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animateoption_test.cpp @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "animate_animateoption_test.h" + +#include "../manager/plugin_manager.h" +#include "slider/slider_track_thickness_test.h" + +namespace ArkUICApiDemo { + +struct AnimateOptionsParams { + int32_t duration; + float tempo; + ArkUI_AnimationCurve curve; + int32_t delay; + int32_t iterations; + ArkUI_AnimationPlayMode playMode; +}; + +static void AnimateUpdate(void* userData) +{ + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetWidth(SIZE_200); + node->SetHeight(SIZE_200); + } +} + +ArkUI_ContextCallback AnimateOptionTest::CreateContextCallback(ArkUI_NodeHandle nodeHandle) +{ + ArkUI_ContextCallback callbackInfo; + callbackInfo.callback = AnimateUpdate; + callbackInfo.userData = nodeHandle; + return callbackInfo; +} + +static void AnimateComplete(void* userData) +{ + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetBorderColor(COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN); + } +} + +ArkUI_AnimateCompleteCallback AnimateOptionTest::CreateCompleteCallback(ArkUI_NodeHandle nodeHandle) +{ + ArkUI_AnimateCompleteCallback callbackInfo; + callbackInfo.type = ARKUI_FINISH_CALLBACK_REMOVED; + callbackInfo.callback = AnimateComplete; + callbackInfo.userData = nodeHandle; + return callbackInfo; +} + +std::shared_ptr CreateAnimateNode(std::shared_ptr parent) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateOptionTest", "CreateAnimateNode"); + + auto outer = std::make_shared(ARKUI_NODE_COLUMN); + outer->SetWidth(SIZE_200); + outer->SetHeight(SIZE_200); + parent->AddChild(outer); + auto node = std::make_shared(ARKUI_NODE_COLUMN); + node->SetWidth(SIZE_100); + node->SetHeight(SIZE_70); + node->SetBorderWidth(15); + node->SetBackgroundImage("resource://media/icon.png"); + node->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + outer->AddChild(node); + + return node; +} + +static void SetAnimateOptions(std::shared_ptr node, const AnimateOptionsParams& params) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateOptionTest", "SetAnimateOptions"); + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, params.duration); + OH_ArkUI_AnimateOption_SetTempo(animateOption, params.tempo); + OH_ArkUI_AnimateOption_SetCurve(animateOption, params.curve); + OH_ArkUI_AnimateOption_SetDelay(animateOption, params.delay); + OH_ArkUI_AnimateOption_SetIterations(animateOption, params.iterations); + OH_ArkUI_AnimateOption_SetPlayMode(animateOption, params.playMode); + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + auto contextCallback = AnimateOptionTest::CreateContextCallback(node->GetComponent()); + auto completeCallback = AnimateOptionTest::CreateCompleteCallback(node->GetComponent()); + animateAPI->animateTo(context, animateOption, &contextCallback, &completeCallback); +} + +static void SetAnimateOptionsDispose(std::shared_ptr node) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateOptionTest", "SetAnimateOptions"); + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + auto contextCallback = AnimateOptionTest::CreateContextCallback(node->GetComponent()); + auto completeCallback = AnimateOptionTest::CreateCompleteCallback(node->GetComponent()); + OH_ArkUI_AnimateOption_Dispose(animateOption); + animateOption = nullptr; + animateAPI->animateTo(context, animateOption, &contextCallback, &completeCallback); +} + +napi_value AnimateOptionTest::CreateNativeNodeDuration(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateOptionTest", "CreateNativeNodeDuration"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateOptionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimateNode(grid); + auto column2 = CreateAnimateNode(grid); + auto column3 = CreateAnimateNode(grid); + auto column4 = CreateAnimateNode(grid); + auto column5 = CreateAnimateNode(grid); + auto column6 = CreateAnimateNode(grid); + + // duration tempo curve test + button->RegisterOnClick([column1, column2, column3, column4, column5, column6]() { + SetAnimateOptions(column1, {2000, 1, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column2, {-500, 1, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column3, {0, 1, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column4, {2000, 2, ARKUI_CURVE_EASE, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column5, {2000, -1, ARKUI_CURVE_EASE_IN, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column6, {2000, 1, ARKUI_CURVE_EASE_OUT, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimateOptionTest::CreateNativeNodeDelay(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateOptionTest", "CreateNativeNodeDelay"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateOptionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimateNode(grid); + auto column2 = CreateAnimateNode(grid); + auto column3 = CreateAnimateNode(grid); + auto column4 = CreateAnimateNode(grid); + auto column5 = CreateAnimateNode(grid); + auto column6 = CreateAnimateNode(grid); + + // curve delay test + button->RegisterOnClick([column1, column2, column3, column4, column5, column6]() { + SetAnimateOptions(column1, {2000, 1, ARKUI_CURVE_EASE_IN_OUT, 1000, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column2, {2000, 1, ARKUI_CURVE_FAST_OUT_SLOW_IN, -500, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column3, + {2000, 1, ARKUI_CURVE_LINEAR_OUT_SLOW_IN, -1000, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column4, {2000, 1, ARKUI_CURVE_FAST_OUT_LINEAR_IN, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column5, {2000, 1, ARKUI_CURVE_EXTREME_DECELERATION, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column6, {2000, 1, ARKUI_CURVE_SHARP, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimateOptionTest::CreateNativeNodeIterations(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateOptionTest", "CreateNativeNodeIterations"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateOptionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimateNode(grid); + auto column2 = CreateAnimateNode(grid); + auto column3 = CreateAnimateNode(grid); + auto column4 = CreateAnimateNode(grid); + auto column5 = CreateAnimateNode(grid); + auto column6 = CreateAnimateNode(grid); + + // curve iterations playMode dispose test + button->RegisterOnClick([column1, column2, column3, column4, column5, column6]() { + SetAnimateOptions(column1, {2000, 1, ARKUI_CURVE_SMOOTH, 0, 0, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column2, {2000, 1, ARKUI_CURVE_FRICTION, 0, -1, ARKUI_ANIMATION_PLAY_MODE_NORMAL}); + SetAnimateOptions(column3, {2000, 1, ARKUI_CURVE_EASE, 0, 3, ARKUI_ANIMATION_PLAY_MODE_REVERSE}); + SetAnimateOptions(column4, {2000, 1, ARKUI_CURVE_EASE, 0, 3, ARKUI_ANIMATION_PLAY_MODE_ALTERNATE}); + SetAnimateOptions(column5, {2000, 1, ARKUI_CURVE_EASE, 0, 3, ARKUI_ANIMATION_PLAY_MODE_ALTERNATE_REVERSE}); + SetAnimateOptionsDispose(column6); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animateoption_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animateoption_test.h new file mode 100644 index 0000000000000000000000000000000000000000..386a58981c996243183687b1f8bd35626d90e170 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animateoption_test.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ANIMATE_ANIMATEOPTION_TEST_H +#define ARKUI_CAPI_DEMO_ANIMATE_ANIMATEOPTION_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" +#include "component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class AnimateOptionTest { +public: + ~AnimateOptionTest(); + static napi_value CreateNativeNodeDuration(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeDelay(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeIterations(napi_env env, napi_callback_info info); + static ArkUI_ContextCallback CreateContextCallback(ArkUI_NodeHandle nodeHandle); + static ArkUI_AnimateCompleteCallback CreateCompleteCallback(ArkUI_NodeHandle nodeHandle); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ANIMATE_ANIMATEOPTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animatoroption_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animatoroption_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9d2d6c59de92aea72ae93016acbf9384293b2243 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animatoroption_test.cpp @@ -0,0 +1,516 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "animate_animatoroption_test.h" + +#include "../manager/plugin_manager.h" +#include "animator_option.h" +#include "slider/slider_track_thickness_test.h" +#include "swiper/swiper_common.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateAnimatorNode(std::shared_ptr parent) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "CreateAnimateNode"); + + auto outer = std::make_shared(); + outer->SetWidth(SIZE_200); + outer->SetHeight(SIZE_200); + parent->AddChild(outer); + auto node = std::make_shared(); + node->SetWidth(SIZE_100); + node->SetHeight(SIZE_100); + node->SetBorderWidth(15); + node->SetBackgroundImage("resource://media/icon.png"); + node->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + outer->AddChild(node); + + return node; +} + +static std::shared_ptr SetAnimateOptions( + std::shared_ptr node, const AnimatorOption& params, int32_t frameCount) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "SetAnimateOptions"); + auto animator = std::make_shared(node->GetComponent(), frameCount); + animator->SetOptionParam(params); + if (frameCount <= 0) { + frameCount = 1; + } + float each = (frameCount <= 0) ? (params.end - params.begin) : (params.end - params.begin) / frameCount; + std::vector keyframes(frameCount); + for (int32_t i = 0; i < frameCount; i++) { + keyframes[i] = { static_cast(i * 1.0 / frameCount), params.begin + i * each, nullptr }; + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "keyTime:%{public}f,keyValue:%{public}f", keyframes[i].keyTime, keyframes[i].keyValue); + } + animator->SetKeyframeParams(keyframes); + animator->RegisterOnFrame([node](float value) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "value:%{public}f", value); + node->SetHeight(value); + node->SetWidth(value); + }); + animator->RegisterOnFinish([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Finish"); + node->SetBorderColor(COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN); + }); + animator->RegisterOnRepeat([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Repeat"); + node->SetBorderColor(COLOR_BLUE, COLOR_BLUE, COLOR_BLUE, COLOR_BLUE); + }); + animator->Reset(); + + return animator; +} + +static std::shared_ptr ResetAnimateOptions(std::shared_ptr node, bool enable) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "ResetAnimateOptions"); + auto animator = std::make_shared(node->GetComponent(), 20); + animator->SetOptionParam({ 500, 0, 3, ARKUI_ANIMATION_FILL_MODE_NONE, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, + nullptr, OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }); + float each = (200 - 100) / 20; + std::vector keyframes(20); + for (int32_t i = 0; i < 20; i++) { + keyframes[i] = { static_cast(i * 1.0 / 20), 100 + i * each, nullptr }; + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "keyTime:%{public}f,keyValue:%{public}f", keyframes[i].keyTime, keyframes[i].keyValue); + } + animator->SetKeyframeParams(keyframes); + animator->RegisterOnFrame([node](float value) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "value:%{public}f", value); + node->SetHeight(value); + node->SetWidth(value); + }); + animator->RegisterOnFinish([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Finish"); + node->SetBorderColor(COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN); + }); + animator->RegisterOnRepeat([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Cancel"); + node->SetBorderColor(COLOR_BLUE, COLOR_BLUE, COLOR_BLUE, COLOR_BLUE); + }); + if (enable) { + animator->Reset(); + } + + return animator; +} + +static std::shared_ptr SetAnimateOptionsWithRegister(std::shared_ptr node) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "SetAnimateOptionsWithRegister"); + auto animator = std::make_shared(node->GetComponent(), 20); + animator->SetOptionParam({ 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_NONE, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, + nullptr, OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }); + float each = (200 - 100) / 20; + std::vector keyframes(20); + for (int32_t i = 0; i < 20; i++) { + keyframes[i] = { static_cast(i * 1.0 / 20), 100 + i * each, nullptr }; + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "keyTime:%{public}f,keyValue:%{public}f", keyframes[i].keyTime, keyframes[i].keyValue); + } + animator->SetKeyframeParams(keyframes); + animator->RegisterOnFrame([node](float value) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "value:%{public}f", value); + node->SetHeight(value); + node->SetWidth(value); + }); + animator->RegisterOnFinish([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Finish"); + node->SetBorderColor(COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN); + }); + animator->RegisterOnCancel([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Cancel"); + node->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + }); + animator->RegisterOnRepeat([node]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "Repeat"); + node->SetBorderColor(COLOR_BLUE, COLOR_BLUE, COLOR_BLUE, COLOR_BLUE); + }); + animator->Reset(); + + return animator; +} + +napi_value AnimatorOptionTest::CreateNativeNodeDuration(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "CreateNativeNodeDuration"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button1"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimatorNode(grid); + auto column2 = CreateAnimatorNode(grid); + auto column3 = CreateAnimatorNode(grid); + auto column4 = CreateAnimatorNode(grid); + auto column5 = CreateAnimatorNode(grid); + auto column6 = CreateAnimatorNode(grid); + + // duration delay fill curve test + auto animator1 = SetAnimateOptions(column1, + { 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_NONE, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator2 = SetAnimateOptions(column2, + { -1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator3 = SetAnimateOptions(column3, + { 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_BACKWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator4 = SetAnimateOptions(column4, + { 1000, 500, 1, ARKUI_ANIMATION_FILL_MODE_BOTH, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator5 = SetAnimateOptions(column5, + { 1000, -1000, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator6 = SetAnimateOptions(column6, + { 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + nullptr }, + 20); + + button->RegisterOnClick([animator1, animator2, animator3, animator4, animator5, animator6]() { + animator1->Play(); + animator2->Play(); + animator3->Play(); + animator4->Play(); + animator5->Play(); + animator6->Play(); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimatorOptionTest::CreateNativeNodeInterpolation(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "CreateNativeNodeInterpolation"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button2"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimatorNode(grid); + auto column2 = CreateAnimatorNode(grid); + auto column3 = CreateAnimatorNode(grid); + auto column4 = CreateAnimatorNode(grid); + auto column5 = CreateAnimatorNode(grid); + auto column6 = CreateAnimatorNode(grid); + + // interpolation frameCount test + auto animator1 = SetAnimateOptions(column1, + { 2000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 400, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 0); + auto animator2 = SetAnimateOptions(column2, + { 2000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 0); + auto animator3 = SetAnimateOptions(column3, + { 2000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, -200, -100, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 0); + auto animator4 = SetAnimateOptions(column4, + { 2000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 0); + auto animator5 = SetAnimateOptions(column5, + { 2000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator6 = SetAnimateOptions(column6, + { 2000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + + button->RegisterOnClick([animator1, animator2, animator3, animator4, animator5, animator6]() { + animator1->Play(); + animator2->Play(); + animator3->Play(); + animator4->Play(); + animator5->Play(); + animator6->Play(); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimatorOptionTest::CreateNativeNodeIterations(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "CreateNativeNodeDuration"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button3"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimatorNode(grid); + auto column2 = CreateAnimatorNode(grid); + auto column3 = CreateAnimatorNode(grid); + auto column4 = CreateAnimatorNode(grid); + auto column5 = CreateAnimatorNode(grid); + auto column6 = CreateAnimatorNode(grid); + + // Iterations direction test + auto animator1 = SetAnimateOptions(column1, + { 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator2 = SetAnimateOptions(column2, + { 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_REVERSE, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator3 = SetAnimateOptions(column3, + { 500, 0, 3, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_ALTERNATE, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator4 = SetAnimateOptions(column4, + { 500, 0, -1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE, 100, 200, + nullptr, OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator5 = SetAnimateOptions(column5, + { 1000, 0, 0, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 20); + auto animator6 = SetAnimateOptions(column6, + { 1000, 0, 1, ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_DIRECTION_NORMAL, 100, 200, nullptr, + OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR) }, + 0); + + button->RegisterOnClick([animator1, animator2, animator3, animator4, animator5, animator6]() { + animator1->Play(); + animator2->Play(); + animator3->Play(); + animator4->Play(); + animator5->Play(); + animator6->Play(); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimatorOptionTest::CreateNativeNodeState(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "CreateNativeNodeState"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + auto row = std::make_shared(ARKUI_NODE_ROW); + column->AddChild(row); + auto button1 = std::make_shared(ARKUI_NODE_BUTTON); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button1->SetId("Play"); + row->AddChild(button1); + auto button2 = std::make_shared(ARKUI_NODE_BUTTON); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Pause"); + row->AddChild(button2); + auto button3 = std::make_shared(ARKUI_NODE_BUTTON); + button3->SetWidth(50); + button3->SetHeight(50); + button3->SetMargin(10); + button3->SetBackgroundColor(COLOR_TRANSPARENT); + button3->SetId("Finish"); + row->AddChild(button3); + auto button4 = std::make_shared(ARKUI_NODE_BUTTON); + button4->SetWidth(50); + button4->SetHeight(50); + button4->SetMargin(10); + button4->SetBackgroundColor(COLOR_TRANSPARENT); + button4->SetId("Cancel"); + row->AddChild(button4); + auto button5 = std::make_shared(ARKUI_NODE_BUTTON); + button5->SetWidth(50); + button5->SetHeight(50); + button5->SetMargin(10); + button5->SetBackgroundColor(COLOR_TRANSPARENT); + button5->SetId("Reverse"); + row->AddChild(button5); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateAnimatorNode(grid); + auto column2 = CreateAnimatorNode(grid); + auto column3 = CreateAnimatorNode(grid); + auto column4 = CreateAnimatorNode(grid); + auto column5 = CreateAnimatorNode(grid); + auto column6 = CreateAnimatorNode(grid); + + // reset play-state register test + auto animator1 = ResetAnimateOptions(column1, false); + auto animator2 = ResetAnimateOptions(column2, true); + auto animator3 = SetAnimateOptionsWithRegister(column3); + auto animator4 = SetAnimateOptionsWithRegister(column4); + auto animator5 = SetAnimateOptionsWithRegister(column5); + auto animator6 = SetAnimateOptionsWithRegister(column6); + + button1->RegisterOnClick([animator1, animator2, animator3, animator4, animator5, animator6]() { + animator1->Play(); + animator2->Play(); + animator3->Play(); + animator4->Play(); + animator5->Play(); + animator6->Reverse(); + }); + button2->RegisterOnClick([animator3]() { animator3->Pause(); }); + button3->RegisterOnClick([animator4]() { animator4->Finish(); }); + button4->RegisterOnClick([animator5]() { animator5->Cancel(); }); + button5->RegisterOnClick([animator6]() { animator6->Play(); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimatorOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animatoroption_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animatoroption_test.h new file mode 100644 index 0000000000000000000000000000000000000000..173a547f311b85b48713853e5072ac637ec44ab7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_animatoroption_test.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ANIMATE_ANIMATOROPTION_TEST_H +#define ARKUI_CAPI_DEMO_ANIMATE_ANIMATOROPTION_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class AnimatorOptionTest { +public: + static napi_value CreateNativeNodeDuration(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeInterpolation(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeIterations(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeState(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ANIMATE_ANIMATOROPTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_curve_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_curve_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25303cbcc980535015181a6fbab424b9a60468eb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_curve_test.cpp @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "animate_curve_test.h" + +#include "../manager/plugin_manager.h" +#include "slider/slider_track_thickness_test.h" + +namespace ArkUICApiDemo { + +static void AnimateUpdate1(void* userData) +{ + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetWidth(SIZE_200); + node->SetHeight(SIZE_200); + } +} + +static void AnimateUpdate2(void* userData) +{ + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetWidth(SIZE_100); + node->SetHeight(SIZE_100); + } +} + +static void SetAnimateCurveWithType(std::shared_ptr node, const std::vector& curves) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateCurveTest", "SetAnimateCurveWithType"); + if (curves.size() == PARAM_0) { + return; + } + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto keyframeAnimateOption = OH_ArkUI_KeyframeAnimateOption_Create(curves.size()); + OH_ArkUI_KeyframeAnimateOption_SetDelay(keyframeAnimateOption, 0); + OH_ArkUI_KeyframeAnimateOption_SetIterations(keyframeAnimateOption, 1); + for (auto index = 0; index < curves.size(); ++index) { + OH_ArkUI_KeyframeAnimateOption_SetDuration(keyframeAnimateOption, 500, index); + auto animationCurve = OH_ArkUI_Curve_CreateCurveByType(curves[index]); + OH_ArkUI_KeyframeAnimateOption_SetCurve(keyframeAnimateOption, animationCurve, index); + if (index % PARAM_2 == PARAM_0) { + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate1, index); + } else { + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate2, index); + } + } + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + animateAPI->keyframeAnimateTo(context, keyframeAnimateOption); +} + +static void SetAnimateCurveWithCurveHandle( + std::shared_ptr node, const std::vector& curveHandles) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateCurveTest", "SetAnimateCurveWithCurveHandle"); + if (curveHandles.size() == PARAM_0) { + return; + } + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto keyframeAnimateOption = OH_ArkUI_KeyframeAnimateOption_Create(curveHandles.size()); + OH_ArkUI_KeyframeAnimateOption_SetDelay(keyframeAnimateOption, 0); + OH_ArkUI_KeyframeAnimateOption_SetIterations(keyframeAnimateOption, 1); + for (auto index = 0; index < curveHandles.size(); ++index) { + OH_ArkUI_KeyframeAnimateOption_SetDuration(keyframeAnimateOption, 500, index); + OH_ArkUI_KeyframeAnimateOption_SetCurve(keyframeAnimateOption, curveHandles[index], index); + if (index % PARAM_2 == PARAM_0) { + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate1, index); + } else { + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate2, index); + } + } + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + animateAPI->keyframeAnimateTo(context, keyframeAnimateOption); +} + +static float CustomBezierInterpolate(float fraction, void* userdata) +{ + float controlPoints[4][2] = { { 0.0, 0.0 }, { 1.0, 0.5 }, { 0.5, 1.0 }, { 1.0, 1.0 } }; + + float x = 0.0f; + float y = 0.0f; + for (int i = 0; i < 4; ++i) { + float t = fraction; + float u = 1.0f - t; + float w1 = u * u * u; + float w2 = 3 * u * u * t; + float w3 = 3 * u * t * t; + float w4 = t * t * t; + + float cx = controlPoints[i][0]; + float cy = controlPoints[i][1]; + if (i == 0) { + x += w1 * cx; + y += w1 * cy; + } else { + x += (w2 * cx); + y += (w2 * cy); + } + if (i == 3) { + x += w4 * cx; + y += w4 * cy; + } else { + x += (w3 * cx); + y += (w3 * cy); + } + } + + return y; +} + +std::shared_ptr CreateCurveNode(std::shared_ptr parent) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateCurveTest", "CreateCurveNode"); + + auto outer = std::make_shared(ARKUI_NODE_COLUMN); + outer->SetWidth(SIZE_200); + outer->SetHeight(SIZE_200); + parent->AddChild(outer); + auto node = std::make_shared(ARKUI_NODE_COLUMN); + node->SetWidth(SIZE_100); + node->SetHeight(SIZE_100); + node->SetBorderWidth(15); + node->SetBackgroundImage("resource://media/icon.png"); + node->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + outer->AddChild(node); + + return node; +} + +napi_value AnimateCurveTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateCurveTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateCurveTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new Component(ARKUI_NODE_COLUMN); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + std::vector> columns = { CreateCurveNode(grid), CreateCurveNode(grid), + CreateCurveNode(grid), CreateCurveNode(grid), CreateCurveNode(grid), CreateCurveNode(grid) }; + + auto animationCurve1 = OH_ArkUI_Curve_CreateStepsCurve(3, true); + auto animationCurve2 = OH_ArkUI_Curve_CreateStepsCurve(-1, true); + auto animationCurve3 = OH_ArkUI_Curve_CreateStepsCurve(3, false); + auto animationCurve4 = OH_ArkUI_Curve_CreateCubicBezierCurve(0, 0, 1, 1); + auto animationCurve5 = OH_ArkUI_Curve_CreateCubicBezierCurve(0, -1, 0, 2); + auto animationCurve6 = OH_ArkUI_Curve_CreateSpringCurve(2, 10, 1, 10); + auto animationCurve7 = OH_ArkUI_Curve_CreateSpringCurve(0, 0, 0, 0); + auto animationCurve8 = OH_ArkUI_Curve_CreateInterpolatingSpring(50, 1, 10, 1); + auto animationCurve9 = OH_ArkUI_Curve_CreateInterpolatingSpring(0, 0, 0, 0); + auto animationCurve10 = OH_ArkUI_Curve_CreateCustomCurve(nullptr, CustomBezierInterpolate); + auto animationCurve11 = OH_ArkUI_Curve_CreateSpringMotion(0.5, 0.5, 0.5); + auto animationCurve12 = OH_ArkUI_Curve_CreateSpringMotion(-1, -1, -1); + auto animationCurve13 = OH_ArkUI_Curve_CreateResponsiveSpringMotion(1, 1, 1); + auto animationCurve14 = OH_ArkUI_Curve_CreateResponsiveSpringMotion(-1, -1, -1); + auto animationCurve15 = OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR); + OH_ArkUI_Curve_DisposeCurve(animationCurve15); + animationCurve15 = nullptr; + std::vector animationCurves = { animationCurve1, animationCurve2, animationCurve3, + animationCurve4, animationCurve5, animationCurve6, animationCurve7, animationCurve8, animationCurve9, + animationCurve10, animationCurve11, animationCurve12, animationCurve13, animationCurve14, animationCurve15 }; + + button->RegisterOnClick([columns, animationCurves]() { + SetAnimateCurveWithType(columns[0], { ARKUI_CURVE_LINEAR, ARKUI_CURVE_EASE, ARKUI_CURVE_EASE_IN, + ARKUI_CURVE_EASE_OUT, ARKUI_CURVE_EASE_IN_OUT }); + SetAnimateCurveWithType(columns[1], { ARKUI_CURVE_FAST_OUT_SLOW_IN, ARKUI_CURVE_LINEAR_OUT_SLOW_IN, + ARKUI_CURVE_FAST_OUT_LINEAR_IN, ARKUI_CURVE_EXTREME_DECELERATION }); + SetAnimateCurveWithType( + columns[2], { ARKUI_CURVE_SHARP, ARKUI_CURVE_RHYTHM, ARKUI_CURVE_SMOOTH, ARKUI_CURVE_FRICTION }); + SetAnimateCurveWithCurveHandle(columns[3], + { animationCurves[0], animationCurves[1], animationCurves[2], animationCurves[3], animationCurves[4] }); + SetAnimateCurveWithCurveHandle(columns[4], + { animationCurves[5], animationCurves[6], animationCurves[7], animationCurves[8], animationCurves[9] }); + SetAnimateCurveWithCurveHandle(columns[5], { animationCurves[10], animationCurves[11], animationCurves[12], + animationCurves[13], animationCurves[14] }); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateCurveTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_curve_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_curve_test.h new file mode 100644 index 0000000000000000000000000000000000000000..eee79da987a698cb0cbf163b2dae2c6219dedaf2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_curve_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ANIMATE_CURVE_TEST_H +#define ARKUI_CAPI_DEMO_ANIMATE_CURVE_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" +#include "component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class AnimateCurveTest { +public: + ~AnimateCurveTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static ArkUI_ContextCallback CreateContextCallback(ArkUI_NodeHandle nodeHandle); + static ArkUI_AnimateCompleteCallback CreateCompleteCallback(ArkUI_NodeHandle nodeHandle); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ANIMATE_CURVE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_geometrytransition_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_geometrytransition_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f8327c722144c7801e81ab4f7023a550b3925194 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_geometrytransition_test.cpp @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "animate_geometrytransition_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +struct Context { + std::shared_ptr stack; + std::shared_ptr column; + std::shared_ptr image1; + std::shared_ptr image2; + std::shared_ptr image3; + std::shared_ptr image4; +}; + +napi_value AnimateGeometryTransitionTest::CreateNativeNodeNormal(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", "CreateNativeNodeNormal"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = std::make_shared(); + column->SetWidth(400); + column->SetHeight(200); + column->SetMargin(DEFAULT_MARGIN); + auto image1 = std::make_shared(); + image1->SetImageSrc("resource://media/red.gif"); + image1->SetWidth(200); + image1->SetHeight(200); + image1->SetBorderRadius(50, 50, 50, 50); + image1->SetGeometryTransition(0, "pic"); + image1->SetId("Image1"); + column->AddChild(image1); + auto image2 = std::make_shared(); + image2->SetImageSrc("resource://media/yellow.bmp"); + image2->SetWidth(400); + image2->SetHeight(400); + image2->SetId("Image2"); + image2->SetMargin(DEFAULT_MARGIN); + + ArkUI_NumberValue opacity[] = { { .i32 = 0 }, { .i32 = 1000 }, { .i32 = 1 } }; + ArkUI_AttributeItem opacity_item = { opacity, 3, "pic" }; + image1->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + image2->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + + auto stack = new ColumnComponent(); + stack->SetWidth(400); + stack->SetHeight(600); + stack->SetAlign(ARKUI_ALIGNMENT_TOP_START); + stack->AddChild(column); + column->AddChild(image1); + + static bool isBack = true; + ArkUI_AnimateCompleteCallback* completeCallback = new ArkUI_AnimateCompleteCallback; + completeCallback->type = ARKUI_FINISH_CALLBACK_REMOVED; + completeCallback->callback = [](void* userData) { isBack = !isBack; }; + + ArkUI_ContextCallback* update = new ArkUI_ContextCallback; + update->userData = new Context { std::shared_ptr(stack), column, image1, image2, nullptr, nullptr }; + update->callback = [](void* userData) { + auto context = static_cast(userData); + auto stackSelf = context->stack; + auto columnSelf = context->column; + if (isBack) { + context->image1->SetGeometryTransition(0, ""); + context->image1->SetGeometryTransition(0, "pic"); + context->image2->SetGeometryTransition(0, ""); + context->image2->SetGeometryTransition(0, "pic"); + columnSelf->RemoveChild(context->image1); + stackSelf->AddChild(context->image2); + } else { + context->image2->SetGeometryTransition(0, ""); + context->image2->SetGeometryTransition(0, "pic"); + context->image1->SetGeometryTransition(0, ""); + context->image1->SetGeometryTransition(0, "pic"); + stackSelf->RemoveChild(context->image2); + columnSelf->AddChild(context->image1); + } + }; + image1->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + image2->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), stack->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimateGeometryTransitionTest::CreateNativeNodeMulti(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", "CreateNativeNodeMulti"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = std::make_shared(); + column->SetWidth(400); + column->SetHeight(200); + column->SetMargin(DEFAULT_MARGIN); + auto image1 = std::make_shared(); + image1->SetImageSrc("resource://media/red.gif"); + image1->SetWidth(200); + image1->SetHeight(200); + image1->SetBorderRadius(20, 20, 20, 20); + image1->SetGeometryTransition(0, "pic"); + image1->SetId("Image1"); + auto image2 = std::make_shared(); + image2->SetImageSrc("resource://media/yellow.bmp"); + image2->SetWidth(400); + image2->SetHeight(200); + image2->SetId("Image2"); + image2->SetMargin(DEFAULT_MARGIN); + auto image3 = std::make_shared(); + image3->SetImageSrc("resource://media/blue.png"); + image3->SetWidth(300); + image3->SetHeight(200); + image3->SetId("Image3"); + image3->SetMargin(DEFAULT_MARGIN); + + ArkUI_NumberValue opacity[] = { { .i32 = 0 }, { .i32 = 1000 }, { .i32 = 1 } }; + ArkUI_AttributeItem opacity_item = { opacity, 3, "pic" }; + image1->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + image2->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + image3->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + + auto stack = new ColumnComponent(); + stack->SetWidth(400); + stack->SetHeight(600); + stack->AddChild(column); + column->AddChild(image1); + + static bool isBack = true; + ArkUI_AnimateCompleteCallback* completeCallback = new ArkUI_AnimateCompleteCallback; + completeCallback->type = ARKUI_FINISH_CALLBACK_REMOVED; + completeCallback->callback = [](void* userData) { isBack = !isBack; }; + + ArkUI_ContextCallback* update = new ArkUI_ContextCallback; + update->userData = new Context { std::shared_ptr(stack), column, image1, image2, image3, nullptr }; + update->callback = [](void* userData) { + auto context = static_cast(userData); + auto stackSelf = context->stack; + auto columnSelf = context->column; + if (isBack) { + context->image1->SetGeometryTransition(0, ""); + context->image1->SetGeometryTransition(0, "pic"); + context->image2->SetGeometryTransition(0, ""); + context->image2->SetGeometryTransition(0, "pic"); + context->image3->SetGeometryTransition(0, ""); + context->image3->SetGeometryTransition(0, "pic"); + columnSelf->RemoveChild(context->image1); + stackSelf->AddChild(context->image2); + stackSelf->AddChild(context->image3); + } else { + context->image2->SetGeometryTransition(0, ""); + context->image2->SetGeometryTransition(0, "pic"); + context->image1->SetGeometryTransition(0, ""); + context->image1->SetGeometryTransition(0, "pic"); + stackSelf->RemoveChild(context->image2); + stackSelf->RemoveChild(context->image3); + columnSelf->AddChild(context->image1); + } + }; + image1->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + image2->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + image3->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), stack->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value AnimateGeometryTransitionTest::CreateNativeNodeDouble(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", "CreateNativeNodeDouble"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = std::make_shared(); + column->SetWidth(400); + column->SetHeight(200); + column->SetMargin(DEFAULT_MARGIN); + auto image1 = std::make_shared(); + image1->SetImageSrc("resource://media/red.gif"); + image1->SetWidth(200); + image1->SetHeight(200); + image1->SetBorderRadius(20, 20, 20, 20); + image1->SetGeometryTransition(0, "pic"); + image1->SetId("Image1"); + auto image2 = std::make_shared(); + image2->SetImageSrc("resource://media/yellow.bmp"); + image2->SetWidth(400); + image2->SetHeight(200); + image2->SetId("Image2"); + image2->SetMargin(DEFAULT_MARGIN); + auto image3 = std::make_shared(); + image3->SetImageSrc("resource://media/blue.png"); + image3->SetWidth(300); + image3->SetHeight(200); + image3->SetId("Image3"); + image3->SetBorderRadius(20, 20, 20, 20); + image3->SetMargin(DEFAULT_MARGIN); + auto image4 = std::make_shared(); + image4->SetImageSrc("resource://media/green.jpg"); + image4->SetWidth(100); + image4->SetHeight(100); + image4->SetId("Image4"); + image4->SetMargin(DEFAULT_MARGIN); + + ArkUI_NumberValue opacity[] = { { .i32 = 0 }, { .i32 = 1000 }, { .i32 = 1 } }; + ArkUI_AttributeItem opacity_item = { opacity, 3, "pic" }; + image1->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + image2->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + image3->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + image4->setAttribute(NODE_OPACITY_TRANSITION, &opacity_item); + + auto stack = new ColumnComponent(); + stack->SetWidth(400); + stack->SetHeight(600); + stack->AddChild(column); + column->AddChild(image1); + stack->AddChild(image4); + + static bool isBack = true; + ArkUI_AnimateCompleteCallback* completeCallback = new ArkUI_AnimateCompleteCallback; + completeCallback->type = ARKUI_FINISH_CALLBACK_REMOVED; + completeCallback->callback = [](void* userData) { isBack = !isBack; }; + + ArkUI_ContextCallback* update = new ArkUI_ContextCallback; + update->userData = new Context { std::shared_ptr(stack), column, image1, image2, image3, image4 }; + update->callback = [](void* userData) { + auto context = static_cast(userData); + auto stackSelf = context->stack; + auto columnSelf = context->column; + if (isBack) { + context->image1->SetGeometryTransition(0, ""); + context->image1->SetGeometryTransition(0, "pic"); + context->image4->SetGeometryTransition(0, ""); + context->image4->SetGeometryTransition(0, "pic"); + context->image2->SetGeometryTransition(0, ""); + context->image2->SetGeometryTransition(0, "pic"); + context->image3->SetGeometryTransition(0, ""); + context->image3->SetGeometryTransition(0, "pic"); + columnSelf->RemoveChild(context->image1); + stackSelf->RemoveChild(context->image4); + stackSelf->AddChild(context->image2); + stackSelf->AddChild(context->image3); + } else { + context->image2->SetGeometryTransition(0, ""); + context->image2->SetGeometryTransition(0, "pic"); + context->image1->SetGeometryTransition(0, ""); + context->image1->SetGeometryTransition(0, "pic"); + stackSelf->RemoveChild(context->image2); + stackSelf->RemoveChild(context->image3); + stackSelf->AddChild(context->image4); + columnSelf->AddChild(context->image1); + } + }; + image1->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + image2->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + image3->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + image4->RegisterOnClick([stack, update, completeCallback]() { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 2000); + + auto context = OH_ArkUI_GetContextByNode(stack->GetComponent()); + animateAPI->animateTo(context, animateOption, update, completeCallback); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), stack->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AnimateGeometryTransitionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_geometrytransition_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_geometrytransition_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7e77442b7fdcea472fc2af7eef41298a9efdb48d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_geometrytransition_test.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ANIMATE_GEOMETRYTRANSITION_TEST_H +#define ARKUI_CAPI_DEMO_ANIMATE_GEOMETRYTRANSITION_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" +#include "component.h" +#include "grid_component.h" +#include "image_component.h" + +namespace ArkUICApiDemo { + +class AnimateGeometryTransitionTest { +public: + ~AnimateGeometryTransitionTest(); + static napi_value CreateNativeNodeNormal(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeMulti(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeDouble(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ANIMATE_GEOMETRYTRANSITION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_keyframeanimateoption_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_keyframeanimateoption_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6cc26577bd2fce94411b755dccdd7fa2f7779f64 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_keyframeanimateoption_test.cpp @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "animate_keyframeanimateoption_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +struct KeyframeAnimateOptionsParams { + int32_t delay; + int32_t iterations; + int32_t duration1; + ArkUI_AnimationCurve curve1; + int32_t duration2; + ArkUI_AnimationCurve curve2; + int32_t index1; + int32_t index2; +}; + +static void AnimateUpdate(void* userData) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "AnimateUpdate"); + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetWidth(SIZE_200); + node->SetHeight(SIZE_200); + } +} + +static void AnimateUpdateAgain(void* userData) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "AnimateUpdateAgain"); + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetWidth(SIZE_100); + node->SetHeight(SIZE_100); + } +} + +static void AnimateComplete(void* userData) +{ + ArkUI_NodeHandle nodeHandle = static_cast(userData); + if (nodeHandle) { + auto node = std::make_shared(nodeHandle); + node->SetBorderColor(COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN); + } +} + +std::shared_ptr CreateKeyframeAnimateNode(std::shared_ptr parent) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "CreateKeyframeAnimateNode"); + + auto outer = std::make_shared(ARKUI_NODE_COLUMN); + outer->SetWidth(SIZE_200); + outer->SetHeight(SIZE_200); + parent->AddChild(outer); + auto node = std::make_shared(ARKUI_NODE_COLUMN); + node->SetWidth(SIZE_100); + node->SetHeight(SIZE_100); + node->SetBorderWidth(15); + node->SetBackgroundImage("resource://media/icon.png"); + node->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + outer->AddChild(node); + + return node; +} + +static void SetKeyframeAnimateOptionsWithIndex( + std::shared_ptr node, const KeyframeAnimateOptionsParams& params) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "SetKeyframeAnimateOptionsWithIndex"); + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animationCurve1 = OH_ArkUI_Curve_CreateCurveByType(params.curve1); + auto animationCurve2 = OH_ArkUI_Curve_CreateCurveByType(params.curve2); + auto keyframeAnimateOption = OH_ArkUI_KeyframeAnimateOption_Create(5); + OH_ArkUI_KeyframeAnimateOption_SetDelay(keyframeAnimateOption, params.delay); + OH_ArkUI_KeyframeAnimateOption_SetIterations(keyframeAnimateOption, params.iterations); + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + OH_ArkUI_KeyframeAnimateOption_SetDuration(keyframeAnimateOption, params.duration1, params.index1); + OH_ArkUI_KeyframeAnimateOption_SetDuration(keyframeAnimateOption, params.duration2, params.index2); + OH_ArkUI_KeyframeAnimateOption_SetCurve(keyframeAnimateOption, animationCurve1, params.index1); + OH_ArkUI_KeyframeAnimateOption_SetCurve(keyframeAnimateOption, animationCurve2, params.index2); + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate, params.index1); + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdateAgain, params.index2); + OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback( + keyframeAnimateOption, node->GetComponent(), AnimateComplete); + animateAPI->keyframeAnimateTo(context, keyframeAnimateOption); +} + +static void SetKeyframeAnimateOptionsWithoutCurve( + std::shared_ptr node, int32_t delay, int32_t iterations, int32_t duration, int32_t index) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "SetKeyframeAnimateOptionsWithoutCurve"); + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto keyframeAnimateOption = OH_ArkUI_KeyframeAnimateOption_Create(5); + OH_ArkUI_KeyframeAnimateOption_SetDelay(keyframeAnimateOption, delay); + OH_ArkUI_KeyframeAnimateOption_SetIterations(keyframeAnimateOption, iterations); + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + OH_ArkUI_KeyframeAnimateOption_SetDuration(keyframeAnimateOption, duration, index); + OH_ArkUI_KeyframeAnimateOption_SetCurve(keyframeAnimateOption, nullptr, index); + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate, index); + OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback( + keyframeAnimateOption, node->GetComponent(), AnimateComplete); + animateAPI->keyframeAnimateTo(context, keyframeAnimateOption); +} + +static void SetKeyframeAnimateOptionsDispose(std::shared_ptr node) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "SetKeyframeAnimateOptionsDispose"); + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto animationCurve = OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_LINEAR); + auto keyframeAnimateOption = OH_ArkUI_KeyframeAnimateOption_Create(5); + OH_ArkUI_KeyframeAnimateOption_SetDelay(keyframeAnimateOption, 0); + OH_ArkUI_KeyframeAnimateOption_SetIterations(keyframeAnimateOption, 1); + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + OH_ArkUI_KeyframeAnimateOption_SetDuration(keyframeAnimateOption, 1000, 0); + OH_ArkUI_KeyframeAnimateOption_SetCurve(keyframeAnimateOption, animationCurve, 0); + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback( + keyframeAnimateOption, node->GetComponent(), AnimateUpdate, 0); + OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback( + keyframeAnimateOption, node->GetComponent(), AnimateComplete); + // dispose + OH_ArkUI_KeyframeAnimateOption_Dispose(keyframeAnimateOption); + keyframeAnimateOption = nullptr; + animateAPI->keyframeAnimateTo(context, keyframeAnimateOption); +} + +static void SetKeyframeAnimateOptionsNullptr(std::shared_ptr node) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "SetKeyframeAnimateOptionsNullptr"); + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto context = OH_ArkUI_GetContextByNode(node->GetComponent()); + animateAPI->keyframeAnimateTo(context, nullptr); +} + +static void AddKeyframeAnimateOptionDurationChild(Component* column) +{ + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button1"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateKeyframeAnimateNode(grid); + auto column2 = CreateKeyframeAnimateNode(grid); + auto column3 = CreateKeyframeAnimateNode(grid); + auto column4 = CreateKeyframeAnimateNode(grid); + auto column5 = CreateKeyframeAnimateNode(grid); + auto column6 = CreateKeyframeAnimateNode(grid); + + // duration curve index test + button->RegisterOnClick([column1, column2, column3, column4, column5, column6]() { + SetKeyframeAnimateOptionsWithIndex(column1, { 0, 1, 2000, ARKUI_CURVE_LINEAR, -500, ARKUI_CURVE_LINEAR, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex(column2, { 0, 1, 0, ARKUI_CURVE_LINEAR, 1000, ARKUI_CURVE_EASE, 1, -1 }); + SetKeyframeAnimateOptionsWithIndex(column3, { 0, 1, 500, ARKUI_CURVE_LINEAR, 1000, ARKUI_CURVE_EASE, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex(column4, { 0, 1, 500, ARKUI_CURVE_LINEAR, 500, ARKUI_CURVE_LINEAR, 0, 0 }); + SetKeyframeAnimateOptionsWithIndex( + column5, { 0, 1, 1000, ARKUI_CURVE_EASE_IN, 1000, ARKUI_CURVE_EASE_OUT, 2, 4 }); + SetKeyframeAnimateOptionsWithIndex( + column6, { 0, 1, 1000, ARKUI_CURVE_EASE_IN_OUT, 1000, ARKUI_CURVE_LINEAR, 0, 100 }); + }); +} + +static void AddKeyframeAnimateOptionDelayChild(Component* column) +{ + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button2"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateKeyframeAnimateNode(grid); + auto column2 = CreateKeyframeAnimateNode(grid); + auto column3 = CreateKeyframeAnimateNode(grid); + auto column4 = CreateKeyframeAnimateNode(grid); + auto column5 = CreateKeyframeAnimateNode(grid); + auto column6 = CreateKeyframeAnimateNode(grid); + + // delay curve test + button->RegisterOnClick([column1, column2, column3, column4, column5, column6]() { + SetKeyframeAnimateOptionsWithIndex( + column1, { -500, 1, 1000, ARKUI_CURVE_LINEAR, 1000, ARKUI_CURVE_FAST_OUT_SLOW_IN, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex( + column2, { -3000, 1, 0, ARKUI_CURVE_LINEAR, 1000, ARKUI_CURVE_LINEAR, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex( + column3, { 0, 1, 1000, ARKUI_CURVE_LINEAR_OUT_SLOW_IN, 1000, ARKUI_CURVE_FAST_OUT_LINEAR_IN, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex( + column4, { 500, 1, 1000, ARKUI_CURVE_EXTREME_DECELERATION, 1000, ARKUI_CURVE_SHARP, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex(column5, { 0, 1, 1000, ARKUI_CURVE_RHYTHM, 1000, ARKUI_CURVE_SMOOTH, 0, 1 }); + SetKeyframeAnimateOptionsWithoutCurve(column6, 0, 1, 1000, 0); + }); +} + +static void AddKeyframeAnimateOptionIterationsChild(Component* column) +{ + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button3"); + column->AddChild(button); + + auto grid = std::make_shared(); + grid->SetGridColumnsGap(30); + grid->SetGridRowsGap(30); + column->AddChild(grid); + auto column1 = CreateKeyframeAnimateNode(grid); + auto column2 = CreateKeyframeAnimateNode(grid); + auto column3 = CreateKeyframeAnimateNode(grid); + auto column4 = CreateKeyframeAnimateNode(grid); + auto column5 = CreateKeyframeAnimateNode(grid); + auto column6 = CreateKeyframeAnimateNode(grid); + + // iterations curve dispose test + button->RegisterOnClick([column1, column2, column3, column4, column5, column6]() { + SetKeyframeAnimateOptionsWithIndex( + column1, { 0, 1, 500, ARKUI_CURVE_FRICTION, 500, ARKUI_CURVE_FRICTION, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex(column2, { 0, -1, 500, ARKUI_CURVE_LINEAR, 500, ARKUI_CURVE_LINEAR, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex(column3, { 0, 0, 500, ARKUI_CURVE_LINEAR, 500, ARKUI_CURVE_LINEAR, 0, 1 }); + SetKeyframeAnimateOptionsWithIndex(column4, { 0, 3, 500, ARKUI_CURVE_LINEAR, 500, ARKUI_CURVE_LINEAR, 0, 1 }); + SetKeyframeAnimateOptionsDispose(column5); + SetKeyframeAnimateOptionsNullptr(column6); + }); +} + +napi_value KeyframeAnimateOptionTest::CreateNativeNodeDuration(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "CreateNativeNodeDuration"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + AddKeyframeAnimateOptionDurationChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value KeyframeAnimateOptionTest::CreateNativeNodeDelay(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "CreateNativeNodeDelay"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + AddKeyframeAnimateOptionDelayChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value KeyframeAnimateOptionTest::CreateNativeNodeIterations(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "CreateNativeNodeIterations"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new Component(ARKUI_NODE_COLUMN); + AddKeyframeAnimateOptionIterationsChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "KeyframeAnimateOptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_keyframeanimateoption_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_keyframeanimateoption_test.h new file mode 100644 index 0000000000000000000000000000000000000000..eae8ea111133940017af2653e0dbc5c085af372d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/animation/animate_keyframeanimateoption_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ANIMATE_KEYFRAMEANIMATEOPTION_TEST_H +#define ARKUI_CAPI_DEMO_ANIMATE_KEYFRAMEANIMATEOPTION_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" +#include "component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class KeyframeAnimateOptionTest { +public: + ~KeyframeAnimateOptionTest(); + static napi_value CreateNativeNodeDuration(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeDelay(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeIterations(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ANIMATE_KEYFRAMEANIMATEOPTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/attributesetting/attribute_setting_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/attributesetting/attribute_setting_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa1aec134e3051e0c8546cd63f2a62ab58e67313 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/attributesetting/attribute_setting_test.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "attribute_setting_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "radio_component.h" +#include "row_component.h" +#include "text_component.h" + +#define COLUMN_ID 2020 +#define TEXT_ID 2121 +#define Dotted 0 +#define Dashed 1 +#define Solid 2 + +namespace ArkUICApiDemo { +napi_value AttributeSettingTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AttributeSettingTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AttributeSettingTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto parentColumn = new ColumnComponent(); + auto button = new ButtonComponent(); + button->SetLable("reset"); + button->SetWidth(150); + button->SetHeight(80); + button->SetBackgroundColor(COLOR_GRAY); + button->SetMargin(10); + button->SetId("reset"); + + auto rowText = new RowComponent(); + auto button1 = new ButtonComponent(); + button1->SetWidth(200); + button1->SetHeight(100); + button1->SetBorderWidth(10); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_GREEN); + rowText->AddChild(std::shared_ptr(button1)); + + auto rowRadio = new RowComponent(); + auto radio = new RadioComponent(); + radio->SetWidth(80); + radio->SetHeight(40); + radio->SetChecked(true); + radio->SetMargin(10); + radio->SetGroup("group1"); + rowRadio->AddChild(std::shared_ptr(radio)); + + button->RegisterOnClick([nodeAPI, rowText, rowRadio, button1, radio]() { + auto button_copyAttr = new ButtonComponent(); + auto button_width = button1->getAttribute(NODE_WIDTH); + button_copyAttr->setAttribute(NODE_WIDTH, button_width); + auto button_height = button1->getAttribute(NODE_HEIGHT); + button_copyAttr->setAttribute(NODE_HEIGHT, button_height); + auto button_borderWidth = button1->getAttribute(NODE_BORDER_WIDTH); + button_copyAttr->setAttribute(NODE_BORDER_WIDTH, button_borderWidth); + rowText->AddChild(std::shared_ptr(button_copyAttr)); + + // reset button and radio + button1->resetAttribute(NODE_BACKGROUND_COLOR); + button1->resetAttribute(NODE_BORDER_WIDTH); + radio->resetAttribute(NODE_RADIO_CHECKED); + }); + + parentColumn->AddChild(std::shared_ptr(button)); + parentColumn->AddChild(std::shared_ptr(rowText)); + parentColumn->AddChild(std::shared_ptr(rowRadio)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AttributeSettingTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/attributesetting/attribute_setting_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/attributesetting/attribute_setting_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e5f7d0f0b77052e90eaf188887859b706a375887 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/attributesetting/attribute_setting_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ATTRIBUTE_SETTING_TEST_H +#define ARKUI_CAPI_DEMO_ATTRIBUTE_SETTING_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class AttributeSettingTest { +public: + ~AttributeSettingTest(); + // testAttributeSetting001 + // setAttribute,resetAttribute,getAttribute + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ATTRIBUTE_SETTING_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/button/button_type_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/button/button_type_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..575e7fc7e2fd0ca4285389211c96a17bd0fc1991 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/button/button_type_test.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "button_type_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetButtonType(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t type) +{ + ArkUI_NumberValue value[] = { { .i32 = type } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BUTTON_TYPE, &item); + return nodeHandle; +} + +static auto SetFontSize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float size) +{ + ArkUI_NumberValue value[] = { { .f32 = size } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &item); + return nodeHandle; +} + +static auto SetButtonLabel(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* label) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_200); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetFontSize(nodeAPI, nodeHandle, SIZE_20); + ArkUI_AttributeItem item = {}; + item.string = label; + nodeAPI->setAttribute(nodeHandle, NODE_BUTTON_LABEL, &item); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t type) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_200); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetButtonType(nodeAPI, nodeHandle, type); + return nodeHandle; +} + +static auto CreateParentNode() +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button2 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button3 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button4 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button5 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button6 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button7 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button8 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button9 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button1); + nodeAPI->addChild(column, button2); + nodeAPI->addChild(column, button3); + nodeAPI->addChild(column, button4); + nodeAPI->addChild(column, button5); + nodeAPI->addChild(column, button6); + nodeAPI->addChild(column, button7); + nodeAPI->addChild(column, button8); + nodeAPI->addChild(column, button9); + button1 = SetButton(nodeAPI, button1, ARKUI_BUTTON_TYPE_NORMAL); + button2 = SetButton(nodeAPI, button2, ARKUI_BUTTON_TYPE_CAPSULE); + button3 = SetButton(nodeAPI, button3, ARKUI_BUTTON_TYPE_CIRCLE); + button4 = SetButton(nodeAPI, button4, PARAM_NEGATIVE_1); + button5 = SetButton(nodeAPI, button5, PARAM_3); + button6 = SetButton(nodeAPI, button6, ARKUI_BUTTON_TYPE_NORMAL); + nodeAPI->resetAttribute(button6, NODE_BUTTON_TYPE); + button7 = SetButtonLabel(nodeAPI, button7, "label"); + button8 = SetButtonLabel(nodeAPI, button8, "long_label_long_label_long_label_long_label"); + button9 = SetButtonLabel(nodeAPI, button9, ""); + return column; +} + +napi_value ButtonTypeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonTypeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonTypeTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = CreateParentNode(); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonTypeTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/button/button_type_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/button/button_type_test.h new file mode 100644 index 0000000000000000000000000000000000000000..232c88e6e97585079d08232f196321179bcc036b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/button/button_type_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_BUTTON_TYPE_TEST_H +#define ARKUI_CAPI_DEMO_BUTTON_TYPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_20 20 + +class ButtonTypeTest { +public: + ~ButtonTypeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_BUTTON_TYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_hint_radius_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_hint_radius_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f628f4d5fe91ac8dee392c4992e36056d101dc06 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_hint_radius_test.cpp @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "calendarpicker_hint_radius_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +#define YEAR 2024 +#define MONTH 1 +#define DATE 1 + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto SetDate(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + ArkUI_NumberValue value[] = { { .u32 = YEAR }, { .u32 = MONTH }, { .u32 = DATE } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_CALENDAR_PICKER_SELECTED_DATE, &item); + return nodeHandle; +} + +static auto SetRadius(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float radius) +{ + ArkUI_NumberValue value[] = { { .f32 = radius } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_CALENDAR_PICKER_HINT_RADIUS, &item); + return nodeHandle; +} + +static auto SetCalendar(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float radius, const char* id) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetDate(nodeAPI, nodeHandle); + nodeHandle = SetRadius(nodeAPI, nodeHandle, radius); + nodeHandle = SetId(nodeAPI, nodeHandle, id); + return nodeHandle; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker1 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker1); + calendarPicker1 = SetCalendar(nodeAPI, calendarPicker1, PARAM_0, "calendarPicker1"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker2 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker2); + calendarPicker2 = SetCalendar(nodeAPI, calendarPicker2, PARAM_1, "calendarPicker2"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage3"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker3 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker3); + calendarPicker3 = SetCalendar(nodeAPI, calendarPicker3, PARAM_10, "calendarPicker3"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage4(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage4"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker4 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker4); + calendarPicker4 = SetCalendar(nodeAPI, calendarPicker4, 15.999, "calendarPicker4"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage5(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage5"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker5 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker5); + calendarPicker5 = SetCalendar(nodeAPI, calendarPicker5, 16.0, "calendarPicker5"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage6(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage6"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker6 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker6); + calendarPicker6 = SetCalendar(nodeAPI, calendarPicker6, 1000, "calendarPicker6"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage7(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage7"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker7 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker7); + calendarPicker7 = SetCalendar(nodeAPI, calendarPicker7, -1, "calendarPicker7"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerHintRadiusTest::CreateNativeNodePage8(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "CreateNativeNodePage8"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker8 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker8); + calendarPicker8 = SetCalendar(nodeAPI, calendarPicker8, 16.0, "calendarPicker8"); + nodeAPI->resetAttribute(calendarPicker8, NODE_CALENDAR_PICKER_HINT_RADIUS); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerHintRadiusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_hint_radius_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_hint_radius_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a86fdcea7cbd3b2e977f96e554f96826fc97bf99 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_hint_radius_test.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CALENDARPICKER_HINT_RADIUS_TEST_H +#define ARKUI_CAPI_DEMO_CALENDARPICKER_HINT_RADIUS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CalendarPickerHintRadiusTest { +public: + ~CalendarPickerHintRadiusTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage4(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage5(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage6(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage7(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage8(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CALENDARPICKER_HINT_RADIUS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_selected_date_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_selected_date_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e973054705e00f4b18e03ce051c32ded1e2d27e6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_selected_date_test.cpp @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "calendarpicker_selected_date_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "commonattrs/commonattrs_outlinecolor_test.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetDate( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t year, uint32_t month, uint32_t date) +{ + ArkUI_NumberValue value[] = { { .u32 = year }, { .u32 = month }, { .u32 = date } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_CALENDAR_PICKER_SELECTED_DATE, &item); + return nodeHandle; +} + +static auto SetCalendar(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t year, uint32_t month, + uint32_t date, const char* id) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetDate(nodeAPI, nodeHandle, year, month, date); + nodeHandle = SetId(nodeAPI, nodeHandle, id); + return nodeHandle; +} + +napi_value CalendarPickerSelectedDateTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "CreateNativeNodePage1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker1 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker1); + calendarPicker1 = SetCalendar(nodeAPI, calendarPicker1, 2024, 1, 1, "calendarPicker1"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerSelectedDateTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "CreateNativeNodePage2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker2 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker2); + calendarPicker2 = SetCalendar(nodeAPI, calendarPicker2, 0, 0, 0, "calendarPicker2"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerSelectedDateTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "CreateNativeNodePage3"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker3 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker3); + calendarPicker3 = SetCalendar(nodeAPI, calendarPicker3, 2024, 16, 36, "calendarPicker3"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CalendarPickerSelectedDateTest::CreateNativeNodePage4(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "CreateNativeNodePage5"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto calendarPicker4 = nodeAPI->createNode(ARKUI_NODE_CALENDAR_PICKER); + nodeAPI->addChild(column, calendarPicker4); + calendarPicker4 = SetCalendar(nodeAPI, calendarPicker4, 2024, 1, 1, "calendarPicker4"); + nodeAPI->resetAttribute(calendarPicker4, NODE_CALENDAR_PICKER_SELECTED_DATE); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CalendarPickerSelectedDateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_selected_date_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_selected_date_test.h new file mode 100644 index 0000000000000000000000000000000000000000..51471c27f47a6c61f54d930a0ddd1eaa73f5c617 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/calendarpicker/calendarpicker_selected_date_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CALENDARPICKER_SELECTED_DATE_TEST_H +#define ARKUI_CAPI_DEMO_CALENDARPICKER_SELECTED_DATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CalendarPickerSelectedDateTest { +public: + ~CalendarPickerSelectedDateTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage4(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CALENDARPICKER_SELECTED_DATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/column/column_align_items_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_align_items_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b8f1dda77a307162a24ec20f25bd64dcb176aab0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_align_items_test.cpp @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "column_align_items_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t horizontalAlign) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + // set AlignItems + ArkUI_NumberValue alignItems_value[] = { { .i32 = horizontalAlign } }; + ArkUI_AttributeItem alignItems_item = { alignItems_value, sizeof(alignItems_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_COLUMN_ALIGN_ITEMS, &alignItems_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t horizontalAlign, int32_t flexAlign) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + // set AlignItems + ArkUI_NumberValue alignItems_value[] = { { .i32 = horizontalAlign } }; + ArkUI_AttributeItem alignItems_item = { alignItems_value, sizeof(alignItems_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_COLUMN_ALIGN_ITEMS, &alignItems_item); + // set justifyContent + ArkUI_NumberValue justifyContent_value[] = { { .i32 = flexAlign } }; + ArkUI_AttributeItem justifyContent_item = { justifyContent_value, + sizeof(justifyContent_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_COLUMN_JUSTIFY_CONTENT, &justifyContent_item); + return nodeHandle; +} +napi_value ColumnAlignItemsTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnAlignItemsTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnAlignItemsTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto columnStart = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_START); + auto columnCenter = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_CENTER); + auto columnEnd = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_END); + auto columnSpaceError = createColumnNode(nodeAPI, -1); + nodeAPI->addChild(parentColumn, columnStart); + nodeAPI->addChild(parentColumn, columnCenter); + nodeAPI->addChild(parentColumn, columnEnd); + nodeAPI->addChild(parentColumn, columnSpaceError); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnAlignItemsTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ColumnAlignItemsTest::CreateMoreAttributeNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnAlignItemsTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnAlignItemsTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_START, ARKUI_FLEX_ALIGNMENT_END); + auto column2 = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_CENTER, ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN); + auto column3 = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_END, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY); + auto column4 = createColumnNode(nodeAPI, ARKUI_HORIZONTAL_ALIGNMENT_CENTER, ARKUI_FLEX_ALIGNMENT_SPACE_AROUND); + nodeAPI->addChild(parentColumn, column1); + nodeAPI->addChild(parentColumn, column2); + nodeAPI->addChild(parentColumn, column3); + nodeAPI->addChild(parentColumn, column4); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnAlignItemsTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/column/column_align_items_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_align_items_test.h new file mode 100644 index 0000000000000000000000000000000000000000..6aa92ee17b6c26deec5cdd717d9f90a0c44a5f63 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_align_items_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COLUMN_ALIGN_ITEMS_TEST_H +#define ARKUI_CAPI_DEMO_COLUMN_ALIGN_ITEMS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ColumnAlignItemsTest { +public: + ~ColumnAlignItemsTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateMoreAttributeNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COLUMN_ALIGN_ITEMS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/column/column_justify_content_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_justify_content_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51b01326680656ded5f784b83d818407bf04059c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_justify_content_test.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "column_justify_content_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t flexAlign) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + // set justifyContent + ArkUI_NumberValue justifyContent_value[] = { { .i32 = flexAlign } }; + ArkUI_AttributeItem justifyContent_item = { justifyContent_value, + sizeof(justifyContent_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_COLUMN_JUSTIFY_CONTENT, &justifyContent_item); + return nodeHandle; +} + +napi_value ColumnJustifyContentTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnJustifyContentTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnJustifyContentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto columnStart = createColumnNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_START); + auto columnCenter = createColumnNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_CENTER); + auto columnEnd = createColumnNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_END); + auto columnSpaceBetween = createColumnNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN); + auto columnSpaceAround = createColumnNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_SPACE_AROUND); + auto columnSpaceEvenly = createColumnNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY); + auto columnSpaceError = createColumnNode(nodeAPI, -1); + nodeAPI->addChild(parentColumn, columnStart); + nodeAPI->addChild(parentColumn, columnCenter); + nodeAPI->addChild(parentColumn, columnEnd); + nodeAPI->addChild(parentColumn, columnSpaceBetween); + nodeAPI->addChild(parentColumn, columnSpaceAround); + nodeAPI->addChild(parentColumn, columnSpaceEvenly); + nodeAPI->addChild(parentColumn, columnSpaceError); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ColumnJustifyContentTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/column/column_justify_content_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_justify_content_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f0442fc8e2a4910386bdc31dee6285841253104b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/column/column_justify_content_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COLUMN_JUSTIFY_CONTENT_TEST_H +#define ARKUI_CAPI_DEMO_COLUMN_JUSTIFY_CONTENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ColumnJustifyContentTest { +public: + ~ColumnJustifyContentTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COLUMN_JUSTIFY_CONTENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/common/common.h b/function/ui_compare/capidemo/entry/src/main/cpp/common/common.h new file mode 100644 index 0000000000000000000000000000000000000000..960c697f3d146feb6577a143e2ccac9988460112 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/common/common.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMON_TEST_H +#define ARKUI_CAPI_DEMO_COMMON_TEST_H + +#include +#include + +namespace ArkUICApiDemo { + +#define PARAM_0 0 +#define PARAM_1 1 +#define PARAM_2 2 +#define PARAM_3 3 +#define PARAM_4 4 +#define PARAM_5 5 +#define PARAM_6 6 +#define PARAM_7 7 +#define PARAM_8 8 +#define PARAM_9 9 +#define PARAM_10 10 +#define PARAM_11 11 +#define PARAM_12 12 +#define PARAM_16 16 +#define PARAM_32 32 +#define PARAM_64 64 +#define DEFAULT_MARGIN 10 +#define SIZE_4 4 +#define SIZE_5 5 +#define SIZE_10 10 +#define SIZE_30 30 +#define SIZE_40 40 +#define SIZE_50 50 +#define SIZE_70 70 +#define SIZE_100 100 +#define SIZE_120 120 +#define SIZE_150 150 +#define SIZE_180 180 +#define SIZE_200 200 +#define SIZE_230 230 +#define SIZE_250 250 +#define SIZE_300 300 +#define SIZE_350 350 +#define SIZE_400 400 +#define SIZE_450 450 +#define SIZE_500 500 +#define SIZE_600 600 +#define SIZE_800 800 +#define SIZE_1000 1000 +#define SIZE_2000 2000 +#define SIZE_3000 3000 +#define DEFAULT_VALUE_TAG 7000 +#define ENUM_ABNORMAL_VALUE 500 +#define INVALID_PARAM 401 +#define COLOR_RED 0xFFFF0000 +#define COLOR_GREEN 0xFF00FF00 +#define COLOR_BLUE 0xFF0000FF +#define COLOR_YELLOW 0xFFFFFF00 +#define COLOR_PURPLE 0xFFFF11FF +#define COLOR_PINK 0xFFFFC0CB +#define COLOR_GRAY 0xFFDDDDDD +#define COLOR_TRANSPARENT 0x00000000 +#define COLOR_BLACK 0xFF000000 +#define COLOR_WHITE 0xFFFFFFFF +#define COLOR_LIGHT_BLUE 0xFF00FFFF +#define ON_CLICK_EVENT_ID 6001 +#define ON_FOCUS_EVENT_ID 6002 +#define ON_TOUCH_EVENT_ID 6003 +#define ON_AREA_CHANGE_EVENT_ID 6004 +#define ON_APPEAR_EVENT_ID 6005 +#define ON_BLUR_EVENT_ID 6006 +#define ON_CHANGE_EVENT_ID 6007 +#define ON_SUBMIT_EVENT_ID 6008 +#define ON_CUT_EVENT_ID 6009 +#define ON_PASTE_EVENT_ID 6010 +#define ON_MEASURE_EVENT_ID 6011 +#define ON_LAYOUT_EVENT_ID 6012 +#define ON_DRAW_EVENT_ID 6013 +#define ON_CUSTOM_EVENT_1_ID 9001 +#define ON_CUSTOM_EVENT_2_ID 9002 +#define ON_CUSTOM_EVENT_3_ID 9003 +#define ON_CUSTOM_EVENT_4_ID 9004 +#define ON_CUSTOM_EVENT_5_ID 9005 +#define ON_CUSTOM_EVENT_6_ID 9006 +#define ON_CUSTOM_EVENT_11_ID 9011 +#define ON_CUSTOM_EVENT_12_ID 9012 +#define ON_CUSTOM_EVENT_13_ID 9013 +#define ON_CUSTOM_EVENT_14_ID 9014 +#define ON_CUSTOM_EVENT_15_ID 9015 +#define ON_CUSTOM_EVENT_16_ID 9016 +#define PARAM_NEGATIVE_1 (-1) +#define PARAM_NEGATIVE_100 (-100) +#define PARAM_NEGATIVE_5 (-5) +/** + * Log print domain. + */ +const unsigned int LOG_PRINT_DOMAIN = 0xFF00; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMON_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityrole_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityrole_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ca3180bfa33ddad532b1d0b02f288541b920ce11 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityrole_test.cpp @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_accessibilityrole_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto GetAccessibilityRole( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, ArkUI_AttributeItem item) +{ + const ArkUI_AttributeItem* role_item_ptr = nodeAPI->getAttribute(nodeHandle, NODE_ACCESSIBILITY_ROLE); + if (role_item_ptr->value[0].u32 == item.value[0].u32) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + return nodeHandle; +} + +static auto SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t role) +{ + ArkUI_NumberValue role_value[] = { { .u32 = role } }; + ArkUI_AttributeItem role_item = { role_value, sizeof(role_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_ROLE, &role_item); + nodeHandle = GetAccessibilityRole(nodeAPI, nodeHandle, role_item); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t role) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetAccessibilityRole(nodeAPI, nodeHandle, role); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateChildNode( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type, uint32_t role) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + childNode = SetText(nodeAPI, childNode, role); + return childNode; +} + +static auto CreateCaseNodeOne(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_CUSTOM); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_TEXT); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_SPAN); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_IMAGE_SPAN); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_IMAGE); + return parentNode; +} + +static auto CreateCaseNodeTwo(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_TOGGLE); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_LOADING_PROGRESS); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_TEXT_INPUT); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_TEXT_AREA); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_BUTTON); + return parentNode; +} + +static auto CreateCaseNodeThree(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_PROGRESS); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_CHECKBOX); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_XCOMPONENT); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_DATE_PICKER); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_TIME_PICKER); + return parentNode; +} + +static auto CreateCaseNodeFour(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_TEXT_PICKER); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_CALENDAR_PICKER); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_SLIDER); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_RADIO); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_IMAGE_ANIMATOR); + return parentNode; +} + +static auto CreateCaseNodeFive(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_STACK); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_SWIPER); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_SCROLL); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_LIST); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_LIST_ITEM); + return parentNode; +} + +static auto CreateCaseNodeSix(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_LIST_ITEM_GROUP); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_COLUMN); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_ROW); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_FLEX); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_REFRESH); + return parentNode; +} + +static auto CreateCaseNodeSeven(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_WATER_FLOW); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_FLOW_ITEM); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_RELATIVE_CONTAINER); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_GRID); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_GRID_ITEM); + return parentNode; +} + +static auto CreateCaseNodeEight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto text1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, ARKUI_NODE_CUSTOM_SPAN); + auto text2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, PARAM_NEGATIVE_100); + auto text3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, SIZE_20); + auto text4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, SIZE_999); + auto text5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_TEXT, SIZE_1016); + return parentNode; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row4 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row5 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row6 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row7 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row8 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + row1 = CreateCaseNodeOne(nodeAPI, row1); + row2 = CreateCaseNodeTwo(nodeAPI, row2); + row3 = CreateCaseNodeThree(nodeAPI, row3); + row4 = CreateCaseNodeFour(nodeAPI, row4); + row5 = CreateCaseNodeFive(nodeAPI, row5); + row6 = CreateCaseNodeSix(nodeAPI, row6); + row7 = CreateCaseNodeSeven(nodeAPI, row7); + row8 = CreateCaseNodeEight(nodeAPI, row8); + return column; +} + +napi_value CommonAttrsAccessibilityRoleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityRoleTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityRoleTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityRoleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityrole_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityrole_test.h new file mode 100644 index 0000000000000000000000000000000000000000..95cce6659a4a8b9d559e23794ce6324904bfb06a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityrole_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYROLE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYROLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_20 20 +#define SIZE_999 999 +#define SIZE_1016 1016 + +class CommonAttrsAccessibilityRoleTest { +public: + ~CommonAttrsAccessibilityRoleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYROLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilitystate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilitystate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ef2bd0fa852ed035e76cb635bd617cb239e4236 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilitystate_test.cpp @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_accessibilitystate_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetDisabledAccessibilityState( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t isDisabled) +{ + ArkUI_AccessibilityState* state = OH_ArkUI_AccessibilityState_Create(); + ArkUI_AttributeItem item = {}; + item.object = state; + OH_ArkUI_AccessibilityState_SetDisabled(state, isDisabled); + if (OH_ArkUI_AccessibilityState_IsDisabled(state) == isDisabled) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_STATE, &item); + return nodeHandle; +} + +static auto SetSelectedAccessibilityState( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t isSelected) +{ + ArkUI_AccessibilityState* state = OH_ArkUI_AccessibilityState_Create(); + ArkUI_AttributeItem item = {}; + item.object = state; + OH_ArkUI_AccessibilityState_SetSelected(state, isSelected); + if (OH_ArkUI_AccessibilityState_IsSelected(state) == isSelected) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_STATE, &item); + return nodeHandle; +} + +static auto SetCheckedStateAccessibilityState( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t isCheckedState) +{ + ArkUI_AccessibilityState* state = OH_ArkUI_AccessibilityState_Create(); + ArkUI_AttributeItem item = {}; + item.object = state; + OH_ArkUI_AccessibilityState_SetCheckedState(state, isCheckedState); + if (OH_ArkUI_AccessibilityState_GetCheckedState(state) == isCheckedState) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_STATE, &item); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateChildNodeText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + childNode = SetText(nodeAPI, childNode); + return childNode; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto text1 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text2 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text3 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text4 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text5 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text6 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text7 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text8 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text9 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text10 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text11 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text12 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + + text1 = SetDisabledAccessibilityState(nodeAPI, text1, PARAM_1); + text2 = SetDisabledAccessibilityState(nodeAPI, text2, PARAM_0); + text3 = SetDisabledAccessibilityState(nodeAPI, text3, PARAM_2); + text4 = SetDisabledAccessibilityState(nodeAPI, text4, PARAM_NEGATIVE_1); + text5 = SetSelectedAccessibilityState(nodeAPI, text5, PARAM_1); + text6 = SetSelectedAccessibilityState(nodeAPI, text6, PARAM_0); + text7 = SetSelectedAccessibilityState(nodeAPI, text7, PARAM_2); + text8 = SetSelectedAccessibilityState(nodeAPI, text8, PARAM_NEGATIVE_1); + text9 = SetCheckedStateAccessibilityState(nodeAPI, text9, PARAM_1); + text10 = SetCheckedStateAccessibilityState(nodeAPI, text10, PARAM_0); + text11 = SetCheckedStateAccessibilityState(nodeAPI, text11, PARAM_2); + text12 = SetCheckedStateAccessibilityState(nodeAPI, text12, PARAM_NEGATIVE_1); + return column; +} + +napi_value CommonAttrsAccessibilityStateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityStateTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityStateTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityStateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilitystate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilitystate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f043a3182b9a045723f030d7e0b3fd8fa1f29471 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilitystate_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYSTATE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYSTATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsAccessibilityStateTest { +public: + ~CommonAttrsAccessibilityStateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYSTATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityvalue_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityvalue_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..db1133d5efd2354989c6f73d411b3b33a415b054 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityvalue_test.cpp @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_accessibilityvalue_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetMinAccessibilityValue(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t min) +{ + ArkUI_AccessibilityValue* value = OH_ArkUI_AccessibilityValue_Create(); + ArkUI_AttributeItem item = {}; + item.object = value; + OH_ArkUI_AccessibilityValue_SetMin(value, min); + if (OH_ArkUI_AccessibilityValue_GetMin(value) == min) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_VALUE, &item); + return nodeHandle; +} + +static auto SetMaxAccessibilityValue(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t max) +{ + ArkUI_AccessibilityValue* value = OH_ArkUI_AccessibilityValue_Create(); + ArkUI_AttributeItem item = {}; + item.object = value; + OH_ArkUI_AccessibilityValue_SetMax(value, max); + if (OH_ArkUI_AccessibilityValue_GetMax(value) == max) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_VALUE, &item); + return nodeHandle; +} + +static auto SetCurrentAccessibilityValue(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t current) +{ + ArkUI_AccessibilityValue* value = OH_ArkUI_AccessibilityValue_Create(); + ArkUI_AttributeItem item = {}; + item.object = value; + OH_ArkUI_AccessibilityValue_SetCurrent(value, current); + if (OH_ArkUI_AccessibilityValue_GetCurrent(value) == current) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_VALUE, &item); + return nodeHandle; +} + +static auto SetTextAccessibilityValue(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* text) +{ + ArkUI_AccessibilityValue* value = OH_ArkUI_AccessibilityValue_Create(); + ArkUI_AttributeItem item = {}; + item.object = value; + OH_ArkUI_AccessibilityValue_SetText(value, text); + const char* getText = OH_ArkUI_AccessibilityValue_GetText(value); + if (strcmp(text, getText) == 0) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + nodeAPI->setAttribute(nodeHandle, NODE_ACCESSIBILITY_VALUE, &item); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateChildNodeText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + childNode = SetText(nodeAPI, childNode); + return childNode; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row4 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto text1 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text2 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text3 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text4 = CreateChildNodeText(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text5 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text6 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text7 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text8 = CreateChildNodeText(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text9 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text10 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text11 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text12 = CreateChildNodeText(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text13 = CreateChildNodeText(nodeAPI, row4, ARKUI_NODE_TEXT); + auto text14 = CreateChildNodeText(nodeAPI, row4, ARKUI_NODE_TEXT); + + text1 = SetMinAccessibilityValue(nodeAPI, text1, SIZE_100); + text2 = SetMinAccessibilityValue(nodeAPI, text2, PARAM_0); + text3 = SetMinAccessibilityValue(nodeAPI, text3, PARAM_NEGATIVE_100); + text4 = SetMinAccessibilityValue(nodeAPI, text4, SIZE_20000); + text5 = SetMaxAccessibilityValue(nodeAPI, text5, SIZE_100); + text6 = SetMaxAccessibilityValue(nodeAPI, text6, PARAM_0); + text7 = SetMaxAccessibilityValue(nodeAPI, text7, PARAM_NEGATIVE_100); + text8 = SetMaxAccessibilityValue(nodeAPI, text8, SIZE_20000); + text9 = SetCurrentAccessibilityValue(nodeAPI, text9, SIZE_100); + text10 = SetCurrentAccessibilityValue(nodeAPI, text10, PARAM_0); + text11 = SetCurrentAccessibilityValue(nodeAPI, text11, PARAM_NEGATIVE_100); + text12 = SetCurrentAccessibilityValue(nodeAPI, text12, SIZE_20000); + text13 = SetTextAccessibilityValue(nodeAPI, text13, + "Hello, World!,h e l l o,!@#$%^&*()_+,1234567890,你好,世界,'example', " + "\"example\"Carriage return: \r,Newline character:\n, tab character: \t"); + text14 = SetTextAccessibilityValue(nodeAPI, text14, ""); + + return column; +} + +napi_value CommonAttrsAccessibilityValueTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityValueTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityValueTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityValueTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityvalue_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityvalue_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7a0510d864645a4ed06d3e18ea361159ca825483 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_accessibilityvalue_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYVALUE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYVALUE_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_20000 20000 + +class CommonAttrsAccessibilityValueTest { +public: + ~CommonAttrsAccessibilityValueTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ACCESSIBILITYVALUE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_alignment_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_alignment_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0deabf5af1d79c49722111ce2d647ea3047ff0d5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_alignment_test.cpp @@ -0,0 +1,381 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_alignment_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetAlignment(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, int32_t align) +{ + ArkUI_NumberValue value[] = { { .i32 = align } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ALIGNMENT, &item); + return nodeHandle; +} + +static auto SetContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + return nodeHandle; +} + +static auto SetStack(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t align) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_90); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_90); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetAlignment(nodeAPI, nodeHandle, align); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float size) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, size); + nodeHandle = SetHeight(nodeAPI, nodeHandle, size); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float size, int32_t align) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, size); + nodeHandle = SetHeight(nodeAPI, nodeHandle, size); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetAlignment(nodeAPI, nodeHandle, align); + nodeHandle = SetContent(nodeAPI, nodeHandle, "AA"); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateChildNodeButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + childNode = SetButton(nodeAPI, childNode); + return childNode; +} + +static auto CreateChildNodeText( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type, float size) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + childNode = SetText(nodeAPI, childNode, size); + return childNode; +} + +static auto CreateParentNodePage1(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row4 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto stack1 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_STACK); + auto stack2 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_STACK); + auto stack3 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_STACK); + auto stack4 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_STACK); + auto stack5 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_STACK); + auto stack6 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_STACK); + auto stack7 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_STACK); + auto stack8 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_STACK); + auto stack9 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_STACK); + auto stack10 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_STACK); + auto stack11 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_STACK); + auto stack12 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_STACK); + auto button1 = CreateChildNodeButton(nodeAPI, stack1, ARKUI_NODE_BUTTON); + auto button2 = CreateChildNodeButton(nodeAPI, stack2, ARKUI_NODE_BUTTON); + auto button3 = CreateChildNodeButton(nodeAPI, stack3, ARKUI_NODE_BUTTON); + auto button4 = CreateChildNodeButton(nodeAPI, stack4, ARKUI_NODE_BUTTON); + auto button5 = CreateChildNodeButton(nodeAPI, stack5, ARKUI_NODE_BUTTON); + auto button6 = CreateChildNodeButton(nodeAPI, stack6, ARKUI_NODE_BUTTON); + auto button7 = CreateChildNodeButton(nodeAPI, stack7, ARKUI_NODE_BUTTON); + auto button8 = CreateChildNodeButton(nodeAPI, stack8, ARKUI_NODE_BUTTON); + auto button9 = CreateChildNodeButton(nodeAPI, stack9, ARKUI_NODE_BUTTON); + auto button10 = CreateChildNodeButton(nodeAPI, stack10, ARKUI_NODE_BUTTON); + auto button11 = CreateChildNodeButton(nodeAPI, stack11, ARKUI_NODE_BUTTON); + auto button12 = CreateChildNodeButton(nodeAPI, stack12, ARKUI_NODE_BUTTON); + stack1 = SetStack(nodeAPI, stack1, ARKUI_ALIGNMENT_TOP_START); + stack2 = SetStack(nodeAPI, stack2, ARKUI_ALIGNMENT_TOP); + stack3 = SetStack(nodeAPI, stack3, ARKUI_ALIGNMENT_TOP_END); + stack4 = SetStack(nodeAPI, stack4, ARKUI_ALIGNMENT_START); + stack5 = SetStack(nodeAPI, stack5, ARKUI_ALIGNMENT_CENTER); + stack6 = SetStack(nodeAPI, stack6, ARKUI_ALIGNMENT_END); + stack7 = SetStack(nodeAPI, stack7, ARKUI_ALIGNMENT_BOTTOM_START); + stack8 = SetStack(nodeAPI, stack8, ARKUI_ALIGNMENT_BOTTOM); + stack9 = SetStack(nodeAPI, stack9, ARKUI_ALIGNMENT_BOTTOM_END); + stack10 = SetStack(nodeAPI, stack10, PARAM_NEGATIVE_1); + stack11 = SetStack(nodeAPI, stack11, PARAM_9); + stack12 = SetStack(nodeAPI, stack12, ARKUI_ALIGNMENT_TOP_START); + nodeAPI->resetAttribute(stack12, NODE_ALIGNMENT); + return column; +} + +static auto CreateParentNodePage2(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row4 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto stack1 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_STACK); + auto stack2 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_STACK); + auto stack3 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_STACK); + auto stack4 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_STACK); + auto stack5 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_STACK); + auto stack6 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_STACK); + auto stack7 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_STACK); + auto stack8 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_STACK); + auto stack9 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_STACK); + auto stack10 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_STACK); + auto stack11 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_STACK); + auto stack12 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_STACK); + auto text1 = CreateChildNodeText(nodeAPI, stack1, ARKUI_NODE_TEXT, SIZE_30); + auto text2 = CreateChildNodeText(nodeAPI, stack2, ARKUI_NODE_TEXT, SIZE_30); + auto text3 = CreateChildNodeText(nodeAPI, stack3, ARKUI_NODE_TEXT, SIZE_30); + auto text4 = CreateChildNodeText(nodeAPI, stack4, ARKUI_NODE_TEXT, SIZE_30); + auto text5 = CreateChildNodeText(nodeAPI, stack5, ARKUI_NODE_TEXT, SIZE_30); + auto text6 = CreateChildNodeText(nodeAPI, stack6, ARKUI_NODE_TEXT, SIZE_30); + auto text7 = CreateChildNodeText(nodeAPI, stack7, ARKUI_NODE_TEXT, SIZE_30); + auto text8 = CreateChildNodeText(nodeAPI, stack8, ARKUI_NODE_TEXT, SIZE_30); + auto text9 = CreateChildNodeText(nodeAPI, stack9, ARKUI_NODE_TEXT, SIZE_30); + auto text10 = CreateChildNodeText(nodeAPI, stack10, ARKUI_NODE_TEXT, SIZE_30); + auto text11 = CreateChildNodeText(nodeAPI, stack11, ARKUI_NODE_TEXT, SIZE_30); + auto text12 = CreateChildNodeText(nodeAPI, stack12, ARKUI_NODE_TEXT, SIZE_30); + stack1 = SetStack(nodeAPI, stack1, ARKUI_ALIGNMENT_TOP_START); + stack2 = SetStack(nodeAPI, stack2, ARKUI_ALIGNMENT_TOP); + stack3 = SetStack(nodeAPI, stack3, ARKUI_ALIGNMENT_TOP_END); + stack4 = SetStack(nodeAPI, stack4, ARKUI_ALIGNMENT_START); + stack5 = SetStack(nodeAPI, stack5, ARKUI_ALIGNMENT_CENTER); + stack6 = SetStack(nodeAPI, stack6, ARKUI_ALIGNMENT_END); + stack7 = SetStack(nodeAPI, stack7, ARKUI_ALIGNMENT_BOTTOM_START); + stack8 = SetStack(nodeAPI, stack8, ARKUI_ALIGNMENT_BOTTOM); + stack9 = SetStack(nodeAPI, stack9, ARKUI_ALIGNMENT_BOTTOM_END); + stack10 = SetStack(nodeAPI, stack10, PARAM_NEGATIVE_1); + stack11 = SetStack(nodeAPI, stack11, PARAM_9); + stack12 = SetStack(nodeAPI, stack12, ARKUI_ALIGNMENT_TOP_START); + nodeAPI->resetAttribute(stack12, NODE_ALIGNMENT); + return column; +} + +static auto CreateParentNodePage3(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto row4 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto text1 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text2 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text3 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_TEXT); + auto text4 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text5 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text6 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_TEXT); + auto text7 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text8 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text9 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_TEXT); + auto text10 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_TEXT); + auto text11 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_TEXT); + auto text12 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_TEXT); + text1 = SetText(nodeAPI, text1, SIZE_90, ARKUI_ALIGNMENT_TOP_START); + text2 = SetText(nodeAPI, text2, SIZE_90, ARKUI_ALIGNMENT_TOP); + text3 = SetText(nodeAPI, text3, SIZE_90, ARKUI_ALIGNMENT_TOP_END); + text4 = SetText(nodeAPI, text4, SIZE_90, ARKUI_ALIGNMENT_START); + text5 = SetText(nodeAPI, text5, SIZE_90, ARKUI_ALIGNMENT_CENTER); + text6 = SetText(nodeAPI, text6, SIZE_90, ARKUI_ALIGNMENT_END); + text7 = SetText(nodeAPI, text7, SIZE_90, ARKUI_ALIGNMENT_BOTTOM_START); + text8 = SetText(nodeAPI, text8, SIZE_90, ARKUI_ALIGNMENT_BOTTOM); + text9 = SetText(nodeAPI, text9, SIZE_90, ARKUI_ALIGNMENT_BOTTOM_END); + text10 = SetText(nodeAPI, text10, SIZE_90, PARAM_NEGATIVE_1); + text11 = SetText(nodeAPI, text11, SIZE_90, PARAM_9); + text12 = SetText(nodeAPI, text12, SIZE_90, ARKUI_ALIGNMENT_TOP_START); + nodeAPI->resetAttribute(text12, NODE_ALIGNMENT); + return column; +} + +napi_value CommonAttrsAlignmentTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNodePage1(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsAlignmentTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNodePage2(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsAlignmentTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNodePage3(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAlignmentTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_alignment_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_alignment_test.h new file mode 100644 index 0000000000000000000000000000000000000000..6b983abb75d2f7c3192dcd06837a1ec030fe05fe --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_alignment_test.h @@ -0,0 +1,39 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ALIGNMENT_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ALIGNMENT_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_90 90 + +class CommonAttrsAlignmentTest { +public: + ~CommonAttrsAlignmentTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ALIGNMENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_aspectratio_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_aspectratio_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a573895742b89893155ea305874b52c1fa87d3aa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_aspectratio_test.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_aspectratio_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateColumnWithAspectRatio(float aspectRatio) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsAspectRatioTest", "CreateColumnWithAspectRatio"); + + auto column = std::make_shared(); + column->SetWidth(SIZE_100); + column->SetHeight(SIZE_100); + column->SetBackgroundColor(COLOR_RED); + column->SetMargin(DEFAULT_MARGIN); + ArkUI_NumberValue aspectratio_value[] = { { .f32 = aspectRatio } }; + ArkUI_AttributeItem aspectratio_item = { aspectratio_value, + sizeof(aspectratio_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_ASPECT_RATIO, &aspectratio_item); + + return column; +} + +napi_value CommonAttrsAspectRatioTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsAspectRatioTest", "CreateNativeNode"); + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAspectRatioTest", "GetContext env or info is null"); + return nullptr; + } + + auto column1 = CreateColumnWithAspectRatio(-5); + auto column2 = CreateColumnWithAspectRatio(0); + auto column3 = CreateColumnWithAspectRatio(0.5); + auto column4 = CreateColumnWithAspectRatio(2); + auto column5 = CreateColumnWithAspectRatio(20); + auto column6 = CreateColumnWithAspectRatio(2); + column6->resetAttribute(NODE_ASPECT_RATIO); + + auto column = new ColumnComponent(); + column->AddChild(column1); + column->AddChild(column2); + column->AddChild(column3); + column->AddChild(column4); + column->AddChild(column5); + column->AddChild(column6); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAspectRatioTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_aspectratio_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_aspectratio_test.h new file mode 100644 index 0000000000000000000000000000000000000000..1060ac8c5e349c569c25abbfce04eb9ec792b130 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_aspectratio_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ASPECT_RATIO_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ASPECT_RATIO_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsAspectRatioTest { +public: + ~CommonAttrsAspectRatioTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ASPECT_RATIO_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundblurstyle_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundblurstyle_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ee6cf7d4e446c527ce2b6a339bcc08114fc9060a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundblurstyle_test.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_backgroundblurstyle_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateChildWithBlurStyle(int32_t blurStyle, int32_t colorMode, int32_t adaptiveColor, + float blurDegree, const std::vector& floatValues) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundBlurStyleTest", "CreateChildWithBlurStyle"); + + auto column = std::make_shared(); + column->SetWidth(80); + column->SetHeight(80); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + if (colorMode != PARAM_NEGATIVE_100 && adaptiveColor != PARAM_NEGATIVE_100) { + ArkUI_NumberValue blurstyle_value[] = { { .i32 = blurStyle }, { .i32 = colorMode }, { .i32 = adaptiveColor } }; + ArkUI_AttributeItem blurstyle_item = { blurstyle_value, sizeof(blurstyle_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_BACKGROUND_BLUR_STYLE, &blurstyle_item); + } else if (blurDegree != PARAM_NEGATIVE_100) { + ArkUI_NumberValue blurstyle_value[] = { { .i32 = blurStyle }, {}, {}, { .f32 = blurDegree } }; + ArkUI_AttributeItem blurstyle_item = { blurstyle_value, sizeof(blurstyle_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_BACKGROUND_BLUR_STYLE, &blurstyle_item); + } else if (floatValues[0] != PARAM_NEGATIVE_100 && floatValues[1] != PARAM_NEGATIVE_100) { + ArkUI_NumberValue blurstyle_value[] = { { .i32 = blurStyle }, { .i32 = ARKUI_COLOR_MODE_LIGHT }, + { .i32 = ARKUI_ADAPTIVE_COLOR_DEFAULT }, { .f32 = 1 }, { .f32 = floatValues[0] }, + { .f32 = floatValues[1] } }; + ArkUI_AttributeItem blurstyle_item = { blurstyle_value, sizeof(blurstyle_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_BACKGROUND_BLUR_STYLE, &blurstyle_item); + } else { + ArkUI_NumberValue blurstyle_value[] = { { .i32 = blurStyle } }; + ArkUI_AttributeItem blurstyle_item = { blurstyle_value, sizeof(blurstyle_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_BACKGROUND_BLUR_STYLE, &blurstyle_item); + } + + return column; +} + +static void AddBlurStyleChild(GridComponent* grid) +{ + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_REGULAR, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THICK, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_BACKGROUND_THIN, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_BACKGROUND_REGULAR, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_BACKGROUND_THICK, -100, -100, -100, { -100, -100 })); + grid->AddChild( + CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_BACKGROUND_ULTRA_THICK, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_NONE, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_COMPONENT_ULTRA_THIN, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_COMPONENT_THIN, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_COMPONENT_REGULAR, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_COMPONENT_THICK, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_COMPONENT_ULTRA_THICK, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(-1, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(13, -100, -100, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_SYSTEM, ARKUI_ADAPTIVE_COLOR_DEFAULT, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_LIGHT, ARKUI_ADAPTIVE_COLOR_DEFAULT, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_DARK, ARKUI_ADAPTIVE_COLOR_DEFAULT, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_SYSTEM, ARKUI_ADAPTIVE_COLOR_AVERAGE, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_LIGHT, ARKUI_ADAPTIVE_COLOR_AVERAGE, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_DARK, ARKUI_ADAPTIVE_COLOR_AVERAGE, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_SYSTEM, -1, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_SYSTEM, 2, -100, { -100, -100 })); + grid->AddChild( + CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -1, ARKUI_ADAPTIVE_COLOR_DEFAULT, -100, { -100, -100 })); + grid->AddChild( + CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, 3, ARKUI_ADAPTIVE_COLOR_DEFAULT, -100, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -1, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, 0, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, 0.5, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, 1, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, 2, { -100, -100 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { 0, 127 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { 0, 64 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { 64, 0 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { 64, 127 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { -1, 127 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { 127, -1 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { -1, -1 })); + grid->AddChild(CreateChildWithBlurStyle(ARKUI_BLUR_STYLE_THIN, -100, -100, -100, { 0, 150 })); +} + +napi_value CommonAttrsBackgroundBlurStyleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundBlurStyleTest", "CreateNativeNode"); + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundBlurStyleTest", + "GetContext env or info is null"); + return nullptr; + } + + auto grid = new GridComponent(); + grid->SetGridColumnsGap(5); + grid->SetGridRowsGap(5); + AddBlurStyleChild(grid); + auto column39 = CreateChildWithBlurStyle( + ARKUI_BLUR_STYLE_THIN, ARKUI_COLOR_MODE_SYSTEM, ARKUI_ADAPTIVE_COLOR_DEFAULT, 0.5, { 0, 127 }); + column39->resetAttribute(NODE_BACKGROUND_BLUR_STYLE); + grid->AddChild(column39); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), grid->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundBlurStyleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundblurstyle_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundblurstyle_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ba3aa6dd517bf3dc823f4748b4555ff4a20f839a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundblurstyle_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDBLURSTYLE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDBLURSTYLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsBackgroundBlurStyleTest { +public: + ~CommonAttrsBackgroundBlurStyleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDBLURSTYLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimage_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimage_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..91e5b3fd1dc6c0c8798431fc62c7394f9d76f525 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimage_test.cpp @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_backgroundimage_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "multimedia/image_framework/image/pixelmap_native.h" + +namespace ArkUICApiDemo { + +static auto CreateChildWithResourceStr( + ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, const char* resourceStr, int imageRepeat) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "CreateChildWithResourceStr"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = PARAM_2 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BORDER_WIDTH, &borderWidth_value_item); + + if (imageRepeat != PARAM_NEGATIVE_100) { + ArkUI_NumberValue repeat_value[] = { { .i32 = imageRepeat } }; + ArkUI_AttributeItem repeat_value_item = { repeat_value, sizeof(repeat_value) / sizeof(ArkUI_NumberValue) }; + repeat_value_item.string = resourceStr; + nodeAPI->setAttribute(column, NODE_BACKGROUND_IMAGE, &repeat_value_item); + } else { + ArkUI_AttributeItem imageStr_item = {}; + imageStr_item.string = resourceStr; + nodeAPI->setAttribute(column, NODE_BACKGROUND_IMAGE, &imageStr_item); + } + return column; +} + +static auto CreateChildWithPixelMap( + ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, OH_PixelmapNative* pixelMap, int imageRepeat) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "CreateChildWithPixelMap"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = PARAM_2 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BORDER_WIDTH, &borderWidth_value_item); + + if (imageRepeat != PARAM_NEGATIVE_100) { + ArkUI_NumberValue repeat_value[] = { { .i32 = imageRepeat } }; + ArkUI_AttributeItem repeat_value_item = { repeat_value, sizeof(repeat_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_DrawableDescriptor* drawableDescriptor = OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(pixelMap); + repeat_value_item.object = drawableDescriptor; + nodeAPI->setAttribute(column, NODE_BACKGROUND_IMAGE, &repeat_value_item); + } else { + ArkUI_AttributeItem imagePixelMap_item = {}; + ArkUI_DrawableDescriptor* drawableDescriptor = OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(pixelMap); + imagePixelMap_item.object = drawableDescriptor; + nodeAPI->setAttribute(column, NODE_BACKGROUND_IMAGE, &imagePixelMap_item); + } + return column; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "CreateParentNode"); + + auto grid = nodeAPI->createNode(ARKUI_NODE_GRID); + ArkUI_NumberValue gap_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem gap_item = { gap_value, sizeof(gap_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(grid, NODE_GRID_COLUMN_GAP, &gap_item); + nodeAPI->setAttribute(grid, NODE_GRID_ROW_GAP, &gap_item); + + return grid; +} + +static OH_PixelmapNative* CreatePixelMap() +{ + OH_Pixelmap_InitializationOptions* options = nullptr; + Image_ErrorCode ret = OH_PixelmapInitializationOptions_Create(&options); + if (ret != IMAGE_SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", + "OH_PixelmapInitializationOptions_Create failed"); + return nullptr; + } + OH_PixelmapInitializationOptions_SetWidth(options, 64); + OH_PixelmapInitializationOptions_SetHeight(options, 64); + OH_PixelmapInitializationOptions_SetPixelFormat(options, PIXEL_FORMAT_BGRA_8888); + size_t dataLength = 64 * 64 * 4; + uint8_t* data = (uint8_t*)malloc(dataLength); + if (data == nullptr) { + OH_PixelmapInitializationOptions_Release(options); + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "GetContext data is null"); + return nullptr; + } + for (int i = 0; i < dataLength;) { + data[i++] = 0; // Blue + data[i++] = 0; // Green + data[i++] = 255; // Red + data[i++] = 255; // Alpha + } + OH_PixelmapNative* pixelmap = nullptr; + ret = OH_PixelmapNative_CreatePixelmap(data, dataLength, options, &pixelmap); + if (ret != IMAGE_SUCCESS) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", + "OH_PixelmapNative_CreatePixelmap failed"); + return nullptr; + } + free(data); + OH_PixelmapInitializationOptions_Release(options); + return pixelmap; +} + +static void AddResourceStrChild(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle grid) +{ + const char* imageStr = "resource://media/icon.png"; + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, PARAM_NEGATIVE_100)); + auto column2 = CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, PARAM_NEGATIVE_100); + ArkUI_NumberValue red_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem red_color_item = { red_color_value, sizeof(red_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column2, NODE_BACKGROUND_COLOR, &red_color_item); + nodeAPI->addChild(grid, column2); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, "", PARAM_NEGATIVE_100)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, "abcdef", PARAM_NEGATIVE_100)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, -1)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, ARKUI_IMAGE_REPEAT_NONE)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, ARKUI_IMAGE_REPEAT_XY)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, 4)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 60, imageStr, -1)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 60, imageStr, ARKUI_IMAGE_REPEAT_NONE)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 60, imageStr, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 60, imageStr, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 60, imageStr, ARKUI_IMAGE_REPEAT_XY)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 60, imageStr, 4)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 60, imageStr, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 60, imageStr, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 100, 60, imageStr, ARKUI_IMAGE_REPEAT_XY)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 100, imageStr, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 100, imageStr, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithResourceStr(nodeAPI, 60, 100, imageStr, ARKUI_IMAGE_REPEAT_XY)); + auto column23 = CreateChildWithResourceStr(nodeAPI, 100, 100, imageStr, ARKUI_IMAGE_REPEAT_X); + nodeAPI->resetAttribute(column23, NODE_BACKGROUND_IMAGE); + nodeAPI->addChild(grid, column23); +} + +static void AddPixelMapChild(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle grid) +{ + auto pixelmap = CreatePixelMap(); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, nullptr, PARAM_NEGATIVE_100)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, PARAM_NEGATIVE_100)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, -1)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, ARKUI_IMAGE_REPEAT_NONE)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, ARKUI_IMAGE_REPEAT_XY)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, 4)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 40, pixelmap, -1)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 40, pixelmap, ARKUI_IMAGE_REPEAT_NONE)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 40, pixelmap, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 40, pixelmap, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 40, pixelmap, ARKUI_IMAGE_REPEAT_XY)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 40, pixelmap, 4)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 40, pixelmap, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 40, pixelmap, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 100, 40, pixelmap, ARKUI_IMAGE_REPEAT_XY)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 100, pixelmap, ARKUI_IMAGE_REPEAT_X)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 100, pixelmap, ARKUI_IMAGE_REPEAT_Y)); + nodeAPI->addChild(grid, CreateChildWithPixelMap(nodeAPI, 40, 100, pixelmap, ARKUI_IMAGE_REPEAT_XY)); + auto column21 = CreateChildWithPixelMap(nodeAPI, 100, 100, pixelmap, ARKUI_IMAGE_REPEAT_X); + nodeAPI->resetAttribute(column21, NODE_BACKGROUND_IMAGE); + nodeAPI->addChild(grid, column21); + OH_PixelmapNative_Release(pixelmap); +} + +napi_value CommonAttrsBackgroundImageTest::CreateNativeNodeResourceStr(napi_env env, napi_callback_info info) +{ + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "CreateNativeNodeResourceStr"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto grid = CreateParentNode(nodeAPI); + AddResourceStrChild(nodeAPI, grid); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), grid) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsBackgroundImageTest::CreateNativeNodePixelMap(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "CreateNativeNodePixelMap"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto grid = CreateParentNode(nodeAPI); + AddPixelMapChild(nodeAPI, grid); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), grid) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimage_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimage_test.h new file mode 100644 index 0000000000000000000000000000000000000000..6c38e5e10204f2bf346959020cfde1daddcf7dac --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimage_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsBackgroundImageTest { +public: + ~CommonAttrsBackgroundImageTest(); + static napi_value CreateNativeNodeResourceStr(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePixelMap(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimageposition_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimageposition_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..18762cb48ea495487f7cb4b5b29896ee7cdd7a6c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimageposition_test.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_backgroundimageposition_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateChildWithPosition(float axisX, float axisY) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImagePositionTest", "CreateChildWithSizeOptions"); + + auto column = std::make_shared(); + column->SetWidth(200); + column->SetHeight(150); + column->SetBorderWidth(2); + column->SetBackgroundImage("resource://media/icon.png"); + ArkUI_NumberValue position_value[] = { { .f32 = axisX }, { .f32 = axisY } }; + ArkUI_AttributeItem position_item = { position_value, sizeof(position_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_BACKGROUND_IMAGE_POSITION, &position_item); + + return column; +} + +napi_value CommonAttrsBackgroundImagePositionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImagePositionTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImagePositionTest", + "GetContext env or info is null"); + return nullptr; + } + + auto grid = new GridComponent(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + grid->AddChild(CreateChildWithPosition(30, 30)); + grid->AddChild(CreateChildWithPosition(-30, 30)); + grid->AddChild(CreateChildWithPosition(30, -30)); + grid->AddChild(CreateChildWithPosition(-30, -30)); + grid->AddChild(CreateChildWithPosition(100, 100)); + grid->AddChild(CreateChildWithPosition(500, 500)); + grid->AddChild(CreateChildWithPosition(0, 0)); + auto column8 = CreateChildWithPosition(30, 30); + column8->resetAttribute(NODE_BACKGROUND_IMAGE_POSITION); + grid->AddChild(column8); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), grid->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImagePositionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimageposition_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimageposition_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ba66ebed64a174ea3d35bbdbdb85a63683ec1074 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimageposition_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGEPOSITION_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGEPOSITION_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsBackgroundImagePositionTest { +public: + ~CommonAttrsBackgroundImagePositionTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGEPOSITION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimagesize_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimagesize_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb80c71250cb560c16c56b68a7445c2d3e63be0d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimagesize_test.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_backgroundimagesize_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateChildWithSizeOptions(float width, float height) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageSizeTest", "CreateChildWithSizeOptions"); + + auto column = std::make_shared(); + column->SetWidth(140); + column->SetHeight(120); + column->SetBorderWidth(2); + column->SetBackgroundImage("resource://media/icon.png"); + ArkUI_NumberValue sizeoptions_value[] = { { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem sizeoptions_item = { sizeoptions_value, + sizeof(sizeoptions_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_BACKGROUND_IMAGE_SIZE, &sizeoptions_item); + + return column; +} + +std::shared_ptr CreateChildWithImageSize(int32_t imageSize) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageSizeTest", "CreateChildWithImageSize"); + + auto column = std::make_shared(); + column->SetWidth(140); + column->SetHeight(120); + column->SetBorderWidth(2); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(imageSize); + + return column; +} + +napi_value CommonAttrsBackgroundImageSizeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageSizeTest", "CreateNativeNode"); + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageSizeTest", + "GetContext env or info is null"); + return nullptr; + } + + auto grid = new GridComponent(); + grid->SetGridColumnsGap(5); + grid->SetGridRowsGap(5); + grid->AddChild(CreateChildWithSizeOptions(100, 100)); + grid->AddChild(CreateChildWithSizeOptions(-100, -100)); + grid->AddChild(CreateChildWithSizeOptions(300, 300)); + auto column4 = CreateChildWithSizeOptions(100, 100); + column4->resetAttribute(NODE_BACKGROUND_IMAGE_SIZE); + grid->AddChild(column4); + grid->AddChild(CreateChildWithImageSize(ARKUI_IMAGE_SIZE_AUTO)); + grid->AddChild(CreateChildWithImageSize(ARKUI_IMAGE_SIZE_COVER)); + grid->AddChild(CreateChildWithImageSize(ARKUI_IMAGE_SIZE_CONTAIN)); + grid->AddChild(CreateChildWithImageSize(3)); + grid->AddChild(CreateChildWithImageSize(-1)); + grid->AddChild(CreateChildWithImageSize(4)); + auto column11 = CreateChildWithImageSize(ARKUI_IMAGE_SIZE_COVER); + column11->resetAttribute(NODE_BACKGROUND_IMAGE_SIZE_WITH_STYLE); + grid->AddChild(column11); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), grid->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBackgroundImageSizeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimagesize_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimagesize_test.h new file mode 100644 index 0000000000000000000000000000000000000000..37a3d8e011e05c391c2aff4b56505f055a58d116 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_backgroundimagesize_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGESIZE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGESIZE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsBackgroundImageSizeTest { +public: + ~CommonAttrsBackgroundImageSizeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_BACKGROUNDIMAGESIZE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_blur_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_blur_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c806730477df1fc4017e5196bf3fb8b428c5de0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_blur_test.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_blur_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateImageWithBlur(float blur) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", "CreateImageNode"); + + auto image = std::make_shared(ARKUI_NODE_IMAGE); + image->SetWidth(SIZE_100); + image->SetHeight(SIZE_100); + image->SetMargin(DEFAULT_MARGIN); + image->SetBackgroundImage("resource://media/icon.png"); + image->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + ArkUI_NumberValue blur_value[] = { { .f32 = blur } }; + ArkUI_AttributeItem blur_item = { blur_value, sizeof(blur_value) / sizeof(ArkUI_NumberValue) }; + image->setAttribute(NODE_BLUR, &blur_item); + + return image; +} + +napi_value CommonAttrsBlurTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", "GetContext env or info is null"); + return nullptr; + } + + auto image1 = CreateImageWithBlur(0); + auto image2 = CreateImageWithBlur(30); + auto image3 = CreateImageWithBlur(50); + auto image4 = CreateImageWithBlur(100); + auto image5 = CreateImageWithBlur(-100); + auto image6 = CreateImageWithBlur(50); + image6->resetAttribute(NODE_BLUR); + + auto column = new ColumnComponent(); + column->AddChild(image1); + column->AddChild(image2); + column->AddChild(image3); + column->AddChild(image4); + column->AddChild(image5); + column->AddChild(image6); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_blur_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_blur_test.h new file mode 100644 index 0000000000000000000000000000000000000000..245034e60f9ee8940385c89042bcaa0ef7cb6cfc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_blur_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_BLUR_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_BLUR_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsBlurTest { +public: + ~CommonAttrsBlurTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_BLUR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_brightness_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_brightness_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7f450bb4f06f9f6791739e64aeb62b77ec5f6934 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_brightness_test.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_brightness_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateImageWithBrightness(float brightness) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBrightnessTest", "CreateImageNode"); + + auto image = std::make_shared(ARKUI_NODE_IMAGE); + image->SetWidth(70); + image->SetHeight(70); + image->SetMargin(DEFAULT_MARGIN); + image->SetBackgroundColor(COLOR_RED); + ArkUI_NumberValue brightness_value[] = { { .f32 = brightness } }; + ArkUI_AttributeItem brightness_item = { brightness_value, sizeof(brightness_value) / sizeof(ArkUI_NumberValue) }; + image->setAttribute(NODE_BRIGHTNESS, &brightness_item); + + return image; +} + +static void AddBrightnessChild(ColumnComponent* column) +{ + auto image1 = CreateImageWithBrightness(0); + auto image2 = CreateImageWithBrightness(0.5); + auto image3 = CreateImageWithBrightness(1); + auto image4 = CreateImageWithBrightness(1.5); + auto image5 = CreateImageWithBrightness(2); + auto image6 = CreateImageWithBrightness(-1); + auto image7 = CreateImageWithBrightness(3); + auto image8 = CreateImageWithBrightness(2); + image8->resetAttribute(NODE_BRIGHTNESS); + column->AddChild(image1); + column->AddChild(image2); + column->AddChild(image3); + column->AddChild(image4); + column->AddChild(image5); + column->AddChild(image6); + column->AddChild(image7); + column->AddChild(image8); +} + +napi_value CommonAttrsBrightnessTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBrightnessTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBrightnessTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + AddBrightnessChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBrightnessTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_brightness_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_brightness_test.h new file mode 100644 index 0000000000000000000000000000000000000000..05b76f8be96d252ef83891575f0cb5719704ceec --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_brightness_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_BRIGHTNESS_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_BRIGHTNESS_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsBrightnessTest { +public: + ~CommonAttrsBrightnessTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_BRIGHTNESS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_chainmode_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_chainmode_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1e05b91e72555457f745fbf84ac2048b3d871dc3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_chainmode_test.cpp @@ -0,0 +1,526 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_chainmode_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateChainModeRelativeContainerNode(std::vector> rows) +{ + auto column = std::make_shared(); + column->SetMargin(5); + auto relativeContainer = std::make_shared(); + relativeContainer->SetWidth(200); + relativeContainer->SetHeight(200); + relativeContainer->SetBorderWidth(1); + for (auto Row : rows) { + relativeContainer->AddChild(Row); + } + column->AddChild(relativeContainer); + return column; +} + +std::shared_ptr CreateChainModeRelativeContainerNode1( + std::vector> columns) +{ + auto column = std::make_shared(); + column->SetMargin(5); + auto relativeContainer = std::make_shared(); + relativeContainer->SetWidth(200); + relativeContainer->SetHeight(200); + relativeContainer->SetBorderWidth(1); + for (auto Column : columns) { + relativeContainer->AddChild(Column); + } + column->AddChild(relativeContainer); + return column; +} + +std::shared_ptr CreateChainModeRowNode( + const std::string& id, uint32_t color, std::shared_ptr ruleOption = nullptr) +{ + auto row = std::make_shared(); + row->SetWidth(50); + row->SetHeight(50); + row->SetId(id); + row->SetAlignRules(ruleOption->GetOption()); + row->SetBackgroundColor(color); + row->SetJustifyContent(ARKUI_FLEX_ALIGNMENT_CENTER); + return row; +} + +std::shared_ptr CreateChainModeColumnNode( + const std::string& id, uint32_t color, std::shared_ptr ruleOption = nullptr) +{ + auto column = std::make_shared(); + column->SetWidth(50); + column->SetHeight(50); + column->SetId(id); + column->SetAlignRules(ruleOption->GetOption()); + column->SetBackgroundColor(color); + column->SetJustifyContent(ARKUI_FLEX_ALIGNMENT_CENTER); + return column; +} + +napi_value CommonAttrsChainModeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create ruleOption + auto rule1 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule1 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + HorizontalAlignRule horizontalAlignRule2 { .anchor = "row2", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule1 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption1 { + .left = horizontalAlignRule1, .right = horizontalAlignRule2, .top = verticalAlignRule1 + }; + rule1->SetAlignOption(ruleOption1); + + auto rule2 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule3 { .anchor = "row1", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + HorizontalAlignRule horizontalAlignRule4 { .anchor = "row3", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule2 { .anchor = "row1", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption2 { + .left = horizontalAlignRule3, .right = horizontalAlignRule4, .top = verticalAlignRule2 + }; + rule2->SetAlignOption(ruleOption2); + + auto rule3 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule5 { .anchor = "row2", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + HorizontalAlignRule horizontalAlignRule6 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + VerticalAlignRule verticalAlignRule3 { .anchor = "row1", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption3 { + .left = horizontalAlignRule5, .right = horizontalAlignRule6, .top = verticalAlignRule3 + }; + rule3->SetAlignOption(ruleOption3); + + auto rule4 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule7 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + HorizontalAlignRule horizontalAlignRule8 { .anchor = "row5", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule4 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_CENTER }; + AlignmentRuleOption ruleOption4 { + .left = horizontalAlignRule7, .right = horizontalAlignRule8, .center = verticalAlignRule4 + }; + rule4->SetAlignOption(ruleOption4); + + auto rule5 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule9 { .anchor = "row4", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + HorizontalAlignRule horizontalAlignRule10 { .anchor = "row6", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule5 { .anchor = "row4", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption5 { + .left = horizontalAlignRule9, .right = horizontalAlignRule10, .top = verticalAlignRule5 + }; + rule5->SetAlignOption(ruleOption5); + + auto rule6 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule11 { .anchor = "row5", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + HorizontalAlignRule horizontalAlignRule12 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + VerticalAlignRule verticalAlignRule6 { .anchor = "row4", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption6 { + .left = horizontalAlignRule11, .right = horizontalAlignRule12, .top = verticalAlignRule6 + }; + rule6->SetAlignOption(ruleOption6); + + auto rule7 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule13 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + HorizontalAlignRule horizontalAlignRule14 { .anchor = "row8", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule7 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption7 { + .left = horizontalAlignRule13, .right = horizontalAlignRule14, .bottom = verticalAlignRule7 + }; + rule7->SetAlignOption(ruleOption7); + + auto rule8 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule15 { .anchor = "row7", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + HorizontalAlignRule horizontalAlignRule16 { .anchor = "row9", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule8 { .anchor = "row7", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption8 { + .left = horizontalAlignRule15, .right = horizontalAlignRule16, .top = verticalAlignRule8 + }; + rule8->SetAlignOption(ruleOption8); + + auto rule9 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule17 { .anchor = "row8", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + HorizontalAlignRule horizontalAlignRule18 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + VerticalAlignRule verticalAlignRule9 { .anchor = "row7", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption9 { + .left = horizontalAlignRule17, .right = horizontalAlignRule18, .top = verticalAlignRule9 + }; + rule9->SetAlignOption(ruleOption9); + + // create row + auto row1 = CreateChainModeRowNode("row1", COLOR_RED, rule1); + auto row2 = CreateChainModeRowNode("row2", COLOR_BLUE, rule2); + auto row3 = CreateChainModeRowNode("row3", COLOR_YELLOW, rule3); + auto row4 = CreateChainModeRowNode("row4", COLOR_LIGHT_BLUE, rule4); + auto row5 = CreateChainModeRowNode("row5", COLOR_PURPLE, rule5); + auto row6 = CreateChainModeRowNode("row6", COLOR_BLACK, rule6); + auto row7 = CreateChainModeRowNode("row7", COLOR_GRAY, rule7); + auto row8 = CreateChainModeRowNode("row8", COLOR_PINK, rule8); + auto row9 = CreateChainModeRowNode("row9", COLOR_GREEN, rule9); + + // set chainMode + ArkUI_NumberValue chainMode1_value[] = { { .i32 = ARKUI_AXIS_HORIZONTAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_SPREAD } }; + ArkUI_AttributeItem chainMode1_item = { chainMode1_value, sizeof(chainMode1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(row1->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode1_item); + ArkUI_NumberValue chainMode2_value[] = { { .i32 = ARKUI_AXIS_HORIZONTAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_SPREAD_INSIDE } }; + ArkUI_AttributeItem chainMode2_item = { chainMode2_value, sizeof(chainMode2_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(row4->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode2_item); + ArkUI_NumberValue chainMode3_value[] = { { .i32 = ARKUI_AXIS_HORIZONTAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_PACKED } }; + ArkUI_AttributeItem chainMode3_item = { chainMode3_value, sizeof(chainMode3_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(row7->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode3_item); + + // add child + auto column = CreateChainModeRelativeContainerNode({ row1, row2, row3, row4, row5, row6, row7, row8, row9 }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonAttrsChainModeTest::CreateNativeNode1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", "CreateNativeNode1"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create ruleOption + auto rule1 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule1 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule1 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + VerticalAlignRule verticalAlignRule2 { .anchor = "column2", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption1 { + .left = horizontalAlignRule1, .top = verticalAlignRule1, .bottom = verticalAlignRule2 + }; + rule1->SetAlignOption(ruleOption1); + + auto rule2 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule2 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule3 { .anchor = "column1", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule4 { .anchor = "column3", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption2 { + .left = horizontalAlignRule2, .top = verticalAlignRule3, .bottom = verticalAlignRule4 + }; + rule2->SetAlignOption(ruleOption2); + + auto rule3 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule3 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_START }; + VerticalAlignRule verticalAlignRule5 { .anchor = "column2", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule6 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption3 { + .left = horizontalAlignRule3, .top = verticalAlignRule5, .bottom = verticalAlignRule6 + }; + rule3->SetAlignOption(ruleOption3); + + auto rule4 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule4 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule7 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + VerticalAlignRule verticalAlignRule8 { .anchor = "column5", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption4 { + .middle = horizontalAlignRule4, .top = verticalAlignRule7, .bottom = verticalAlignRule8 + }; + rule4->SetAlignOption(ruleOption4); + + auto rule5 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule5 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule9 { .anchor = "column4", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule10 { .anchor = "column6", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption5 { + .middle = horizontalAlignRule5, .top = verticalAlignRule9, .bottom = verticalAlignRule10 + }; + rule5->SetAlignOption(ruleOption5); + + auto rule6 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule6 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule11 { .anchor = "column5", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule12 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption6 { + .middle = horizontalAlignRule6, .top = verticalAlignRule11, .bottom = verticalAlignRule12 + }; + rule6->SetAlignOption(ruleOption6); + + auto rule7 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule7 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + VerticalAlignRule verticalAlignRule13 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + VerticalAlignRule verticalAlignRule14 { .anchor = "column8", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption7 { + .right = horizontalAlignRule7, .top = verticalAlignRule13, .bottom = verticalAlignRule14 + }; + rule7->SetAlignOption(ruleOption7); + + auto rule8 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule8 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + VerticalAlignRule verticalAlignRule15 { .anchor = "column7", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule16 { .anchor = "column9", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption8 { + .right = horizontalAlignRule8, .top = verticalAlignRule15, .bottom = verticalAlignRule16 + }; + rule8->SetAlignOption(ruleOption8); + + auto rule9 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule9 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_END }; + VerticalAlignRule verticalAlignRule17 { .anchor = "column8", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule18 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption9 { + .right = horizontalAlignRule9, .top = verticalAlignRule17, .bottom = verticalAlignRule18 + }; + rule9->SetAlignOption(ruleOption9); + + // create column + auto column1 = CreateChainModeColumnNode("column1", COLOR_RED, rule1); + auto column2 = CreateChainModeColumnNode("column2", COLOR_BLUE, rule2); + auto column3 = CreateChainModeColumnNode("column3", COLOR_YELLOW, rule3); + auto column4 = CreateChainModeColumnNode("column4", COLOR_LIGHT_BLUE, rule4); + auto column5 = CreateChainModeColumnNode("column5", COLOR_PURPLE, rule5); + auto column6 = CreateChainModeColumnNode("column6", COLOR_BLACK, rule6); + auto column7 = CreateChainModeColumnNode("column7", COLOR_GRAY, rule7); + auto column8 = CreateChainModeColumnNode("column8", COLOR_PINK, rule8); + auto column9 = CreateChainModeColumnNode("column9", COLOR_GREEN, rule9); + + // set chainMode + ArkUI_NumberValue chainMode1_value[] = { { .i32 = ARKUI_AXIS_VERTICAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_SPREAD } }; + ArkUI_AttributeItem chainMode1_item = { chainMode1_value, sizeof(chainMode1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column1->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode1_item); + ArkUI_NumberValue chainMode2_value[] = { { .i32 = ARKUI_AXIS_VERTICAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_SPREAD_INSIDE } }; + ArkUI_AttributeItem chainMode2_item = { chainMode2_value, sizeof(chainMode2_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column4->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode2_item); + ArkUI_NumberValue chainMode3_value[] = { { .i32 = ARKUI_AXIS_VERTICAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_PACKED } }; + ArkUI_AttributeItem chainMode3_item = { chainMode3_value, sizeof(chainMode3_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column7->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode3_item); + + // add child + auto column = CreateChainModeRelativeContainerNode1( + { column1, column2, column3, column4, column5, column6, column7, column8, column9 }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonAttrsChainModeTest::CreateNativeNode2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", "CreateNativeNode2"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create ruleOption + auto rule1 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule1 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule1 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + VerticalAlignRule verticalAlignRule2 { .anchor = "row2", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption1 { + .top = verticalAlignRule1, .bottom = verticalAlignRule2, .middle = horizontalAlignRule1 + }; + rule1->SetAlignOption(ruleOption1); + + auto rule2 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule2 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule3 { .anchor = "row1", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule4 { .anchor = "row3", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption2 { + .top = verticalAlignRule3, .bottom = verticalAlignRule4, .middle = horizontalAlignRule2 + }; + rule2->SetAlignOption(ruleOption2); + + auto rule3 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule3 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule5 { .anchor = "row2", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule6 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption3 { + .top = verticalAlignRule5, .bottom = verticalAlignRule6, .middle = horizontalAlignRule3 + }; + rule3->SetAlignOption(ruleOption3); + + auto rule4 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule4 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule7 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + VerticalAlignRule verticalAlignRule8 { .anchor = "row5", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption4 { + .top = verticalAlignRule7, .bottom = verticalAlignRule8, .middle = horizontalAlignRule4 + }; + rule4->SetAlignOption(ruleOption4); + + auto rule5 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule5 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule9 { .anchor = "row4", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule10 { .anchor = "row6", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption5 { + .top = verticalAlignRule9, .bottom = verticalAlignRule10, .middle = horizontalAlignRule5 + }; + rule5->SetAlignOption(ruleOption5); + + auto rule6 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule6 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule11 { .anchor = "row5", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule12 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption6 { + .top = verticalAlignRule11, .bottom = verticalAlignRule12, .middle = horizontalAlignRule6 + }; + rule6->SetAlignOption(ruleOption6); + + auto rule7 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule7 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule13 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + VerticalAlignRule verticalAlignRule14 { .anchor = "row8", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption7 { + .top = verticalAlignRule13, .bottom = verticalAlignRule14, .middle = horizontalAlignRule7 + }; + rule7->SetAlignOption(ruleOption7); + + auto rule8 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule8 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule15 { .anchor = "row7", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule16 { .anchor = "row9", .align = ARKUI_VERTICAL_ALIGNMENT_TOP }; + AlignmentRuleOption ruleOption8 { + .top = verticalAlignRule15, .bottom = verticalAlignRule16, .middle = horizontalAlignRule8 + }; + rule8->SetAlignOption(ruleOption8); + + auto rule9 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule9 { .anchor = "__container__", .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER }; + VerticalAlignRule verticalAlignRule17 { .anchor = "row8", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + VerticalAlignRule verticalAlignRule18 { .anchor = "__container__", .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM }; + AlignmentRuleOption ruleOption9 { + .top = verticalAlignRule17, .bottom = verticalAlignRule18, .middle = horizontalAlignRule9 + }; + rule9->SetAlignOption(ruleOption9); + + // create row + auto row1 = CreateChainModeRowNode("row1", COLOR_RED, rule1); + auto row2 = CreateChainModeRowNode("row2", COLOR_BLUE, rule2); + auto row3 = CreateChainModeRowNode("row3", COLOR_YELLOW, rule3); + auto row4 = CreateChainModeRowNode("row4", COLOR_LIGHT_BLUE, rule4); + auto row5 = CreateChainModeRowNode("row5", COLOR_PURPLE, rule5); + auto row6 = CreateChainModeRowNode("row6", COLOR_BLACK, rule6); + auto row7 = CreateChainModeRowNode("row7", COLOR_GRAY, rule7); + auto row8 = CreateChainModeRowNode("row8", COLOR_PINK, rule8); + auto row9 = CreateChainModeRowNode("row9", COLOR_GREEN, rule9); + + // set chainMode + ArkUI_NumberValue chainMode1_value[] = { { .i32 = ARKUI_AXIS_VERTICAL }, + { .i32 = ARKUI_RELATIVE_LAYOUT_CHAIN_STYLE_SPREAD } }; + ArkUI_AttributeItem chainMode1_item = { chainMode1_value, sizeof(chainMode1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(row1->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode1_item); + nodeAPI->resetAttribute(row1->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE); + ArkUI_NumberValue chainMode2_value[] = { { .i32 = -1 }, { .i32 = -1 } }; + ArkUI_AttributeItem chainMode2_item = { chainMode2_value, sizeof(chainMode2_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(row4->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode2_item); + ArkUI_NumberValue chainMode3_value[] = { { .i32 = 2 }, { .i32 = 3 } }; + ArkUI_AttributeItem chainMode3_item = { chainMode3_value, sizeof(chainMode3_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(row7->GetComponent(), NODE_RELATIVE_LAYOUT_CHAIN_MODE, &chainMode3_item); + + // add child + auto columnP1 = CreateChainModeRelativeContainerNode({ row1, row2, row3 }); + auto columnP2 = CreateChainModeRelativeContainerNode({ row4, row5, row6 }); + auto columnP3 = CreateChainModeRelativeContainerNode({ row7, row8, row9 }); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, columnP1->GetComponent()); + nodeAPI->addChild(column, columnP2->GetComponent()); + nodeAPI->addChild(column, columnP3->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsChainModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_chainmode_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_chainmode_test.h new file mode 100644 index 0000000000000000000000000000000000000000..bb60a4f26d04876e83cb3bbf7fe5a3e1975985bd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_chainmode_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_CHAINMODE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_CHAINMODE_TEST_H + +#include + +#include "../common/common.h" +#include "../component/relativecontainer_component.h" +#include "arkui/native_node.h" +#include "component/column_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsChainModeTest { +public: + ~CommonAttrsChainModeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode2(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_CHAINMODE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_clipshape_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_clipshape_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..38129896e739bb3759daaa2e10a724a1500e630e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_clipshape_test.cpp @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_clipshape_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateNodeRect( + ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, float cornerWidth, float cornerHeight) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "createNodeRect"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue clipshape_value[] = { { .i32 = ARKUI_CLIP_TYPE_RECTANGLE }, { .f32 = width }, { .f32 = height }, + { .f32 = cornerWidth }, { .f32 = cornerHeight } }; + ArkUI_AttributeItem clipshape_item = { clipshape_value, sizeof(clipshape_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipshape_item); + + return column; +} + +static auto CreateNodeRectDiffCornerRadius(ArkUI_NativeNodeAPI_1* nodeAPI, const std::vector& floatValues) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "createNodeRectDiffCornerRadius"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + std::vector clipshape_value; + clipshape_value.push_back({ .i32 = ARKUI_CLIP_TYPE_RECTANGLE }); + clipshape_value.push_back({ .f32 = 100 }); + clipshape_value.push_back({ .f32 = 100 }); + for (auto floatValue : floatValues) { + clipshape_value.push_back({ .f32 = floatValue }); + } + ArkUI_AttributeItem clipshape_item = { clipshape_value.data(), sizeof(clipshape_value) }; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipshape_item); + + return column; +} + +static auto CreateNodeCircle(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "createNodeCircle"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue clipshape_value[] = { { .i32 = ARKUI_CLIP_TYPE_CIRCLE }, { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem clipshape_item = { clipshape_value, sizeof(clipshape_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipshape_item); + + return column; +} + +static auto CreateNodeEllipse(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "createNodeEllipse"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue clipshape_value[] = { { .i32 = ARKUI_CLIP_TYPE_ELLIPSE }, { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem clipshape_item = { clipshape_value, sizeof(clipshape_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipshape_item); + + return column; +} + +static auto CreateNodePath(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, const char* command) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "createNodePath"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue clipshape_value[] = { { .i32 = ARKUI_CLIP_TYPE_PATH }, { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem clipshape_item = { clipshape_value, sizeof(clipshape_value) / sizeof(ArkUI_NumberValue) }; + clipshape_item.string = command; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipshape_item); + + return column; +} + +static auto CreateNodeOutliers(ArkUI_NativeNodeAPI_1* nodeAPI, int outliers, const std::vector& floatValues) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "createNodeOutliers"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + std::vector clipshape_value; + clipshape_value.push_back({ .i32 = outliers }); + for (auto floatValue : floatValues) { + clipshape_value.push_back({ .f32 = floatValue }); + } + ArkUI_AttributeItem clipshape_item = { clipshape_value.data(), sizeof(clipshape_value) }; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipshape_item); + + return column; +} + +static void AddClipShapeChild(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle grid) +{ + const char* command1 = "M60 0 L120 100 L0 100 Z"; + const char* command2 = ""; + nodeAPI->addChild(grid, CreateNodeRect(nodeAPI, 100, 100, 30, 10)); + nodeAPI->addChild(grid, CreateNodeRect(nodeAPI, 70, 100, 30, 10)); + nodeAPI->addChild(grid, CreateNodeRect(nodeAPI, 100, 100, -1, -1)); + nodeAPI->addChild(grid, CreateNodeRect(nodeAPI, 500, 300, 30, 10)); + nodeAPI->addChild(grid, CreateNodeCircle(nodeAPI, 100, 100)); + nodeAPI->addChild(grid, CreateNodeCircle(nodeAPI, 70, 100)); + nodeAPI->addChild(grid, CreateNodeCircle(nodeAPI, -1, -1)); + nodeAPI->addChild(grid, CreateNodeCircle(nodeAPI, 500, 300)); + nodeAPI->addChild(grid, CreateNodeEllipse(nodeAPI, 100, 100)); + nodeAPI->addChild(grid, CreateNodeEllipse(nodeAPI, 70, 100)); + nodeAPI->addChild(grid, CreateNodeEllipse(nodeAPI, -1, -1)); + nodeAPI->addChild(grid, CreateNodeEllipse(nodeAPI, 500, 300)); + nodeAPI->addChild(grid, CreateNodePath(nodeAPI, 100, 100, command1)); + nodeAPI->addChild(grid, CreateNodePath(nodeAPI, 100, 100, command2)); + nodeAPI->addChild(grid, CreateNodePath(nodeAPI, -1, -1, command1)); + nodeAPI->addChild(grid, CreateNodePath(nodeAPI, 500, 300, command1)); + nodeAPI->addChild(grid, CreateNodeRectDiffCornerRadius(nodeAPI, { 30, 10, 10, 10, 10, 10 })); + nodeAPI->addChild(grid, CreateNodeRectDiffCornerRadius(nodeAPI, { 30, 10, 10, 10, 0, 0 })); + nodeAPI->addChild(grid, CreateNodeRectDiffCornerRadius(nodeAPI, { 30, 10, -1, -1, -1, -1 })); + nodeAPI->addChild(grid, CreateNodeOutliers(nodeAPI, -1, { 100, 100, 30, 10 })); + nodeAPI->addChild(grid, CreateNodeOutliers(nodeAPI, 4, { 100, 100, 30, 10 })); + auto column22 = CreateNodeRect(nodeAPI, 100, 100, 30, 10); + nodeAPI->resetAttribute(column22, NODE_CLIP_SHAPE); + nodeAPI->addChild(grid, column22); +} + +napi_value CommonAttrsClipShapeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto grid = nodeAPI->createNode(ARKUI_NODE_GRID); + ArkUI_NumberValue gap_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem gap_item = { gap_value, sizeof(gap_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(grid, NODE_GRID_COLUMN_GAP, &gap_item); + nodeAPI->setAttribute(grid, NODE_GRID_ROW_GAP, &gap_item); + AddClipShapeChild(nodeAPI, grid); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), grid) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsClipShapeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_clipshape_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_clipshape_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9c4f6c0f5b986ef756309b15f771cc8050d4ee90 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_clipshape_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_CLIPSHAPE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_CLIPSHAPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsClipShapeTest { +public: + ~CommonAttrsClipShapeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_CLIPSHAPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_colorblend_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_colorblend_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6b820618a89b98ecf401d12c2b84f3a40a057fa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_colorblend_test.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_colorblend_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t colorBackground, uint32_t colorBlend) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue image_value[] = {}; + ArkUI_AttributeItem image_item = { image_value, sizeof(image_value) / sizeof(ArkUI_NumberValue) }; + image_item.string = "resource://media/icon.png"; + nodeAPI->setAttribute(column, NODE_BACKGROUND_IMAGE, &image_item); + + ArkUI_NumberValue image_size_value[] = { { .i32 = ARKUI_IMAGE_SIZE_COVER } }; + ArkUI_AttributeItem image_size_item = { image_size_value, sizeof(image_size_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_IMAGE_SIZE_WITH_STYLE, &image_size_item); + + ArkUI_NumberValue color_background_value[] = { { .u32 = colorBackground } }; + ArkUI_AttributeItem color_background_item = { color_background_value, + sizeof(color_background_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &color_background_item); + + ArkUI_NumberValue color_blend_value[] = { { .u32 = colorBlend } }; + ArkUI_AttributeItem color_blend_item = { color_blend_value, + sizeof(color_blend_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLOR_BLEND, &color_blend_item); + + return column; +} + +napi_value CommonAttrsColorBlendTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsColorBlendTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsColorBlendTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column and set colorBlend + auto column1 = CreateChildNode(nodeAPI, COLOR_GREEN, COLOR_RED); + auto column2 = CreateChildNode(nodeAPI, COLOR_GREEN, COLOR_RED); + auto column3 = CreateChildNode(nodeAPI, COLOR_GREEN, COLOR_TRANSPARENT); + auto column4 = CreateChildNode(nodeAPI, COLOR_GREEN, COLOR_RED); + nodeAPI->resetAttribute(column2, NODE_COLOR_BLEND); + ArkUI_NumberValue color_blend_value[] = { { .u32 = COLOR_GRAY } }; + ArkUI_AttributeItem color_blend_item = { color_blend_value, + sizeof(color_blend_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column4, NODE_COLOR_BLEND, &color_blend_item); + + // add child + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, column1); + nodeAPI->addChild(column, column2); + nodeAPI->addChild(column, column3); + nodeAPI->addChild(column, column4); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsColorBlendTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_colorblend_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_colorblend_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3464a3f66f02e942e8b13febaf749ecd64c2503a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_colorblend_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_COLORBLEND_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_COLORBLEND_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsColorBlendTest { +public: + ~CommonAttrsColorBlendTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_COLORBLEND_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_customshadow_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_customshadow_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c62406ce8d465b569828ce31e1ba9a5f384a4c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_customshadow_test.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_customshadow_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +struct CustomShadowParams { + float blurRadius; + int32_t coloringStrategy; + float offsetX; + float offsetY; + int32_t type; + uint32_t color; + uint32_t fill; +}; + +std::shared_ptr CreateCustomShadow(const CustomShadowParams& params) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsCustomShadowTest", "CreateCustomShadow"); + + auto column = std::make_shared(); + column->SetWidth(70); + column->SetHeight(70); + column->SetMargin(20); + column->SetBackgroundColor(COLOR_GRAY); + ArkUI_NumberValue customshadow_value[] = { { .f32 = params.blurRadius }, { .i32 = params.coloringStrategy }, + { .f32 = params.offsetX }, { .f32 = params.offsetY }, { .i32 = params.type }, { .u32 = params.color }, + { .u32 = params.fill } }; + ArkUI_AttributeItem customshadow_item = { customshadow_value, + sizeof(customshadow_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_CUSTOM_SHADOW, &customshadow_item); + + return column; +} + +static void AddCustomShadowChild(ColumnComponent* column) +{ + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + auto row4 = std::make_shared(); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(row4); + + row1->AddChild(CreateCustomShadow({ -30, {}, {}, {}, {}, COLOR_RED, 100 })); + row1->AddChild(CreateCustomShadow({ 0, {}, {}, {}, {}, COLOR_RED, 100 })); + row1->AddChild(CreateCustomShadow({ 30, {}, {}, {}, {}, COLOR_RED, 100 })); + row1->AddChild(CreateCustomShadow({ 30, true, {}, {}, {}, COLOR_GREEN, 100 })); + row2->AddChild(CreateCustomShadow({ 30, false, {}, {}, {}, COLOR_GREEN, 100 })); + row2->AddChild(CreateCustomShadow({ 30, -1, {}, {}, {}, COLOR_GREEN, 100 })); + row2->AddChild(CreateCustomShadow({ 30, {}, 20, 20, {}, COLOR_PINK, 100 })); + row2->AddChild(CreateCustomShadow({ 30, {}, 0, -100, {}, COLOR_PINK, 100 })); + row3->AddChild(CreateCustomShadow({ 30, {}, {}, {}, ARKUI_SHADOW_TYPE_COLOR, COLOR_BLUE, 100 })); + row3->AddChild(CreateCustomShadow({ 30, {}, {}, {}, ARKUI_SHADOW_TYPE_BLUR, COLOR_BLUE, 100 })); + row3->AddChild(CreateCustomShadow({ 30, {}, {}, {}, -1, COLOR_BLUE, 100 })); + row3->AddChild(CreateCustomShadow({ 30, {}, {}, {}, 2, COLOR_BLUE, 100 })); + row4->AddChild(CreateCustomShadow({ 30, {}, {}, {}, {}, {}, 100 })); + row4->AddChild(CreateCustomShadow({ 30, {}, {}, {}, {}, COLOR_BLACK, true })); + row4->AddChild(CreateCustomShadow({ 30, {}, {}, {}, {}, COLOR_BLACK, false })); + auto column16 = CreateCustomShadow({ 30, false, 10, 10, ARKUI_SHADOW_TYPE_COLOR, COLOR_RED, true }); + column16->resetAttribute(NODE_CUSTOM_SHADOW); + row4->AddChild(column16); +} + +napi_value CommonAttrsCustomShadowTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsCustomShadowTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsCustomShadowTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + column->SetBackgroundColor(COLOR_YELLOW); + AddCustomShadowChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsCustomShadowTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_customshadow_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_customshadow_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e8efc1dae672b28488b3897a21a85c10baeaaa1b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_customshadow_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_CUSTOMSHADOW_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_CUSTOMSHADOW_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsCustomShadowTest { +public: + ~CommonAttrsCustomShadowTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_CUSTOMSHADOW_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_defaultfocus_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_defaultfocus_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2fa79e30967fb2247cb56796dcd81eb92d296a06 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_defaultfocus_test.cpp @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_defaultfocus_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateNodeWithoutDefaultFocus(const std::string& id) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "CreateNodeWithoutDefaultFocus"); + auto radio = std::make_shared(ARKUI_NODE_RADIO); + radio->SetWidth(SIZE_100); + radio->SetHeight(SIZE_100); + radio->SetMargin(DEFAULT_MARGIN); + radio->SetId(id); + radio->RegisterOnFocus([radio]() { + ArkUI_NumberValue checked_value[] = { { .i32 = true } }; + ArkUI_AttributeItem checked_item = { checked_value, sizeof(checked_value) / sizeof(ArkUI_NumberValue) }; + radio->setAttribute(NODE_RADIO_CHECKED, &checked_item); + }); + + return radio; +} + +std::shared_ptr CreateNodeWithDefaultFocus(const std::string& id, int32_t defaultFocus) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "CreateNodeWithDefaultFocus"); + auto radio = CreateNodeWithoutDefaultFocus(id); + ArkUI_NumberValue textarea_value[] = { { .i32 = defaultFocus } }; + ArkUI_AttributeItem focus_item = { textarea_value, sizeof(textarea_value) / sizeof(ArkUI_NumberValue) }; + radio->setAttribute(NODE_DEFAULT_FOCUS, &focus_item); + + return radio; +} + +napi_value CommonAttrsDefaultFocusTest::CreateNativeNodeSingle(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "CreateNativeNodeSingle"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + column->AddChild(CreateNodeWithDefaultFocus("R1", false)); + column->AddChild(CreateNodeWithDefaultFocus("R2", true)); + column->AddChild(CreateNodeWithDefaultFocus("R3", false)); + column->AddChild(CreateNodeWithoutDefaultFocus("R4")); + column->AddChild(CreateNodeWithoutDefaultFocus("R5")); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsDefaultFocusTest::CreateNativeNodeNone(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "CreateNativeNodeNone"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + column->AddChild(CreateNodeWithoutDefaultFocus("R1")); + column->AddChild(CreateNodeWithDefaultFocus("R2", false)); + column->AddChild(CreateNodeWithoutDefaultFocus("R3")); + column->AddChild(CreateNodeWithDefaultFocus("R4", false)); + auto radio5 = CreateNodeWithDefaultFocus("R5", true); + radio5->resetAttribute(NODE_DEFAULT_FOCUS); + column->AddChild(radio5); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsDefaultFocusTest::CreateNativeNodeMulti(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "CreateNativeNodeMulti"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + column->AddChild(CreateNodeWithDefaultFocus("R1", false)); + column->AddChild(CreateNodeWithDefaultFocus("R2", false)); + column->AddChild(CreateNodeWithDefaultFocus("R3", true)); + column->AddChild(CreateNodeWithDefaultFocus("R4", true)); + column->AddChild(CreateNodeWithDefaultFocus("R5", true)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsDefaultFocusTest::CreateNativeNodeAbnormal(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "CreateNativeNodeAbnormal"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + column->AddChild(CreateNodeWithDefaultFocus("R1", -1)); + column->AddChild(CreateNodeWithDefaultFocus("R2", -1)); + column->AddChild(CreateNodeWithDefaultFocus("R3", true)); + column->AddChild(CreateNodeWithDefaultFocus("R4", false)); + column->AddChild(CreateNodeWithDefaultFocus("R5", false)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDefaultFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_defaultfocus_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_defaultfocus_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a99901eccba028d86710434e9bf0bfbdc6d649da --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_defaultfocus_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_DEFAULT_FOCUS_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_DEFAULT_FOCUS_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsDefaultFocusTest { +public: + ~CommonAttrsDefaultFocusTest(); + static napi_value CreateNativeNodeSingle(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeNone(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeMulti(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeAbnormal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_DEFAULT_FOCUS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_displaypriority_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_displaypriority_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0b36421b8220ced5c1f55a1d71e20bdaaf76f782 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_displaypriority_test.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_displaypriority_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + + return nodeHandle; +} + +static auto CreateFlexNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t displayPriority, uint32_t color) +{ + auto button = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_HEIGHT, &height_item); + ArkUI_NumberValue displayPriority_value[] = { { .u32 = displayPriority } }; + ArkUI_AttributeItem displayPriority_item = { displayPriority_value, + sizeof(displayPriority_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_DISPLAY_PRIORITY, &displayPriority_item); + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_BACKGROUND_COLOR, &background_color_item); + + return button; +} + +napi_value CommonAttrsDisplayPriorityTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDisplayPriorityTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDisplayPriorityTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column and set displayPriority + auto column1 = CreateChildNode(nodeAPI, 3, COLOR_RED); + auto column2 = CreateChildNode(nodeAPI, 5, COLOR_YELLOW); + auto column3 = CreateChildNode(nodeAPI, 0, COLOR_BLUE); + auto column4 = CreateChildNode(nodeAPI, 1, COLOR_BLACK); + auto column5 = CreateChildNode(nodeAPI, 2, COLOR_GREEN); + nodeAPI->resetAttribute(column2, NODE_DISPLAY_PRIORITY); + + auto column6 = CreateChildNode(nodeAPI, 1, COLOR_RED); + auto column7 = CreateChildNode(nodeAPI, 2, COLOR_BLUE); + auto column8 = CreateChildNode(nodeAPI, 0, COLOR_BLACK); + auto column9 = CreateChildNode(nodeAPI, 2, COLOR_GREEN); + + // add child + auto columnP1 = CreateColumnNode(nodeAPI); + auto flexP2 = CreateFlexNode(nodeAPI); + nodeAPI->addChild(columnP1, column1); + nodeAPI->addChild(columnP1, column2); + nodeAPI->addChild(columnP1, column3); + nodeAPI->addChild(columnP1, column4); + nodeAPI->addChild(columnP1, column5); + nodeAPI->addChild(flexP2, column6); + nodeAPI->addChild(flexP2, column7); + nodeAPI->addChild(flexP2, column8); + nodeAPI->addChild(flexP2, column9); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, columnP1); + nodeAPI->addChild(column, flexP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsDisplayPriorityTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_displaypriority_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_displaypriority_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2ff6bf1c24e3fdcd17757b3e29d87774cdf0fc72 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_displaypriority_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_DISPLAYPRIORITY_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_DISPLAYPRIORITY_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsDisplayPriorityTest { +public: + ~CommonAttrsDisplayPriorityTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_DISPLAYPRIORITY_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_expand_safe_area_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_expand_safe_area_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2bd547b6dff053bbd7350027bf43923d5850c912 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_expand_safe_area_test.cpp @@ -0,0 +1,1014 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "../manager/plugin_manager.h" +#include "commonattrs_expand_safe_area_test.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetWidthPercent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetHeightPercent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetOffSet(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float offSetX, float offSetY) +{ + ArkUI_NumberValue value[] = { { .f32 = offSetX }, { .f32 = offSetY } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OFFSET, &item); + return nodeHandle; +} + +static auto SetButtonType(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t type) +{ + ArkUI_NumberValue value[] = { { .u32 = type } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BUTTON_TYPE, &item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto SetExpandSafeArea(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t type) +{ + ArkUI_NumberValue value[] = { { .u32 = type } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_EXPAND_SAFE_AREA, &item); + return nodeHandle; +} + +static auto SetExpandSafeArea( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t type, uint32_t edge) +{ + ArkUI_NumberValue value[] = { { .u32 = type }, { .u32 = edge } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_EXPAND_SAFE_AREA, &item); + return nodeHandle; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CLICK_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + if (eventId == ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "record begin"); + } +} + +static auto SetColumn(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidthPercent(nodeAPI, nodeHandle, 1.0); + nodeHandle = SetHeightPercent(nodeAPI, nodeHandle, 1.0); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_400); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + nodeHandle = SetOffSet(nodeAPI, nodeHandle, PARAM_0, SIZE_200); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + nodeHandle = SetWidthPercent(nodeAPI, nodeHandle, 1.0); + nodeHandle = SetHeightPercent(nodeAPI, nodeHandle, 1.0); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_BLUE); + nodeHandle = SetId(nodeAPI, nodeHandle, id); + nodeHandle = SetButtonType(nodeAPI, nodeHandle, ARKUI_BUTTON_TYPE_NORMAL); + return nodeHandle; +} + +// case: ARKUI_SAFE_AREA_TYPE_SYSTEM +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_SYSTEM); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_TOP +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_TOP); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_BOTTOM +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_BOTTOM); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// 安全区操作是否正常响应 +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage4(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button1); + button1 = SetButton(nodeAPI, button1, "button1"); + button1 = SetExpandSafeArea(nodeAPI, button1, ARKUI_SAFE_AREA_TYPE_SYSTEM); + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(button1, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_START +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage5(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_START); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_END +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage6(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_SYSTEM, ARKUI_SAFE_AREA_EDGE_END); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case: ARKUI_SAFE_AREA_TYPE_CUTOUT +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage7(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_CUTOUT); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_TOP +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage8(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_TOP); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_BOTTOM +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage9(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_BOTTOM); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_START +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage10(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_START); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_END +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage11(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column = SetColumn(nodeAPI, column); + column = SetExpandSafeArea(nodeAPI, column, ARKUI_SAFE_AREA_TYPE_CUTOUT, ARKUI_SAFE_AREA_EDGE_END); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case: ARKUI_SAFE_AREA_TYPE_KEYBOARD +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage12(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + column = SetColumn(nodeAPI, column); + textInput = SetText(nodeAPI, textInput); + textInput = SetExpandSafeArea(nodeAPI, textInput, ARKUI_SAFE_AREA_TYPE_KEYBOARD); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetId(nodeAPI, textInput, "textInput"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_TOP +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage13(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + column = SetColumn(nodeAPI, column); + textInput = SetText(nodeAPI, textInput); + textInput = SetExpandSafeArea(nodeAPI, textInput, ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_TOP); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetId(nodeAPI, textInput, "textInput"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_BOTTOM +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage14(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + column = SetColumn(nodeAPI, column); + textInput = SetText(nodeAPI, textInput); + textInput = SetExpandSafeArea(nodeAPI, textInput, ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_BOTTOM); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetId(nodeAPI, textInput, "textInput"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_START +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage15(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + column = SetColumn(nodeAPI, column); + textInput = SetText(nodeAPI, textInput); + textInput = SetExpandSafeArea(nodeAPI, textInput, ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_START); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetId(nodeAPI, textInput, "textInput"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// case:ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_END +napi_value CommonAttrsExpandSafeAreaTest::CreateNativeNodePage16(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + column = SetColumn(nodeAPI, column); + textInput = SetText(nodeAPI, textInput); + textInput = SetExpandSafeArea(nodeAPI, textInput, ARKUI_SAFE_AREA_TYPE_KEYBOARD, ARKUI_SAFE_AREA_EDGE_END); + + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput); + SetWidth(nodeAPI, button, 100); + SetHeight(nodeAPI, button, 100); + SetId(nodeAPI, button, "button"); + SetId(nodeAPI, textInput, "textInput"); + SetBackgroundColor(nodeAPI, button, COLOR_TRANSPARENT); + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsExpandSafeAreaTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_expand_safe_area_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_expand_safe_area_test.h new file mode 100644 index 0000000000000000000000000000000000000000..26eaf21b643fd80f37ad89f950e5324b2b64df9b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_expand_safe_area_test.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_EXPAND_SAFE_AREA_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_EXPAND_SAFE_AREA_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +#define ON_CLICK_EVENT_ID_EXPANDSAFAAREA_1 7000 + +class CommonAttrsExpandSafeAreaTest { +public: + ~CommonAttrsExpandSafeAreaTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage4(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage5(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage6(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage7(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage8(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage9(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage10(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage11(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage12(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage13(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage14(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage15(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage16(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_EXPAND_SAFE_AREA_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focus_on_touch_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focus_on_touch_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb4073e6ddf545502c3302cbc6db71b11512ccf9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focus_on_touch_test.cpp @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_focus_on_touch_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto SetCaretColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_CARET_COLOR, &color_item); + return nodeHandle; +} + +static auto SetEnableKeyboardOnFocus(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + return nodeHandle; +} + +static auto SetFocusOnTouch(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t focus) +{ + ArkUI_NumberValue value[] = { { .i32 = focus } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FOCUS_ON_TOUCH, &item); + return nodeHandle; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsFocusOnTouchTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsFocusOnTouchTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsFocusOnTouchTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_FOCUS_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t focus, const char* id) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_200); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetEnableKeyboardOnFocus(nodeAPI, nodeHandle); + nodeHandle = SetFocusOnTouch(nodeAPI, nodeHandle, focus); + nodeHandle = SetId(nodeAPI, nodeHandle, id); + nodeHandle = SetCaretColor(nodeAPI, nodeHandle, COLOR_TRANSPARENT); + return nodeHandle; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto text1 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto text2 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto text3 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto text4 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto text5 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + + text1 = SetText(nodeAPI, text1, PARAM_1, "text1"); + text2 = SetText(nodeAPI, text2, PARAM_0, "text2"); + text3 = SetText(nodeAPI, text3, PARAM_2, "text3"); + text4 = SetText(nodeAPI, text4, PARAM_NEGATIVE_1, "text4"); + text5 = SetText(nodeAPI, text5, PARAM_1, "text5"); + nodeAPI->resetAttribute(text5, NODE_FOCUS_ON_TOUCH); + + nodeAPI->registerNodeEvent(text1, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(text2, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(text3, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(text4, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(text5, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + return column; +} + +napi_value CommonAttrsFocusOnTouchTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityRoleTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityRoleTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsAccessibilityRoleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focus_on_touch_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focus_on_touch_test.h new file mode 100644 index 0000000000000000000000000000000000000000..440447c92ffa1f2247012ab758dfa7a95097594f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focus_on_touch_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_FOCUS_ON_TOUCH_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_FOCUS_ON_TOUCH_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsFocusOnTouchTest { +public: + ~CommonAttrsFocusOnTouchTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_FOCUS_ON_TOUCH_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focusstatus_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focusstatus_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc101dc1cc80b4e0f356224e722b07f3554f0e88 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focusstatus_test.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_focusstatus_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateNodeWithoutFocusStatus(const std::string& id) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsFocusStatusTest", "CreateNodeWithoutFocusStatus"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto radio = std::make_shared(ARKUI_NODE_RADIO); + radio->SetWidth(SIZE_100); + radio->SetHeight(SIZE_100); + radio->SetMargin(DEFAULT_MARGIN); + radio->SetId(id); + radio->RegisterOnFocus([radio]() { + ArkUI_NumberValue checked_value[] = { { .i32 = true } }; + ArkUI_AttributeItem checked_item = { checked_value, sizeof(checked_value) / sizeof(ArkUI_NumberValue) }; + radio->setAttribute(NODE_RADIO_CHECKED, &checked_item); + }); + + return radio; +} + +std::shared_ptr CreateNodeWithFocusStatus(const std::string& id, int32_t focusStatus) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsFocusStatusTest", "CreateNodeWithFocusStatus"); + auto radio = CreateNodeWithoutFocusStatus(id); + ArkUI_NumberValue textarea_value[] = { { .i32 = focusStatus } }; + ArkUI_AttributeItem focus_item = { textarea_value, sizeof(textarea_value) / sizeof(ArkUI_NumberValue) }; + radio->setAttribute(NODE_FOCUS_STATUS, &focus_item); + + return radio; +} + +static void AddFocusStatusChild(ColumnComponent* column) +{ + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto radio1 = CreateNodeWithoutFocusStatus("R1"); + auto radio2 = CreateNodeWithFocusStatus("R2", -1); + auto radio3 = CreateNodeWithFocusStatus("R3", 0); + auto radio4 = CreateNodeWithFocusStatus("R4", 1); + column->AddChild(radio1); + column->AddChild(radio2); + column->AddChild(radio3); + column->AddChild(radio4); + + button->RegisterOnClick([radio1]() { + ArkUI_NumberValue focus_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem focus_item = { focus_value, sizeof(focus_value) / sizeof(ArkUI_NumberValue) }; + radio1->setAttribute(NODE_FOCUS_STATUS, &focus_item); + }); +} + +napi_value CommonAttrsFocusStatusTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsFocusStatusTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsFocusStatusTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + AddFocusStatusChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsFocusStatusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focusstatus_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focusstatus_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ac5ce296306e39f12f0dab10d3516f7ebf6ddb49 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_focusstatus_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_FOCUS_STATUS_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_FOCUS_STATUS_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsFocusStatusTest { +public: + ~CommonAttrsFocusStatusTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_FOCUS_STATUS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_foregroundcolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_foregroundcolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79b09e424739af6d01498b06801932e52127c0b3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_foregroundcolor_test.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_foregroundcolor_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateColumnWithForegroundColor(uint32_t foregroundColor) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsForegroundColorTest", "CreateColumnWithForegroundColor"); + + auto column = std::make_shared(); + column->SetWidth(250); + column->SetHeight(140); + column->SetMargin(DEFAULT_MARGIN); + column->SetBorderWidth(2); + ArkUI_NumberValue foregroundcolor_value[] = { { .u32 = foregroundColor } }; + ArkUI_AttributeItem foregroundcolor_item = { foregroundcolor_value, + sizeof(foregroundcolor_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_FOREGROUND_COLOR, &foregroundcolor_item); + + return column; +} + +std::shared_ptr CreateButtonWithForegroundColor(uint32_t foregroundColor) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsForegroundColorTest", "CreateButtonWithForegroundColor"); + + auto button = std::make_shared(); + button->SetWidth(150); + button->SetHeight(50); + button->SetMargin(8); + button->SetFontSize(30); + ArkUI_NumberValue text_value[] = {}; + ArkUI_AttributeItem text_item = { text_value, sizeof(text_value) / sizeof(ArkUI_NumberValue) }; + text_item.string = "TEXT"; + button->setAttribute(NODE_BUTTON_LABEL, &text_item); + if (foregroundColor != NULL) { + ArkUI_NumberValue foregroundcolor_value[] = { { .u32 = foregroundColor } }; + ArkUI_AttributeItem foregroundcolor_item = { foregroundcolor_value, + sizeof(foregroundcolor_value) / sizeof(ArkUI_NumberValue) }; + button->setAttribute(NODE_FOREGROUND_COLOR, &foregroundcolor_item); + } + + return button; +} + +static void AddForegroundColorChild(ColumnComponent* column) +{ + auto column1 = CreateColumnWithForegroundColor({}); + column1->SetHeight(210); + auto column2 = CreateColumnWithForegroundColor(COLOR_GREEN); + auto column3 = CreateColumnWithForegroundColor(COLOR_GREEN); + auto column4 = CreateColumnWithForegroundColor(COLOR_GREEN); + ArkUI_NumberValue colorblend_value[] = { { .u32 = COLOR_BLUE } }; + ArkUI_AttributeItem colorblend_item = { colorblend_value, sizeof(colorblend_value) / sizeof(ArkUI_NumberValue) }; + column4->setAttribute(NODE_COLOR_BLEND, &colorblend_item); + + auto button1 = CreateButtonWithForegroundColor({}); + auto button2 = CreateButtonWithForegroundColor(COLOR_RED); + auto button3 = CreateButtonWithForegroundColor(COLOR_RED); + button3->resetAttribute(NODE_FOREGROUND_COLOR); + auto button4 = CreateButtonWithForegroundColor({}); + auto button5 = CreateButtonWithForegroundColor(COLOR_RED); + auto button6 = CreateButtonWithForegroundColor({}); + button6->SetBackgroundImage("resource://media/background_yellow.png"); + button6->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + auto button7 = CreateButtonWithForegroundColor(COLOR_RED); + button7->SetBackgroundImage("resource://media/background_yellow.png"); + button7->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + auto button8 = CreateButtonWithForegroundColor({}); + auto button9 = CreateButtonWithForegroundColor(COLOR_RED); + ArkUI_NumberValue colorblendgray_value[] = { { .u32 = COLOR_PURPLE } }; + colorblend_item = { colorblendgray_value, sizeof(colorblendgray_value) / sizeof(ArkUI_NumberValue) }; + button8->setAttribute(NODE_COLOR_BLEND, &colorblend_item); + button9->setAttribute(NODE_COLOR_BLEND, &colorblend_item); + + column->AddChild(column1); + column->AddChild(column2); + column->AddChild(column3); + column->AddChild(column4); + column1->AddChild(button1); + column1->AddChild(button2); + column1->AddChild(button3); + column2->AddChild(button4); + column2->AddChild(button5); + column3->AddChild(button6); + column3->AddChild(button7); + column4->AddChild(button8); + column4->AddChild(button9); +} + +napi_value CommonAttrsForegroundColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsForegroundColorTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsForegroundColorTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + AddForegroundColorChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsForegroundColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_foregroundcolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_foregroundcolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9282110541cad52298eb672f0671ef226eb75905 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_foregroundcolor_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_FOREGROUND_COLOR_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_FOREGROUND_COLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsForegroundColorTest { +public: + ~CommonAttrsForegroundColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_FOREGROUND_COLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_layoutweight_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_layoutweight_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..08caeadedf0b9623a21baa9814657fbbf2957edb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_layoutweight_test.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_layoutweight_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t layoutWeight, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue layoutWeight_value[] = { { .u32 = layoutWeight } }; + ArkUI_AttributeItem layoutWeight_item = { layoutWeight_value, + sizeof(layoutWeight_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_LAYOUT_WEIGHT, &layoutWeight_item); + + return nodeHandle; +} + +static auto CreateColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + + return nodeHandle; +} + +static auto CreateFlexNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + + return nodeHandle; +} + +napi_value CommonAttrsLayoutWeightTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsLayoutWeightTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsLayoutWeightTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column and set layoutWeight + auto column1 = CreateChildNode(nodeAPI, 1, COLOR_GREEN); + auto column2 = CreateChildNode(nodeAPI, 0, COLOR_BLUE); + auto column3 = CreateChildNode(nodeAPI, 2, COLOR_RED); + auto column4 = CreateChildNode(nodeAPI, 3, COLOR_GRAY); + nodeAPI->resetAttribute(column4, NODE_LAYOUT_WEIGHT); + auto column5 = CreateChildNode(nodeAPI, 1, COLOR_GREEN); + auto column6 = CreateChildNode(nodeAPI, 0, COLOR_BLUE); + auto column7 = CreateChildNode(nodeAPI, 2, COLOR_RED); + auto column8 = CreateChildNode(nodeAPI, 3, COLOR_GRAY); + nodeAPI->resetAttribute(column8, NODE_LAYOUT_WEIGHT); + + // add child + auto columnP1 = CreateColumnNode(nodeAPI); + auto flexP2 = CreateFlexNode(nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(columnP1, column1); + nodeAPI->addChild(columnP1, column2); + nodeAPI->addChild(columnP1, column3); + nodeAPI->addChild(columnP1, column4); + nodeAPI->addChild(flexP2, column5); + nodeAPI->addChild(flexP2, column6); + nodeAPI->addChild(flexP2, column7); + nodeAPI->addChild(flexP2, column8); + nodeAPI->addChild(column, columnP1); + nodeAPI->addChild(column, flexP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsLayoutWeightTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_layoutweight_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_layoutweight_test.h new file mode 100644 index 0000000000000000000000000000000000000000..65e66451ef34a160f7427d3cbb9055833938fe38 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_layoutweight_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_LAYOUTWEIGHT_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_LAYOUTWEIGHT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsLayoutWeightTest { +public: + ~CommonAttrsLayoutWeightTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_LAYOUTWEIGHT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_markanchor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_markanchor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..31c1619cdfde46eea2c5e4e84d80a955cd95edc4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_markanchor_test.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_markanchor_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithMarkAnchor(uint32_t color, float markAnchorX, float markAnchorY) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsMarkAnchorTest", "CreateWithMarkAnchor"); + + auto column = std::make_shared(); + column->SetWidth(SIZE_200); + column->SetHeight(SIZE_100); + column->SetBackgroundColor(color); + ArkUI_NumberValue markanchor_value[] = { { .f32 = markAnchorX }, { .f32 = markAnchorY } }; + ArkUI_AttributeItem markanchor_item = { markanchor_value, sizeof(markanchor_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_MARK_ANCHOR, &markanchor_item); + + return column; +} + +std::shared_ptr CreateWithPositionAndMarkAnchor( + uint32_t color, float positionX, float positionY, float markAnchorX, float markAnchorY) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsMarkAnchorTest", "CreateWithPositionAndMarkAnchor"); + + auto column = CreateWithMarkAnchor(color, markAnchorX, markAnchorY); + ArkUI_NumberValue position_value[] = { { .f32 = positionX }, { .f32 = positionY } }; + ArkUI_AttributeItem position_item = { position_value, sizeof(position_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_POSITION, &position_item); + + return column; +} + +std::shared_ptr CreateBorder() +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsMarkAnchorTest", "CreateBorder"); + + auto column = std::make_shared(); + column->SetWidth(SIZE_200); + column->SetHeight(SIZE_100); + column->SetMargin(5); + column->SetBorderWidth(2); + return column; +} + +static void AddMarkAnchorChild(ColumnComponent* column) +{ + auto column1 = CreateWithPositionAndMarkAnchor(COLOR_RED, 30, 0, {}, {}); + auto column2 = CreateWithPositionAndMarkAnchor(COLOR_GREEN, 30, 0, 30, -40); + auto column3 = CreateWithPositionAndMarkAnchor(COLOR_BLACK, 30, 0, -150, 0); + auto column4 = CreateWithMarkAnchor(COLOR_PURPLE, 0, 0); + auto column5 = CreateWithMarkAnchor(COLOR_BLUE, 30, -40); + auto column6 = CreateWithMarkAnchor(COLOR_YELLOW, -150, 0); + auto column7 = CreateWithMarkAnchor(COLOR_PINK, 30, -40); + column7->resetAttribute(NODE_MARK_ANCHOR); + + auto column01 = CreateBorder(); + auto column02 = CreateBorder(); + auto column03 = CreateBorder(); + auto column04 = CreateBorder(); + auto column05 = CreateBorder(); + auto column06 = CreateBorder(); + auto column07 = CreateBorder(); + + column01->AddChild(column1); + column02->AddChild(column2); + column03->AddChild(column3); + column04->AddChild(column4); + column05->AddChild(column5); + column06->AddChild(column6); + column07->AddChild(column7); + column->AddChild(column01); + column->AddChild(column02); + column->AddChild(column03); + column->AddChild(column04); + column->AddChild(column05); + column->AddChild(column06); + column->AddChild(column07); +} + +napi_value CommonAttrsMarkAnchorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsMarkAnchorTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsMarkAnchorTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + AddMarkAnchorChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsMarkAnchorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_markanchor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_markanchor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2e17d842b1092880c7cc31d67bfc46c52f6edf39 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_markanchor_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_MARK_ANCHOR_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_MARK_ANCHOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsMarkAnchorTest { +public: + ~CommonAttrsMarkAnchorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_MARK_ANCHOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_offset_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_offset_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..83b8ef494556b8c16a86662e6f78e78c138dd4ad --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_offset_test.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_offset_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateColumnWithOffset(uint32_t color, float offsetX, float offsetY) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsOffsetTest", "CreateColumnWithOffset"); + + auto column = std::make_shared(); + column->SetWidth(120); + column->SetHeight(120); + column->SetMargin(DEFAULT_MARGIN); + column->SetBackgroundColor(color); + ArkUI_NumberValue offset_value[] = { { .f32 = offsetX }, { .f32 = offsetY } }; + ArkUI_AttributeItem offset_item = { offset_value, sizeof(offset_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_OFFSET, &offset_item); + + return column; +} + +napi_value CommonAttrsOffsetTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsOffsetTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + auto column1 = CreateColumnWithOffset(COLOR_YELLOW, 30, 10); + auto column2 = CreateColumnWithOffset(COLOR_RED, 30, 10); + auto column3 = CreateColumnWithOffset(COLOR_BLUE, 230, 0); + auto column4 = CreateColumnWithOffset(COLOR_GREEN, 300, 800); + auto column5 = CreateColumnWithOffset(COLOR_PINK, {}, {}); + column2->resetAttribute(NODE_OFFSET); + + auto column = new ColumnComponent(); + column->AddChild(column1); + column->AddChild(column2); + column->AddChild(column3); + column->AddChild(column4); + column->AddChild(column5); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_offset_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_offset_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f0bbecb2d692052530fbdd8c8f6eca0901ba15bd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_offset_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_OFFSET_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_OFFSET_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsOffsetTest { +public: + ~CommonAttrsOffsetTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_OFFSET_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinecolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinecolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d1d15bacbc723d808fd2f356067bbafc6cbedd74 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinecolor_test.cpp @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_outlinecolor_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetOutlineColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + ArkUI_NumberValue color_value[] = {}; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OUTLINE_COLOR, &color_item); + return nodeHandle; +} + +static auto SetOutlineColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OUTLINE_COLOR, &color_item); + return nodeHandle; +} + +static auto SetOutlineColor( + ArkUI_NodeHandle& nodeHandle, uint32_t color1, uint32_t color2, uint32_t color3, uint32_t color4) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ArkUI_NumberValue color_value[] = { { .u32 = color1 }, { .u32 = color2 }, { .u32 = color3 }, { .u32 = color4 } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OUTLINE_COLOR, &color_item); + return nodeHandle; +} + +static auto SetOutlineWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width }, { .f32 = width }, { .f32 = width }, { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OUTLINE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetButtonType(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t type) +{ + ArkUI_NumberValue value[] = { { .u32 = type } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BUTTON_TYPE, &item); + return nodeHandle; +} + +static auto SetShape(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + ArkUI_NumberValue value[] = { { .i32 = ARKUI_CLIP_TYPE_PATH }, { .f32 = SIZE_100 }, { .f32 = SIZE_100 } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + item.string = "M60 0 L120 100 L0 100 Z"; + nodeAPI->setAttribute(nodeHandle, NODE_CLIP_SHAPE, &item); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_20); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_10); + nodeHandle = SetOutlineWidth(nodeAPI, nodeHandle, PARAM_5); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + return nodeHandle; +} + +static auto SetColumn(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_10); + nodeHandle = SetOutlineWidth(nodeAPI, nodeHandle, PARAM_5); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t type) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_20); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_10); + nodeHandle = SetOutlineWidth(nodeAPI, nodeHandle, PARAM_5); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + nodeHandle = SetButtonType(nodeAPI, nodeHandle, type); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t type, float width) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, width); + nodeHandle = SetHeight(nodeAPI, nodeHandle, width); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_10); + nodeHandle = SetOutlineWidth(nodeAPI, nodeHandle, PARAM_5); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + nodeHandle = SetButtonType(nodeAPI, nodeHandle, type); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto text1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_TEXT); + auto text2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_TEXT); + auto text3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_TEXT); + auto text4 = CreateChildNode(nodeAPI, column, ARKUI_NODE_TEXT); + auto button1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_BUTTON); + auto button2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_BUTTON); + auto button3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_BUTTON); + auto row = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto button4 = CreateChildNode(nodeAPI, row, ARKUI_NODE_BUTTON); + auto button5 = CreateChildNode(nodeAPI, row, ARKUI_NODE_BUTTON); + auto button6 = CreateChildNode(nodeAPI, row, ARKUI_NODE_BUTTON); + auto column1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_COLUMN); + auto column2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_COLUMN); + auto column3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_COLUMN); + text1 = SetText(nodeAPI, text1); + text2 = SetText(nodeAPI, text2); + text3 = SetText(nodeAPI, text3); + text4 = SetText(nodeAPI, text4); + button1 = SetButton(nodeAPI, button1, ARKUI_BUTTON_TYPE_CAPSULE); + button2 = SetButton(nodeAPI, button2, ARKUI_BUTTON_TYPE_CAPSULE); + button3 = SetButton(nodeAPI, button3, ARKUI_BUTTON_TYPE_CAPSULE); + button4 = SetButton(nodeAPI, button4, ARKUI_BUTTON_TYPE_CIRCLE, SIZE_50); + button5 = SetButton(nodeAPI, button5, ARKUI_BUTTON_TYPE_CIRCLE, SIZE_50); + button6 = SetButton(nodeAPI, button6, ARKUI_BUTTON_TYPE_CIRCLE, SIZE_50); + column1 = SetColumn(nodeAPI, column1); + column2 = SetColumn(nodeAPI, column2); + column3 = SetColumn(nodeAPI, column3); + column1 = SetShape(nodeAPI, column1); + column2 = SetShape(nodeAPI, column2); + column3 = SetShape(nodeAPI, column3); + text1 = SetOutlineColor(nodeAPI, text1, COLOR_RED); + text2 = SetOutlineColor(text2, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_PURPLE); + text3 = SetOutlineColor(nodeAPI, text3); + text4 = SetOutlineColor(text4, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_PURPLE); + nodeAPI->resetAttribute(text4, NODE_OUTLINE_COLOR); + button1 = SetOutlineColor(nodeAPI, button1, COLOR_RED); + button2 = SetOutlineColor(button2, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_PURPLE); + button3 = SetOutlineColor(nodeAPI, button3); + button4 = SetOutlineColor(nodeAPI, button4, COLOR_RED); + button5 = SetOutlineColor(button5, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_PURPLE); + button6 = SetOutlineColor(nodeAPI, button6); + column1 = SetOutlineColor(nodeAPI, column1, COLOR_RED); + column2 = SetOutlineColor(column2, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_PURPLE); + column3 = SetOutlineColor(nodeAPI, column3); + return column; +} + +napi_value CommonAttrsOutlineColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOutlineColorTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOutlineColorTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOutlineColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinecolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinecolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3fc01a692d72858a8bc3715b2385d776f03ea756 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinecolor_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_OUTLINECOLOR_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_OUTLINECOLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_20 20 + +class CommonAttrsOutlineColorTest { +public: + ~CommonAttrsOutlineColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_OUTLINECOLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinewidth_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinewidth_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..67f15f15405049ef1b11d0b7b4d18a3641ad33eb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinewidth_test.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_outlinewidth_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateNodePath(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, const char* command) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + ArkUI_NumberValue clipShape_value[] = { { .i32 = ARKUI_CLIP_TYPE_PATH }, { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem clipShape_item = { clipShape_value, sizeof(clipShape_value) / sizeof(ArkUI_NumberValue) }; + clipShape_item.string = command; + nodeAPI->setAttribute(column, NODE_CLIP_SHAPE, &clipShape_item); + + return column; +} + +static auto CreateButtonNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_BUTTON); + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_50 } }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + ArkUI_NumberValue buttonType_value[] = { { .i32 = ARKUI_BUTTON_TYPE_CIRCLE } }; + ArkUI_AttributeItem buttonType_item = { buttonType_value, sizeof(buttonType_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BUTTON_TYPE, &buttonType_item); + + return column; +} + +napi_value CommonAttrsOutlineWidthTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOutlineWidthTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOutlineWidthTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // creat column + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column3 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + const char* command1 = "M60 0 L120 100 L0 100 Z"; + auto column4 = CreateNodePath(nodeAPI, 100, 100, command1); + auto column5 = CreateButtonNode(nodeAPI); + auto column6 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // set attribute + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue green_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem green_item = { green_value, sizeof(green_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue red_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem red_item = { red_value, sizeof(red_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue blue_value[] = { { .u32 = COLOR_BLUE } }; + ArkUI_AttributeItem blue_item = { blue_value, sizeof(blue_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue outline1_value[] = { { .f32 = 5 }, { .f32 = 5 }, { .f32 = 5 }, { .f32 = 5 } }; + ArkUI_AttributeItem outline1_item = { outline1_value, sizeof(outline1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column1, NODE_OUTLINE_WIDTH, &outline1_item); + ArkUI_NumberValue outline2_value[] = { { .f32 = 0 }, { .f32 = 0 }, { .f32 = 0 }, { .f32 = 0 } }; + ArkUI_AttributeItem outline2_item = { outline2_value, sizeof(outline2_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column2, NODE_OUTLINE_WIDTH, &outline2_item); + ArkUI_NumberValue outline3_value[] = { { .f32 = -1 }, { .f32 = -1 }, { .f32 = -1 }, { .f32 = -1 } }; + ArkUI_AttributeItem outline3_item = { outline3_value, sizeof(outline3_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column3, NODE_OUTLINE_WIDTH, &outline3_item); + ArkUI_NumberValue outline4_value[] = { { .f32 = 5 }, { .f32 = 10 }, { .f32 = 5 }, { .f32 = 20 } }; + ArkUI_AttributeItem outline4_item = { outline4_value, sizeof(outline4_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue outline5_value[] = { { .f32 = 5 }, { .f32 = 5 }, { .f32 = 5 }, { .f32 = 5 } }; + ArkUI_AttributeItem outline5_item = { outline5_value, sizeof(outline5_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue outline6_value[] = { { .f32 = 10 }, { .f32 = 10 }, { .f32 = 10 }, { .f32 = 10 } }; + ArkUI_AttributeItem outline6_item = { outline6_value, sizeof(outline6_value) / sizeof(ArkUI_NumberValue) }; + + nodeAPI->setAttribute(column1, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column1, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(column1, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(column1, NODE_BACKGROUND_COLOR, &green_item); + nodeAPI->setAttribute(column2, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column2, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(column2, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(column2, NODE_BACKGROUND_COLOR, &red_item); + nodeAPI->setAttribute(column3, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column3, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(column3, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(column3, NODE_BACKGROUND_COLOR, &blue_item); + nodeAPI->setAttribute(column4, NODE_OUTLINE_WIDTH, &outline4_item); + nodeAPI->setAttribute(column4, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(column5, NODE_OUTLINE_WIDTH, &outline5_item); + nodeAPI->setAttribute(column5, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(column6, NODE_OUTLINE_WIDTH, &outline6_item); + nodeAPI->resetAttribute(column6, NODE_OUTLINE_WIDTH); + nodeAPI->setAttribute(column6, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(column6, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(column6, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(column6, NODE_BACKGROUND_COLOR, &green_item); + + // add child + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, column1); + nodeAPI->addChild(column, column2); + nodeAPI->addChild(column, column3); + nodeAPI->addChild(column, column4); + nodeAPI->addChild(column, column5); + nodeAPI->addChild(column, column6); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsOutlineWidthTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinewidth_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinewidth_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ef16ad9025447568648f15c1813d27a05f683406 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_outlinewidth_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_OUTLINEWIDTH_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_OUTLINEWIDTH_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsOutlineWidthTest { +public: + ~CommonAttrsOutlineWidthTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_OUTLINEWIDTH_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_overlay_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_overlay_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a37e77fdf85a3f33288487933a7945344c4b613 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_overlay_test.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_overlay_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateNodeWithOverlay(int32_t type, float offsetX, float offsetY) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", "CreateImageNode"); + + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_150); + column->SetBorderWidth(1); + column->SetBackgroundImage("resource://media/background_yellow.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + ArkUI_NumberValue overlay_value[] = { { .i32 = type }, { .f32 = offsetX }, { .f32 = offsetY } }; + ArkUI_AttributeItem overlay_item = { overlay_value, sizeof(overlay_value) / sizeof(ArkUI_NumberValue) }; + overlay_item.string = "Overlay"; + column->setAttribute(NODE_OVERLAY, &overlay_item); + + return column; +} + +static void AddOverlayChild(GridComponent* grid) +{ + grid->AddChild(CreateNodeWithOverlay({}, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_TOP_START, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_TOP, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_TOP_END, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_START, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_CENTER, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_END, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_BOTTOM_START, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_BOTTOM, {}, {})); + grid->AddChild(CreateNodeWithOverlay(ARKUI_ALIGNMENT_BOTTOM_END, {}, {})); + grid->AddChild(CreateNodeWithOverlay(-1, {}, {})); + grid->AddChild(CreateNodeWithOverlay(9, {}, {})); + grid->AddChild(CreateNodeWithOverlay({}, 0, -15)); + grid->AddChild(CreateNodeWithOverlay({}, 30, 15)); + auto column15 = CreateNodeWithOverlay(ARKUI_ALIGNMENT_CENTER, 30, 15); + column15->resetAttribute(NODE_OVERLAY); + grid->AddChild(column15); +} + +napi_value CommonAttrsOverlayTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", "GetContext env or info is null"); + return nullptr; + } + + auto grid = new GridComponent(); + grid->SetGridRowsGap(5); + grid->SetGridColumnsGap(5); + AddOverlayChild(grid); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), grid->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsBlurTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_overlay_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_overlay_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7a9392649beb61f0e78519f6cfec5081b7bb9d4e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_overlay_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_OVERLAY_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_OVERLAY_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsOverlayTest { +public: + ~CommonAttrsOverlayTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_OVERLAY_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_padding_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_padding_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..09716e8612478a44d579289c27f29f67e990e1a3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_padding_test.cpp @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_padding_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetPadding(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, float padding) +{ + ArkUI_NumberValue value[] = { { .f32 = padding } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_PADDING, &item); + return nodeHandle; +} + +static auto SetPadding(ArkUI_NodeHandle nodeHandle, float padding1, float padding2, float padding3, float padding4) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ArkUI_NumberValue value[] = { { .f32 = padding1 }, { .f32 = padding2 }, { .f32 = padding3 }, { .f32 = padding4 } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_PADDING, &item); + return nodeHandle; +} + +static auto SetSize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, float width, float height) +{ + ArkUI_NumberValue value[] = { { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_SIZE, &item); + return nodeHandle; +} + +static auto SetColumn(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle) +{ + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetSize(nodeAPI, nodeHandle, SIZE_50, SIZE_50); + return nodeHandle; +} + +static auto SetText(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle) +{ + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetSize(nodeAPI, nodeHandle, 25, 25); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateCaseNodeOne(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row1 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column1 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto column2 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text1 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_TEXT); + auto text2 = CreateChildNode(nodeAPI, column2, ARKUI_NODE_TEXT); + column1 = SetColumn(nodeAPI, column1); + column2 = SetColumn(nodeAPI, column2); + text1 = SetText(nodeAPI, text1); + text2 = SetText(nodeAPI, text2); + column1 = SetPadding(nodeAPI, column1, PARAM_0); + column2 = SetPadding(column2, PARAM_0, PARAM_0, PARAM_0, PARAM_0); +} + +static auto CreateCaseNodeTwo(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row2 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column3 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_COLUMN); + auto column4 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_COLUMN); + auto text3 = CreateChildNode(nodeAPI, column3, ARKUI_NODE_TEXT); + auto text4 = CreateChildNode(nodeAPI, column4, ARKUI_NODE_TEXT); + column3 = SetColumn(nodeAPI, column3); + column4 = SetColumn(nodeAPI, column4); + text3 = SetText(nodeAPI, text3); + text4 = SetText(nodeAPI, text4); + column3 = SetPadding(nodeAPI, column3, SIZE_25); + column4 = SetPadding(column4, SIZE_25, SIZE_25, SIZE_25, SIZE_25); +} + +static auto CreateCaseNodeThree(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row3 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column5 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_COLUMN); + auto column6 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_COLUMN); + auto text5 = CreateChildNode(nodeAPI, column5, ARKUI_NODE_TEXT); + auto text6 = CreateChildNode(nodeAPI, column6, ARKUI_NODE_TEXT); + column5 = SetColumn(nodeAPI, column5); + column6 = SetColumn(nodeAPI, column6); + text5 = SetText(nodeAPI, text5); + text6 = SetText(nodeAPI, text6); + column5 = SetPadding(nodeAPI, column5, SIZE_50); + column6 = SetPadding(column6, SIZE_50, SIZE_50, SIZE_50, SIZE_50); +} + +static auto CreateCaseNodeFour(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row4 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column7 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_COLUMN); + auto column8 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_COLUMN); + auto text7 = CreateChildNode(nodeAPI, column7, ARKUI_NODE_TEXT); + auto text8 = CreateChildNode(nodeAPI, column8, ARKUI_NODE_TEXT); + column7 = SetColumn(nodeAPI, column7); + column8 = SetColumn(nodeAPI, column8); + column7 = SetMargin(nodeAPI, column7, SIZE_25); + column8 = SetMargin(nodeAPI, column8, SIZE_25); + text7 = SetText(nodeAPI, text7); + text8 = SetText(nodeAPI, text8); + column7 = SetPadding(nodeAPI, column7, PARAM_NEGATIVE_25); + column8 = SetPadding(column8, PARAM_NEGATIVE_25, PARAM_NEGATIVE_25, PARAM_NEGATIVE_25, PARAM_NEGATIVE_25); +} + +static auto CreateCaseNodeFive(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row5 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column9 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_COLUMN); + auto column10 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_COLUMN); + auto column11 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_COLUMN); + auto column12 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_COLUMN); + auto text9 = CreateChildNode(nodeAPI, column9, ARKUI_NODE_TEXT); + auto text10 = CreateChildNode(nodeAPI, column10, ARKUI_NODE_TEXT); + auto text11 = CreateChildNode(nodeAPI, column11, ARKUI_NODE_TEXT); + auto text12 = CreateChildNode(nodeAPI, column12, ARKUI_NODE_TEXT); + column9 = SetColumn(nodeAPI, column9); + column10 = SetColumn(nodeAPI, column10); + column11 = SetColumn(nodeAPI, column11); + column12 = SetColumn(nodeAPI, column12); + text9 = SetText(nodeAPI, text9); + text10 = SetText(nodeAPI, text10); + text11 = SetText(nodeAPI, text11); + text12 = SetText(nodeAPI, text12); + column9 = SetPadding(column9, PARAM_NEGATIVE_25, PARAM_0, PARAM_0, PARAM_0); + column10 = SetPadding(column10, PARAM_0, PARAM_NEGATIVE_25, PARAM_0, PARAM_0); + column11 = SetPadding(column11, PARAM_0, PARAM_0, PARAM_NEGATIVE_25, PARAM_0); + column12 = SetPadding(column12, PARAM_0, PARAM_0, PARAM_0, PARAM_NEGATIVE_25); +} + +static auto CreateCaseNodeSix(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row6 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column13 = CreateChildNode(nodeAPI, row6, ARKUI_NODE_COLUMN); + auto column14 = CreateChildNode(nodeAPI, row6, ARKUI_NODE_COLUMN); + auto column15 = CreateChildNode(nodeAPI, row6, ARKUI_NODE_COLUMN); + auto column16 = CreateChildNode(nodeAPI, row6, ARKUI_NODE_COLUMN); + auto text13 = CreateChildNode(nodeAPI, column13, ARKUI_NODE_TEXT); + auto text14 = CreateChildNode(nodeAPI, column14, ARKUI_NODE_TEXT); + auto text15 = CreateChildNode(nodeAPI, column15, ARKUI_NODE_TEXT); + auto text16 = CreateChildNode(nodeAPI, column16, ARKUI_NODE_TEXT); + column13 = SetColumn(nodeAPI, column13); + column14 = SetColumn(nodeAPI, column14); + column15 = SetColumn(nodeAPI, column15); + column16 = SetColumn(nodeAPI, column16); + text13 = SetText(nodeAPI, text13); + text14 = SetText(nodeAPI, text14); + text15 = SetText(nodeAPI, text15); + text16 = SetText(nodeAPI, text16); + column13 = SetPadding(column13, SIZE_25, PARAM_0, PARAM_0, PARAM_0); + column14 = SetPadding(column14, PARAM_0, SIZE_25, PARAM_0, PARAM_0); + column15 = SetPadding(column15, PARAM_0, PARAM_0, SIZE_25, PARAM_0); + column16 = SetPadding(column16, PARAM_0, PARAM_0, PARAM_0, SIZE_25); +} + +static auto CreateCaseNodeSeven(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row7 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column17 = CreateChildNode(nodeAPI, row7, ARKUI_NODE_COLUMN); + auto column18 = CreateChildNode(nodeAPI, row7, ARKUI_NODE_COLUMN); + auto column19 = CreateChildNode(nodeAPI, row7, ARKUI_NODE_COLUMN); + auto column20 = CreateChildNode(nodeAPI, row7, ARKUI_NODE_COLUMN); + auto text17 = CreateChildNode(nodeAPI, column17, ARKUI_NODE_TEXT); + auto text18 = CreateChildNode(nodeAPI, column18, ARKUI_NODE_TEXT); + auto text19 = CreateChildNode(nodeAPI, column19, ARKUI_NODE_TEXT); + auto text20 = CreateChildNode(nodeAPI, column20, ARKUI_NODE_TEXT); + column17 = SetColumn(nodeAPI, column17); + column18 = SetColumn(nodeAPI, column18); + column19 = SetColumn(nodeAPI, column19); + column20 = SetColumn(nodeAPI, column20); + column17 = SetMargin(nodeAPI, column17, SIZE_25); + column18 = SetMargin(nodeAPI, column18, SIZE_25); + column19 = SetMargin(nodeAPI, column19, SIZE_25); + column20 = SetMargin(nodeAPI, column20, SIZE_25); + text17 = SetText(nodeAPI, text17); + text18 = SetText(nodeAPI, text18); + text19 = SetText(nodeAPI, text19); + text20 = SetText(nodeAPI, text20); + column17 = SetPadding(column17, PARAM_NEGATIVE_50, PARAM_0, PARAM_0, PARAM_0); + column18 = SetPadding(column18, PARAM_0, PARAM_NEGATIVE_50, PARAM_0, PARAM_0); + column19 = SetPadding(column19, PARAM_0, PARAM_0, PARAM_NEGATIVE_50, PARAM_0); + column20 = SetPadding(column20, PARAM_0, PARAM_0, PARAM_0, PARAM_NEGATIVE_50); +} + +static auto CreateCaseNodeEight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row8 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column21 = CreateChildNode(nodeAPI, row8, ARKUI_NODE_COLUMN); + auto column22 = CreateChildNode(nodeAPI, row8, ARKUI_NODE_COLUMN); + auto column23 = CreateChildNode(nodeAPI, row8, ARKUI_NODE_COLUMN); + auto column24 = CreateChildNode(nodeAPI, row8, ARKUI_NODE_COLUMN); + auto text21 = CreateChildNode(nodeAPI, column21, ARKUI_NODE_TEXT); + auto text22 = CreateChildNode(nodeAPI, column22, ARKUI_NODE_TEXT); + auto text23 = CreateChildNode(nodeAPI, column23, ARKUI_NODE_TEXT); + auto text24 = CreateChildNode(nodeAPI, column24, ARKUI_NODE_TEXT); + column21 = SetColumn(nodeAPI, column21); + column22 = SetColumn(nodeAPI, column22); + column23 = SetColumn(nodeAPI, column23); + column24 = SetColumn(nodeAPI, column24); + column21 = SetMargin(nodeAPI, column21, SIZE_25); + column22 = SetMargin(nodeAPI, column22, SIZE_25); + column23 = SetMargin(nodeAPI, column23, SIZE_25); + column24 = SetMargin(nodeAPI, column24, SIZE_25); + text21 = SetText(nodeAPI, text21); + text22 = SetText(nodeAPI, text22); + text23 = SetText(nodeAPI, text23); + text24 = SetText(nodeAPI, text24); + column21 = SetPadding(column21, SIZE_50, PARAM_0, PARAM_0, PARAM_0); + column22 = SetPadding(column22, PARAM_0, SIZE_50, PARAM_0, PARAM_0); + column23 = SetPadding(column23, PARAM_0, PARAM_0, SIZE_50, PARAM_0); + column24 = SetPadding(column24, PARAM_0, PARAM_0, PARAM_0, SIZE_50); +} + +static auto CreateCaseNodeNine(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode) +{ + auto row9 = CreateChildNode(nodeAPI, parentNode, ARKUI_NODE_ROW); + auto column25 = CreateChildNode(nodeAPI, row9, ARKUI_NODE_COLUMN); + auto column26 = CreateChildNode(nodeAPI, row9, ARKUI_NODE_COLUMN); + auto text25 = CreateChildNode(nodeAPI, column25, ARKUI_NODE_TEXT); + auto text26 = CreateChildNode(nodeAPI, column26, ARKUI_NODE_TEXT); + column25 = SetColumn(nodeAPI, column25); + column26 = SetColumn(nodeAPI, column26); + text25 = SetText(nodeAPI, text25); + text26 = SetText(nodeAPI, text26); + column25 = SetPadding(column25, SIZE_50, PARAM_0, SIZE_50, PARAM_0); + column26 = SetPadding(column26, SIZE_50, PARAM_0, SIZE_50, PARAM_0); + nodeAPI->resetAttribute(column26, NODE_PADDING); +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + CreateCaseNodeOne(nodeAPI, column); + CreateCaseNodeTwo(nodeAPI, column); + CreateCaseNodeThree(nodeAPI, column); + CreateCaseNodeFour(nodeAPI, column); + CreateCaseNodeFive(nodeAPI, column); + CreateCaseNodeSix(nodeAPI, column); + CreateCaseNodeSeven(nodeAPI, column); + CreateCaseNodeEight(nodeAPI, column); + CreateCaseNodeNine(nodeAPI, column); + return column; +} + +napi_value CommonAttrsPaddingTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsPaddingTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsPaddingTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsPaddingTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_padding_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_padding_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2ddbd14b235c7e9d38bc2db460af8f66fc9429c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_padding_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_PADDING_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_PADDING_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_25 25 +#define SIZE_50 50 +#define PARAM_NEGATIVE_25 (-25) +#define PARAM_NEGATIVE_50 (-50) + +class CommonAttrsPaddingTest { +public: + ~CommonAttrsPaddingTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_PADDING_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_renderfit_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_renderfit_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..624ab3571d95a6bd4147cb4a6324e56c192dcd40 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_renderfit_test.cpp @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_renderfit_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "component.h" + +namespace ArkUICApiDemo { + +ArkUI_NativeNodeAPI_1* renderFitNodeAPI = nullptr; +ArkUI_NodeHandle buttonRenderFit = nullptr; + +static void OnClickButtonNode(const std::string& id) +{ + buttonRenderFit = renderFitNodeAPI->createNode(ARKUI_NODE_BUTTON); + ArkUI_NumberValue enable_value[] = { { .i32 = true } }; + ArkUI_AttributeItem enable_item = { enable_value, sizeof(enable_value) / sizeof(ArkUI_NumberValue) }; + renderFitNodeAPI->setAttribute(buttonRenderFit, NODE_ENABLED, &enable_item); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_30 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_30 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + renderFitNodeAPI->setAttribute(buttonRenderFit, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(buttonRenderFit, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue id_value[] = {}; + ArkUI_AttributeItem id_item = { id_value, sizeof(id_value) / sizeof(ArkUI_NumberValue) }; + id_item.string = id.c_str(); + renderFitNodeAPI->setAttribute(buttonRenderFit, NODE_ID, &id_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + renderFitNodeAPI->setAttribute(buttonRenderFit, NODE_MARGIN, &margin_item); + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_TRANSPARENT } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + renderFitNodeAPI->setAttribute(buttonRenderFit, NODE_BACKGROUND_COLOR, &background_color_item); + renderFitNodeAPI->registerNodeEvent(buttonRenderFit, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + + return; +} +static auto createChildColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI, float fontSize, int32_t align, int32_t renderFit) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_NumberValue width_value[] = { { .f32 = 120 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + ArkUI_NumberValue fontSize_value[] = { { .f32 = fontSize } }; + ArkUI_AttributeItem fontSize_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontSize_item); + ArkUI_NumberValue text_value[] = {}; + ArkUI_AttributeItem text_item = { text_value, sizeof(text_value) / sizeof(ArkUI_NumberValue) }; + text_item.string = "TEXT"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &text_item); + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + ArkUI_NumberValue align_value[] = { { .i32 = align } }; + ArkUI_AttributeItem align_item = { align_value, sizeof(align_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_ALIGN, &align_item); + ArkUI_NumberValue renderFit_value[] = { { .i32 = renderFit } }; + ArkUI_AttributeItem renderFit_item = { renderFit_value, sizeof(renderFit_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_RENDER_FIT, &renderFit_item); + + return nodeHandle; +} +void MyCustomEventCallback(void* userData) +{ + auto text1 = renderFitNodeAPI->getPreviousSibling(buttonRenderFit); + auto text2 = renderFitNodeAPI->getPreviousSibling(text1); + auto text3 = renderFitNodeAPI->getPreviousSibling(text2); + auto text4 = renderFitNodeAPI->getPreviousSibling(text3); + ArkUI_NumberValue width_value[] = { { .f32 = 240 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = 160 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + renderFitNodeAPI->setAttribute(text1, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text1, NODE_HEIGHT, &height_item); + renderFitNodeAPI->setAttribute(text2, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text2, NODE_HEIGHT, &height_item); + renderFitNodeAPI->setAttribute(text3, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text3, NODE_HEIGHT, &height_item); + renderFitNodeAPI->setAttribute(text4, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text4, NODE_HEIGHT, &height_item); +} +void MyCustomEventCallback1(void* userData) +{ + auto text1 = renderFitNodeAPI->getPreviousSibling(buttonRenderFit); + auto text2 = renderFitNodeAPI->getPreviousSibling(text1); + auto text3 = renderFitNodeAPI->getPreviousSibling(text2); + auto text4 = renderFitNodeAPI->getPreviousSibling(text3); + ArkUI_NumberValue width_value[] = { { .f32 = 120 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + renderFitNodeAPI->setAttribute(text1, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text1, NODE_HEIGHT, &height_item); + renderFitNodeAPI->setAttribute(text2, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text2, NODE_HEIGHT, &height_item); + renderFitNodeAPI->setAttribute(text3, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text3, NODE_HEIGHT, &height_item); + renderFitNodeAPI->setAttribute(text4, NODE_WIDTH, &width_item); + renderFitNodeAPI->setAttribute(text4, NODE_HEIGHT, &height_item); +} +static void CallKeyFrameAnimator(ArkUI_NodeEvent* event) +{ + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, renderFitNodeAPI); + ArkUI_NativeAnimateAPI_1* animateApi = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateApi); + auto option = OH_ArkUI_KeyframeAnimateOption_Create(120); + if (option == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonOnClickTest", + "OnEventReceive: KeyframeAnimate option is null"); + return; + } + auto contextHandle = OH_ArkUI_GetContextByNode(buttonRenderFit); + auto curveHandle = OH_ArkUI_Curve_CreateCurveByType(ARKUI_CURVE_FRICTION); + struct UserData { + int32_t data; + }; + UserData* onFinishUser = new UserData; + onFinishUser->data = 101; + UserData* eventUser = new UserData; + eventUser->data = 201; + OH_ArkUI_KeyframeAnimateOption_SetDelay(option, 20); + OH_ArkUI_KeyframeAnimateOption_SetIterations(option, 1); + OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback(option, onFinishUser, nullptr); + for (int32_t i = 0; i < 3; ++i) { + OH_ArkUI_KeyframeAnimateOption_SetDuration(option, 1000, i); + OH_ArkUI_KeyframeAnimateOption_SetCurve(option, curveHandle, i); + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(option, eventUser, MyCustomEventCallback, i); + } + for (int32_t i = 3; i > 0; i--) { + OH_ArkUI_KeyframeAnimateOption_SetDuration(option, 1000, i); + OH_ArkUI_KeyframeAnimateOption_SetCurve(option, curveHandle, i); + OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(option, eventUser, MyCustomEventCallback1, i); + } + + animateApi->keyframeAnimateTo(contextHandle, option); +} +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ButtonOnClickTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonOnClickTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ButtonOnClickTest", "OnEventReceive eventId: %{public}d", eventId); + + if (eventId == ON_CLICK_EVENT_ID) { + CallKeyFrameAnimator(event); + } +} + +napi_value CommonAttrsRenderFitTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, renderFitNodeAPI); + + // create column and set renderFit + auto column = renderFitNodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_CENTER); + auto column2 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_TOP); + auto column3 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_BOTTOM); + auto column4 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_START, ARKUI_RENDER_FIT_LEFT); + + // add child + renderFitNodeAPI->addChild(column, column1); + renderFitNodeAPI->addChild(column, column2); + renderFitNodeAPI->addChild(column, column3); + renderFitNodeAPI->addChild(column, column4); + OnClickButtonNode("button"); + renderFitNodeAPI->addChild(column, buttonRenderFit); + renderFitNodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonAttrsRenderFitTest::CreateNativeNode1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "CreateNativeNode1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, renderFitNodeAPI); + + auto column = renderFitNodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_END, ARKUI_RENDER_FIT_RIGHT); + auto column2 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_TOP_LEFT); + auto column3 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_TOP_RIGHT); + auto column4 = + createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_BOTTOM_LEFT); + renderFitNodeAPI->addChild(column, column1); + renderFitNodeAPI->addChild(column, column2); + renderFitNodeAPI->addChild(column, column3); + renderFitNodeAPI->addChild(column, column4); + OnClickButtonNode("button1"); + renderFitNodeAPI->addChild(column, buttonRenderFit); + renderFitNodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonAttrsRenderFitTest::CreateNativeNode2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "CreateNativeNode2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, renderFitNodeAPI); + + auto column = renderFitNodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = + createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_BOTTOM_RIGHT); + auto column2 = + createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_RESIZE_FILL); + auto column3 = + createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_RESIZE_CONTAIN); + auto column4 = createChildColumnNode( + renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_START, ARKUI_RENDER_FIT_RESIZE_CONTAIN_TOP_LEFT); + renderFitNodeAPI->addChild(column, column1); + renderFitNodeAPI->addChild(column, column2); + renderFitNodeAPI->addChild(column, column3); + renderFitNodeAPI->addChild(column, column4); + OnClickButtonNode("button2"); + renderFitNodeAPI->addChild(column, buttonRenderFit); + renderFitNodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonAttrsRenderFitTest::CreateNativeNode3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "CreateNativeNode3"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, renderFitNodeAPI); + + auto column = renderFitNodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createChildColumnNode( + renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_END, ARKUI_RENDER_FIT_RESIZE_CONTAIN_BOTTOM_RIGHT); + auto column2 = + createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, ARKUI_RENDER_FIT_RESIZE_COVER); + auto column3 = + createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_START, ARKUI_RENDER_FIT_RESIZE_COVER_TOP_LEFT); + auto column4 = createChildColumnNode( + renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_END, ARKUI_RENDER_FIT_RESIZE_COVER_BOTTOM_RIGHT); + renderFitNodeAPI->addChild(column, column1); + renderFitNodeAPI->addChild(column, column2); + renderFitNodeAPI->addChild(column, column3); + renderFitNodeAPI->addChild(column, column4); + OnClickButtonNode("button3"); + renderFitNodeAPI->addChild(column, buttonRenderFit); + renderFitNodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonAttrsRenderFitTest::CreateNativeNode4(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "CreateNativeNode4"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, renderFitNodeAPI); + + auto column = renderFitNodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, 17); + auto column2 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, -1); + auto column3 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_CENTER, {}); + auto column4 = createChildColumnNode(renderFitNodeAPI, 20, ARKUI_TEXT_ALIGNMENT_START, ARKUI_RENDER_FIT_LEFT); + renderFitNodeAPI->resetAttribute(column4, NODE_RENDER_FIT); + renderFitNodeAPI->addChild(column, column1); + renderFitNodeAPI->addChild(column, column2); + renderFitNodeAPI->addChild(column, column3); + renderFitNodeAPI->addChild(column, column4); + OnClickButtonNode("button4"); + renderFitNodeAPI->addChild(column, buttonRenderFit); + renderFitNodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_renderfit_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_renderfit_test.h new file mode 100644 index 0000000000000000000000000000000000000000..1b45e56b6d2e44e01c383f226da6e610c9f5d099 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_renderfit_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_RENDERFIT_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_RENDERFIT_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsRenderFitTest { +public: + ~CommonAttrsRenderFitTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode3(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode4(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_RENDERFIT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rendergroup_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rendergroup_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5fcafbf9651b6ae647324efd01180c4c7dd344f6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rendergroup_test.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_rendergroup_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, float opacity, uint32_t color) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue opacity_value[] = { { .f32 = opacity } }; + ArkUI_AttributeItem opacity_item = { opacity_value, sizeof(opacity_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_OPACITY, &opacity_item); + + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &background_color_item); + + return column; +} + +napi_value CommonAttrsRenderGroupTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTranslateTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTranslateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue justify_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_CENTER } }; + ArkUI_AttributeItem justify_item = { justify_value, sizeof(justify_value) / sizeof(ArkUI_NumberValue) }; + auto column1 = CreateChildNode(nodeAPI, 150, 150, 1, COLOR_BLACK); + auto column2 = CreateChildNode(nodeAPI, 100, 100, 0.6, COLOR_WHITE); + auto column3 = CreateChildNode(nodeAPI, 50, 50, 1, COLOR_BLACK); + ArkUI_NumberValue renderGroup_value1[] = { { .i32 = 1 } }; + ArkUI_AttributeItem renderGroup_item1 = { renderGroup_value1, + sizeof(renderGroup_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column2, NODE_RENDER_GROUP, &renderGroup_item1); + auto renderGroupAttrs = nodeAPI->getAttribute(column2, NODE_RENDER_GROUP); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRenderGroupTest", "renderGroupAttrs: %{public}d", + renderGroupAttrs->value[0].i32); + nodeAPI->setAttribute(column1, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column2, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column1, NODE_MARGIN, &margin_item); + nodeAPI->addChild(column1, column2); + nodeAPI->addChild(column2, column3); + auto column4 = CreateChildNode(nodeAPI, 150, 150, 1, COLOR_BLACK); + auto column5 = CreateChildNode(nodeAPI, 100, 100, 0.6, COLOR_WHITE); + auto column6 = CreateChildNode(nodeAPI, 50, 50, 1, COLOR_BLACK); + ArkUI_NumberValue renderGroup_value2[] = { { .i32 = 1 } }; + ArkUI_AttributeItem renderGroup_item2 = { renderGroup_value2, + sizeof(renderGroup_value2) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column5, NODE_RENDER_GROUP, &renderGroup_item2); + nodeAPI->resetAttribute(column5, NODE_RENDER_GROUP); + nodeAPI->setAttribute(column4, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column5, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column4, NODE_MARGIN, &margin_item); + nodeAPI->addChild(column4, column5); + nodeAPI->addChild(column5, column6); + auto column7 = CreateChildNode(nodeAPI, 150, 150, 1, COLOR_BLACK); + auto column8 = CreateChildNode(nodeAPI, 100, 100, 0.6, COLOR_WHITE); + auto column9 = CreateChildNode(nodeAPI, 50, 50, 1, COLOR_BLACK); + ArkUI_NumberValue renderGroup_value3[] = { { .i32 = 0 } }; + ArkUI_AttributeItem renderGroup_item3 = { renderGroup_value3, + sizeof(renderGroup_value3) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column8, NODE_RENDER_GROUP, &renderGroup_item3); + nodeAPI->setAttribute(column7, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column8, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column7, NODE_MARGIN, &margin_item); + nodeAPI->addChild(column7, column8); + nodeAPI->addChild(column8, column9); + auto column10 = CreateChildNode(nodeAPI, 150, 150, 1, COLOR_BLACK); + auto column11 = CreateChildNode(nodeAPI, 100, 100, 0.6, COLOR_WHITE); + auto column12 = CreateChildNode(nodeAPI, 50, 50, 1, COLOR_BLACK); + ArkUI_NumberValue renderGroup_value4[] = { { .i32 = -1 } }; + ArkUI_AttributeItem renderGroup_item4 = { renderGroup_value4, + sizeof(renderGroup_value4) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column11, NODE_RENDER_GROUP, &renderGroup_item4); + nodeAPI->setAttribute(column10, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column11, NODE_COLUMN_JUSTIFY_CONTENT, &justify_item); + nodeAPI->setAttribute(column10, NODE_MARGIN, &margin_item); + nodeAPI->addChild(column10, column11); + nodeAPI->addChild(column11, column12); + + auto columnP1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto columnP2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(columnP1, column1); + nodeAPI->addChild(columnP1, column4); + nodeAPI->addChild(columnP2, column7); + nodeAPI->addChild(columnP2, column10); + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + nodeAPI->addChild(row, columnP1); + nodeAPI->addChild(row, columnP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTranslateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rendergroup_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rendergroup_test.h new file mode 100644 index 0000000000000000000000000000000000000000..b43bb65d83482cb57d44981f44062e4097bb5249 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rendergroup_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_RENDERGROUP_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_RENDERGROUP_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsRenderGroupTest { +public: + ~CommonAttrsRenderGroupTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_RENDERGROUP_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_responseregion_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_responseregion_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79f47b636c986b48e878e171bde00f44e443277f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_responseregion_test.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_responseregion_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateButtonWithResponseRegion( + const std::string& id, const std::vector& values) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", "CreateButtonWithResponseRegion"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto button = std::make_shared(); + button->SetWidth(150); + button->SetHeight(75); + button->SetId(id); + std::vector responseregion_values; + for (auto value : values) { + responseregion_values.push_back({ .f32 = value }); + } + ArkUI_AttributeItem responseregion_item = { responseregion_values.data(), sizeof(responseregion_values) }; + button->setAttribute(NODE_RESPONSE_REGION, &responseregion_item); + nodeAPI->registerNodeEvent(button->GetComponent(), NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + + return button; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandle = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + // 事件回调时,修改组件背景色 + if (eventId == ON_CLICK_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return; + } +} + +static void AddResponseRegionChild(GridComponent* grid) +{ + grid->AddChild(CreateButtonWithResponseRegion("BTN1", { 0, 0, 50, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN2", { 0, 0, 50, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN3", { 0, 0, 50, 100, 50, 0, 50, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN4", { 0, 0, 50, 100, 50, 0, 50, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN5", { 0, 0, 50, 100, 0, 0, 100, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN6", { 0, 0, 0, 0 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN7", { 0, 0, 0, 0 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN8", { -50, 0, 100, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN9", { 100, 0, 200, 200 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN10", { 0, 0, 0, 0 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN11", { 0, 0, 300, 100 })); + grid->AddChild(CreateButtonWithResponseRegion("BTN12", { 0, 0, 100, 100 })); +} + +napi_value CommonAttrsResponseRegionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto grid = new GridComponent(); + grid->SetGridColumnsGap(20); + grid->SetGridRowsGap(30); + AddResponseRegionChild(grid); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), grid->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsResponseRegionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_responseregion_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_responseregion_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0fe388a8444db4f04bd8da2df1a87892ffa67a00 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_responseregion_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_RESPONSE_REGION_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_RESPONSE_REGION_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsResponseRegionTest { +public: + ~CommonAttrsResponseRegionTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_RESPONSE_REGION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rotate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rotate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a7505cf393370219a7f807db4670f43ecf14323 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rotate_test.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_rotate_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateChildNode(float x, float y, float z, float angle, float perspective) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue rotateValue[] = { { .f32 = x }, { .f32 = y }, { .f32 = z }, { .f32 = angle }, + { .f32 = perspective } }; + ArkUI_AttributeItem rotateItem = { rotateValue, sizeof(rotateValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ROTATE, &rotateItem); + + return nodeHandle; +} + +napi_value CommonAttrsRotateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRotateTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRotateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column and set rotate + auto column1 = CreateChildNode(0, 0, 0, 0, 0); + auto column2 = CreateChildNode(1, 1, 1, 45, 0); + auto column3 = CreateChildNode(1, 1, 1, -45, 0); + auto column4 = CreateChildNode(-1, -1, -1, 45, 0); + auto column5 = CreateChildNode(-1, -1, -1, -45, 0); + auto column6 = CreateChildNode(1, -1, 1, 45, 10); + auto column7 = CreateChildNode(-1, 1, -1, 45, -10); + auto column8 = CreateChildNode({}, {}, {}, 45, {}); + auto column9 = CreateChildNode(0, 0, 1, 45, 0); + nodeAPI->resetAttribute(column9, NODE_ROTATE); + + // add child + auto columnP1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto columnP2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(columnP1, column1); + nodeAPI->addChild(columnP1, column2); + nodeAPI->addChild(columnP1, column3); + nodeAPI->addChild(columnP1, column4); + nodeAPI->addChild(columnP2, column5); + nodeAPI->addChild(columnP2, column6); + nodeAPI->addChild(columnP2, column7); + nodeAPI->addChild(columnP2, column8); + nodeAPI->addChild(columnP2, column9); + + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + nodeAPI->addChild(row, columnP1); + nodeAPI->addChild(row, columnP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsRotateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rotate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rotate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..bc5bd964160fe55178f049ff130b83bb04fbedda --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_rotate_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ROTATE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ROTATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsRotateTest { +public: + ~CommonAttrsRotateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ROTATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_saturate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_saturate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..74476e438a3e9b354d9085c9b856ba856057649b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_saturate_test.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_saturate_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateImageWithSaturate(float saturate) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsSaturateTest", "CreateImageNode"); + + auto image = std::make_shared(ARKUI_NODE_IMAGE); + image->SetWidth(80); + image->SetHeight(80); + image->SetMargin(DEFAULT_MARGIN); + image->SetBackgroundImage("resource://media/icon.png"); + image->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + ArkUI_NumberValue saturate_value[] = { { .f32 = saturate } }; + ArkUI_AttributeItem saturate_item = { saturate_value, sizeof(saturate_value) / sizeof(ArkUI_NumberValue) }; + image->setAttribute(NODE_SATURATION, &saturate_item); + + return image; +} + +napi_value CommonAttrsSaturateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsSaturateTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsSaturateTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + auto image1 = CreateImageWithSaturate(0); + auto image2 = CreateImageWithSaturate(1); + auto image3 = CreateImageWithSaturate(5); + auto image4 = CreateImageWithSaturate(30); + auto image5 = CreateImageWithSaturate(51); + auto image6 = CreateImageWithSaturate(-1); + auto image7 = CreateImageWithSaturate(30); + image7->resetAttribute(NODE_SATURATION); + column->AddChild(image1); + column->AddChild(image2); + column->AddChild(image3); + column->AddChild(image4); + column->AddChild(image5); + column->AddChild(image6); + column->AddChild(image7); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsSaturateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_saturate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_saturate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..6f817aa73c138778ea83bd2d99cf95f94246f19a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_saturate_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_SATURATE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_SATURATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsSaturateTest { +public: + ~CommonAttrsSaturateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_SATURATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_scale_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_scale_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..455b7ba38d36634081d35d9515288559b6dec8de --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_scale_test.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_scale_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateImageWithScale(float scaleX, float scaleY) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsScaleTest", "CreateImageWithScale"); + + auto image = std::make_shared(ARKUI_NODE_IMAGE); + image->SetWidth(SIZE_100); + image->SetHeight(SIZE_100); + image->SetMargin(10); + image->SetBackgroundImage("resource://media/startIcon.png"); + image->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + ArkUI_NumberValue scale_value[] = { { .f32 = scaleX }, { .f32 = scaleY } }; + ArkUI_AttributeItem scale_item = { scale_value, sizeof(scale_value) / sizeof(ArkUI_NumberValue) }; + image->setAttribute(NODE_SCALE, &scale_item); + + return image; +} + +napi_value CommonAttrsScaleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsScaleTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsScaleTest", "GetContext env or info is null"); + return nullptr; + } + + auto image1 = CreateImageWithScale(2, 1.5); + auto image2 = CreateImageWithScale(200, 0.5); + auto image3 = CreateImageWithScale(-1, 1); + auto image4 = CreateImageWithScale(1, -1); + auto image5 = CreateImageWithScale(-1, -1); + auto image6 = CreateImageWithScale(2, 1.5); + image6->resetAttribute(NODE_SCALE); + + auto column = new ColumnComponent(); + column->AddChild(image1); + column->AddChild(image2); + column->AddChild(image3); + column->AddChild(image4); + column->AddChild(image5); + column->AddChild(image6); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsScaleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_scale_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_scale_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9cab6ad4e74f2cb7d4ab7b247e55c4755dd9c632 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_scale_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_SCALE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_SCALE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsScaleTest { +public: + ~CommonAttrsScaleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_SCALE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_size_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_size_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..56d0c52d364115e90c09420c74c4671b67a2dbaa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_size_test.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_size_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetOutlineWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width }, { .f32 = width }, { .f32 = width }, { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OUTLINE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetSize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, float width, float height) +{ + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_10); + nodeHandle = SetOutlineWidth(nodeAPI, nodeHandle, PARAM_5); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + ArkUI_NumberValue value[] = { { .f32 = width }, { .f32 = height } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_SIZE, &item); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateCaseNodeOne(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle column) +{ + auto row1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto column1 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text1 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_TEXT); + auto column2 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text2 = CreateChildNode(nodeAPI, column2, ARKUI_NODE_TEXT); + auto column3 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text3 = CreateChildNode(nodeAPI, column3, ARKUI_NODE_TEXT); + auto column4 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text4 = CreateChildNode(nodeAPI, column4, ARKUI_NODE_TEXT); + auto column5 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text5 = CreateChildNode(nodeAPI, column5, ARKUI_NODE_TEXT); + auto column6 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text6 = CreateChildNode(nodeAPI, column6, ARKUI_NODE_TEXT); + auto column7 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text7 = CreateChildNode(nodeAPI, column7, ARKUI_NODE_TEXT); + auto column8 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text8 = CreateChildNode(nodeAPI, column8, ARKUI_NODE_TEXT); + auto column9 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_COLUMN); + auto text9 = CreateChildNode(nodeAPI, column9, ARKUI_NODE_TEXT); + row1 = SetBackgroundColor(nodeAPI, row1, COLOR_GREEN); + column1 = SetBackgroundColor(nodeAPI, column1, COLOR_BLUE); + text1 = SetSize(nodeAPI, text1, SIZE_30, SIZE_30); + column2 = SetBackgroundColor(nodeAPI, column2, COLOR_PURPLE); + text2 = SetSize(nodeAPI, text2, SIZE_30, PARAM_0); + column3 = SetBackgroundColor(nodeAPI, column3, COLOR_BLUE); + text3 = SetSize(nodeAPI, text3, SIZE_30, PARAM_NEGATIVE_100); + column4 = SetBackgroundColor(nodeAPI, column4, COLOR_PURPLE); + text4 = SetSize(nodeAPI, text4, PARAM_0, SIZE_30); + column5 = SetBackgroundColor(nodeAPI, column5, COLOR_BLUE); + text5 = SetSize(nodeAPI, text5, PARAM_0, PARAM_0); + column6 = SetBackgroundColor(nodeAPI, column6, COLOR_PURPLE); + text6 = SetSize(nodeAPI, text6, PARAM_0, PARAM_NEGATIVE_100); + column7 = SetBackgroundColor(nodeAPI, column7, COLOR_BLUE); + text7 = SetSize(nodeAPI, text7, PARAM_NEGATIVE_100, SIZE_30); + column8 = SetBackgroundColor(nodeAPI, column8, COLOR_PURPLE); + text8 = SetSize(nodeAPI, text8, PARAM_NEGATIVE_100, PARAM_0); + column9 = SetBackgroundColor(nodeAPI, column9, COLOR_BLUE); + text9 = SetSize(nodeAPI, text9, PARAM_NEGATIVE_100, PARAM_NEGATIVE_100); +} + +static auto CreateCaseNodeTwo(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle column) +{ + auto column10 = CreateChildNode(nodeAPI, column, ARKUI_NODE_COLUMN); + auto text10 = CreateChildNode(nodeAPI, column10, ARKUI_NODE_TEXT); + auto row2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_ROW); + auto text11 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_TEXT); + auto column12 = CreateChildNode(nodeAPI, column, ARKUI_NODE_COLUMN); + auto text12 = CreateChildNode(nodeAPI, column12, ARKUI_NODE_TEXT); + column10 = SetBackgroundColor(nodeAPI, column10, COLOR_PURPLE); + text10 = SetSize(nodeAPI, text10, SIZE_30, SIZE_300); + nodeAPI->resetAttribute(text10, NODE_SIZE); + row2 = SetBackgroundColor(nodeAPI, row2, COLOR_RED); + text11 = SetSize(nodeAPI, text11, SIZE_2000, SIZE_30); + column12 = SetBackgroundColor(nodeAPI, column12, COLOR_GREEN); + text12 = SetSize(nodeAPI, text12, SIZE_30, SIZE_2000); +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + CreateCaseNodeOne(nodeAPI, column); + CreateCaseNodeTwo(nodeAPI, column); + return column; +} + +napi_value CommonAttrsSizeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsSizeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsSizeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsSizeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_size_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_size_test.h new file mode 100644 index 0000000000000000000000000000000000000000..176599fe14ba9fe97d88e2182fa3be5b69e94f90 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_size_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_SIZE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_SIZE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_2000 2000 + +class CommonAttrsSizeTest { +public: + ~CommonAttrsSizeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_SIZE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_touchable_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_touchable_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a76539796062db12d8eb9688d6f34ba9ad21c4ae --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_touchable_test.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_touchable_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +using namespace std; +static ArkUI_NodeHandle text; + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t hitTestMode, const char* id) +{ + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue hitTestMode_value[] = { { .i32 = hitTestMode } }; + ArkUI_AttributeItem hitTestMode_item = { hitTestMode_value, + sizeof(hitTestMode_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_HIT_TEST_BEHAVIOR, &hitTestMode_item); + + ArkUI_NumberValue id_value[] = {}; + ArkUI_AttributeItem id_item = { id_value, sizeof(id_value) / sizeof(ArkUI_NumberValue) }; + id_item.string = id; + nodeAPI->setAttribute(button, NODE_ID, &id_item); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(button, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(button, NODE_BACKGROUND_COLOR, &background_color_item); + + nodeAPI->registerNodeEvent(button, NODE_ON_TOUCH_INTERCEPT, ON_TOUCH_EVENT_ID, nullptr); + + return button; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ButtonOnClickTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonOnClickTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ButtonOnClickTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_TOUCH_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + return; + } +} + +napi_value CommonAttrsTouchAbleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTouchAbleTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTouchAbleTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto button1 = CreateChildNode(nodeAPI, ARKUI_HIT_TEST_MODE_DEFAULT, "button1"); + auto button2 = CreateChildNode(nodeAPI, ARKUI_HIT_TEST_MODE_BLOCK, "button2"); + auto button3 = CreateChildNode(nodeAPI, ARKUI_HIT_TEST_MODE_TRANSPARENT, "button3"); + auto button4 = CreateChildNode(nodeAPI, ARKUI_HIT_TEST_MODE_NONE, "button4"); + auto button5 = CreateChildNode(nodeAPI, -1, "button5"); + auto button6 = CreateChildNode(nodeAPI, 4, "button6"); + auto button7 = CreateChildNode(nodeAPI, ARKUI_HIT_TEST_MODE_DEFAULT, "button7"); + nodeAPI->resetAttribute(button7, NODE_HIT_TEST_BEHAVIOR); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + auto columnP1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto columnP2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + + nodeAPI->addChild(columnP1, button1); + nodeAPI->addChild(columnP1, button2); + nodeAPI->addChild(columnP1, button3); + nodeAPI->addChild(columnP1, button4); + nodeAPI->addChild(columnP2, button5); + nodeAPI->addChild(columnP2, button6); + nodeAPI->addChild(columnP2, button7); + nodeAPI->addChild(row, columnP1); + nodeAPI->addChild(row, columnP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTouchAbleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_touchable_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_touchable_test.h new file mode 100644 index 0000000000000000000000000000000000000000..25476be786565902610f9f591b937921129502da --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_touchable_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TOUCHABLE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TOUCHABLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTouchAbleTest { +public: + ~CommonAttrsTouchAbleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSFORM_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transformcenter_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transformcenter_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b3541129cb83b90365587e15144cfed7b3d1c9c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transformcenter_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transformcenter_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateColumnWithTransformCenter(const std::vector& values) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransformCenterTest", "CreateColumnWithTransformCenter"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(SIZE_150); + col->SetHeight(SIZE_150); + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_150); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + ArkUI_NumberValue rotate_value[] = { { .f32 = 0 }, { .f32 = 0 }, { .f32 = 10 }, { .f32 = 60 }, { .f32 = 100 }, + { .i32 = 1000 }, { .i32 = ARKUI_CURVE_LINEAR }, { .i32 = 0 }, { .i32 = 1 }, + { .i32 = ARKUI_ANIMATION_PLAY_MODE_NORMAL }, { .f32 = 1 } }; + ArkUI_AttributeItem rotate_item = { rotate_value, sizeof(rotate_value) / sizeof(ArkUI_NumberValue) }; + column->setAttribute(NODE_ROTATE_TRANSITION, &rotate_item); + std::vector transformcenter_values; + for (auto value : values) { + transformcenter_values.push_back({ .f32 = value }); + } + ArkUI_AttributeItem transformcenter_item = { transformcenter_values.data(), sizeof(transformcenter_values) }; + column->setAttribute(NODE_TRANSFORM_CENTER, &transformcenter_item); + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild(CreateColumnWithTransformCenter({ 150, 150, 0 })); + component->AddChild(CreateColumnWithTransformCenter({ -150, -150, 0 })); + component->AddChild(CreateColumnWithTransformCenter({ 150, 150, 150 })); + component->AddChild(CreateColumnWithTransformCenter({ 150, 150, 0, 0.5, 0.5, 0 })); + component->AddChild(CreateColumnWithTransformCenter({ 150, 150, 0, {}, {}, {} })); + component->AddChild(CreateColumnWithTransformCenter({ 150, 150, 0, 0.5, -0.8, 0.5 })); + auto column7 = CreateColumnWithTransformCenter({ 150, 150, 0 }); + column7->resetAttribute(NODE_TRANSFORM_CENTER); + component->AddChild(column7); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransformCenterTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransformCenterTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransformCenterTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransformCenterTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transformcenter_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transformcenter_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9a55ab719c7422591239e24044c99cadff02543e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transformcenter_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSFORM_CENTER_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSFORM_CENTER_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransformCenterTest { +public: + ~CommonAttrsTransformCenterTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSFORM_CENTER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionasymmetric_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionasymmetric_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..926c9415131243cdf5ee7ff06a692abc752fc6d2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionasymmetric_test.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transitionasymmetric_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithTransitionAsymmetric(const int32_t flag) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionAsymmetricTest", "CreateWithTransitionAsymmetric"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(150); + col->SetHeight(150); + auto column = std::make_shared(); + column->SetWidth(150); + column->SetHeight(150); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + auto opacityEffect = OH_ArkUI_CreateOpacityTransitionEffect(0); + ArkUI_RotationOptions rotationOptions = { 20.0f, 20.0f, 0.0f, 180.0f, 125.0f, 125.0f, 0.0f, 0.0f }; + auto rotationEffect = OH_ArkUI_CreateRotationTransitionEffect(&rotationOptions); + ArkUI_ScaleOptions scaleOptions = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + auto scaleEffect = OH_ArkUI_CreateScaleTransitionEffect(&scaleOptions); + ArkUI_TranslationOptions translationOptions = { 30.0f, 30.0f, -20.0f }; + auto translationEffect = OH_ArkUI_CreateTranslationTransitionEffect(&translationOptions); + auto animateOption = OH_ArkUI_AnimateOption_Create(); + OH_ArkUI_AnimateOption_SetDuration(animateOption, 1000); + OH_ArkUI_AnimateOption_SetTempo(animateOption, 1); + OH_ArkUI_AnimateOption_SetCurve(animateOption, ARKUI_CURVE_LINEAR); + OH_ArkUI_AnimateOption_SetDelay(animateOption, 0); + OH_ArkUI_AnimateOption_SetIterations(animateOption, 1); + OH_ArkUI_AnimateOption_SetPlayMode(animateOption, ARKUI_ANIMATION_PLAY_MODE_NORMAL); + ArkUI_ExpectedFrameRateRange expectedFrameRateRange = { 30, 60, 60 }; + OH_ArkUI_AnimateOption_SetExpectedFrameRateRange(animateOption, &expectedFrameRateRange); + ArkUI_NumberValue transition_value[] = {}; + ArkUI_AttributeItem transition_item = { transition_value, sizeof(transition_value) / sizeof(ArkUI_NumberValue) }; + switch (flag) { + case 1: { + transition_item.object = nullptr; + column->setAttribute(NODE_TRANSITION, &transition_item); + break; + } + case 2: { + OH_ArkUI_TransitionEffect_SetAnimation(scaleEffect, animateOption); + transition_item.object = scaleEffect; + column->setAttribute(NODE_TRANSITION, &transition_item); + break; + } + case 3: { + OH_ArkUI_TransitionEffect_SetAnimation(rotationEffect, animateOption); + OH_ArkUI_TransitionEffect_SetAnimation(scaleEffect, animateOption); + auto transitionEffect1 = OH_ArkUI_CreateAsymmetricTransitionEffect(rotationEffect, scaleEffect); + transition_item.object = transitionEffect1; + column->setAttribute(NODE_TRANSITION, &transition_item); + break; + } + case 4: { + OH_ArkUI_TransitionEffect_Combine(rotationEffect, opacityEffect); + OH_ArkUI_TransitionEffect_Combine(scaleEffect, translationEffect); + OH_ArkUI_TransitionEffect_SetAnimation(rotationEffect, animateOption); + OH_ArkUI_TransitionEffect_SetAnimation(scaleEffect, animateOption); + auto transitionEffect2 = OH_ArkUI_CreateAsymmetricTransitionEffect(rotationEffect, scaleEffect); + transition_item.object = transitionEffect2; + column->setAttribute(NODE_TRANSITION, &transition_item); + break; + } + default: + break; + } + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild(CreateWithTransitionAsymmetric(1)); + component->AddChild(CreateWithTransitionAsymmetric(2)); + component->AddChild(CreateWithTransitionAsymmetric(3)); + component->AddChild(CreateWithTransitionAsymmetric(4)); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransitionAsymmetricTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionAsymmetricTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionAsymmetricTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionAsymmetricTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionasymmetric_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionasymmetric_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a38ea14765d7a6333394a1a1e5ed56393e375e69 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionasymmetric_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_ASYMMETRIC_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_ASYMMETRIC_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransitionAsymmetricTest { +public: + ~CommonAttrsTransitionAsymmetricTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_ASYMMETRIC_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionmove_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionmove_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d6470c09cacdf755b4164c5d91e385b22b87eee5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionmove_test.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transitionmove_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithTransitionMove(const std::vector& values, float tempo) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionMoveTest", "CreateWithTransitionMove"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(80); + col->SetHeight(80); + auto column = std::make_shared(); + column->SetWidth(80); + column->SetHeight(80); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + std::vector move_transition_value; + for (auto value : values) { + move_transition_value.push_back({ .i32 = value }); + } + move_transition_value.push_back({ .f32 = tempo }); + ArkUI_AttributeItem move_transition_item = { move_transition_value.data(), sizeof(move_transition_value) }; + column->setAttribute(NODE_MOVE_TRANSITION, &move_transition_item); + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_BOTTOM, 1000, ARKUI_CURVE_EASE, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_START, 1000, ARKUI_CURVE_EASE_IN, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_END, 1000, ARKUI_CURVE_EASE_OUT, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild( + CreateWithTransitionMove({ -1, 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild( + CreateWithTransitionMove({ 4, 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, -1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 0, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 2000, ARKUI_CURVE_FAST_OUT_SLOW_IN, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_LINEAR, -1000, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_FAST_OUT_LINEAR_IN, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, + 1)); + component->AddChild(CreateWithTransitionMove({ ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_EXTREME_DECELERATION, + 1000, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, + 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 500, ARKUI_CURVE_LINEAR, 0, 0, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_SHARP, 0, -1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_SHARP, 0, 3, ARKUI_ANIMATION_PLAY_MODE_REVERSE }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_RHYTHM, 0, 3, ARKUI_ANIMATION_PLAY_MODE_ALTERNATE }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_RHYTHM, 0, 4, ARKUI_ANIMATION_PLAY_MODE_ALTERNATE_REVERSE }, 1)); + component->AddChild(CreateWithTransitionMove({ ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_RHYTHM, 0, 3, -1 }, 1)); + component->AddChild(CreateWithTransitionMove({ ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_RHYTHM, 0, 3, 4 }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_SMOOTH, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 2)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_SMOOTH, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_SMOOTH, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 0)); + component->AddChild(CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_SMOOTH, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, -1)); + component->AddChild( + CreateWithTransitionMove({ ARKUI_TRANSITION_EDGE_TOP, 1000, -1, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild( + CreateWithTransitionMove({ ARKUI_TRANSITION_EDGE_TOP, 1000, 13, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + auto column = CreateWithTransitionMove( + { ARKUI_TRANSITION_EDGE_TOP, 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1); + column->resetAttribute(NODE_MOVE_TRANSITION); + component->AddChild(column); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransitionMoveTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionMoveTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionMoveTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(5); + grid->SetGridRowsGap(5); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionMoveTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionmove_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionmove_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f12b5db19198e21828ec013ae85a7df2e3844ace --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionmove_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_MOVE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_MOVE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransitionMoveTest { +public: + ~CommonAttrsTransitionMoveTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_MOVE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionopacity_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionopacity_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7860cfe9aaf6fd19e18bef3fc3d4f8fe07c0ad66 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionopacity_test.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transitionopacity_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithTransitionOpacity( + float opacity, const std::vector& values, float tempo) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionOpacityTest", "CreateWithTransitionOpacity"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(150); + col->SetHeight(150); + auto column = std::make_shared(); + column->SetWidth(150); + column->SetHeight(150); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + std::vector opacity_transition_value; + opacity_transition_value.push_back({ .f32 = opacity }); + for (auto value : values) { + opacity_transition_value.push_back({ .i32 = value }); + } + opacity_transition_value.push_back({ .f32 = tempo }); + ArkUI_AttributeItem opacity_transition_item = { opacity_transition_value.data(), sizeof(opacity_transition_value) }; + column->setAttribute(NODE_OPACITY_TRANSITION, &opacity_transition_item); + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild( + CreateWithTransitionOpacity(-1, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild( + CreateWithTransitionOpacity(0, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild( + CreateWithTransitionOpacity(0.5, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild( + CreateWithTransitionOpacity(1, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + auto column = + CreateWithTransitionOpacity(0.5, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1); + column->resetAttribute(NODE_OPACITY_TRANSITION); + component->AddChild(column); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransitionOpacityTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionOpacityTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionMoveTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionOpacityTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionopacity_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionopacity_test.h new file mode 100644 index 0000000000000000000000000000000000000000..43f019bf9a25426caeb1c391cee142bff356c030 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionopacity_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_OPACITY_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_OPACITY_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransitionOpacityTest { +public: + ~CommonAttrsTransitionOpacityTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_OPACITY_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionrotate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionrotate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5d0318a1b8e03115a18f18c9f4caff5aebeb78c8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionrotate_test.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transitionrotate_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithTransitionRotate( + const std::vector& options, const std::vector& values, float tempo) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionRotateTest", "CreateWithTransitionRotate"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(150); + col->SetHeight(150); + auto column = std::make_shared(); + column->SetWidth(150); + column->SetHeight(150); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + std::vector rotate_transition_value; + for (auto option : options) { + rotate_transition_value.push_back({ .f32 = option }); + } + for (auto value : values) { + rotate_transition_value.push_back({ .i32 = value }); + } + rotate_transition_value.push_back({ .f32 = tempo }); + ArkUI_AttributeItem rotate_transition_item = { rotate_transition_value.data(), sizeof(rotate_transition_value) }; + column->setAttribute(NODE_ROTATE_TRANSITION, &rotate_transition_item); + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild(CreateWithTransitionRotate( + { 20, 20, 0, 180, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionRotate( + { 20, 20, 50, 180, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionRotate( + { 0, -50, 0, 180, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionRotate( + { 20, 20, 0, -180, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionRotate( + { 20, 20, 0, 0, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionRotate( + { 20, 20, 0, 180, -1 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionRotate( + { 20, 20, 0, 180, 1 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + auto column = CreateWithTransitionRotate( + { 20, 20, 0, 180, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1); + column->resetAttribute(NODE_ROTATE_TRANSITION); + component->AddChild(column); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransitionRotateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionRotateTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionRotateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionRotateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionrotate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionrotate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..12ec67b30fd13c303821bef77a8ca879fcc71ba7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionrotate_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_ROTATE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_ROTATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransitionRotateTest { +public: + ~CommonAttrsTransitionRotateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_ROTATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionscale_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionscale_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..49131cf6cde2400ba471c179b4b1a5f9d76e1b96 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionscale_test.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transitionscale_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithTransitionScale( + const std::vector& options, const std::vector& values, float tempo) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionScaleTest", "CreateWithTransitionScale"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(150); + col->SetHeight(150); + auto column = std::make_shared(); + column->SetWidth(150); + column->SetHeight(150); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + std::vector rotate_transition_value; + for (auto option : options) { + rotate_transition_value.push_back({ .f32 = option }); + } + for (auto value : values) { + rotate_transition_value.push_back({ .i32 = value }); + } + rotate_transition_value.push_back({ .f32 = tempo }); + ArkUI_AttributeItem rotate_transition_item = { rotate_transition_value.data(), sizeof(rotate_transition_value) }; + column->setAttribute(NODE_SCALE_TRANSITION, &rotate_transition_item); + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild(CreateWithTransitionScale( + { 0, 0, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionScale( + { 0.5, 0.5, 0.5 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionScale( + { 1, 1, 1 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionScale( + { -1, -1, -1 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + auto column = CreateWithTransitionScale( + { 0.5, 0.5, 0.5 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1); + column->resetAttribute(NODE_SCALE_TRANSITION); + component->AddChild(column); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransitionScaleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionScaleTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionScaleTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionScaleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionscale_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionscale_test.h new file mode 100644 index 0000000000000000000000000000000000000000..cbb5491091f42d370f447c81fc9a055d43562ed4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitionscale_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_SCALE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_SCALE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransitionScaleTest { +public: + ~CommonAttrsTransitionScaleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_SCALE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitiontranslate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitiontranslate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6531d4e53964e79008ca2a111b5054d16cd6914e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitiontranslate_test.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_transitiontranslate_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateWithTransitionTranslate( + const std::vector& options, const std::vector& values, float tempo) +{ + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionTranslateTest", "CreateWithTransitionTranslate"); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col = std::make_shared(); + col->SetWidth(150); + col->SetHeight(150); + auto column = std::make_shared(); + column->SetWidth(150); + column->SetHeight(150); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + std::vector translate_transition_value; + for (auto option : options) { + translate_transition_value.push_back({ .f32 = option }); + } + for (auto value : values) { + translate_transition_value.push_back({ .i32 = value }); + } + translate_transition_value.push_back({ .f32 = tempo }); + ArkUI_AttributeItem translate_transition_item = { translate_transition_value.data(), + sizeof(translate_transition_value) }; + column->setAttribute(NODE_TRANSLATE_TRANSITION, &translate_transition_item); + col->AddChild(column); + + return col; +} + +static void AddAllNode(std::shared_ptr component) +{ + component->AddChild(CreateWithTransitionTranslate( + { 0, 0, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionTranslate( + { 20, 20, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionTranslate( + { 20, 20, 20 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + component->AddChild(CreateWithTransitionTranslate( + { -20, -20, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1)); + auto column = CreateWithTransitionTranslate( + { 20, 20, 0 }, { 1000, ARKUI_CURVE_LINEAR, 0, 1, ARKUI_ANIMATION_PLAY_MODE_NORMAL }, 1); + column->resetAttribute(NODE_TRANSLATE_TRANSITION); + component->AddChild(column); +} + +static void RemoveAllNode(std::shared_ptr component) +{ + auto children = component->GetChildren(); + for (auto it = children.begin(); it != children.end(); ++it) { + (*it)->RemoveChild((*it)->GetChildren().front()); + } +} + +napi_value CommonAttrsTransitionTranslateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsTransitionTranslateTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionTranslateTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto row = std::make_shared(ARKUI_NODE_ROW); + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + button1->SetId("Button1"); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button2->SetId("Button2"); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + row->AddChild(button1); + row->AddChild(button2); + auto column1 = std::make_shared(); + column1->SetWidth(400); + column1->SetHeight(600); + column->AddChild(row); + column->AddChild(column1); + auto grid = std::make_shared(); + grid->SetGridColumnsGap(10); + grid->SetGridRowsGap(10); + column1->AddChild(grid); + + button1->RegisterOnClick([grid]() { AddAllNode(grid); }); + button2->RegisterOnClick([grid]() { RemoveAllNode(grid); }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTransitionTranslateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitiontranslate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitiontranslate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..c02aa51f305a66719849168dadf395dce092c6e2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_transitiontranslate_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_TRANSLATE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_TRANSLATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "button_component.h" +#include "column_component.h" +#include "grid_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTransitionTranslateTest { +public: + ~CommonAttrsTransitionTranslateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSITION_TRANSLATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_translate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_translate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f9a51f8e83846818adc74a5041f555eb1f3c6b98 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_translate_test.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_translate_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, float x, float y, float z) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 60 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 60 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue translateValue[] = { { .f32 = x }, { .f32 = y }, { .f32 = z } }; + ArkUI_AttributeItem translateItem = { translateValue, sizeof(translateValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TRANSLATE, &translateItem); + + return nodeHandle; +} + +static auto CreateChildNode1(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 60 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 60 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + + ArkUI_NumberValue translateValue[] = { {}, {}, {} }; + ArkUI_AttributeItem translateItem = { translateValue, sizeof(translateValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TRANSLATE, &translateItem); + + return nodeHandle; +} + +static auto CreateColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue width_value[] = { { .f32 = 230 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 230 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + + return nodeHandle; +} + +static auto CreateRowNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_ROW); + + ArkUI_NumberValue width_value[] = { { .f32 = 230 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 230 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_item); + + return nodeHandle; +} + +napi_value CommonAttrsTranslateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTranslateTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTranslateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column and set translate + auto column1 = CreateChildNode(nodeAPI, 0, 0, 0); + auto column2 = CreateChildNode(nodeAPI, 60, 0, 0); + auto column3 = CreateChildNode(nodeAPI, -60, 0, 0); + auto column4 = CreateChildNode(nodeAPI, 0, 0, 0); + auto column5 = CreateChildNode(nodeAPI, 0, 60, 0); + auto column6 = CreateChildNode(nodeAPI, 0, -60, 0); + auto column7 = CreateChildNode(nodeAPI, 0, 0, 0); + auto column8 = CreateChildNode(nodeAPI, 0, 0, 100); + auto column9 = CreateChildNode(nodeAPI, 0, 0, -10); + auto column10 = CreateChildNode1(nodeAPI); + auto column11 = CreateChildNode(nodeAPI, 60, 60, 60); + auto column12 = CreateChildNode(nodeAPI, 400, 400, 400); + auto column13 = CreateChildNode(nodeAPI, -60, 40, 60); + auto column14 = CreateChildNode(nodeAPI, -60, 80, -60); + auto column15 = CreateChildNode(nodeAPI, 60, -80, 60); + auto column16 = CreateChildNode(nodeAPI, 60, -40, -60); + auto column17 = CreateChildNode(nodeAPI, 60, 40, 60); + auto column18 = CreateChildNode(nodeAPI, 60, 80, -60); + auto column19 = CreateChildNode(nodeAPI, -60, -80, 60); + auto column20 = CreateChildNode(nodeAPI, -60, -40, -60); + + // add child + auto columnP1 = CreateColumnNode(nodeAPI); + auto rowP2 = CreateRowNode(nodeAPI); + auto columnP3 = CreateColumnNode(nodeAPI); + auto columnP4 = CreateColumnNode(nodeAPI); + auto columnP5 = CreateColumnNode(nodeAPI); + auto columnP6 = CreateColumnNode(nodeAPI); + auto ColumnP1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto ColumnP2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + nodeAPI->addChild(columnP1, column1); + nodeAPI->addChild(columnP1, column2); + nodeAPI->addChild(columnP1, column3); + nodeAPI->addChild(rowP2, column4); + nodeAPI->addChild(rowP2, column5); + nodeAPI->addChild(rowP2, column6); + nodeAPI->addChild(columnP3, column7); + nodeAPI->addChild(columnP3, column8); + nodeAPI->addChild(columnP3, column9); + nodeAPI->resetAttribute(column11, NODE_TRANSLATE); + nodeAPI->addChild(columnP4, column10); + nodeAPI->addChild(columnP4, column11); + nodeAPI->addChild(columnP4, column12); + nodeAPI->addChild(columnP5, column13); + nodeAPI->addChild(columnP5, column14); + nodeAPI->addChild(columnP5, column15); + nodeAPI->addChild(columnP5, column16); + nodeAPI->addChild(columnP6, column17); + nodeAPI->addChild(columnP6, column18); + nodeAPI->addChild(columnP6, column19); + nodeAPI->addChild(columnP6, column20); + nodeAPI->addChild(ColumnP1, columnP1); + nodeAPI->addChild(ColumnP1, rowP2); + nodeAPI->addChild(ColumnP1, columnP3); + nodeAPI->addChild(ColumnP2, columnP4); + nodeAPI->addChild(ColumnP2, columnP5); + nodeAPI->addChild(ColumnP2, columnP6); + nodeAPI->addChild(row, ColumnP1); + nodeAPI->addChild(row, ColumnP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsTranslateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_translate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_translate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f48f1062752f3ff8518aa74f3d2c1cb6f39833ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_translate_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_TRANSLATE_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_TRANSLATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsTranslateTest { +public: + ~CommonAttrsTranslateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_TRANSLATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_visibility_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_visibility_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0aff86cdd3174dbc1a9dab8fc6da2da52e8fbe52 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_visibility_test.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_visibility_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateChildWithVisibility(int32_t visibility) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsVisibilityTest", "CreateChildWithVisibility"); + + auto column = std::make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetMargin(DEFAULT_MARGIN); + column->SetBackgroundImage("resource://media/icon.png"); + column->SetBackgroundImageSizeWithStyle(ARKUI_IMAGE_SIZE_COVER); + if (visibility != PARAM_NEGATIVE_100) { + column->SetVisibility(visibility); + } + + return column; +} + +napi_value CommonAttrsVisibilityTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonAttrsVisibilityTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsVisibilityTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + auto column1 = CreateChildWithVisibility(ARKUI_VISIBILITY_VISIBLE); + auto column2 = CreateChildWithVisibility(ARKUI_VISIBILITY_HIDDEN); + auto column3 = CreateChildWithVisibility(ARKUI_VISIBILITY_NONE); + auto column4 = CreateChildWithVisibility(-1); + auto column5 = CreateChildWithVisibility(3); + auto column6 = CreateChildWithVisibility(ARKUI_VISIBILITY_HIDDEN); + auto column7 = CreateChildWithVisibility(PARAM_NEGATIVE_100); + column6->resetAttribute(NODE_VISIBILITY); + column->AddChild(column1); + column->AddChild(column2); + column->AddChild(column3); + column->AddChild(column4); + column->AddChild(column5); + column->AddChild(column6); + column->AddChild(column7); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsVisibilityTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_visibility_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_visibility_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e16a5c08d6b377ca8debf8509cef62ad40fe9902 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_visibility_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_VISIBILITY_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_VISIBILITY_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class CommonAttrsVisibilityTest { +public: + ~CommonAttrsVisibilityTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_VISIBILITY_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_zindex_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_zindex_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..794859ae75ab43226ff638d378aea53fa709fa60 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_zindex_test.cpp @@ -0,0 +1,290 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "commonattrs_zindex_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetZIndex(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float zIndex) +{ + ArkUI_NumberValue zIndex_value[] = { { .f32 = zIndex } }; + ArkUI_AttributeItem zIndex_item = { zIndex_value, sizeof(zIndex_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_Z_INDEX, &zIndex_item); + return nodeHandle; +} + +static auto SetOther(ArkUI_NodeHandle& nodeHandle, float width, float height, uint32_t backgroundColor, char* id) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + nodeHandle = SetWidth(nodeAPI, nodeHandle, width); + nodeHandle = SetHeight(nodeAPI, nodeHandle, height); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, backgroundColor); + nodeHandle = SetId(nodeAPI, nodeHandle, id); + return nodeHandle; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CLICK_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static auto CreateParentNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto stack1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_STACK); + auto text1 = CreateChildNode(nodeAPI, stack1, ARKUI_NODE_TEXT); + auto text2 = CreateChildNode(nodeAPI, stack1, ARKUI_NODE_TEXT); + auto text3 = CreateChildNode(nodeAPI, stack1, ARKUI_NODE_TEXT); + auto stack2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_STACK); + auto text4 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_TEXT); + auto text5 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_TEXT); + auto text6 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_TEXT); + auto text7 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_TEXT); + auto stack3 = CreateChildNode(nodeAPI, column, ARKUI_NODE_STACK); + auto text8 = CreateChildNode(nodeAPI, stack3, ARKUI_NODE_TEXT); + auto text9 = CreateChildNode(nodeAPI, stack3, ARKUI_NODE_TEXT); + auto text10 = CreateChildNode(nodeAPI, stack3, ARKUI_NODE_TEXT); + + stack1 = SetOther(stack1, SIZE_300, SIZE_300, COLOR_RED, "stack1"); + text1 = SetOther(text1, SIZE_250, SIZE_250, COLOR_GREEN, "text1"); + text2 = SetOther(text2, SIZE_200, SIZE_200, COLOR_BLUE, "text2"); + text3 = SetOther(text3, SIZE_150, SIZE_150, COLOR_YELLOW, "text3"); + stack2 = SetOther(stack1, SIZE_300, SIZE_300, COLOR_RED, "stack2"); + text4 = SetOther(text4, SIZE_150, SIZE_150, COLOR_GREEN, "text4"); + text5 = SetOther(text5, SIZE_200, SIZE_200, COLOR_BLUE, "text5"); + text6 = SetOther(text6, SIZE_100, SIZE_100, COLOR_YELLOW, "text6"); + text7 = SetOther(text7, SIZE_250, SIZE_250, COLOR_PURPLE, "text7"); + stack3 = SetOther(stack3, SIZE_150, SIZE_150, COLOR_RED, "stack3"); + text8 = SetOther(text8, SIZE_50, SIZE_150, COLOR_GREEN, "text8"); + text9 = SetOther(text9, SIZE_100, SIZE_100, COLOR_BLUE, "text9"); + text10 = SetOther(text10, SIZE_150, SIZE_50, COLOR_YELLOW, "text10"); + text1 = SetZIndex(nodeAPI, text1, PARAM_0); + text2 = SetZIndex(nodeAPI, text2, PARAM_1); + text3 = SetZIndex(nodeAPI, text3, PARAM_2); + text4 = SetZIndex(nodeAPI, text4, PARAM_2); + text5 = SetZIndex(nodeAPI, text5, PARAM_0); + text6 = SetZIndex(nodeAPI, text6, SIZE_300); + text7 = SetZIndex(nodeAPI, text7, PARAM_NEGATIVE_1); + text8 = SetZIndex(nodeAPI, text8, PARAM_2); + text9 = SetZIndex(nodeAPI, text9, PARAM_1); + text10 = SetZIndex(nodeAPI, text10, PARAM_0); + nodeAPI->resetAttribute(text8, NODE_Z_INDEX); + nodeAPI->resetAttribute(text9, NODE_Z_INDEX); + nodeAPI->resetAttribute(text10, NODE_Z_INDEX); + return column; +} + +napi_value CommonAttrsZIndexTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", "CreateNativeNodePage1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = CreateParentNode(nodeAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsZIndexTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", "CreateNativeNodePage2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto stack1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_STACK); + auto button1 = CreateChildNode(nodeAPI, stack1, ARKUI_NODE_BUTTON); + auto button2 = CreateChildNode(nodeAPI, stack1, ARKUI_NODE_BUTTON); + auto button3 = CreateChildNode(nodeAPI, stack1, ARKUI_NODE_BUTTON); + stack1 = SetOther(stack1, SIZE_400, SIZE_400, COLOR_RED, "stack1"); + button1 = SetOther(button1, SIZE_300, SIZE_300, COLOR_YELLOW, "button1"); + button2 = SetOther(button2, SIZE_200, SIZE_200, COLOR_BLUE, "button2"); + button3 = SetOther(button3, SIZE_100, SIZE_100, COLOR_GREEN, "button3"); + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(button2, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(button3, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CommonAttrsZIndexTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", "CreateNativeNodePage3"); + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto stack2 = CreateChildNode(nodeAPI, column, ARKUI_NODE_STACK); + auto button4 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_BUTTON); + auto button5 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_BUTTON); + auto button6 = CreateChildNode(nodeAPI, stack2, ARKUI_NODE_BUTTON); + stack2 = SetOther(stack2, SIZE_400, SIZE_400, COLOR_RED, "stack2"); + button4 = SetOther(button4, SIZE_100, SIZE_100, COLOR_YELLOW, "button4"); + button5 = SetOther(button5, SIZE_200, SIZE_200, COLOR_BLUE, "button5"); + button6 = SetOther(button6, SIZE_300, SIZE_300, COLOR_GREEN, "button6"); + button4 = SetZIndex(nodeAPI, button4, PARAM_3); + button5 = SetZIndex(nodeAPI, button5, PARAM_2); + button6 = SetZIndex(nodeAPI, button6, PARAM_1); + nodeAPI->registerNodeEvent(button4, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(button5, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(button6, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonAttrsZIndexTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_zindex_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_zindex_test.h new file mode 100644 index 0000000000000000000000000000000000000000..229eff51dd5463dd12ec4cf9d4952e30b72b9376 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonattrs/commonattrs_zindex_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMONATTRS_ZINDEX_TEST_H +#define ARKUI_CAPI_DEMO_COMMONATTRS_ZINDEX_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonAttrsZIndexTest { +public: + ~CommonAttrsZIndexTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMONATTRS_ZINDEX_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonevent/common_event.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/commonevent/common_event.cpp new file mode 100644 index 0000000000000000000000000000000000000000..447612d26ac16cb766aed013e07f3b15e9026d9f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonevent/common_event.cpp @@ -0,0 +1,507 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "common_event.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +constexpr int32_t LEFT_MOUSE_BUTTON = 1; +constexpr int32_t RIGHT_MOUSE_BUTTON = 2; +constexpr int32_t MIDDLE_MOUSE_BUTTON = 3; +constexpr int32_t MOUSE_PRESSED = 1; +constexpr int32_t MOUSE_RELEASE = 2; +constexpr int32_t MOUSE_MOVEMENT = 3; +static std::vector MouseActionVector; + +napi_value CommonEventTest::CreateNativeNode001(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + + auto text = new TextComponent(); + text->SetWidth(300); + text->SetHeight(100); + text->SetBackgroundColor(COLOR_GRAY); + text->SetMargin(10); + text->SetFontSize(20); + + auto button_disappear = new ButtonComponent(); + button_disappear->SetWidth(200); + button_disappear->SetHeight(100); + button_disappear->SetBackgroundColor(COLOR_BLUE); + button_disappear->SetMargin(10); + button_disappear->SetLable("disappear"); + button_disappear->RegisterOnDisappear( + [nodeAPI, text, parentColumn]() { nodeAPI->addChild(parentColumn->GetComponent(), text->GetComponent()); }); + + auto button = new ButtonComponent(); + button->SetWidth(200); + button->SetHeight(100); + button->SetBackgroundColor(COLOR_GREEN); + button->SetLable("Click"); + button->SetFontSize(20); + button->SetId("onTouchTest"); + button->RegisterOnClick([parentColumn, button_disappear, nodeAPI]() { + nodeAPI->removeChild(parentColumn->GetComponent(), button_disappear->GetComponent()); + }); + button->RegisterOnTouch([text](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + + float x = OH_ArkUI_PointerEvent_GetX(uiInputEvent); + float y = OH_ArkUI_PointerEvent_GetY(uiInputEvent); + auto type = OH_ArkUI_UIInputEvent_GetAction(uiInputEvent); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "button OnTouch type=%{public}d,x=%{public}f,y=%{public}f", type, x, y); + // 如果不设置,则会执行column的touch事件,text显示下面设置的"colum On Touch" + OH_ArkUI_PointerEvent_SetStopPropagation(uiInputEvent, true); + text->SetTextContent("SetStopPropagationTrue"); + }); + + parentColumn->RegisterOnTouch([text](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + float x = OH_ArkUI_PointerEvent_GetX(uiInputEvent); + float y = OH_ArkUI_PointerEvent_GetY(uiInputEvent); + auto type = OH_ArkUI_UIInputEvent_GetAction(uiInputEvent); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "parentColumn OnTouch type=%{public}d,x=%{public}f,y=%{public}f", type, x, y); + text->SetTextContent("colum On Touch"); + }); + + parentColumn->AddChild(std::shared_ptr(button)); + parentColumn->AddChild(std::shared_ptr(button_disappear)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonEventTest::CreateNativeNodeForOnHover(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "CreateNativeNodeForHover"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + + auto button = new ButtonComponent(); + button->SetWidth(200); + button->SetHeight(100); + button->SetBackgroundColor(COLOR_BLUE); + button->SetFontSize(20); + button->SetId("onHoverTest"); + button->RegisterOnHover([button](bool isHover) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "OnHover isHover=%{public}d", isHover); + if (isHover) { + button->SetBackgroundColor(COLOR_GRAY); + } else { + button->SetBackgroundColor(COLOR_BLUE); + } + }); + parentColumn->AddChild(std::shared_ptr(button)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonEventTest::CreateNativeNodeForOnVisibleAreaChange(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "CreateNativeNodeForOnVisibleAreaChange"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto text = new TextComponent(); + text->SetWidth(300); + text->SetHeight(50); + text->SetBackgroundColor(COLOR_GREEN); + text->SetMargin(10); + auto scroll = new Component(ARKUI_NODE_SCROLL); + scroll->SetWidth(400); + scroll->SetHeight(800); + scroll->SetBackgroundColor(COLOR_GRAY); + + auto column = new ColumnComponent(); + auto button = new ButtonComponent(); + button->SetWidth(300); + button->SetHeight(100); + button->SetLable("OnVisibleAreaChange"); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_BLUE); + button->SetId("OnVisibleAreaChange"); + parentColumn->AddChild(std::shared_ptr(text)); + parentColumn->AddChild(std::shared_ptr(scroll)); + scroll->AddChild(std::shared_ptr(column)); + column->AddChild(std::shared_ptr(button)); + for (int32_t i = 0; i <= 10; i++) { + auto text = new TextComponent(); + text->SetWidth(380); + text->SetHeight(80); + text->SetBackgroundColor(COLOR_LIGHT_BLUE); + text->SetTextContent(std::to_string(i)); + text->SetFontSize(20); + text->SetMargin(10); + text->SetTextAlign(ARKUI_TEXT_ALIGNMENT_CENTER); + column->AddChild(std::shared_ptr(text)); + } + std::vector ratioArray; + ratioArray.push_back(0.0f); + ratioArray.push_back(1.0f); + button->RegisterOnVisibleAreaChange( + [text](bool isExpanding, float currentRatio) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "RegisterOnVisibleAreaChange callback, isExpanding=%{public}d, currentRatio=%{public}f", isExpanding, + currentRatio); + if (isExpanding && currentRatio >= 1.0) { + text->SetBackgroundColor(COLOR_GREEN); + } + if (!isExpanding && currentRatio <= 0.0) { + text->SetBackgroundColor(COLOR_GRAY); + } + }, + ratioArray); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonEventTest::CreateNativeNodeForOnMouse(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "CreateNativeNodeForHover"); + MouseActionVector.clear(); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto button = new ButtonComponent(); + button->SetWidth(200); + button->SetHeight(100); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_BLUE); + button->SetFontSize(20); + button->SetId("onMouseRightTest"); + button->RegisterOnMouse([button](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + auto mouseAction = OH_ArkUI_MouseEvent_GetMouseAction(uiInputEvent); + auto mouseButton = OH_ArkUI_MouseEvent_GetMouseButton(uiInputEvent); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "CreateNativeNodeForOnMouse mouseAction=%{public}d,mouseButton=%{public}d", mouseAction, mouseButton); + // 先收到MOUSE_PRESSED,再收到MOUSE_RELEASE + if (mouseButton != RIGHT_MOUSE_BUTTON) { + return; + } + if (mouseAction == MOUSE_PRESSED) { + MouseActionVector.push_back(MOUSE_PRESSED); + } + if (mouseAction == MOUSE_RELEASE) { + auto actionLength = MouseActionVector.size(); + if (actionLength == 1) { + auto action = MouseActionVector[0]; + if (action == MOUSE_PRESSED) { + button->SetBackgroundColor(COLOR_YELLOW); + } + } + } + }); + parentColumn->AddChild(std::shared_ptr(button)); + + auto button1 = new ButtonComponent(); + button1->SetWidth(200); + button1->SetHeight(100); + button1->SetMargin(10); + button1->SetBackgroundColor(COLOR_BLUE); + button1->SetFontSize(20); + button1->SetId("onMouseLeftTest"); + button1->RegisterOnMouse([button1](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + auto mouseAction = OH_ArkUI_MouseEvent_GetMouseAction(uiInputEvent); + auto mouseButton = OH_ArkUI_MouseEvent_GetMouseButton(uiInputEvent); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "CreateNativeNodeForOnMouse mouseAction=%{public}d,mouseButton=%{public}d", mouseAction, mouseButton); + + if (mouseButton == LEFT_MOUSE_BUTTON && mouseAction == MOUSE_PRESSED) { + button1->SetBackgroundColor(COLOR_PURPLE); + } + }); + parentColumn->AddChild(std::shared_ptr(button1)); + + auto button2 = new ButtonComponent(); + button2->SetWidth(200); + button2->SetHeight(100); + button2->SetMargin(10); + button2->SetBackgroundColor(COLOR_BLUE); + button2->SetFontSize(20); + button2->SetId("onMouseMiddleTest"); + button2->RegisterOnMouse([button2](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + auto mouseAction = OH_ArkUI_MouseEvent_GetMouseAction(uiInputEvent); + auto mouseButton = OH_ArkUI_MouseEvent_GetMouseButton(uiInputEvent); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "CreateNativeNodeForOnMouse mouseAction=%{public}d,mouseButton=%{public}d", mouseAction, mouseButton); + if (mouseButton == MIDDLE_MOUSE_BUTTON && mouseAction == MOUSE_PRESSED) { + button2->SetBackgroundColor(COLOR_PINK); + } + }); + parentColumn->AddChild(std::shared_ptr(button2)); + + auto button3 = new ButtonComponent(); + button3->SetWidth(200); + button3->SetHeight(100); + button3->SetMargin(10); + button3->SetBackgroundColor(COLOR_BLUE); + button3->SetFontSize(20); + button3->SetId("onMouseMoveTest"); + button3->RegisterOnMouse([button3](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + auto mouseAction = OH_ArkUI_MouseEvent_GetMouseAction(uiInputEvent); + auto mouseButton = OH_ArkUI_MouseEvent_GetMouseButton(uiInputEvent); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", + "CreateNativeNodeForOnMouse mouseAction=%{public}d,mouseButton=%{public}d", mouseAction, mouseButton); + if (mouseAction == MOUSE_MOVEMENT) { + button3->SetBackgroundColor(COLOR_BLACK); + } + }); + parentColumn->AddChild(std::shared_ptr(button3)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value CommonEventTest::CreateNativeNodeForOnTouchIntercept(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "CreateNativeNodeForonTouchIntercept"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto column1 = new ColumnComponent(); + column1->SetMargin(5); + column1->SetWidth(400); + column1->SetHeight(200); + column1->SetBackgroundColor(COLOR_PINK); + auto text1 = new TextComponent(); + text1->SetMargin(10); + text1->SetWidth(300); + text1->SetHeight(100); + text1->SetId("HitTestModeNone"); + text1->SetBackgroundColor(COLOR_BLUE); + text1->RegisterOnTouch([text1](ArkUI_NodeEvent* event) { text1->SetBackgroundColor(COLOR_GREEN); }); + column1->RegisterOnTouch([column1](ArkUI_NodeEvent* event) { column1->SetBackgroundColor(COLOR_RED); }); + column1->RegisterOnTouchIntercept([column1](ArkUI_NodeEvent* event) { + // Set HitTestMode HitTestMode::HTM_NONE + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + OH_ArkUI_PointerEvent_SetInterceptHitTestMode(uiInputEvent, HitTestMode::HTM_NONE); + }); + column1->AddChild(std::shared_ptr(text1)); + + auto column2 = new ColumnComponent(); + column2->SetMargin(5); + column2->SetWidth(400); + column2->SetHeight(200); + column2->SetBackgroundColor(COLOR_PINK); + auto text2 = new TextComponent(); + text2->SetMargin(10); + text2->SetWidth(300); + text2->SetHeight(100); + text2->SetBackgroundColor(COLOR_BLUE); + text2->SetId("HitTestModeTransparent"); + text2->RegisterOnTouch([text2](ArkUI_NodeEvent* event) { text2->SetBackgroundColor(COLOR_GREEN); }); + column2->RegisterOnTouch([column2](ArkUI_NodeEvent* event) { column2->SetBackgroundColor(COLOR_RED); }); + column2->RegisterOnTouchIntercept([column2](ArkUI_NodeEvent* event) { + // Set HitTestMode HitTestMode::HTM_TRANSPARENT + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + OH_ArkUI_PointerEvent_SetInterceptHitTestMode(uiInputEvent, HitTestMode::HTM_TRANSPARENT); + }); + column2->AddChild(std::shared_ptr(text2)); + + auto column3 = new ColumnComponent(); + column3->SetMargin(5); + column3->SetWidth(400); + column3->SetHeight(200); + column3->SetBackgroundColor(COLOR_PINK); + auto text3 = new TextComponent(); + text3->SetMargin(10); + text3->SetWidth(300); + text3->SetHeight(100); + text3->SetBackgroundColor(COLOR_BLUE); + text3->SetId("HitTestModeBlock"); + text3->RegisterOnTouch([text3](ArkUI_NodeEvent* event) { text3->SetBackgroundColor(COLOR_GREEN); }); + column3->RegisterOnTouch([column3](ArkUI_NodeEvent* event) { column3->SetBackgroundColor(COLOR_RED); }); + column3->RegisterOnTouchIntercept([column3](ArkUI_NodeEvent* event) { + // Set HitTestMode HitTestMode::HTM_BLOCK + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + OH_ArkUI_PointerEvent_SetInterceptHitTestMode(uiInputEvent, HitTestMode::HTM_BLOCK); + }); + column3->AddChild(std::shared_ptr(text3)); + + auto column4 = new ColumnComponent(); + column4->SetMargin(5); + column4->SetWidth(400); + column4->SetHeight(200); + column4->SetBackgroundColor(COLOR_PINK); + auto text4 = new TextComponent(); + text4->SetMargin(10); + text4->SetWidth(300); + text4->SetHeight(100); + text4->SetBackgroundColor(COLOR_BLUE); + text4->SetId("HitTestModeDefault"); + text4->RegisterOnTouch([text4](ArkUI_NodeEvent* event) { text4->SetBackgroundColor(COLOR_GREEN); }); + column4->RegisterOnTouch([column4](ArkUI_NodeEvent* event) { column4->SetBackgroundColor(COLOR_RED); }); + column4->RegisterOnTouchIntercept([column4](ArkUI_NodeEvent* event) { + // Set HitTestMode HitTestMode::HTM_DEFAULT + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + OH_ArkUI_PointerEvent_SetInterceptHitTestMode(uiInputEvent, HitTestMode::HTM_DEFAULT); + }); + column4->AddChild(std::shared_ptr(text4)); + + parentColumn->AddChild(std::shared_ptr(column1)); + parentColumn->AddChild(std::shared_ptr(column2)); + parentColumn->AddChild(std::shared_ptr(column3)); + parentColumn->AddChild(std::shared_ptr(column4)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/commonevent/common_event.h b/function/ui_compare/capidemo/entry/src/main/cpp/commonevent/common_event.h new file mode 100644 index 0000000000000000000000000000000000000000..3520f543867f4f94198ecf41b78ebbb9555c9d49 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/commonevent/common_event.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMMON_EVENT_TEST_H +#define ARKUI_CAPI_DEMO_COMMON_EVENT_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CommonEventTest { +public: + ~CommonEventTest(); + // testCommonEventTest001 + static napi_value CreateNativeNode001(napi_env env, napi_callback_info info); + // testCommonEventTest002 + static napi_value CreateNativeNodeForOnHover(napi_env env, napi_callback_info info); + // testCommonEventTest003 + static napi_value CreateNativeNodeForOnVisibleAreaChange(napi_env env, napi_callback_info info); + // testCommonEventTest004 + static napi_value CreateNativeNodeForOnMouse(napi_env env, napi_callback_info info); + // testCommonEventTest004 + static napi_value CreateNativeNodeForOnTouchIntercept(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_COMMON_EVENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/animator_option.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/animator_option.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1163b9abc07e5f42a632c30e5a44dd049f19bba0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/animator_option.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "animator_option.h" + +namespace ArkUICApiDemo { +bool Animator::SetOptionParam(const AnimatorOption& param) +{ + if (OH_ArkUI_AnimatorOption_SetDuration(_option, param.duration) || + OH_ArkUI_AnimatorOption_SetDelay(_option, param.delay) || + OH_ArkUI_AnimatorOption_SetIterations(_option, param.iterations) || + OH_ArkUI_AnimatorOption_SetFill(_option, param.fill) || + OH_ArkUI_AnimatorOption_SetDirection(_option, param.direction) || + OH_ArkUI_AnimatorOption_SetBegin(_option, param.begin) || OH_ArkUI_AnimatorOption_SetEnd(_option, param.end) || + OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange(_option, param.expectedFrameRateRange) || + OH_ArkUI_AnimatorOption_SetCurve(_option, param.easing)) { + return false; + } + return true; +} + +AnimatorOption Animator::GetOptionParam() +{ + AnimatorOption option; + option.duration = OH_ArkUI_AnimatorOption_GetDuration(_option); + option.delay = OH_ArkUI_AnimatorOption_GetDelay(_option); + option.iterations = OH_ArkUI_AnimatorOption_GetIterations(_option); + option.fill = OH_ArkUI_AnimatorOption_GetFill(_option); + option.direction = OH_ArkUI_AnimatorOption_GetDirection(_option); + option.begin = OH_ArkUI_AnimatorOption_GetBegin(_option); + option.end = OH_ArkUI_AnimatorOption_GetEnd(_option); + option.expectedFrameRateRange = OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(_option); + option.easing = OH_ArkUI_AnimatorOption_GetCurve(_option); + return option; +} + +bool Animator::SetKeyframeParams(const std::vector& params) +{ + for (size_t i = 0; i < params.size(); i++) { + if (OH_ArkUI_AnimatorOption_SetKeyframe(_option, params[i].keyTime, params[i].keyValue, i) || + OH_ArkUI_AnimatorOption_SetKeyframeCurve(_option, params[i].curve, i)) { + return false; + } + } + return true; +} + +Keyframe Animator::GetKeyframeParam(int32_t index) +{ + Keyframe keyframe; + keyframe.keyTime = OH_ArkUI_AnimatorOption_GetKeyframeTime(_option, index); + keyframe.keyValue = OH_ArkUI_AnimatorOption_GetKeyframeValue(_option, index); + keyframe.curve = OH_ArkUI_AnimatorOption_GetKeyframeCurve(_option, index); + return keyframe; +} + +void Animator::RegisterOnFrame(const std::function& onFrame) +{ + if (onFrame) { + _onFrame = onFrame; + } +} + +void Animator::RegisterOnFinish(const std::function& onFinish) +{ + if (onFinish) { + _onFinish = onFinish; + } +} + +void Animator::RegisterOnCancel(const std::function& onCancel) +{ + if (onCancel) { + _onCancel = onCancel; + } +} + +void Animator::RegisterOnRepeat(const std::function& onRepeat) +{ + if (onRepeat) { + _onRepeat = onRepeat; + } +} + +bool Animator::Play() +{ + return !OH_ArkUI_Animator_Play(_animatorHandle); +} + +bool Animator::Finish() +{ + return !OH_ArkUI_Animator_Finish(_animatorHandle); +} + +bool Animator::Pause() +{ + return !OH_ArkUI_Animator_Pause(_animatorHandle); +} + +bool Animator::Cancel() +{ + return !OH_ArkUI_Animator_Cancel(_animatorHandle); +} + +bool Animator::Reverse() +{ + return !OH_ArkUI_Animator_Reverse(_animatorHandle); +} + +bool Animator::Reset() +{ + return !OH_ArkUI_Animator_ResetAnimatorOption(_animatorHandle, _option); +} + +void Animator::RegisterReceiver() +{ + OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(_option, this, [](ArkUI_AnimatorOnFrameEvent* event) { + auto animator = static_cast(OH_ArkUI_AnimatorOnFrameEvent_GetUserData(event)); + auto value = OH_ArkUI_AnimatorOnFrameEvent_GetValue(event); + animator->_onFrame(value); + }); + OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(_option, this, [](ArkUI_AnimatorEvent* event) { + auto animator = static_cast(OH_ArkUI_AnimatorEvent_GetUserData(event)); + animator->_onFinish(); + }); + OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(_option, this, [](ArkUI_AnimatorEvent* event) { + auto animator = static_cast(OH_ArkUI_AnimatorEvent_GetUserData(event)); + animator->_onCancel(); + }); + OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(_option, this, [](ArkUI_AnimatorEvent* event) { + auto animator = static_cast(OH_ArkUI_AnimatorEvent_GetUserData(event)); + animator->_onRepeat(); + }); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/animator_option.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/animator_option.h new file mode 100644 index 0000000000000000000000000000000000000000..8724bfe2a8aac480d42621e04323462e3ccb6e90 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/animator_option.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_ANIMATOR_OPTION_H +#define CAPIDEMO_ANIMATOR_OPTION_H + +#include +#include +#include +#include + +#include "component.h" + +namespace ArkUICApiDemo { + +struct Keyframe { + float keyTime; + float keyValue; + ArkUI_CurveHandle curve; +}; + +struct AnimatorOption { + int32_t duration; + int32_t delay; + int32_t iterations; + ArkUI_AnimationFillMode fill; + ArkUI_AnimationDirection direction; + float begin; + float end; + ArkUI_ExpectedFrameRateRange* expectedFrameRateRange; + ArkUI_CurveHandle easing; +}; + +class Animator { +public: + explicit Animator(ArkUI_NodeHandle node, int32_t keyframeSize) + : _option(OH_ArkUI_AnimatorOption_Create(keyframeSize)) + { + ArkUI_NativeAnimateAPI_1* animateAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_ANIMATE, ArkUI_NativeAnimateAPI_1, animateAPI); + auto context = OH_ArkUI_GetContextByNode(node); + _animatorHandle = animateAPI->createAnimator(context, _option); + RegisterReceiver(); + } + ~Animator() + { + OH_ArkUI_AnimatorOption_Dispose(_option); + _option = nullptr; + } + + bool SetOptionParam(const AnimatorOption& param); + AnimatorOption GetOptionParam(); + bool SetKeyframeParams(const std::vector& params); + Keyframe GetKeyframeParam(int32_t index); + void RegisterOnFrame(const std::function& onFrame); + void RegisterOnFinish(const std::function& onFinish); + void RegisterOnCancel(const std::function& onCancel); + void RegisterOnRepeat(const std::function& onRepeat); + + bool Play(); + bool Finish(); + bool Pause(); + bool Cancel(); + bool Reverse(); + bool Reset(); + +protected: + void RegisterReceiver(); + +private: + ArkUI_AnimatorOption* _option; + ArkUI_AnimatorHandle _animatorHandle; + std::function _onFrame; + std::function _onFinish; + std::function _onCancel; + std::function _onRepeat; +}; +} // namespace ArkUICApiDemo + +#endif // CAPIDEMO_ANIMATOR_OPTION_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/button_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/button_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6fd8c36a04d4828db0d71f0bc954b57ed67de04d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/button_component.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "button_component.h" + +namespace ArkUICApiDemo { + +void ButtonComponent::SetLable(const std::string& content) +{ + ArkUI_AttributeItem item = { nullptr, 0, content.c_str() }; + _nodeAPI->setAttribute(_component, NODE_BUTTON_LABEL, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/button_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/button_component.h new file mode 100644 index 0000000000000000000000000000000000000000..a0fafb7c813a7d61a0a8e79984bb0ed39397a34e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/button_component.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_BUTTON_COMPONENT_H +#define ARKUI_CAPI_DEMO_BUTTON_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class ButtonComponent : public Component { +public: + ButtonComponent() : Component(ARKUI_NODE_BUTTON) {} + explicit ButtonComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetLable(const std::string& content); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_BUTTON_COMPONENT_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/column_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/column_component.h new file mode 100644 index 0000000000000000000000000000000000000000..56c93a34b2a7f605b3db0a9b1e6cb9be5092374c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/column_component.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COLUMN_COMPONENT_H +#define ARKUI_CAPI_DEMO_COLUMN_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class ColumnComponent : public Component { +public: + ColumnComponent() : Component(ARKUI_NODE_COLUMN) {} + explicit ColumnComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetAlignItems(int32_t verticalAlign) + { + ArkUI_NumberValue value[] = { { .i32 = verticalAlign } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_COLUMN_ALIGN_ITEMS, &item); + } + void SetJustifyContent(int32_t flexAlign) + { + ArkUI_NumberValue value[] = { { .i32 = flexAlign } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_COLUMN_JUSTIFY_CONTENT, &item); + } +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_COLUMN_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4f70bbaa38135fd8ac976ab30f5f41616b8c9fba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/component.cpp @@ -0,0 +1,405 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "component.h" + +#include +#include + +namespace ArkUICApiDemo { + +Component::Component(ArkUI_NodeType type) +{ + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, _nodeAPI); + _component = _nodeAPI->createNode(type); + _nodeAPI->setUserData(_component, this); + _nodeAPI->addNodeEventReceiver(_component, Component::NodeEventReceiver); +} + +Component::Component(ArkUI_NodeHandle handle) +{ + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, _nodeAPI); + _component = handle; + _nodeAPI->setUserData(_component, this); + _nodeAPI->addNodeEventReceiver(_component, Component::NodeEventReceiver); + + int32_t count = _nodeAPI->getTotalChildCount(_component); + for (int32_t i = 0; i < count; i++) { + auto temp = _nodeAPI->getChildAt(_component, i); + children_.emplace_back(std::make_shared(temp)); + } +} + +int32_t Component::setAttribute(ArkUI_NodeAttributeType attribute, const ArkUI_AttributeItem* item) +{ + return _nodeAPI->setAttribute(_component, attribute, item); +} + +const ArkUI_AttributeItem* Component::getAttribute(ArkUI_NodeAttributeType attribute) +{ + return _nodeAPI->getAttribute(_component, attribute); +} + +int32_t Component::resetAttribute(ArkUI_NodeAttributeType attribute) +{ + return _nodeAPI->resetAttribute(_component, attribute); +} + +void Component::SetWidth(float width) +{ + ArkUI_NumberValue value[] = { { .f32 = width } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WIDTH, &item); +} +void Component::SetPercentWidth(float percent) +{ + ArkUI_NumberValue value[] = { { .f32 = percent } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WIDTH_PERCENT, &item); +} +void Component::SetHeight(float height) +{ + ArkUI_NumberValue value[] = { { .f32 = height } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_HEIGHT, &item); +} +void Component::SetPercentHeight(float percent) +{ + ArkUI_NumberValue value[] = { { .f32 = percent } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_HEIGHT_PERCENT, &item); +} +void Component::SetLayoutRect(int32_t x, int32_t y, int32_t width, int32_t height) +{ + ArkUI_NumberValue layoutRect_value[] = { { .i32 = x }, { .i32 = y }, { .i32 = width }, { .i32 = height } }; + ArkUI_AttributeItem layoutRect_item = { layoutRect_value, 4 }; + _nodeAPI->setAttribute(_component, NODE_LAYOUT_RECT, &layoutRect_item); +} +void Component::SetBackgroundColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_BACKGROUND_COLOR, &item); +} +void Component::SetBackgroundImage(const std::string& backgroundImage) +{ + ArkUI_AttributeItem item = { nullptr, 0, backgroundImage.c_str() }; + _nodeAPI->setAttribute(_component, NODE_BACKGROUND_IMAGE, &item); +} +void Component::SetBackgroundImageSizeWithStyle(int32_t imageSize) +{ + ArkUI_NumberValue value[] = { { .i32 = imageSize } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_BACKGROUND_IMAGE_SIZE_WITH_STYLE, &item); +} +void Component::SetBorderRadius(float topLeft, float topRight, float bottomLeft, float bottomRight) +{ + ArkUI_NumberValue value[] = { { .f32 = topLeft }, { .f32 = topRight }, { .f32 = bottomLeft }, + { .f32 = bottomRight } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_BORDER_RADIUS, &item); +} + +void Component::SetPadding(float top, float right, float bottom, float left) +{ + ArkUI_NumberValue value[] = { { .f32 = top }, { .f32 = right }, { .f32 = bottom }, { .f32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_PADDING, &item); +} + +void Component::SetPaddingPercent(float top, float right, float bottom, float left) +{ + ArkUI_NumberValue value[] = { { .f32 = top }, { .f32 = right }, { .f32 = bottom }, { .f32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_PADDING_PERCENT, &item); +} + +void Component::SetMargin(float top, float right, float bottom, float left) +{ + ArkUI_NumberValue value[] = { { .f32 = top }, { .f32 = right }, { .f32 = bottom }, { .f32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_MARGIN, &item); +} +void Component::SetMargin(float margin) +{ + ArkUI_NumberValue value[] = { { .f32 = margin }, { .f32 = margin }, { .f32 = margin }, { .f32 = margin } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_MARGIN, &item); +} + +void Component::SetMarginPercent(float top, float right, float bottom, float left) +{ + ArkUI_NumberValue value[] = { { .f32 = top }, { .f32 = right }, { .f32 = bottom }, { .f32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_MARGIN_PERCENT, &item); +} + +void Component::SetEnabled(int32_t enable) +{ + ArkUI_NumberValue value[] = { { .i32 = enable } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_ENABLED, &item); +} + +void Component::SetAlign(int32_t align) +{ + ArkUI_NumberValue value[] = { { .i32 = align } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_ALIGNMENT, &item); +} + +void Component::SetAlignRules(ArkUI_AlignmentRuleOption* option) +{ + ArkUI_AttributeItem item = { .object = option }; + _nodeAPI->setAttribute(_component, NODE_ALIGN_RULES, &item); +} + +void Component::SetAlignSelf(int32_t value) +{ + ArkUI_NumberValue val[] = { { .i32 = value } }; + ArkUI_AttributeItem item = { val, 1 }; + _nodeAPI->setAttribute(_component, NODE_ALIGN_SELF, &item); +} + +void Component::SetOpacity(float opacity) +{ + ArkUI_NumberValue value[] = { { .f32 = opacity } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_OPACITY, &item); +} + +void Component::SetBorderWidth(float top, float right, float bottom, float left) +{ + ArkUI_NumberValue value[] = { { .f32 = top }, { .f32 = right }, { .f32 = bottom }, { .f32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_BORDER_WIDTH, &item); +} + +void Component::SetBorderWidth(float borderWidth) +{ + ArkUI_NumberValue value[] = { { .f32 = borderWidth }, { .f32 = borderWidth }, { .f32 = borderWidth }, + { .f32 = borderWidth } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_BORDER_WIDTH, &item); +} + +void Component::SetBorderColor(uint32_t top, uint32_t right, uint32_t bottom, uint32_t left) +{ + ArkUI_NumberValue value[] = { { .u32 = top }, { .u32 = right }, { .u32 = bottom }, { .u32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_BORDER_COLOR, &item); +} + +void Component::SetBorderStyle(int32_t top, int32_t right, int32_t bottom, int32_t left) +{ + ArkUI_NumberValue value[] = { { .i32 = top }, { .i32 = right }, { .i32 = bottom }, { .i32 = left } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_BORDER_STYLE, &item); +} + +void Component::SetVisibility(int32_t visibility) +{ + ArkUI_NumberValue value[] = { { .i32 = visibility } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_VISIBILITY, &item); +} +void Component::SetId(const std::string& id) +{ + ArkUI_AttributeItem item = { nullptr, 0, id.c_str() }; + _nodeAPI->setAttribute(_component, NODE_ID, &item); +} +void Component::AddChild(const std::shared_ptr& child) +{ + children_.emplace_back(child); + OnAddChild(child); +} + +void Component::RemoveChild(const std::shared_ptr& child) +{ + children_.remove(child); + OnRemoveChild(child); +} + +void Component::RemoveAll() +{ + children_.clear(); + OnRemoveAll(); +} + +void Component::InsertChild(const std::shared_ptr& child, int32_t index) +{ + if (index >= children_.size()) { + AddChild(child); + } else { + auto iter = children_.begin(); + std::advance(iter, index); + children_.insert(iter, child); + OnInsertChild(child, index); + } +} + +std::shared_ptr Component::GetPreviousSibling() +{ + auto previousSibling = _nodeAPI->getPreviousSibling(_component); + return std::make_shared(previousSibling); +}; + +std::shared_ptr Component::GetNextSibling() +{ + auto nextSibling = _nodeAPI->getNextSibling(_component); + return std::make_shared(nextSibling); +}; + +void Component::NodeEventReceiver(ArkUI_NodeEvent* event) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // 获取事件发生的UI组件对象。 + auto nodeHandle = OH_ArkUI_NodeEvent_GetNodeHandle(event); + // 获取保持在UI组件对象中的自定义数据,返回封装类指针。 + auto* node = reinterpret_cast(nodeAPI->getUserData(nodeHandle)); + // 基于封装类实例对象处理事件。 + if (node) { + node->ProcessNodeEvent(event); + } +} +void Component::SetFontSize(float fontSize) +{ + ArkUI_NumberValue value[] = { { .f32 = fontSize } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_FONT_SIZE, &item); +} +void Component::ProcessNodeEvent(ArkUI_NodeEvent* event) +{ + auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "ProcessNodeEvent eventType=%{public}d", eventType); + if (eventMap_.find(eventType) != eventMap_.end()) { + eventMap_[eventType](event); + } else { + OnNodeEvent(event); + } +} + +void Component::RegisterOnClick(const std::function& onClick) +{ + auto onClickCallback = [onClick](ArkUI_NodeEvent*) { + if (onClick) { + onClick(); + } + }; + eventMap_[NODE_ON_CLICK] = onClickCallback; + _nodeAPI->registerNodeEvent(_component, NODE_ON_CLICK, 0, nullptr); +} + +void Component::RegisterOnTouch(const std::function& onTouch) +{ + auto onTouchCallback = [onTouch](ArkUI_NodeEvent* event) { + if (onTouch) { + onTouch(event); + } + }; + eventMap_[NODE_TOUCH_EVENT] = onTouchCallback; + _nodeAPI->registerNodeEvent(_component, NODE_TOUCH_EVENT, 0, nullptr); +} + +void Component::RegisterOnDisappear(const std::function& onDisappear) +{ + auto onDisappearCallback = [onDisappear](ArkUI_NodeEvent*) { + if (onDisappear) { + onDisappear(); + } + }; + eventMap_[NODE_EVENT_ON_DISAPPEAR] = onDisappearCallback; + _nodeAPI->registerNodeEvent(_component, NODE_EVENT_ON_DISAPPEAR, 0, nullptr); +} + +void Component::RegisterOnAppear(const std::function& onAppear) +{ + auto onAppearCallback = [onAppear](ArkUI_NodeEvent*) { + if (onAppear) { + onAppear(); + } + }; + eventMap_[NODE_EVENT_ON_APPEAR] = onAppearCallback; + _nodeAPI->registerNodeEvent(_component, NODE_EVENT_ON_APPEAR, 0, nullptr); +} +void Component::RegisterOnHover(const std::function& onHover) +{ + auto onHoverCallback = [onHover](ArkUI_NodeEvent* event) { + if (onHover) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "NODE_ON_HOVER"); + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + int32_t isHover = result->data[0].i32; + onHover(static_cast(isHover)); + } + }; + eventMap_[NODE_ON_HOVER] = onHoverCallback; + _nodeAPI->registerNodeEvent(_component, NODE_ON_HOVER, 0, nullptr); +} +void Component::RegisterOnMouse(const std::function& onMouse) +{ + auto onMouseCallback = [onMouse](ArkUI_NodeEvent* event) { + if (onMouse) { + onMouse(event); + } + }; + eventMap_[NODE_ON_MOUSE] = onMouseCallback; + _nodeAPI->registerNodeEvent(_component, NODE_ON_MOUSE, 0, nullptr); +} +void Component::RegisterOnTouchIntercept(const std::function& onTouchIntercept) +{ + auto onTouchInterceptCallback = [onTouchIntercept](ArkUI_NodeEvent* event) { + if (onTouchIntercept) { + onTouchIntercept(event); + } + }; + eventMap_[NODE_ON_TOUCH_INTERCEPT] = onTouchInterceptCallback; + _nodeAPI->registerNodeEvent(_component, NODE_ON_TOUCH_INTERCEPT, 0, nullptr); +} +void Component::RegisterOnFocus(const std::function& onFocus) +{ + auto onFocusCallback = [onFocus](ArkUI_NodeEvent*) { + if (onFocus) { + onFocus(); + } + }; + eventMap_[NODE_ON_FOCUS] = onFocusCallback; + _nodeAPI->registerNodeEvent(_component, NODE_ON_FOCUS, 0, nullptr); +} + +void Component::RegisterOnVisibleAreaChange( + const std::function& onVisibleAreaChange, std::vector ratioArray) +{ + ArkUI_NumberValue value[ratioArray.size()]; + + for (size_t i = 0; i < ratioArray.size(); i++) { + value[i].f32 = { ratioArray[i] }; + } + ArkUI_AttributeItem item = { value, static_cast(ratioArray.size()) }; + + auto onVisibleAreaChangeCallback = [onVisibleAreaChange](ArkUI_NodeEvent* event) { + if (onVisibleAreaChange) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "commonEvent", "NODE_EVENT_ON_VISIBLE_AREA_CHANGE"); + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + bool visible = static_cast(result->data[0].i32); + float ratio = result->data[1].f32; + onVisibleAreaChange(visible, ratio); + } + }; + eventMap_[NODE_EVENT_ON_VISIBLE_AREA_CHANGE] = onVisibleAreaChangeCallback; + _nodeAPI->registerNodeEvent(_component, NODE_EVENT_ON_VISIBLE_AREA_CHANGE, 0, &item); +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/component.h new file mode 100644 index 0000000000000000000000000000000000000000..0f1e06df6b24c3dee02c31cdcc1b9bd8183ef76f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/component.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_COMPONENT_H +#define ARKUI_CAPI_DEMO_COMPONENT_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class Component { +public: + explicit Component(ArkUI_NodeType type); + explicit Component(ArkUI_NodeHandle handle); + virtual ~Component() = default; + + int32_t setAttribute(ArkUI_NodeAttributeType attribute, const ArkUI_AttributeItem* item); + const ArkUI_AttributeItem* getAttribute(ArkUI_NodeAttributeType attribute); + int32_t resetAttribute(ArkUI_NodeAttributeType attribute); + + void SetWidth(float width); + void SetPercentWidth(float percent); + void SetHeight(float height); + void SetPercentHeight(float percent); + void SetLayoutRect(int32_t x, int32_t y, int32_t width, int32_t height); + void SetBackgroundColor(uint32_t color); + void SetBackgroundImage(const std::string& backgroundImage); + void SetBackgroundImageSizeWithStyle(int32_t imageSize); + void SetBorderRadius(float topLeft, float topRight, float bottomLeft, float bottomRight); + void SetPadding(float top, float right, float bottom, float left); + void SetPaddingPercent(float top, float right, float bottom, float left); + void SetMargin(float top, float right, float bottom, float left); + void SetMargin(float margin); + void SetMarginPercent(float top, float right, float bottom, float left); + void SetEnabled(int32_t enable); + void SetAlign(int32_t align); + void SetAlignRules(ArkUI_AlignmentRuleOption* option); + void SetAlignSelf(int32_t value); + void SetOpacity(float opacity); + void SetBorderWidth(float top, float right, float bottom, float left); + void SetBorderWidth(float borderWidth); + void SetBorderColor(uint32_t top, uint32_t right, uint32_t bottom, uint32_t left); + void SetBorderStyle(int32_t top, int32_t right, int32_t bottom, int32_t left); + void SetVisibility(int32_t visibility); + virtual void SetFontSize(float fontSize); + void SetId(const std::string& id); + void AddChild(const std::shared_ptr& child); + void RemoveChild(const std::shared_ptr& child); + void RemoveAll(); + void InsertChild(const std::shared_ptr& child, int32_t index); + std::list> GetChildren() + { + return children_; + } + std::shared_ptr GetPreviousSibling(); + std::shared_ptr GetNextSibling(); + + ArkUI_NodeHandle GetComponent() + { + return _component; + } + // 处理通用事件。 + void RegisterOnClick(const std::function& onClick); + void RegisterOnTouch(const std::function& onTouch); + void RegisterOnDisappear(const std::function& onDisappear); + void RegisterOnAppear(const std::function& onAppear); + void RegisterOnHover(const std::function& onHover); + void RegisterOnMouse(const std::function& onMouse); + void RegisterOnTouchIntercept(const std::function& onTouchIntercept); + void RegisterOnFocus(const std::function& onFocus); + void RegisterOnVisibleAreaChange( + const std::function& onVisibleAreaChange, std::vector ratioArray); + + static void NodeEventReceiver(ArkUI_NodeEvent* event); + void ProcessNodeEvent(ArkUI_NodeEvent* event); + virtual void OnNodeEvent(ArkUI_NodeEvent* event) {} + +protected: + // 组件树操作的实现类对接。 + void OnAddChild(const std::shared_ptr& child) + { + _nodeAPI->addChild(_component, child->GetComponent()); + } + void OnRemoveChild(const std::shared_ptr& child) + { + _nodeAPI->removeChild(_component, child->GetComponent()); + } + void OnRemoveAll() + { + _nodeAPI->removeAllChildren(_component); + } + void OnInsertChild(const std::shared_ptr& child, int32_t index) + { + _nodeAPI->insertChildAt(_component, child->GetComponent(), index); + } + +protected: + std::unordered_map> eventMap_; + std::list> children_; + ArkUI_NodeHandle _component { nullptr }; + ArkUI_NativeNodeAPI_1* _nodeAPI { nullptr }; +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/custom_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/custom_component.h new file mode 100644 index 0000000000000000000000000000000000000000..99db97b37b53790a7b2db354741cc4c75e4a3d4d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/custom_component.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_BUTTON_COMPONENT_H +#define ARKUI_CAPI_DEMO_BUTTON_COMPONENT_H + +#include "component.h" +#include +#include + +namespace ArkUICApiDemo { +class CustomComponent : public Component { +public: + CustomComponent() : Component(ARKUI_NODE_CUSTOM) {} + explicit CustomComponent(ArkUI_NodeHandle handle) : Component(handle) {} +}; +} +#endif //ARKUI_CAPI_DEMO_BUTTON_COMPONENT_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/flex_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/flex_component.h new file mode 100644 index 0000000000000000000000000000000000000000..eff5362acb8054e10efe69f596c3ee7fef6b9bbd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/flex_component.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_FLEX_COMPONENT_H +#define ARKUI_CAPI_DEMO_FLEX_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class FlexComponent : public Component { +public: + FlexComponent() : Component(ARKUI_NODE_COLUMN) {} + explicit FlexComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetOptions(int32_t* options) + { + ArkUI_NumberValue options_value[] = { { .i32 = options[0] }, { .i32 = options[1] }, { .i32 = options[2] }, + { .i32 = options[3] }, { .i32 = options[4] } }; + ArkUI_AttributeItem options_item = { options_value, sizeof(options_value) / sizeof(ArkUI_NumberValue) }; + _nodeAPI->setAttribute(_component, NODE_FLEX_OPTION, &options_item); + } +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_FLEX_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/flowitem_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/flowitem_component.h new file mode 100644 index 0000000000000000000000000000000000000000..6c9e26da66515c89cee0b0e8615ce9034064c96a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/flowitem_component.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_FLOWITEM_COMPONENT_H +#define ARKUI_CAPI_DEMO_FLOWITEM_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { + +class FlowItemComponent : public Component { +public: + FlowItemComponent() : Component(ARKUI_NODE_FLOW_ITEM) {} + explicit FlowItemComponent(ArkUI_NodeHandle handle) : Component(handle) {} +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_FLOWITEM_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/grid_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/grid_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4fcbf0b516edaefc6917bae35546d3dbf6ea33fc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/grid_component.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "grid_component.h" + +namespace ArkUICApiDemo { +void GridComponent::SetGridColumnsTemplate(const std::string& str) +{ + ArkUI_AttributeItem item = { .string = str.c_str() }; + _nodeAPI->setAttribute(_component, NODE_GRID_COLUMN_TEMPLATE, &item); +} +void GridComponent::SetGridRowsTemplate(const std::string& str) +{ + ArkUI_AttributeItem item = { .string = str.c_str() }; + _nodeAPI->setAttribute(_component, NODE_GRID_ROW_TEMPLATE, &item); +} +void GridComponent::SetGridColumnsGap(float val) +{ + ArkUI_NumberValue value[] = { { .f32 = val } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_GRID_COLUMN_GAP, &item); +} +void GridComponent::SetGridRowsGap(float val) +{ + ArkUI_NumberValue value[] = { { .f32 = val } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_GRID_ROW_GAP, &item); +} +void GridComponent::SetGridCachedCount(int32_t cachedCount) +{ + ArkUI_NumberValue value[] = { { .i32 = cachedCount } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_GRID_CACHED_COUNT, &item); +} +void GridComponent::SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams) +{ + auto value = new ArkUI_NumberValue[2 + static_cast(optionalParams.size())]; + value[0] = { .f32 = hOffset }; + value[1] = { .f32 = vOffset }; + for (int32_t i = 0; i < optionalParams.size(); i++) { + value[2 + i] = { .i32 = optionalParams[i] }; + } + ArkUI_AttributeItem item = { value, 2 + static_cast(optionalParams.size()) }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_OFFSET, &item); +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/grid_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/grid_component.h new file mode 100644 index 0000000000000000000000000000000000000000..2fbf1b1d9a5d9508caf9d45f45cec15bec901ae0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/grid_component.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_GRID_COMPONENT_H +#define ARKUI_CAPI_DEMO_GRID_COMPONENT_H + +#include "component.h" +#include "node_adapter.h" + +namespace ArkUICApiDemo { + +class GridItemComponent : public Component { +public: + GridItemComponent() : Component(ARKUI_NODE_GRID_ITEM) {} + explicit GridItemComponent(ArkUI_NodeHandle handle) : Component(handle) {} +}; + +class GridComponent : public Component { +public: + GridComponent() : Component(ARKUI_NODE_GRID) {} + explicit GridComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetLazyAdapter(const std::shared_ptr>& adapter) + { + ArkUI_AttributeItem item { nullptr, 0, nullptr, adapter->GetAdapter() }; + _nodeAPI->setAttribute(_component, NODE_GRID_NODE_ADAPTER, &item); + _adapter = adapter; + } + void SetGridColumnsTemplate(const std::string& str); + void SetGridRowsTemplate(const std::string& str); + void SetGridColumnsGap(float val); + void SetGridRowsGap(float val); + void SetGridCachedCount(int32_t cachedCount); + /** + * @brief Set the scroll position to the specified offset. + * @param hOffset horizontal scrolling offset + * @param vOffset vertical scrolling offset + * @param optionalParams + * [0] scrolling duration, in milliseconds. + * [1] scrolling curve. The parameter type is ArkUI_AnimationCurve. + * [2] whether to enable the default spring animation. + * [3] sets whether scrolling can cross the boundary. + * [4] canOverScroll. + */ + void SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams); + + std::shared_ptr> GetAdapter() const + { + return _adapter; + } + void ReleaseAdapter() + { + return _adapter.reset(); + } + +private: + std::shared_ptr> _adapter; +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_GRID_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/image_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/image_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2342158cf649e3e652ef1803e943d3c0f6b16210 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/image_component.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "image_component.h" + +#include + +namespace ArkUICApiDemo { + +int32_t ImageComponent::SetImageSrc(const std::string& content) +{ + ArkUI_AttributeItem item = { nullptr, 0, content.c_str() }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_SRC, &item); +} +int32_t ImageComponent::SetImageSrc(ArkUI_DrawableDescriptor* descriptors) +{ + ArkUI_AttributeItem item = { .object = descriptors }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_SRC, &item); +} +int32_t ImageComponent::SetObjectFit(const int32_t objectFit) +{ + ArkUI_NumberValue value[] = { { .i32 = objectFit } }; + ArkUI_AttributeItem item = { value, 1 }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_OBJECT_FIT, &item); +} +int32_t ImageComponent::SetResizable(const float left, const float top, const float right, const float bottom) +{ + ArkUI_NumberValue value[] = { { .f32 = left }, { .f32 = top }, { .f32 = right }, { .f32 = bottom } }; + ArkUI_AttributeItem item = { value, 4 }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_RESIZABLE, &item); +} +int32_t ImageComponent::SetImageDraggable(bool isDraggable) +{ + ArkUI_NumberValue value[] = { { .i32 = isDraggable } }; + ArkUI_AttributeItem item = { value, 1 }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_DRAGGABLE, &item); +} +int32_t ImageComponent::SetImageRenderMode(int32_t renderMode) +{ + ArkUI_NumberValue value[] = { { .i32 = renderMode } }; + ArkUI_AttributeItem item = { value, 1 }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_RENDER_MODE, &item); +} +int32_t ImageComponent::SetImageFitOriginalSize(int32_t fitOriginalSize) +{ + ArkUI_NumberValue value[] = { { .i32 = fitOriginalSize } }; + ArkUI_AttributeItem item = { value, 1 }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_FIT_ORIGINAL_SIZE, &item); +} +int32_t ImageComponent::SetImageFillColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_FILL_COLOR, &item); +} +int32_t ImageComponent::SetGeometryTransition(int32_t type, const std::string& id) +{ + ArkUI_NumberValue value[] = { { .i32 = type } }; + ArkUI_AttributeItem item = { value, 1, id.c_str() }; + return _nodeAPI->setAttribute(_component, NODE_GEOMETRY_TRANSITION, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/image_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/image_component.h new file mode 100644 index 0000000000000000000000000000000000000000..a0b35f6978a021c64f7a3ad67ba499d25bba90dc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/image_component.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGE_COMPONENT_H +#define ARKUI_CAPI_DEMO_IMAGE_COMPONENT_H + +#include +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class ImageComponent : public Component { +public: + ImageComponent() : Component(ARKUI_NODE_IMAGE) {} + explicit ImageComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + int32_t SetImageSrc(const std::string& content); + int32_t SetImageSrc(ArkUI_DrawableDescriptor* descriptors); + int32_t SetObjectFit(const int32_t objectFit); + int32_t SetResizable(const float left, const float top, const float right, const float bottom); + int32_t SetImageDraggable(bool isDraggable); + int32_t SetImageRenderMode(int32_t renderMode); + int32_t SetImageFitOriginalSize(int32_t fitOriginalSize); + int32_t SetImageFillColor(uint32_t color); + int32_t SetGeometryTransition(int32_t type, const std::string &id); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_COMPONENT_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/imageanimator_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/imageanimator_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8eefc40e6b766c4971809bd94e5347c10f411e9d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/imageanimator_component.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "imageanimator_component.h" + +namespace ArkUICApiDemo { +void ImageAnimatorComponent::SetState(int32_t state) +{ + ArkUI_NumberValue value[] = { { .i32 = state } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_STATE, &item); +} + +void ImageAnimatorComponent::SetIteration(int32_t iteration) +{ + ArkUI_NumberValue value[] = { { .i32 = iteration } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_ITERATION, &item); +} + +void ImageAnimatorComponent::SetImage(std::vector& vector) +{ + ArkUI_AttributeItem item = { .object = vector.data(), .size = static_cast(vector.size()) }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_IMAGES, &item); +} + +void ImageAnimatorComponent::SetFixedSize(int32_t fixedSize) +{ + ArkUI_NumberValue value[] = { { .i32 = fixedSize } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_FIXED_SIZE, &item); +} + +void ImageAnimatorComponent::SetReverse(int32_t reverse) +{ + ArkUI_NumberValue value[] = { { .i32 = reverse } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_REVERSE, &item); +} + +void ImageAnimatorComponent::SetFillMode(int32_t mode) +{ + ArkUI_NumberValue value[] = { { .i32 = mode } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_FILL_MODE, &item); +} + +void ImageAnimatorComponent::SetDuration(int32_t duration) +{ + ArkUI_NumberValue value[] = { { .i32 = duration } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_IMAGE_ANIMATOR_DURATION, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/imageanimator_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/imageanimator_component.h new file mode 100644 index 0000000000000000000000000000000000000000..cf18cd881bacd1973721a4fc2e75f1ee21b320d4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/imageanimator_component.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMPONENT_H +#define ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class ImageAnimatorComponent : public Component { +public: + ImageAnimatorComponent() : Component(ARKUI_NODE_IMAGE_ANIMATOR) {} + explicit ImageAnimatorComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetState(int32_t state); + void SetIteration(int32_t iteration); + void SetImage(std::vector& vector); + void SetFixedSize(int32_t fixedSize); + void SetReverse(int32_t reverse); + void SetFillMode(int32_t mode); + void SetDuration(int32_t duration); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/imagespan_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/imagespan_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d10ff2c71767dd389e189e8f154644176fe76ab2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/imagespan_component.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "imagespan_component.h" + +namespace ArkUICApiDemo { + +int32_t ImageSpanComponent::SetImageSpanSrc(const std::string& content) +{ + ArkUI_AttributeItem item = { nullptr, 0, content.c_str() }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_SPAN_SRC, &item); +} +int32_t ImageSpanComponent::SetImageSpanSrc(ArkUI_DrawableDescriptor* descriptors) +{ + ArkUI_AttributeItem item = { .object = descriptors }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_SPAN_SRC, &item); +} +int32_t ImageSpanComponent::SetImageSpanAlt(const std::string& alt) +{ + ArkUI_AttributeItem item = { nullptr, 0, alt.c_str() }; + return _nodeAPI->setAttribute(_component, NODE_IMAGE_SPAN_ALT, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/imagespan_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/imagespan_component.h new file mode 100644 index 0000000000000000000000000000000000000000..bbb06e2d2d82c20bfffc6203556b63a1c4b35d6b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/imagespan_component.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGESPAN_COMPONENT_H +#define ARKUI_CAPI_DEMO_IMAGESPAN_COMPONENT_H + +#include +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class ImageSpanComponent : public Component { +public: + ImageSpanComponent() : Component(ARKUI_NODE_IMAGE_SPAN) {} + explicit ImageSpanComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + int32_t SetImageSpanSrc(const std::string& content); + int32_t SetImageSpanSrc(ArkUI_DrawableDescriptor* descriptors); + int32_t SetImageSpanAlt(const std::string& alt); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGESPAN_COMPONENT_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/list_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/list_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e058ee5454fa0d374467a9810d0b96a42d976e5d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/list_component.cpp @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "list_component.h" + +#include + +namespace ArkUICApiDemo { + +void ListItemSwipeActionOption::SetStart(ArkUI_ListItemSwipeActionItem* item) +{ + OH_ArkUI_ListItemSwipeActionOption_SetStart(_option, item); +} + +void ListItemSwipeActionOption::SetEnd(ArkUI_ListItemSwipeActionItem* item) +{ + OH_ArkUI_ListItemSwipeActionOption_SetEnd(_option, item); +} + +void ListItemSwipeActionOption::SetEdgeEffect(ArkUI_ListItemSwipeEdgeEffect edgeEffect) +{ + OH_ArkUI_ListItemSwipeActionOption_SetEdgeEffect(_option, edgeEffect); +} + +int32_t ListItemSwipeActionOption::GetEdgeEffect() +{ + return OH_ArkUI_ListItemSwipeActionOption_GetEdgeEffect(_option); +} + +void ListItemSwipeActionOption::SetOnOffsetChange(OnOffsetChangeCallback callback) +{ + OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChange(_option, callback); +} + +void ListItemSwipeActionOption::SetOnOffsetChangWithUserData( + OnOffsetChangeWithUserDataCallback callback, void* userData) +{ + OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChangeWithUserData(_option, userData, callback); +} + +int32_t ListChildrenMainSizeOption::SetDefaultMainSize(float defaultMainSize) +{ + return OH_ArkUI_ListChildrenMainSizeOption_SetDefaultMainSize(_option, defaultMainSize); +} + +float ListChildrenMainSizeOption::GetDefaultMainSize() +{ + return OH_ArkUI_ListChildrenMainSizeOption_GetDefaultMainSize(_option); +} + +void ListChildrenMainSizeOption::Resize(int32_t totalSize) +{ + OH_ArkUI_ListChildrenMainSizeOption_Resize(_option, totalSize); +} + +int32_t ListChildrenMainSizeOption::Delete(int32_t start, int32_t deleteCount) +{ + return SpliceInline(start, deleteCount, 0); +} + +int32_t ListChildrenMainSizeOption::Update(int32_t start, int32_t updateCount, std::vector childrenSize) +{ + if (updateCount != childrenSize.size()) { + return -1; + } + int32_t ret = 0; + for (int index = 0; index < childrenSize.size(); index++) { + ret = UpdateSize(start + index, childrenSize[index]); + } + + return ret; +} + +int32_t ListChildrenMainSizeOption::Add(int32_t start, int32_t addCount, std::vector childrenSize) +{ + if (addCount != childrenSize.size()) { + return -1; + } + auto ret = SpliceInline(start, 0, addCount); + for (int index = 0; index < childrenSize.size(); index++) { + ret = UpdateSize(start + index, childrenSize[index]); + } + + return ret; +} + +int32_t ListChildrenMainSizeOption::SpliceInline(int32_t index, int32_t deleteCount, int32_t addCount) +{ + return OH_ArkUI_ListChildrenMainSizeOption_Splice(_option, index, deleteCount, addCount); +} + +int32_t ListChildrenMainSizeOption::UpdateSize(int32_t index, float mainSize) +{ + return OH_ArkUI_ListChildrenMainSizeOption_UpdateSize(_option, index, mainSize); +} + +float ListChildrenMainSizeOption::GetMainSize(int32_t index) +{ + return OH_ArkUI_ListChildrenMainSizeOption_GetMainSize(_option, index); +} + +void ListItemComponent::SetListItemSwiperAction(ListItemSwipeActionOption* option) +{ + ArkUI_AttributeItem item = { nullptr, 0, nullptr, option->GetOption() }; + _nodeAPI->setAttribute(_component, NODE_LIST_ITEM_SWIPE_ACTION, &item); +} + +void ListComponent::SetNestedScroll(int32_t forward, int32_t backward) +{ + ArkUI_NumberValue value[] = { { .i32 = forward }, { .i32 = backward } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_NESTED_SCROLL, &item); +} + +void ListComponent::SetListDirection(int32_t direction) +{ + ArkUI_NumberValue value[] = { { .i32 = direction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_LIST_DIRECTION, &item); +} + +void ListComponent::SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams) +{ + auto value = new ArkUI_NumberValue[2 + static_cast(optionalParams.size())]; + value[0] = { .f32 = hOffset }; + value[1] = { .f32 = vOffset }; + for (int32_t i = 0; i < optionalParams.size(); i++) { + value[2 + i] = { .i32 = optionalParams[i] }; + } + ArkUI_AttributeItem item = { value, 2 + static_cast(optionalParams.size()) }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_OFFSET, &item); +} + +void ListComponent::SetScrollEdge(int32_t type) +{ + ArkUI_NumberValue value[] = { { .i32 = type } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_EDGE, &item); +} + +void ListComponent::SetScrollEdgeEffect(int32_t edgeEffect, bool alwaysEnabled) +{ + ArkUI_NumberValue value[] = { { .i32 = edgeEffect }, { .i32 = alwaysEnabled } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_EDGE_EFFECT, &item); +} + +void ListComponent::SetScrollPage(int32_t next) +{ + ArkUI_NumberValue value[] = { { .i32 = next } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_PAGE, &item); +} +void ListComponent::SetScrollPage(int32_t next, int32_t animation) +{ + ArkUI_NumberValue value[] = { { .i32 = next }, { .i32 = animation } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_PAGE, &item); +} +void ListComponent::SetScrollBy(float hDistance, float vDistance) +{ + ArkUI_NumberValue value[] = { { .f32 = hDistance }, { .f32 = vDistance } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BY, &item); +} + +void ListComponent::SetListSticky(int32_t stickyStyle) +{ + ArkUI_NumberValue value[] = { { .i32 = stickyStyle } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_LIST_STICKY, &item); +} + +void ListComponent::SetListSpace(float space) +{ + ArkUI_NumberValue value[] = { { .f32 = space } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_LIST_SPACE, &item); +} + +void ListComponent::ResetListSpace() +{ + _nodeAPI->resetAttribute(_component, NODE_LIST_SPACE); +} + +void ListComponent::SetListCachedCount(int32_t count) +{ + ArkUI_NumberValue value[] = { { .i32 = count } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_LIST_CACHED_COUNT, &item); +} + +void ListComponent::SetListScrollToIndex(const std::vector& data) +{ + auto value = new ArkUI_NumberValue[static_cast(data.size())]; + for (int32_t i = 0; i < data.size(); i++) { + value[i] = { .i32 = data[i] }; + } + ArkUI_AttributeItem item = { value, static_cast(data.size()) }; + _nodeAPI->setAttribute(_component, NODE_LIST_SCROLL_TO_INDEX, &item); +} + +void ListComponent::SetListAlignListItem(int32_t align) +{ + ArkUI_NumberValue value[] = { { .i32 = align } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_LIST_ALIGN_LIST_ITEM, &item); +} + +void ListComponent::SetListChildrenMainSize(ListChildrenMainSizeOption* mainSize) +{ + ArkUI_AttributeItem item = { .object = mainSize->GetOption() }; + _nodeAPI->setAttribute(_component, NODE_LIST_CHILDREN_MAIN_SIZE, &item); + _childrenMainSize.reset(mainSize); +} + +void ListComponent::SetListInitialIndex(int32_t index) +{ + ArkUI_NumberValue value[] = { { .i32 = index } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_LIST_INITIAL_INDEX, &item); +} + +void ListComponent::SetListDivider(uint32_t color, float width, float distanceStart, float distanceEnd) +{ + ArkUI_NumberValue value[] = { { .u32 = color }, { .f32 = width }, { .f32 = distanceStart }, + { .f32 = distanceEnd } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_LIST_DIVIDER, &item); +} + +void ListComponent::SetScrollBarWidth(float width) +{ + ArkUI_NumberValue value[] = { { .f32 = width } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_WIDTH, &item); +} + +void ListComponent::SetScrollBarColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_COLOR, &item); +} + +void ListComponent::SetScrollBar(int32_t barState) +{ + ArkUI_NumberValue value[] = { { .i32 = barState } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_DISPLAY_MODE, &item); +} + +void ListItemGroupComponent::SetListItemGroupHeader(Component* node) +{ + ArkUI_AttributeItem item = { nullptr, 0, nullptr, node->GetComponent() }; + _nodeAPI->setAttribute(_component, NODE_LIST_ITEM_GROUP_SET_HEADER, &item); +} + +void ListItemGroupComponent::SetListItemGroupFooter(Component* node) +{ + ArkUI_AttributeItem item = { nullptr, 0, nullptr, node->GetComponent() }; + _nodeAPI->setAttribute(_component, NODE_LIST_ITEM_GROUP_SET_FOOTER, &item); +} + +void ListItemGroupComponent::SetListItemGroupDivider( + uint32_t color, float width, float distanceStart, float distanceEnd) +{ + ArkUI_NumberValue value[] = { { .u32 = color }, { .f32 = width }, { .f32 = distanceStart }, + { .f32 = distanceEnd } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_LIST_ITEM_GROUP_SET_DIVIDER, &item); +} + +void ListItemGroupComponent::SetListItemGroupChildrenMainSize(ListChildrenMainSizeOption* mainSize) +{ + ArkUI_AttributeItem item = { .object = mainSize->GetOption() }; + _nodeAPI->setAttribute(_component, NODE_LIST_ITEM_GROUP_CHILDREN_MAIN_SIZE, &item); + _childrenMainSize.reset(mainSize); +} + +void ListItemGroupAdapter::OnNewItemAttached(ArkUI_NodeAdapterEvent* event) +{ + auto index = OH_ArkUI_NodeAdapterEvent_GetItemIndex(event); + ArkUI_NodeHandle handle = nullptr; + int32_t start = index > 0 ? _groupList[index - 1] : 0, end = _groupList[index]; + if (end - start != 1) { + handle = UpdateNewItemByGroup(start, end); + } else { + handle = UpdateNewItem(start, end); + } + // 设置需要展示的元素。 + OH_ArkUI_NodeAdapterEvent_SetItem(event, handle); +} + +void ListItemGroupAdapter::OnItemDetached(ArkUI_NodeAdapterEvent* event) +{ + auto item = OH_ArkUI_NodeAdapterEvent_GetRemovedNode(event); + if (_removedNodeCallback) { + _removedNodeCallback(std::make_shared(item)); + } + // 放置到缓存池中进行回收复用。 + if (Component(item).GetChildren().size() == 1) { + _cachedListItems.emplace(_listItems[item]); + } else { + _cachedItems.emplace(_items[item]); + } +} + +ArkUI_NodeHandle ListItemGroupAdapter::UpdateNewItemByGroup(int32_t start, int32_t end) +{ + ArkUI_NodeHandle handle = nullptr; + if (!_cachedItems.empty()) { + // 使用并更新回收复用的缓存。 + auto recycledItem = _cachedItems.top(); + recycledItem->RemoveAll(); + for (int32_t i = start; i < end; i++) { + recycledItem->AddChild(_data[i]); + } + handle = recycledItem->GetComponent(); + // 释放缓存池的引用。 + _cachedItems.pop(); + } else { + // 创建新的元素。 + auto groupItem = std::make_shared(); + groupItem->RemoveAll(); + for (int32_t i = start; i < end; i++) { + groupItem->AddChild(_data[i]); + } + groupItem->SetBorderWidth(1); + handle = groupItem->GetComponent(); + // 保持文本列表项的引用。 + _items.emplace(handle, groupItem); + } + return handle; +} + +ArkUI_NodeHandle ListItemGroupAdapter::UpdateNewItem(int32_t start, int32_t end) +{ + ArkUI_NodeHandle handle = nullptr; + if (!_cachedListItems.empty()) { + // 使用并更新回收复用的缓存。 + auto recycledItem = _cachedListItems.top(); + recycledItem->RemoveAll(); + for (int32_t i = start; i < end; i++) { + recycledItem->AddChild(_data[i]); + } + handle = recycledItem->GetComponent(); + // 释放缓存池的引用。 + _cachedListItems.pop(); + } else { + // 创建新的元素。 + auto listItem = std::make_shared(); + listItem->RemoveAll(); + for (int32_t i = start; i < end; i++) { + listItem->AddChild(_data[i]); + } + handle = listItem->GetComponent(); + // 保持文本列表项的引用。 + _listItems.emplace(handle, listItem); + } + return handle; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/list_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/list_component.h new file mode 100644 index 0000000000000000000000000000000000000000..bc1f823139536e955a4e63ddccbb65a6810f0546 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/list_component.h @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_LIST_COMPONENT_H +#define CAPIDEMO_LIST_COMPONENT_H +#include + +#include "component.h" +#include "node_adapter.h" + +namespace ArkUICApiDemo { +//////////////////////////////////////ListItem/////////////////////////////////////// +typedef void (*OnOffsetChangeCallback)(float offset); +typedef void (*OnOffsetChangeWithUserDataCallback)(float offset, void* userData); +typedef void (*OnFinish)(void* userData); + +class ListItemSwipeActionOption { +public: + ListItemSwipeActionOption() : _option(OH_ArkUI_ListItemSwipeActionOption_Create()) {} + ~ListItemSwipeActionOption() + { + OH_ArkUI_ListItemSwipeActionOption_Dispose(_option); + } + + void SetStart(ArkUI_ListItemSwipeActionItem* item); + void SetEnd(ArkUI_ListItemSwipeActionItem* item); + // ArkUI_ListItemSwipeEdgeEffect + void SetEdgeEffect(ArkUI_ListItemSwipeEdgeEffect edgeEffect); + int32_t GetEdgeEffect(); + void SetOnOffsetChange(OnOffsetChangeCallback callback); + void SetOnOffsetChangWithUserData(OnOffsetChangeWithUserDataCallback callback, void* userData); + + ArkUI_ListItemSwipeActionOption* GetOption() + { + return _option; + } + +private: + ArkUI_ListItemSwipeActionOption* _option; +}; + +class ListItemComponent : public Component { +public: + ListItemComponent() : Component(ARKUI_NODE_LIST_ITEM) {} + explicit ListItemComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetListItemSwiperAction(ListItemSwipeActionOption* option); + std::shared_ptr GetSwipeActionOption() const + { + return _swipeActionOption; + } + void ReleaseSwipeActionOption() + { + _swipeActionOption.reset(); + } + +private: + std::shared_ptr _swipeActionOption; +}; + +class ListChildrenMainSizeOption { +public: + ListChildrenMainSizeOption() : _option(OH_ArkUI_ListChildrenMainSizeOption_Create()) {} + ~ListChildrenMainSizeOption() + { + OH_ArkUI_ListChildrenMainSizeOption_Dispose(_option); + } + int32_t SetDefaultMainSize(float defaultMainSize); + float GetDefaultMainSize(); + void Resize(int32_t totalSize); + + int32_t UpdateSize(int32_t index, float mainSize); + float GetMainSize(int32_t index); + int32_t Add(int32_t start, int32_t addCount, std::vector childrenSize); + int32_t Delete(int32_t start, int32_t deleteCount); + int32_t Update(int32_t start, int32_t updateCount, std::vector childrenSize); + ArkUI_ListChildrenMainSize* GetOption() + { + return _option; + } + +private: + int32_t SpliceInline(int32_t index, int32_t deleteCount, int32_t addCount); + ArkUI_ListChildrenMainSize* _option; +}; + +///////////////////////////////////ListItemGroup/////////////////////////////////////// + +class ListItemGroupComponent : public Component { +public: + ListItemGroupComponent() : Component(ARKUI_NODE_LIST_ITEM_GROUP) {} + explicit ListItemGroupComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetListItemGroupHeader(Component* node); + void SetListItemGroupFooter(Component* node); + void SetListItemGroupDivider(uint32_t color, float width, float distanceStart, float distanceEnd); + void SetListItemGroupChildrenMainSize(ListChildrenMainSizeOption* mainSize); + + std::shared_ptr GetSizeOption() const + { + return _childrenMainSize; + } + void ReleaseSizeOption() + { + _childrenMainSize.reset(); + } + +private: + std::shared_ptr _childrenMainSize; +}; + +///////////////////////////////////ListItemGroupAdapter/////////////////////////////////////// +class ListItemGroupAdapter : public ItemAdapter { +public: + ListItemGroupAdapter(std::vector>& dataSource, const std::vector& groupList) + : ItemAdapter(dataSource) + { + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, groupList.size()); + int32_t sum = 0; + for (auto& item : groupList) { + sum += item; + _groupList.push_back(sum); + } + } + virtual ~ListItemGroupAdapter() {} + std::unordered_map>& getGroup() + { + return _items; + } + +protected: + void OnNewItemAttached(ArkUI_NodeAdapterEvent* event) override; + void OnItemDetached(ArkUI_NodeAdapterEvent* event) override; + ArkUI_NodeHandle UpdateNewItemByGroup(int32_t start, int32_t end); + ArkUI_NodeHandle UpdateNewItem(int32_t start, int32_t end); + +private: + std::vector _groupList; + // 缓存listItemComponent + std::stack> _cachedListItems; + // 存储list嵌套的单个listItem + std::unordered_map> _listItems; +}; + +///////////////////////////////////List/////////////////////////////////////// + +class ListComponent : public Component { +public: + ListComponent() : Component(ARKUI_NODE_LIST) {} + explicit ListComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + // 引入懒加载模块。 + void SetLazyAdapter(const std::shared_ptr>& adapter) + { + ArkUI_AttributeItem item { nullptr, 0, nullptr, adapter->GetAdapter() }; + _nodeAPI->setAttribute(_component, NODE_LIST_NODE_ADAPTER, &item); + _adapter = adapter; + } + void SetLazyAdapterByGroup(const std::shared_ptr& adapter) + { + ArkUI_AttributeItem item { nullptr, 0, nullptr, adapter->GetAdapter() }; + _nodeAPI->setAttribute(_component, NODE_LIST_NODE_ADAPTER, &item); + _groupAdapter = adapter; + } + /** + * @param direction ArkUI_Axis + */ + void SetListDirection(int32_t direction); + /** + * @param stickyStyle ArkUI_StickyStyle + */ + void SetListSticky(int32_t stickyStyle); + void SetListSpace(float space); + void ResetListSpace(); + void SetListCachedCount(int32_t count); + /** + * data[0].i32:The index value of the target element to be slid to in the current container.\n + * data[1]?.i32:Set whether there is an action when sliding to the index value of a list item in the list, where + * 1 indicates an action and 0 indicates no action. Default value: 0。\n + * data[2]?.i32:ArkUI_ScrollAlignment + */ + void SetListScrollToIndex(const std::vector& data); + void SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams); + void SetScrollEdge(int32_t type); + void SetScrollEdgeEffect(int32_t edgeEffect, bool alwaysEnabled); + void SetScrollPage(int32_t next); + void SetScrollPage(int32_t next, int32_t animation); + void SetScrollBy(float hDistance, float vDistance); + /** + * @param align ArkUI_ListItemAlignment + */ + void SetListAlignListItem(int32_t align); + void SetListChildrenMainSize(ListChildrenMainSizeOption* mainSize); + void SetListInitialIndex(int32_t index); + void SetListDivider(uint32_t color, float width, float distanceStart, float distanceEnd); + void SetScrollBarWidth(float width); + void SetScrollBarColor(uint32_t color); + void SetScrollBar(int32_t barState); + void SetNestedScroll(int32_t forward, int32_t backward); + + std::shared_ptr> GetAdapter() const + { + return _adapter; + } + std::shared_ptr GetGroupAdapter() const + { + return _groupAdapter; + } + std::shared_ptr GetSizeOption() const + { + return _childrenMainSize; + } + void ReleaseSizeOption() + { + _childrenMainSize.reset(); + } + +private: + std::shared_ptr> _adapter; + std::shared_ptr _groupAdapter; + std::shared_ptr _childrenMainSize; +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_LIST_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/node_adapter.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/node_adapter.h new file mode 100644 index 0000000000000000000000000000000000000000..a57d15eb9ebe26e41651c00a27ebde31009f4629 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/node_adapter.h @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_NODE_ADAPTER_H +#define ARKUI_CAPI_DEMO_NODE_ADAPTER_H + +#include +#include +#include +#include +#include +#include + +#include "column_component.h" +namespace ArkUICApiDemo { +using AllItemCallBack = std::function, uint32_t)>; + +template +class ItemAdapter { +public: + explicit ItemAdapter(std::vector>& dataSource); + virtual ~ItemAdapter(); + ArkUI_NodeAdapterHandle GetAdapter() const + { + return _adapter; + } + void RemoveItem(int32_t index); + void RemoveItems(int32_t startPosition, int32_t itemCount); + void InsertItem(int32_t index, const std::shared_ptr& value); + void InsertItems(int32_t index, std::vector>& dataSource); + void MoveItem(int32_t oldIndex, int32_t newIndex); + void ReloadItem(int32_t index, const std::shared_ptr& value); + void ReloadItems(int32_t startPosition, std::vector>& dataSource); + void ReloadAllItem(); + void SetAllItem(AllItemCallBack callback); + void UnregisterEventReceiver(); + void SetNodeAdapterEvent(const std::function& callback); + void RegisterRemovedNodeCallback(std::function)> callback) + { + _removedNodeCallback = callback; + } + void SetTotalNodeCount(uint32_t count) + { + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, count); + } + uint32_t GetTotalNodeCount() + { + return OH_ArkUI_NodeAdapter_GetTotalNodeCount(_adapter); + } + +protected: + static void OnStaticAdapterEvent(ArkUI_NodeAdapterEvent* event); + virtual void OnAdapterEvent(ArkUI_NodeAdapterEvent* event); + // 分配ID给需要显示的Item,用于ReloadAllItems场景的元素diff。 + virtual void OnNewItemIdCreated(ArkUI_NodeAdapterEvent* event); + // 需要新的Item显示在可见区域。 + virtual void OnNewItemAttached(ArkUI_NodeAdapterEvent* event); + // Item从可见区域移除。 + virtual void OnItemDetached(ArkUI_NodeAdapterEvent* event); + + std::vector> _data; + ArkUI_NativeNodeAPI_1* _nodeAPI = nullptr; + ArkUI_NodeAdapterHandle _adapter = nullptr; + // 管理NodeAdapter生成的元素。 + std::unordered_map> _items; + // 管理回收复用组件池。 + std::stack> _cachedItems; + std::function _eventCallBack; + std::function)> _removedNodeCallback; +}; + +template +ItemAdapter::ItemAdapter(std::vector>& dataSource) + : _adapter(OH_ArkUI_NodeAdapter_Create()) +{ + // 使用NodeAdapter创建函数。 + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, _nodeAPI); + std::swap(_data, dataSource); + // 设置懒加载数据。 + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, _data.size()); + // 设置懒加载回调事件。 + OH_ArkUI_NodeAdapter_RegisterEventReceiver(_adapter, this, OnStaticAdapterEvent); +} + +template +ItemAdapter::~ItemAdapter() +{ + // 释放创建的组件。 + while (!_cachedItems.empty()) { + _cachedItems.pop(); + } + _items.clear(); + // 释放Adapter相关资源。 + OH_ArkUI_NodeAdapter_UnregisterEventReceiver(_adapter); + OH_ArkUI_NodeAdapter_Dispose(_adapter); +} + +template +void ItemAdapter::RemoveItem(int32_t index) +{ + // 删除第index个数据。 + _data.erase(_data.begin() + index); + // 如果index会导致可视区域元素发生可见性变化,则会回调NODE_ADAPTER_EVENT_ON_REMOVE_NODE_FROM_ADAPTER事件删除元素, + // 根据是否有新增元素回调NODE_ADAPTER_EVENT_ON_GET_NODE_ID和NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER事件。 + OH_ArkUI_NodeAdapter_RemoveItem(_adapter, index, 1); + // 更新新的数量。 + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, _data.size()); +} + +template +void ItemAdapter::RemoveItems(int32_t startPosition, int32_t itemCount) +{ + auto end = _data.begin() + startPosition + itemCount; + if (startPosition + itemCount > _data.size()) { + end = _data.end(); + } + _data.erase(_data.begin() + startPosition, end); + OH_ArkUI_NodeAdapter_RemoveItem(_adapter, startPosition, itemCount); + // 更新新的数量。 + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, _data.size()); +} + +template +void ItemAdapter::InsertItem(int32_t index, const std::shared_ptr& value) +{ + _data.insert(_data.begin() + index, value); + // 如果index会导致可视区域元素发生可见性变化,则会回调NODE_ADAPTER_EVENT_ON_GET_NODE_ID和NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER事件, + // 根据是否有删除元素回调NODE_ADAPTER_EVENT_ON_REMOVE_NODE_FROM_ADAPTER事件。 + OH_ArkUI_NodeAdapter_InsertItem(_adapter, index, 1); + // 更新新的数量。 + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, _data.size()); +} + +template +void ItemAdapter::InsertItems(int32_t index, std::vector>& dataSource) +{ + _data.insert(_data.begin() + index, dataSource.begin(), dataSource.end()); + OH_ArkUI_NodeAdapter_InsertItem(_adapter, index, dataSource.size()); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(_adapter, _data.size()); +} + +template +void ItemAdapter::MoveItem(int32_t oldIndex, int32_t newIndex) +{ + auto temp = _data[oldIndex]; + _data.insert(_data.begin() + newIndex, temp); + _data.erase(_data.begin() + oldIndex); + // 移到位置如果未发生可视区域内元素的可见性变化,则不回调事件,反之根据新增和删除场景回调对应的事件。 + OH_ArkUI_NodeAdapter_MoveItem(_adapter, oldIndex, newIndex); +} + +template +void ItemAdapter::ReloadItem(int32_t index, const std::shared_ptr& value) +{ + _data[index] = value; + // 如果index位于可视区域内,先回调NODE_ADAPTER_EVENT_ON_REMOVE_NODE_FROM_ADAPTER删除老元素, + // 再回调NODE_ADAPTER_EVENT_ON_GET_NODE_ID和NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER事件。 + OH_ArkUI_NodeAdapter_ReloadItem(_adapter, index, 1); +} + +template +void ItemAdapter::ReloadItems(int32_t startPosition, std::vector>& dataSource) +{ + if (startPosition + dataSource.size() > _data.size()) { + // 防止nodeAdapter崩溃 + return; + } + for (int32_t i = 0; i < dataSource.size(); i++) { + _data[startPosition + i] = dataSource[i]; + } + // 如果index位于可视区域内,先回调NODE_ADAPTER_EVENT_ON_REMOVE_NODE_FROM_ADAPTER删除老元素, + // 再回调NODE_ADAPTER_EVENT_ON_GET_NODE_ID和NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER事件。 + OH_ArkUI_NodeAdapter_ReloadItem(_adapter, startPosition, dataSource.size()); +} + +template +void ItemAdapter::SetAllItem(AllItemCallBack callback) +{ + ArkUI_NodeHandle* items = nullptr; + uint32_t size = 0; + OH_ArkUI_NodeAdapter_GetAllItems(_adapter, &items, &size); + for (uint32_t i = 0; i < size; i++) { + if (!items[i]) { + continue; + } + auto temp = std::make_shared(items[i]); + if (callback) { + callback(temp, i); + } + } +} + +template +void ItemAdapter::UnregisterEventReceiver() +{ + OH_ArkUI_NodeAdapter_UnregisterEventReceiver(_adapter); +} + +template +void ItemAdapter::SetNodeAdapterEvent(const std::function& callback) +{ + _eventCallBack = callback; +} + +template +void ItemAdapter::ReloadAllItem() +{ + std::reverse(_data.begin(), _data.end()); + // 全部重新加载场景下,会回调NODE_ADAPTER_EVENT_ON_GET_NODE_ID接口获取新的组件ID, + // 根据新的组件ID进行对比,ID不发生变化的进行复用, + // 针对新增ID的元素,调用NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER事件创建新的组件, + // 然后判断老数据中遗留的未使用ID,调用NODE_ADAPTER_EVENT_ON_REMOVE_NODE_FROM_ADAPTER删除老元素。 + OH_ArkUI_NodeAdapter_ReloadAllItems(_adapter); +} + +template +void ItemAdapter::OnStaticAdapterEvent(ArkUI_NodeAdapterEvent* event) +{ + // 获取实例对象,回调实例事件。 + auto itemAdapter = reinterpret_cast(OH_ArkUI_NodeAdapterEvent_GetUserData(event)); + itemAdapter->OnAdapterEvent(event); +} + +template +void ItemAdapter::OnAdapterEvent(ArkUI_NodeAdapterEvent* event) +{ + auto type = OH_ArkUI_NodeAdapterEvent_GetType(event); + switch (type) { + case NODE_ADAPTER_EVENT_WILL_ATTACH_TO_NODE: + break; + case NODE_ADAPTER_EVENT_WILL_DETACH_FROM_NODE: + break; + case NODE_ADAPTER_EVENT_ON_GET_NODE_ID: + OnNewItemIdCreated(event); + break; + case NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER: + OnNewItemAttached(event); + break; + case NODE_ADAPTER_EVENT_ON_REMOVE_NODE_FROM_ADAPTER: + OnItemDetached(event); + break; + default: + break; + } + if (_eventCallBack) { + _eventCallBack(event); + } +} +template +void ItemAdapter::OnNewItemIdCreated(ArkUI_NodeAdapterEvent* event) +{ + auto index = OH_ArkUI_NodeAdapterEvent_GetItemIndex(event); + static std::hash hashId = std::hash(); + auto id = hashId(std::to_string(index)); + OH_ArkUI_NodeAdapterEvent_SetNodeId(event, id); +} + +// 需要新的Item显示在可见区域。 +template +void ItemAdapter::OnNewItemAttached(ArkUI_NodeAdapterEvent* event) +{ + auto index = OH_ArkUI_NodeAdapterEvent_GetItemIndex(event); + ArkUI_NodeHandle handle = nullptr; + auto showNode = _data[index]; + if (!_cachedItems.empty()) { + // 使用并更新回收复用的缓存。 + auto recycledItem = _cachedItems.top(); + recycledItem->RemoveAll(); + recycledItem->AddChild(showNode); + handle = recycledItem->GetComponent(); + // 释放缓存池的引用。 + _cachedItems.pop(); + } else { + // 创建新的元素。 + auto flowItem = std::make_shared(); + flowItem->RemoveAll(); + flowItem->AddChild(showNode); + handle = flowItem->GetComponent(); + // 保持文本列表项的引用。 + _items.emplace(handle, flowItem); + } + // 设置需要展示的元素。 + OH_ArkUI_NodeAdapterEvent_SetItem(event, handle); +} + +// Item从可见区域移除。 +template +void ItemAdapter::OnItemDetached(ArkUI_NodeAdapterEvent* event) +{ + auto item = OH_ArkUI_NodeAdapterEvent_GetRemovedNode(event); + if (_removedNodeCallback) { + _removedNodeCallback(std::make_shared(item)); + } + // 放置到缓存池中进行回收复用。 + _cachedItems.emplace(_items[item]); +} +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_NODE_ADAPTER_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/radio_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/radio_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..02c85ad2bca935053185089689a839a8baac7c96 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/radio_component.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "radio_component.h" + +#include + +namespace ArkUICApiDemo { +constexpr size_t ALLOW_SIZE_3 = 3; +void RadioComponent::SetChecked(const bool& isChecked) +{ + ArkUI_NumberValue value[] = { { .i32 = static_cast(isChecked) } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_RADIO_CHECKED, &item); +} +void RadioComponent::SetGroup(const std::string& group) +{ + ArkUI_AttributeItem item = { .string = group.c_str() }; + _nodeAPI->setAttribute(_component, NODE_RADIO_GROUP, &item); +} +void RadioComponent::SetStyled(const uint32_t* colorArray, size_t size) +{ + if (size == ALLOW_SIZE_3) { + ArkUI_NumberValue radioStyle_value[] = { { .u32 = colorArray[0] }, { .u32 = colorArray[1] }, + { .u32 = colorArray[2] } }; + ArkUI_AttributeItem radioStyle_value_item = { radioStyle_value, ALLOW_SIZE_3 }; + _nodeAPI->setAttribute(_component, NODE_RADIO_STYLE, &radioStyle_value_item); + } +} +void RadioComponent::SetValue(const std::string& value) +{ + ArkUI_AttributeItem item = { .string = value.c_str() }; + _nodeAPI->setAttribute(_component, NODE_RADIO_VALUE, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/radio_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/radio_component.h new file mode 100644 index 0000000000000000000000000000000000000000..244feba45818192f38c9421e8f71dd801c973a43 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/radio_component.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RADIO_COMPONENT_H +#define ARKUI_CAPI_DEMO_RADIO_COMPONENT_H + +#include +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class RadioComponent : public Component { +public: + RadioComponent() : Component(ARKUI_NODE_RADIO) {} + explicit RadioComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetChecked(const bool& isChecked); + void SetGroup(const std::string& group); + void SetStyled(const uint32_t* colorArray, size_t size); + void SetValue(const std::string& value); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RADIO_COMPONENT_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/refresh_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/refresh_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b4c5ab7b17b2de50b63b201e68919fcda9170216 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/refresh_component.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "refresh_component.h" + +#include + +namespace ArkUICApiDemo { + +void RefreshComponent::SetPullToRefresh(int32_t pullToRefresh) +{ + ArkUI_NumberValue value[] = { { .i32 = pullToRefresh } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_REFRESH_PULL_TO_REFRESH, &item); +} +void RefreshComponent::SetPullDownRatio(float pullDownRatio) +{ + ArkUI_NumberValue value[] = { { .f32 = pullDownRatio } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_REFRESH_PULL_DOWN_RATIO, &item); +} +void RefreshComponent::SetRefreshOffset(float refreshOffset) +{ + ArkUI_NumberValue value[] = { { .f32 = refreshOffset } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_REFRESH_OFFSET, &item); +} +void RefreshComponent::SetRefreshing(bool refreshing) +{ + ArkUI_NumberValue value[] = { { .i32 = refreshing } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_REFRESH_REFRESHING, &item); +} +void RefreshComponent::SetRefreshContent(ArkUI_NodeHandle& node) +{ + ArkUI_AttributeItem item { .object = node }; + _nodeAPI->setAttribute(_component, NODE_REFRESH_CONTENT, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/refresh_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/refresh_component.h new file mode 100644 index 0000000000000000000000000000000000000000..cb5af060c21baf7d78a33de3adaa4a5f911ace0d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/refresh_component.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_REFRESH_COMPONENT_H +#define ARKUI_CAPI_DEMO_REFRESH_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class RefreshComponent : public Component { +public: + RefreshComponent() : Component(ARKUI_NODE_REFRESH) {} + explicit RefreshComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetPullToRefresh(int32_t pullToRefresh); + void SetPullDownRatio(float pullDownRatio); + void SetRefreshOffset(float refreshOffset); + void SetRefreshing(bool refreshing); + void SetRefreshContent(ArkUI_NodeHandle& node); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_REFRESH_COMPONENT_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/relativecontainer_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/relativecontainer_component.h new file mode 100644 index 0000000000000000000000000000000000000000..20166edb80ab847c476567f2e53ecb87c5e98126 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/relativecontainer_component.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RELATIVECONTAINER_COMPONENT_H +#define ARKUI_CAPI_DEMO_RELATIVECONTAINER_COMPONENT_H + +#include +#include + +#include "./relativeContainer/ruleOption.h" +#include "component.h" +namespace ArkUICApiDemo { +class RelativeContainerComponent : public Component { +public: + RelativeContainerComponent() : Component(ARKUI_NODE_RELATIVE_CONTAINER) {} + explicit RelativeContainerComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetRelativeContainerGuideLine(const std::shared_ptr guidelineOption) + { + ArkUI_AttributeItem item = { .object = guidelineOption->GetOption() }; + _nodeAPI->setAttribute(_component, NODE_RELATIVE_CONTAINER_GUIDE_LINE, &item); + guidelineOption_ = guidelineOption; + } + + void SetRelativeContainerBarrier(const std::shared_ptr barrierOption) + { + ArkUI_AttributeItem item = { .object = barrierOption->GetOption() }; + _nodeAPI->setAttribute(_component, NODE_RELATIVE_CONTAINER_BARRIER, &item); + barrierOption_ = barrierOption; + } + + std::shared_ptr GetRuleOption() const + { + return ruleOption_; + } + std::shared_ptr GetGuideLineOption() const + { + return guidelineOption_; + } + std::shared_ptr GetBarrierOption() const + { + return barrierOption_; + } + +private: + std::shared_ptr ruleOption_ = nullptr; + std::shared_ptr guidelineOption_ = nullptr; + std::shared_ptr barrierOption_ = nullptr; +}; +; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RELATIVECONTAINER_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/row_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/row_component.h new file mode 100644 index 0000000000000000000000000000000000000000..13e837e5e6d3f6b38159a8e11a795fe61abe73d1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/row_component.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ROW_COMPONENT_H +#define ARKUI_CAPI_DEMO_ROW_COMPONENT_H + +#include "component.h" +namespace ArkUICApiDemo { +class RowComponent : public Component { +public: + RowComponent() : Component(ARKUI_NODE_ROW) {} + explicit RowComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetAlignItems(int32_t verticalAlign) + { + ArkUI_NumberValue value[] = { { .i32 = verticalAlign } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_ROW_ALIGN_ITEMS, &item); + } + void SetJustifyContent(int32_t flexAlign) + { + ArkUI_NumberValue value[] = { { .i32 = flexAlign } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_ROW_JUSTIFY_CONTENT, &item); + } +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_ROW_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/scroll_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/scroll_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b717da4b29462de48f9693c49e18563d4b9e913a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/scroll_component.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_component.h" +namespace ArkUICApiDemo { + +void ScrollComponent::SetScrollScrollBar(int32_t barState) +{ + ArkUI_NumberValue value[] = { { .i32 = barState } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_DISPLAY_MODE, &item); +} +void ScrollComponent::SetScrollScrollBarWidth(float width) +{ + ArkUI_NumberValue value[] = { { .f32 = width } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_WIDTH, &item); +} +void ScrollComponent::SetScrollScrollBarColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_COLOR, &item); +} +void ScrollComponent::SetScrollScrollable(int32_t scrollable) +{ + ArkUI_NumberValue value[] = { { .i32 = scrollable } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_SCROLL_DIRECTION, &item); +} +void ScrollComponent::SetScrollEdgeEffect(int32_t edgeEffect, bool alwaysEnabled) +{ + ArkUI_NumberValue value[] = { { .i32 = edgeEffect }, { .i32 = alwaysEnabled } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_EDGE_EFFECT, &item); +} +void ScrollComponent::SetScrollEnableScrollInteraction(bool enableScrollInteraction) +{ + ArkUI_NumberValue value[] = { { .i32 = enableScrollInteraction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_ENABLE_SCROLL_INTERACTION, &item); +} +void ScrollComponent::SetScrollFriction(float friction) +{ + ArkUI_NumberValue value[] = { { .f32 = friction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_FRICTION, &item); +} +void ScrollComponent::SetScrollScrollSnap( + int32_t snapAlign, int32_t enableSnapToStart, int32_t enableSnapToEnd, const std::vector& pagination) +{ + auto value = new ArkUI_NumberValue[3 + static_cast(pagination.size())]; + value[0] = { .i32 = snapAlign }; + value[1] = { .i32 = enableSnapToStart }; + value[2] = { .i32 = enableSnapToEnd }; + for (int32_t i = 0; i < pagination.size(); i++) { + value[3 + i] = { .f32 = pagination[i] }; + } + ArkUI_AttributeItem item = { value, 3 + static_cast(pagination.size()) }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_SNAP, &item); +} +void ScrollComponent::SetScrollNestedScroll(int32_t forward, int32_t backward) +{ + ArkUI_NumberValue value[] = { { .i32 = forward }, { .i32 = backward } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_NESTED_SCROLL, &item); +} +void ScrollComponent::SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams) +{ + auto value = new ArkUI_NumberValue[2 + static_cast(optionalParams.size())]; + value[0] = { .f32 = hOffset }; + value[1] = { .f32 = vOffset }; + for (int32_t i = 0; i < optionalParams.size(); i++) { + value[2 + i] = { .i32 = optionalParams[i] }; + } + ArkUI_AttributeItem item = { value, 2 + static_cast(optionalParams.size()) }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_OFFSET, &item); +} +void ScrollComponent::SetScrollEdge(int32_t type) +{ + ArkUI_NumberValue value[] = { { .i32 = type } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_EDGE, &item); +} +void ScrollComponent::SetScrollEnablePaging(int32_t enablePaging) +{ + ArkUI_NumberValue value[] = { { .i32 = enablePaging } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_ENABLE_PAGING, &item); +} +void ScrollComponent::SetScrollPage(int32_t next) +{ + ArkUI_NumberValue value[] = { { .i32 = next } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_PAGE, &item); +} +void ScrollComponent::SetScrollPage(int32_t next, int32_t animation) +{ + ArkUI_NumberValue value[] = { { .i32 = next }, { .i32 = animation } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_PAGE, &item); +} +void ScrollComponent::SetScrollBy(float hDistance, float vDistance) +{ + ArkUI_NumberValue value[] = { { .f32 = hDistance }, { .f32 = vDistance } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BY, &item); +} +void ScrollComponent::SetScrollScrollDirection(int32_t direction) +{ + ArkUI_NumberValue value[] = { { .i32 = direction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_SCROLL_DIRECTION, &item); +} +void ScrollComponent::AddChildWithNumber(int32_t number, ArkUI_NodeType type) +{ + SetBorderWidth(2); + auto node = std::make_shared(type); + if (type == ARKUI_NODE_LIST) { + ArkUI_NumberValue value[] = { { .i32 = ARKUI_AXIS_HORIZONTAL } }; + ArkUI_AttributeItem item = { value, 1 }; + node->setAttribute(NODE_LIST_DIRECTION, &item); + node->SetMargin(DEFAULT_MARGIN); + } + for (int32_t i = 0; i < number; ++i) { + auto column = std::make_shared(ARKUI_NODE_COLUMN); + column->SetWidth(SIZE_50); + column->SetHeight(SIZE_50); + column->SetMargin(DEFAULT_MARGIN); + if (number == 0) { + number = 1; + } + column->SetBackgroundColor((i * 0xFFFFFF / number) | 0xFF000000); + node->AddChild(column); + } + AddChild(node); +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/scroll_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/scroll_component.h new file mode 100644 index 0000000000000000000000000000000000000000..1e221aed7923b20045c7ca3982546aa5261732a0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/scroll_component.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_SCROLL_COMPONENT_H +#define CAPIDEMO_SCROLL_COMPONENT_H + +#include "component.h" + +namespace ArkUICApiDemo { +class ScrollComponent : public Component { +public: + ScrollComponent() : Component(ARKUI_NODE_SCROLL) {} + explicit ScrollComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + void SetScrollScrollBar(int32_t barState); + void SetScrollScrollBarWidth(float width); + void SetScrollScrollBarColor(uint32_t color); + void SetScrollScrollable(int32_t scrollable); + void SetScrollEdgeEffect(int32_t edgeEffect, bool alwaysEnabled); + void SetScrollEnableScrollInteraction(bool enableScrollInteraction); + void SetScrollFriction(float friction); + void SetScrollScrollSnap( + int32_t snapAlign, int32_t enableSnapToStart, int32_t enableSnapToEnd, const std::vector& pagination); + void SetScrollNestedScroll(int32_t forward, int32_t backward); + /** + * @brief Set the scroll position to the specified offset. + * @param hOffset horizontal scrolling offset + * @param vOffset vertical scrolling offset + * @param optionalParams + * [0] scrolling duration, in milliseconds. + * [1] scrolling curve. The parameter type is ArkUI_AnimationCurve. + * [2] whether to enable the default spring animation. + * [3] sets whether scrolling can cross the boundary. + */ + void SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams); + void SetScrollEdge(int32_t type); + void SetScrollEnablePaging(int32_t enablePaging); + void SetScrollPage(int32_t next); + void SetScrollPage(int32_t next, int32_t animation); + void SetScrollBy(float hDistance, float vDistance); + void SetScrollScrollDirection(int32_t direction); + void AddChildWithNumber(int32_t number, ArkUI_NodeType type); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_SCROLL_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/swiper_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/swiper_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86ea8643fcd1aae7d19c437dfd8b1414a2fd5afb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/swiper_component.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_component.h" + +namespace ArkUICApiDemo { + +void SwiperComponent::SetSwiperLoop(int32_t loop) +{ + ArkUI_NumberValue value[] = { { .i32 = loop } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_LOOP, &item); +} + +void SwiperComponent::SetSwiperAutoPlay(int32_t status) +{ + ArkUI_NumberValue value[] = { { .i32 = status } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_AUTO_PLAY, &item); +} + +void SwiperComponent::SetSwiperPrevMigration(float migration, int32_t ignoreBlank) +{ + ArkUI_NumberValue value[] = { { .f32 = migration }, { .i32 = ignoreBlank } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_PREV_MARGIN, &item); +} + +void SwiperComponent::SetSwiperNextMigration(float migration, int32_t ignoreBlank) +{ + ArkUI_NumberValue value[] = { { .f32 = migration }, { .i32 = ignoreBlank } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_NEXT_MARGIN, &item); +} + +void SwiperComponent::SetSwiperDisplayCount(int32_t count) +{ + ArkUI_NumberValue value[] = { { .i32 = count } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_DISPLAY_COUNT, &item); +} + +void SwiperComponent::SetSwiperIndex(int32_t index) +{ + ArkUI_NumberValue value[] = { { .i32 = index } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_INDEX, &item); +} + +void SwiperComponent::SetSwiperVertical(int32_t vertical) +{ + ArkUI_NumberValue value[] = { { .i32 = vertical } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_VERTICAL, &item); +} + +void SwiperComponent::SetSwiperEffectMode(int32_t effect) +{ + ArkUI_NumberValue value[] = { { .i32 = effect } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_EDGE_EFFECT_MODE, &item); +} + +void SwiperComponent::SetSwiperNestedScroll(int32_t nestedScroll) +{ + ArkUI_NumberValue value[] = { { .i32 = nestedScroll } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_NESTED_SCROLL, &item); +} + +void SwiperComponent::SetSwiperInterval(float interval) +{ + ArkUI_NumberValue value[] = { { .f32 = interval } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_INTERVAL, &item); +} + +void SwiperComponent::SetSwiperDirection(int32_t direction) +{ + ArkUI_NumberValue value[] = { { .i32 = direction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_DIRECTION, &item); +} + +void SwiperComponent::SetSwiperIndicator(ArkUI_SwiperIndicator* indicator) +{ + ArkUI_NumberValue indicator_value[] = { { .i32 = ARKUI_SWIPER_INDICATOR_TYPE_DOT } }; + ArkUI_AttributeItem indicator_item = { indicator_value, sizeof(indicator_value) / sizeof(ArkUI_NumberValue), "", + indicator }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_INDICATOR, &indicator_item); +} + +void SwiperComponent::SetSwiperToIndex(int32_t index, int32_t useAnimation) +{ + ArkUI_NumberValue value[] = { { .i32 = index }, { .i32 = useAnimation } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_SWIPE_TO_INDEX, &item); +} + +void SwiperComponent::SetSwiperDuration(float duration) +{ + ArkUI_NumberValue value[] = { { .f32 = duration } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SWIPER_DURATION, &item); +} + +void SwiperComponent::RegisterOnGesture(const std::function& onGesture) +{ + onGesture_ = onGesture; + _nodeAPI->registerNodeEvent(_component, NODE_SWIPER_EVENT_ON_GESTURE_SWIPE, 0, nullptr); +} + +void SwiperComponent::RegisterOnChange(const std::function& onChange) +{ + onChange_ = onChange; + _nodeAPI->registerNodeEvent(_component, NODE_SWIPER_EVENT_ON_CHANGE, 0, nullptr); +} + +void SwiperComponent::RegisterOnDidScrollContext(const std::function& onDid) +{ + onDid_ = onDid; + _nodeAPI->registerNodeEvent(_component, NODE_SWIPER_EVENT_ON_CONTENT_DID_SCROLL, 0, nullptr); +} + +void SwiperComponent::RegisterOnAnimationStart(const std::function& onStart) +{ + onStart_ = onStart; + _nodeAPI->registerNodeEvent(_component, NODE_SWIPER_EVENT_ON_ANIMATION_START, 0, nullptr); +} + +void SwiperComponent::RegisterOnAnimationEnd(const std::function& onEnd) +{ + onEnd_ = onEnd; + _nodeAPI->registerNodeEvent(_component, NODE_SWIPER_EVENT_ON_ANIMATION_END, 0, nullptr); +} + +void SwiperComponent::OnNodeEvent(ArkUI_NodeEvent* event) +{ + auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); + switch (eventType) { + case NODE_SWIPER_EVENT_ON_GESTURE_SWIPE: + if (onGesture_) { + onGesture_(event); + } + break; + case NODE_SWIPER_EVENT_ON_CHANGE: + if (onChange_) { + onChange_(event); + } + break; + case NODE_SWIPER_EVENT_ON_CONTENT_DID_SCROLL: + if (onDid_) { + onDid_(event); + } + break; + case NODE_SWIPER_EVENT_ON_ANIMATION_START: + if (onStart_) { + onStart_(event); + } + break; + case NODE_SWIPER_EVENT_ON_ANIMATION_END: + if (onEnd_) { + onEnd_(event); + } + break; + default: + break; + } +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/swiper_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/swiper_component.h new file mode 100644 index 0000000000000000000000000000000000000000..03b59d3c09d55bc7ad7fd8d90846073283a3bca4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/swiper_component.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_SWIPER_COMPONENT_H +#define CAPIDEMO_SWIPER_COMPONENT_H + +#include + +#include "component.h" +#include "node_adapter.h" + +namespace ArkUICApiDemo { +class SwiperComponent : public Component { +public: + SwiperComponent() : Component(ARKUI_NODE_SWIPER) {} + explicit SwiperComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetSwiperLoop(int32_t loop); + void SetSwiperAutoPlay(int32_t status); + void SetSwiperPrevMigration(float migration, int32_t ignoreBlank = false); + void SetSwiperNextMigration(float migration, int32_t ignoreBlank = false); + void SetSwiperDisplayCount(int32_t count); + void SetSwiperIndex(int32_t index); + void SetSwiperVertical(int32_t vertical); + void SetSwiperNestedScroll(int32_t nestedScroll); + void SetSwiperEffectMode(int32_t effect); + void SetSwiperInterval(float interval); + void SetSwiperDirection(int32_t direction); + void SetSwiperIndicator(ArkUI_SwiperIndicator* indicator); + void SetSwiperToIndex(int32_t index, int32_t useAnimation = false); + void SetSwiperDuration(float duration); + void RegisterOnGesture(const std::function& onGesture); + void RegisterOnChange(const std::function& onChange); + void RegisterOnDidScrollContext(const std::function& onDid); + void RegisterOnAnimationStart(const std::function& onStart); + void RegisterOnAnimationEnd(const std::function& onEnd); + void OnNodeEvent(ArkUI_NodeEvent* event) override; + + std::function onGesture_; + std::function onDid_; + std::function onChange_; + std::function onStart_; + std::function onEnd_; +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_SWIPER_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/text_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/text_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d1d1f88266d9d08d170bb141b0eaee8101612e7a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/text_component.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "text_component.h" + +namespace ArkUICApiDemo { + +void TextComponent::SetFontSize(float fontSize) +{ + ArkUI_NumberValue value[] = { { .f32 = fontSize } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_FONT_SIZE, &item); +} +void TextComponent::SetFontColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_FONT_COLOR, &item); +} +void TextComponent::SetTextContent(const std::string& content) +{ + ArkUI_AttributeItem item = { nullptr, 0, content.c_str() }; + _nodeAPI->setAttribute(_component, NODE_TEXT_CONTENT, &item); +} +void TextComponent::SetTextAlign(ArkUI_TextAlignment align) +{ + ArkUI_NumberValue value[] = { { .i32 = align } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_TEXT_ALIGN, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/text_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/text_component.h new file mode 100644 index 0000000000000000000000000000000000000000..c5f2e4f1fefcbc9c99c7085080475693f9134e5f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/text_component.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_COMPONENT_H +#define ARKUI_CAPI_DEMO_TEXT_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class TextComponent : public Component { +public: + TextComponent() : Component(ARKUI_NODE_TEXT) {} + explicit TextComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetFontSize(float fontSize) override; + void SetFontColor(uint32_t color); + void SetTextContent(const std::string& content); + void SetTextAlign(ArkUI_TextAlignment align); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/toggle_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/toggle_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e8a79b78368c3f3c4db889e4c00cba87d03461a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/toggle_component.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "toggle_component.h" + +namespace ArkUICApiDemo { + +void ToggleComponent::SetUnselectedColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_TOGGLE_UNSELECTED_COLOR, &item); +} + +void ToggleComponent::SetToggleValue(int32_t type) +{ + ArkUI_NumberValue value[] = { { .i32 = type } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_TOGGLE_VALUE, &item); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/toggle_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/toggle_component.h new file mode 100644 index 0000000000000000000000000000000000000000..bcae66515a587b7960c8c1565a93c77069a03d52 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/toggle_component.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TOGGLE_COMPONENT_H +#define ARKUI_CAPI_DEMO_TOGGLE_COMPONENT_H + +#include + +#include "component.h" + +namespace ArkUICApiDemo { +class ToggleComponent : public Component { +public: + ToggleComponent() : Component(ARKUI_NODE_TOGGLE) {} + explicit ToggleComponent(ArkUI_NodeHandle handle) : Component(handle) {} + void SetUnselectedColor(uint32_t color); + void SetToggleValue(int32_t type); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TOGGLE_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/waterflow_component.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/component/waterflow_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..777c075537f8b516ae8cd740fd9950f4824d4196 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/waterflow_component.cpp @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +void WaterFlowSectionOption::SetSection(int32_t index, WaterFlowSection section) +{ + OH_ArkUI_WaterFlowSectionOption_SetItemCount(_option, index, section.itemsCount); + OH_ArkUI_WaterFlowSectionOption_SetCrossCount(_option, index, section.crossCount); + OH_ArkUI_WaterFlowSectionOption_SetColumnGap(_option, index, section.columnsGap); + OH_ArkUI_WaterFlowSectionOption_SetRowGap(_option, index, section.rowsGap); + OH_ArkUI_WaterFlowSectionOption_SetMargin( + _option, index, section.margin.top, section.margin.right, section.margin.bottom, section.margin.left); + OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndex( + _option, index, section.onGetItemMainSizeByIndex); +} +WaterFlowSection WaterFlowSectionOption::GetSection(int32_t index) +{ + return { OH_ArkUI_WaterFlowSectionOption_GetItemCount(_option, index), + OH_ArkUI_WaterFlowSectionOption_GetCrossCount(_option, index), + OH_ArkUI_WaterFlowSectionOption_GetColumnGap(_option, index), + OH_ArkUI_WaterFlowSectionOption_GetRowGap(_option, index), + OH_ArkUI_WaterFlowSectionOption_GetMargin(_option, index) }; +} + +void WaterFlowSectionOption::SetSize(int32_t size) +{ + OH_ArkUI_WaterFlowSectionOption_SetSize(_option, size); +} +int32_t WaterFlowSectionOption::GetSize() +{ + return OH_ArkUI_WaterFlowSectionOption_GetSize(_option); +} + +void WaterFlowComponent::SetLayoutDirection(int32_t layoutDirection) +{ + ArkUI_NumberValue value[] = { { .i32 = layoutDirection } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_LAYOUT_DIRECTION, &item); +} + +void WaterFlowComponent::SetColumnsTemplate(const std::string& str) +{ + ArkUI_AttributeItem item = { .string = str.c_str() }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_COLUMN_TEMPLATE, &item); +} + +void WaterFlowComponent::SetRowsTemplate(const std::string& str) +{ + ArkUI_AttributeItem item = { .string = str.c_str() }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_ROW_TEMPLATE, &item); +} + +void WaterFlowComponent::SetWaterFlowColumnsGap(float val) +{ + ArkUI_NumberValue value[] = { { .f32 = val } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_COLUMN_GAP, &item); +} + +void WaterFlowComponent::SetWaterFlowRowsGap(float val) +{ + ArkUI_NumberValue value[] = { { .f32 = val } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_ROW_GAP, &item); +} + +void WaterFlowComponent::SetWaterFlowSectionOption(int32_t start, const std::shared_ptr& option) +{ + ArkUI_NumberValue value[] = { { .i32 = start } }; + ArkUI_AttributeItem item = { value, 1, nullptr, option->GetOption() }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_SECTION_OPTION, &item); + _sectionsOption = option; +} + +void WaterFlowComponent::SetWaterFlowCachedCount(int32_t cachedCount) +{ + ArkUI_NumberValue value[] = { { .i32 = cachedCount } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_CACHED_COUNT, &item); +} + +void WaterFlowComponent::SetWaterFlowFooter(ArkUI_NodeHandle node) +{ + ArkUI_AttributeItem item = { .object = node }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_FOOTER, &item); +} + +void WaterFlowComponent::SetWaterFlowScrollToIndex(int32_t index) +{ + ArkUI_NumberValue value[] = { { .i32 = index } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_SCROLL_TO_INDEX, &item); +} + +void WaterFlowComponent::SetWaterFlowScrollToIndex(int32_t index, int32_t animation) +{ + ArkUI_NumberValue value[] = { { .i32 = index }, { .i32 = animation } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_SCROLL_TO_INDEX, &item); +} + +void WaterFlowComponent::SetWaterFlowScrollToIndex(int32_t index, int32_t animation, int32_t alignment) +{ + ArkUI_NumberValue value[] = { { .i32 = index }, { .i32 = animation }, { .i32 = alignment } }; + ArkUI_AttributeItem item = { value, 3 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_SCROLL_TO_INDEX, &item); +} + +void WaterFlowComponent::SetItemConstraintSize(float minWidth, float maxWidth, float minHeight, float maxHeight) +{ + ArkUI_NumberValue value[] = { { .f32 = minWidth }, { .f32 = maxWidth }, { .f32 = minHeight }, + { .f32 = maxHeight } }; + ArkUI_AttributeItem item = { value, 4 }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_ITEM_CONSTRAINT_SIZE, &item); +} +void WaterFlowComponent::SetWaterFlowNestedScroll(int32_t forward, int32_t backward) +{ + ArkUI_NumberValue value[] = { { .i32 = forward }, { .i32 = backward } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_NESTED_SCROLL, &item); +} +void WaterFlowComponent::SetWaterFlowScrollBar(int32_t barState) +{ + ArkUI_NumberValue value[] = { { .i32 = barState } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_DISPLAY_MODE, &item); +} +void WaterFlowComponent::SetWaterFlowScrollBarWidth(float width) +{ + ArkUI_NumberValue value[] = { { .f32 = width } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_WIDTH, &item); +} +void WaterFlowComponent::SetWaterFlowScrollBarColor(uint32_t color) +{ + ArkUI_NumberValue value[] = { { .u32 = color } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BAR_COLOR, &item); +} +void WaterFlowComponent::SetWaterFlowEnableScrollInteraction(bool enableScrollInteraction) +{ + ArkUI_NumberValue value[] = { { .i32 = enableScrollInteraction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_ENABLE_SCROLL_INTERACTION, &item); +} +void WaterFlowComponent::SetWaterFlowFriction(float friction) +{ + ArkUI_NumberValue value[] = { { .f32 = friction } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_FRICTION, &item); +} +void WaterFlowComponent::SetWaterFlowEdgeEffect(int32_t edgeEffect, bool alwaysEnabled) +{ + ArkUI_NumberValue value[] = { { .i32 = edgeEffect }, { .i32 = alwaysEnabled } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_EDGE_EFFECT, &item); +} +void WaterFlowComponent::SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams) +{ + auto value = new ArkUI_NumberValue[2 + static_cast(optionalParams.size())]; + value[0] = { .f32 = hOffset }; + value[1] = { .f32 = vOffset }; + for (int32_t i = 0; i < optionalParams.size(); i++) { + value[2 + i] = { .i32 = optionalParams[i] }; + } + ArkUI_AttributeItem item = { value, 2 + static_cast(optionalParams.size()) }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_OFFSET, &item); +} +void WaterFlowComponent::SetScrollEdge(int32_t type) +{ + ArkUI_NumberValue value[] = { { .i32 = type } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_EDGE, &item); +} +void WaterFlowComponent::SetScrollPage(bool next) +{ + ArkUI_NumberValue value[] = { { .i32 = next } }; + ArkUI_AttributeItem item = { value, 1 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_PAGE, &item); +} +void WaterFlowComponent::SetScrollPage(bool next, bool animation) +{ + ArkUI_NumberValue value[] = { { .i32 = next }, { .i32 = animation } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_PAGE, &item); +} +void WaterFlowComponent::SetScrollBy(float hDistance, float vDistance) +{ + ArkUI_NumberValue value[] = { { .f32 = hDistance }, { .f32 = vDistance } }; + ArkUI_AttributeItem item = { value, 2 }; + _nodeAPI->setAttribute(_component, NODE_SCROLL_BY, &item); +} +void WaterFlowComponent::OnNodeEvent(ArkUI_NodeEvent* event) +{ + auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); + if (eventMap_.find(eventType) != eventMap_.end()) { + eventMap_[eventType](event); + } +} +void WaterFlowComponent::SetOnWillScroll(OnWillScroll onWillScroll) +{ + auto onWillScrollCallback = [onWillScroll](ArkUI_NodeEvent* event) { + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + float offset = result->data[0].f32; + int32_t state = result->data[1].i32; + int32_t source = result->data[2].i32; + if (onWillScroll) { + onWillScroll(offset, state, source); + } + }; + eventMap_[NODE_ON_WILL_SCROLL] = onWillScrollCallback; + _nodeAPI->registerNodeEvent(_component, NODE_ON_WILL_SCROLL, 0, nullptr); +} +void WaterFlowComponent::SetOnReachStart(OnReachStart onReachStart) +{ + auto onReachStartCallback = [onReachStart](ArkUI_NodeEvent*) { + if (onReachStart) { + onReachStart(); + } + }; + eventMap_[NODE_SCROLL_EVENT_ON_REACH_START] = onReachStartCallback; + _nodeAPI->registerNodeEvent(_component, NODE_SCROLL_EVENT_ON_REACH_START, 0, nullptr); +} +void WaterFlowComponent::SetOnReachEnd(OnReachEnd onReachEnd) +{ + auto onReachEndCallback = [onReachEnd](ArkUI_NodeEvent*) { + if (onReachEnd) { + onReachEnd(); + } + }; + eventMap_[NODE_SCROLL_EVENT_ON_REACH_END] = onReachEndCallback; + _nodeAPI->registerNodeEvent(_component, NODE_SCROLL_EVENT_ON_REACH_END, 0, nullptr); +} +void WaterFlowComponent::SetOnScrollStop(OnScrollStop onScrollStop) +{ + auto onScrollStopCallback = [onScrollStop](ArkUI_NodeEvent*) { + if (onScrollStop) { + onScrollStop(); + } + }; + eventMap_[NODE_SCROLL_EVENT_ON_SCROLL_STOP] = onScrollStopCallback; + _nodeAPI->registerNodeEvent(_component, NODE_SCROLL_EVENT_ON_SCROLL_STOP, 0, nullptr); +} +void WaterFlowComponent::SetOnDidScroll(OnDidScroll onDidScroll) +{ + auto onDidScrollCallback = [onDidScroll](ArkUI_NodeEvent* event) { + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + if (onDidScroll) { + float offset = result->data[0].f32; + int32_t state = result->data[1].i32; + onDidScroll(offset, state); + } + }; + eventMap_[NODE_WATER_FLOW_ON_DID_SCROLL] = onDidScrollCallback; + _nodeAPI->registerNodeEvent(_component, NODE_WATER_FLOW_ON_DID_SCROLL, 0, nullptr); +} +void WaterFlowComponent::SetOnScrollFrameBegin(OnScrollFrameBegin onScrollFrameBegin) +{ + auto onScrollFrameBeginCallback = [onScrollFrameBegin](ArkUI_NodeEvent* event) { + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + if (onScrollFrameBegin) { + float offset = result->data[0].f32; + int32_t state = result->data[1].i32; + result->data[0].f32 = onScrollFrameBegin(offset, state); + } + }; + eventMap_[NODE_SCROLL_EVENT_ON_SCROLL_FRAME_BEGIN] = onScrollFrameBeginCallback; + _nodeAPI->registerNodeEvent(_component, NODE_SCROLL_EVENT_ON_SCROLL_FRAME_BEGIN, 0, nullptr); +} +void WaterFlowComponent::SetOnScrollIndex(OnScrollIndex onScrollIndex) +{ + auto onScrollIndexCallback = [onScrollIndex](ArkUI_NodeEvent* event) { + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + if (onScrollIndex) { + int32_t first = result->data[0].i32; + int32_t last = result->data[1].i32; + onScrollIndex(first, last); + } + }; + eventMap_[NODE_WATER_FLOW_ON_SCROLL_INDEX] = onScrollIndexCallback; + _nodeAPI->registerNodeEvent(_component, NODE_WATER_FLOW_ON_SCROLL_INDEX, 0, nullptr); +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/component/waterflow_component.h b/function/ui_compare/capidemo/entry/src/main/cpp/component/waterflow_component.h new file mode 100644 index 0000000000000000000000000000000000000000..621a1dd321ab12bfc7b7d9cbb4321d0859ca8cf7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/component/waterflow_component.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_WATERFLOW_COMPONENT_H +#define ARKUI_CAPI_DEMO_WATERFLOW_COMPONENT_H + +#include +#include + +#include "component.h" +#include "flowitem_component.h" +#include "node_adapter.h" + +namespace ArkUICApiDemo { +using OnWillScroll = std::function; +using OnReachStart = std::function; +using OnReachEnd = std::function; +using OnScrollStop = std::function; +using OnDidScroll = std::function; +using OnScrollFrameBegin = std::function; +using OnScrollIndex = std::function; + +struct WaterFlowSection { + int32_t itemsCount = 0; + int32_t crossCount; + float columnsGap; + float rowsGap; + // top right bottom left + ArkUI_Margin margin { 0, 0, 0, 0 }; + float (*onGetItemMainSizeByIndex)(int32_t itemIndex); + void* userData; +}; + +class WaterFlowSectionOption { +public: + WaterFlowSectionOption() : _option(OH_ArkUI_WaterFlowSectionOption_Create()) {} + ~WaterFlowSectionOption() + { + OH_ArkUI_WaterFlowSectionOption_Dispose(_option); + } + void SetSection(int32_t index, WaterFlowSection section); + WaterFlowSection GetSection(int32_t index); + + void SetSize(int32_t size); + int32_t GetSize(); + ArkUI_WaterFlowSectionOption* GetOption() + { + return _option; + } + +private: + ArkUI_WaterFlowSectionOption* _option; +}; + +class WaterFlowComponent : public Component { +public: + WaterFlowComponent() : Component(ARKUI_NODE_WATER_FLOW) {} + explicit WaterFlowComponent(ArkUI_NodeHandle handle) : Component(handle) {} + + // 引入懒加载模块。 + void SetLazyAdapter(const std::shared_ptr>& adapter) + { + ArkUI_AttributeItem item { nullptr, 0, nullptr, adapter->GetAdapter() }; + _nodeAPI->setAttribute(_component, NODE_WATER_FLOW_NODE_ADAPTER, &item); + _adapter = adapter; + } + void SetLayoutDirection(int32_t layoutDirection); + void SetColumnsTemplate(const std::string& str); + void SetRowsTemplate(const std::string& str); + void SetWaterFlowColumnsGap(float val); + void SetWaterFlowRowsGap(float val); + void SetWaterFlowSectionOption(int32_t start, const std::shared_ptr& option); + void SetWaterFlowCachedCount(int32_t cachedCount); + void SetWaterFlowFooter(ArkUI_NodeHandle node); + void SetWaterFlowScrollToIndex(int32_t index); + void SetWaterFlowScrollToIndex(int32_t index, int32_t animation); + void SetWaterFlowScrollToIndex(int32_t index, int32_t animation, int32_t alignment); + void SetItemConstraintSize(float minWidth, float maxWidth, float minHeight, float maxHeight); + void SetWaterFlowNestedScroll(int32_t forward, int32_t backward); + void SetWaterFlowScrollBar(int32_t barState); + void SetWaterFlowScrollBarWidth(float width); + void SetWaterFlowScrollBarColor(uint32_t color); + void SetWaterFlowEnableScrollInteraction(bool enableScrollInteraction); + void SetWaterFlowFriction(float friction); + void SetWaterFlowEdgeEffect(int32_t edgeEffect, bool alwaysEnabled); + /** + * @brief Set the scroll position to the specified offset. + * @param hOffset horizontal scrolling offset + * @param vOffset vertical scrolling offset + * @param optionalParams + * [0] scrolling duration, in milliseconds. + * [1] scrolling curve. The parameter type is ArkUI_AnimationCurve. + * [2] whether to enable the default spring animation. + * [3] sets whether scrolling can cross the boundary. + * [4] canOverScroll. + */ + void SetScrollTo(float hOffset, float vOffset, const std::vector& optionalParams); + void SetScrollEdge(int32_t type); + void SetScrollPage(bool next); + void SetScrollPage(bool next, bool animation); + void SetScrollBy(float hDistance, float vDistance); + + void OnNodeEvent(ArkUI_NodeEvent* event) override; + void SetOnWillScroll(OnWillScroll onWillScroll); + void SetOnReachStart(OnReachStart onReachStart); + void SetOnReachEnd(OnReachEnd onReachEnd); + void SetOnScrollStop(OnScrollStop onScrollStop); + void SetOnDidScroll(OnDidScroll onDidScroll); + void SetOnScrollFrameBegin(OnScrollFrameBegin onScrollFrameBegin); + void SetOnScrollIndex(OnScrollIndex onScrollIndex); + + std::shared_ptr> GetAdapter() const + { + return _adapter; + } + std::shared_ptr GetSectionOption() const + { + return _sectionsOption; + } + void ReleaseSectionOption() + { + _sectionsOption.reset(); + } + +private: + std::shared_ptr _sectionsOption; + std::shared_ptr> _adapter; +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_WATERFLOW_COMPONENT_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_customevent_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_customevent_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0a31b55d9546418fc1430d295f4684a3d0b691e8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_customevent_test.cpp @@ -0,0 +1,362 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_customevent_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static int32_t dataInt = 6; +static char* dataString = "CustomEvent"; +static float dataFloat = 6.0; +static bool dataBool = true; +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_CUSTOM); + // set width + ArkUI_NumberValue custom_width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem custom_width_item = { custom_width_value, + sizeof(custom_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &custom_width_item); + // set height + ArkUI_NumberValue custom_height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem custom_height_item = { custom_height_value, + sizeof(custom_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &custom_height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + auto ret = nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set background color + ArkUI_NumberValue custom1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem custom1_background_color_item = { custom1_background_color_value, + sizeof(custom1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &custom1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} +static void OnEventReceive(ArkUI_NodeCustomEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + // if event is called, set background color to green + if (eventId == ON_CUSTOM_EVENT_1_ID || eventId == ON_CUSTOM_EVENT_6_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + nodeAPI->setMeasuredSize(nodeHandler, 200, 50); + return; + } +} + +static void OnEventReceive2(ArkUI_NodeCustomEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive2: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OnEventReceive2 eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + // if event is called, set background color to green + if (eventId == ON_CUSTOM_EVENT_2_ID) { + auto dataIntTemp = OH_ArkUI_NodeCustomEvent_GetUserData(event); + int32_t tempDataInt = *static_cast(dataIntTemp); + if (tempDataInt == 6) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + return; + } +} + +static void OnEventReceive3(ArkUI_NodeCustomEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive3: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OnEventReceive3 eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + // if event is called, set background color to green + if (eventId == ON_CUSTOM_EVENT_3_ID) { + auto dataStringTemp = OH_ArkUI_NodeCustomEvent_GetUserData(event); + char* tempDataString = static_cast(dataStringTemp); + if (strcmp(tempDataString, "CustomEvent") == 0) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + return; + } +} + +static void OnEventReceive4(ArkUI_NodeCustomEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive4: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OnEventReceive4 eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + // if event is called, set background color to green + if (eventId == ON_CUSTOM_EVENT_4_ID) { + auto dataFloatTemp = OH_ArkUI_NodeCustomEvent_GetUserData(event); + float tempDataFloat = *static_cast(dataFloatTemp); + if (tempDataFloat == 6.0) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + return; + } +} + +static void OnEventReceive5(ArkUI_NodeCustomEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "OnEventReceive5: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OnEventReceive5 eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + // if event is called, set background color to green + if (eventId == ON_CUSTOM_EVENT_5_ID) { + auto dataBoolTemp = OH_ArkUI_NodeCustomEvent_GetUserData(event); + bool tempDataBool = *static_cast(dataBoolTemp); + if (tempDataBool == true) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + return; + } +} + +napi_value CustomComponentCustomEventTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createColumnNode(nodeAPI); + nodeAPI->addChild(parentColumn, column1); + // set children + auto custom1 = createChildNode(nodeAPI, COLOR_RED); + auto custom2 = createChildNode(nodeAPI, COLOR_PURPLE); + auto custom3 = createChildNode(nodeAPI, COLOR_YELLOW); + auto custom4 = createChildNode(nodeAPI, COLOR_GRAY); + auto custom5 = createChildNode(nodeAPI, COLOR_BLUE); + auto custom6 = createChildNode(nodeAPI, COLOR_WHITE); + nodeAPI->addChild(column1, custom1); + nodeAPI->addChild(column1, custom2); + nodeAPI->addChild(column1, custom3); + nodeAPI->addChild(column1, custom4); + nodeAPI->addChild(column1, custom5); + nodeAPI->addChild(column1, custom6); + + nodeAPI->registerNodeCustomEvent(custom1, ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_1_ID, nullptr); + dataInt = 6; + nodeAPI->registerNodeCustomEvent(custom2, ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_2_ID, &dataInt); + dataString = "CustomEvent"; + nodeAPI->registerNodeCustomEvent(custom3, ARKUI_NODE_CUSTOM_EVENT_ON_DRAW, ON_CUSTOM_EVENT_3_ID, &dataString); + dataFloat = 6.0; + nodeAPI->registerNodeCustomEvent( + custom4, ARKUI_NODE_CUSTOM_EVENT_ON_FOREGROUND_DRAW, ON_CUSTOM_EVENT_4_ID, &dataFloat); + dataBool = true; + nodeAPI->registerNodeCustomEvent(custom5, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW, ON_CUSTOM_EVENT_5_ID, &dataBool); + nodeAPI->registerNodeCustomEvent(custom6, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW, ON_CUSTOM_EVENT_6_ID, &dataBool); + + nodeAPI->unregisterNodeCustomEvent(custom6, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW); + nodeAPI->registerNodeCustomEventReceiver(&OnEventReceive); + nodeAPI->addNodeCustomEventReceiver(custom2, &OnEventReceive2); + nodeAPI->addNodeCustomEventReceiver(custom3, &OnEventReceive3); + nodeAPI->addNodeCustomEventReceiver(custom4, &OnEventReceive4); + nodeAPI->addNodeCustomEventReceiver(custom5, &OnEventReceive5); + nodeAPI->removeNodeCustomEventReceiver(custom4, &OnEventReceive4); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value CustomComponentCustomEventTest::CreateUnregisterNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = createColumnNode(nodeAPI); + nodeAPI->addChild(parentColumn, column1); + // set children + auto custom1 = createChildNode(nodeAPI, COLOR_RED); + auto custom2 = createChildNode(nodeAPI, COLOR_PURPLE); + auto custom3 = createChildNode(nodeAPI, COLOR_YELLOW); + auto custom4 = createChildNode(nodeAPI, COLOR_GRAY); + auto custom5 = createChildNode(nodeAPI, COLOR_BLUE); + auto custom6 = createChildNode(nodeAPI, COLOR_WHITE); + nodeAPI->addChild(column1, custom1); + nodeAPI->addChild(column1, custom2); + nodeAPI->addChild(column1, custom3); + nodeAPI->addChild(column1, custom4); + nodeAPI->addChild(column1, custom5); + nodeAPI->addChild(column1, custom6); + + nodeAPI->registerNodeCustomEvent(custom1, ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_1_ID, nullptr); + dataInt = 6; + nodeAPI->registerNodeCustomEvent(custom2, ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_2_ID, &dataInt); + dataString = "CustomEvent"; + nodeAPI->registerNodeCustomEvent(custom3, ARKUI_NODE_CUSTOM_EVENT_ON_DRAW, ON_CUSTOM_EVENT_3_ID, &dataString); + dataFloat = 6.0; + nodeAPI->registerNodeCustomEvent( + custom4, ARKUI_NODE_CUSTOM_EVENT_ON_FOREGROUND_DRAW, ON_CUSTOM_EVENT_4_ID, &dataFloat); + dataBool = true; + nodeAPI->registerNodeCustomEvent(custom5, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW, ON_CUSTOM_EVENT_5_ID, &dataBool); + nodeAPI->registerNodeCustomEvent(custom6, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW, ON_CUSTOM_EVENT_6_ID, &dataBool); + + nodeAPI->unregisterNodeCustomEvent(custom6, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW); + nodeAPI->registerNodeCustomEventReceiver(&OnEventReceive); + nodeAPI->addNodeCustomEventReceiver(custom2, &OnEventReceive2); + nodeAPI->addNodeCustomEventReceiver(custom3, &OnEventReceive3); + nodeAPI->addNodeCustomEventReceiver(custom4, &OnEventReceive4); + nodeAPI->addNodeCustomEventReceiver(custom5, &OnEventReceive5); + nodeAPI->unregisterNodeCustomEventReceiver(); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentCustomEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_customevent_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_customevent_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2d2da03ba610a5f4c0f112899c67e20310bd1358 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_customevent_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_CUSTOMEVENT_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_CUSTOMEVENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentCustomEventTest { +public: + ~CustomComponentCustomEventTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateUnregisterNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_CUSTOMEVENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_drawcontext_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_drawcontext_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..580461252931783ed677016046a9ac731fa94502 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_drawcontext_test.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_drawcontext_test.h" + +#include +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static ArkUI_NodeHandle columnWidth; +static ArkUI_NodeHandle columnHeight; +static void OnEventReceive(ArkUI_NodeCustomEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", "OnEventReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", + "OnEventReceive eventId: %{public}d", eventId); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + + if (eventId == ON_DRAW_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + ArkUI_DrawContext* drawContext = OH_ArkUI_NodeCustomEvent_GetDrawContextInDraw(event); + OH_Drawing_Canvas* canvas = reinterpret_cast(OH_ArkUI_DrawContext_GetCanvas(drawContext)); + auto size = OH_ArkUI_DrawContext_GetSize(drawContext); + ArkUI_NumberValue backgroundColorValue[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem backgroundColorItem = { backgroundColorValue, + sizeof(backgroundColorValue) / sizeof(ArkUI_NumberValue) }; + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", + "Size: width=%{public}d, height=%{public}d", size.width, size.height); + // Context_GetSize 正确改变背景颜色 + if (size.width == 300) { + nodeAPI->setAttribute(columnWidth, NODE_BACKGROUND_COLOR, &backgroundColorItem); + } + if (size.height == 270) { + nodeAPI->setAttribute(columnHeight, NODE_BACKGROUND_COLOR, &backgroundColorItem); + } + // 创建画笔 + OH_Drawing_Pen* pen = OH_Drawing_PenCreate(); + // 通过canvas修改属性 + OH_Drawing_CanvasDrawColor(canvas, COLOR_RED, BLEND_MODE_SCREEN); + OH_Drawing_PenSetAntiAlias(pen, true); + OH_Drawing_PenSetColor(pen, COLOR_BLUE); + OH_Drawing_PenSetWidth(pen, SIZE_30); + OH_Drawing_CanvasAttachPen(canvas, pen); + OH_Drawing_CanvasDrawLine(canvas, SIZE_10, SIZE_10, SIZE_180, SIZE_180); + OH_Drawing_PenDestroy(pen); + pen = nullptr; + } +} + +napi_value CustomComponentDrawContextTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto custom = nodeAPI->createNode(ARKUI_NODE_CUSTOM); + nodeAPI->addChild(column, custom); + + ArkUI_NumberValue sizeValue[] = { { .f32 = 300 }, { .f32 = 270 } }; + ArkUI_AttributeItem sizeItem = { sizeValue, sizeof(sizeValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setLengthMetricUnit(custom, ARKUI_LENGTH_METRIC_UNIT_PX); + nodeAPI->setAttribute(custom, NODE_SIZE, &sizeItem); + + ArkUI_NumberValue backgroundColorValue[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem backgroundColorItem = { backgroundColorValue, + sizeof(backgroundColorValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(custom, NODE_BACKGROUND_COLOR, &backgroundColorItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(custom, NODE_MARGIN, &margin_item); + + columnWidth = nodeAPI->createNode(ARKUI_NODE_COLUMN); + columnHeight = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, columnWidth); + nodeAPI->addChild(column, columnHeight); + ArkUI_NumberValue columnSizeValue[] = { { .f32 = 100 }, { .f32 = 100 } }; + ArkUI_AttributeItem columnSizeItem = { columnSizeValue, sizeof(columnSizeValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(columnWidth, NODE_SIZE, &columnSizeItem); + nodeAPI->setAttribute(columnHeight, NODE_SIZE, &columnSizeItem); + nodeAPI->setAttribute(columnWidth, NODE_BACKGROUND_COLOR, &backgroundColorItem); + nodeAPI->setAttribute(columnHeight, NODE_BACKGROUND_COLOR, &backgroundColorItem); + nodeAPI->setAttribute(columnWidth, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(columnHeight, NODE_MARGIN, &margin_item); + + nodeAPI->addNodeCustomEventReceiver(custom, &OnEventReceive); + nodeAPI->registerNodeCustomEvent(custom, ARKUI_NODE_CUSTOM_EVENT_ON_DRAW, ON_DRAW_EVENT_ID, nullptr); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentDrawContextTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_drawcontext_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_drawcontext_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f9daffc29311af3c6d87afb8c390ed608f59306d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_drawcontext_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_DRAWCONTEXT_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_DRAWCONTEXT_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class CustomComponentDrawContextTest { +public: + ~CustomComponentDrawContextTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_DRAWCONTEXT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getchildat_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getchildat_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..faf796f3f3bba1d93dd2afc1e5f02eb5163e0522 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getchildat_test.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_getchildat_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 120 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_PURPLE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GRAY)); + return nodeHandle; +} + +static auto setNodeColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return nodeHandle; +} + +napi_value CustomComponentGetChildAtTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentAccessibilityDescriptionTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentAccessibilityDescriptionTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto column1 = createColumnNode(nodeAPI); + auto nodeAt0 = nodeAPI->getChildAt(column1, 0); + if (nodeAt0 != nullptr) { + setNodeColor(nodeAPI, nodeAt0, COLOR_GREEN); + } + auto nodeAt2 = nodeAPI->getChildAt(column1, 2); + if (nodeAt2 != nullptr) { + setNodeColor(nodeAPI, nodeAt2, COLOR_GREEN); + } + auto nodeAtNull = nodeAPI->getChildAt(column1, 10); + if (nodeAtNull != nullptr) { + setNodeColor(nodeAPI, nodeAtNull, COLOR_GREEN); + } + auto nodeAtIncorrect = nodeAPI->getChildAt(column1, -1); + if (nodeAtIncorrect != nullptr) { + setNodeColor(nodeAPI, nodeAtIncorrect, COLOR_GREEN); + } + nodeAPI->addChild(parentColumn, column1); + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentAccessibilityDescriptionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getchildat_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getchildat_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7128c6c40cbdb8647f62c38ce79cf77c602f1962 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getchildat_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETCHILDAT_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETCHILDAT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentGetChildAtTest { +public: + ~CustomComponentGetChildAtTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETCHILDAT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getfirstchild_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getfirstchild_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f869afa8c90474dea9092488e6b678d490159be4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getfirstchild_test.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_getfirstchild_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_PURPLE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + return nodeHandle; +} + +static auto createTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* text) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set text content + ArkUI_AttributeItem content_item = {}; + content_item.string = text; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + return nodeHandle; +} + +static auto setNodeColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return nodeHandle; +} + +napi_value CustomComponentGetFirstChildTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetFirstChildTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetFirstChildTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto column1 = createColumnNode(nodeAPI); + auto column2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column3 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column3child = createColumnNode(nodeAPI); + nodeAPI->addChild(column3, column3child); + auto text1 = createTextNode(nodeAPI, "Text"); + auto nodeFirst1 = nodeAPI->getFirstChild(column1); + if (nodeFirst1 != nullptr) { + setNodeColor(nodeAPI, nodeFirst1, COLOR_GREEN); + } + auto nodeFirst2 = nodeAPI->getFirstChild(column2); + if (nodeFirst2 != nullptr) { + setNodeColor(nodeAPI, nodeFirst2, COLOR_GREEN); + } + auto nodeFirst3 = nodeAPI->getFirstChild(column3); + if (nodeFirst3 != nullptr) { + setNodeColor(nodeAPI, nodeFirst3, COLOR_GREEN); + } + auto nodeFirst4 = nodeAPI->getFirstChild(text1); + if (nodeFirst4 != nullptr) { + setNodeColor(nodeAPI, nodeFirst4, COLOR_GREEN); + } else { + setNodeColor(nodeAPI, text1, COLOR_GREEN); + } + nodeAPI->addChild(parentColumn, column1); + nodeAPI->addChild(parentColumn, column2); + nodeAPI->addChild(parentColumn, column3); + nodeAPI->addChild(parentColumn, text1); + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetFirstChildTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getfirstchild_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getfirstchild_test.h new file mode 100644 index 0000000000000000000000000000000000000000..386bca95f3d18a834c300e7b1150dcc94a32eeeb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getfirstchild_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETFIRSTCHILD_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETFIRSTCHILD_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentGetFirstChildTest { +public: + ~CustomComponentGetFirstChildTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETFIRSTCHILD_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getlastchild_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getlastchild_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..896e0746de9aeffd33d9f2ea71db6df636e93a01 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getlastchild_test.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_getlastchild_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_PURPLE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + return nodeHandle; +} + +static auto createTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* text) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set text content + ArkUI_AttributeItem content_item = {}; + content_item.string = text; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + return nodeHandle; +} + +static auto setNodeColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return nodeHandle; +} + +napi_value CustomComponentGetLastChildTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetLastChildTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetLastChildTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto column1 = createColumnNode(nodeAPI); + auto column2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column3 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column3child = createColumnNode(nodeAPI); + nodeAPI->addChild(column3, column3child); + auto text1 = createTextNode(nodeAPI, "Text"); + auto nodeLast1 = nodeAPI->getLastChild(column1); + if (nodeLast1 != nullptr) { + setNodeColor(nodeAPI, nodeLast1, COLOR_GREEN); + } + auto nodeLast2 = nodeAPI->getLastChild(column2); + if (nodeLast2 != nullptr) { + setNodeColor(nodeAPI, nodeLast2, COLOR_GREEN); + } + auto nodeLast3 = nodeAPI->getLastChild(column3); + if (nodeLast3 != nullptr) { + setNodeColor(nodeAPI, nodeLast3, COLOR_GREEN); + } + auto nodeLast4 = nodeAPI->getLastChild(text1); + if (nodeLast4 != nullptr) { + setNodeColor(nodeAPI, nodeLast4, COLOR_GREEN); + } else { + setNodeColor(nodeAPI, text1, COLOR_GREEN); + } + nodeAPI->addChild(parentColumn, column1); + nodeAPI->addChild(parentColumn, column2); + nodeAPI->addChild(parentColumn, column3); + nodeAPI->addChild(parentColumn, text1); + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetLastChildTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getlastchild_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getlastchild_test.h new file mode 100644 index 0000000000000000000000000000000000000000..cdcaa8d0db4f5bae835159eb618e6172749ee0a4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getlastchild_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETLASTCHILD_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETLASTCHILD_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentGetLastChildTest { +public: + ~CustomComponentGetLastChildTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETLASTCHILD_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getperviousnextsibling_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getperviousnextsibling_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5bde7e3d33c4bbdff9efaf1479c1b7e0cc22f3ad --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getperviousnextsibling_test.cpp @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "../manager/plugin_manager.h" +#include "customcomponent_getpreviousnetsibling_test.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 120 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 280 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_PURPLE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GRAY)); + return nodeHandle; +} + +static auto createEmptyColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 280 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setNodeColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return nodeHandle; +} + +napi_value CustomComponentGetPreviousNextSiblingTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetPreviousNextSiblingTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetPreviousNextSiblingTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto column1 = createColumnNode(nodeAPI); + auto column2 = createEmptyColumnNode(nodeAPI); + auto column3 = createEmptyColumnNode(nodeAPI); + auto column4 = createEmptyColumnNode(nodeAPI); + auto column5 = createEmptyColumnNode(nodeAPI); + auto column6 = createEmptyColumnNode(nodeAPI); + auto column7 = createEmptyColumnNode(nodeAPI); + auto column5Child = createColumnNode(nodeAPI); + auto column6Child = createColumnNode(nodeAPI); + auto column7Child = createColumnNode(nodeAPI); + setNodeColor(nodeAPI, column5Child, COLOR_TRANSPARENT); + setNodeColor(nodeAPI, column6Child, COLOR_TRANSPARENT); + setNodeColor(nodeAPI, column7Child, COLOR_TRANSPARENT); + nodeAPI->addChild(column5, column5Child); + nodeAPI->addChild(column6, column6Child); + nodeAPI->addChild(column7, column7Child); + + nodeAPI->addChild(parentColumn, column1); + nodeAPI->addChild(parentColumn, column2); + nodeAPI->addChild(parentColumn, column3); + nodeAPI->addChild(parentColumn, column4); + nodeAPI->addChild(parentColumn, column5); + nodeAPI->addChild(parentColumn, column6); + nodeAPI->addChild(parentColumn, column7); + + auto node1 = nodeAPI->getChildAt(column1, 1); + if (node1 != nullptr) { + auto nodePre = nodeAPI->getPreviousSibling(node1); + if (nodePre != nullptr) { + setNodeColor(nodeAPI, nodePre, COLOR_GREEN); + } + auto nodeNext = nodeAPI->getNextSibling(node1); + if (nodeNext != nullptr) { + setNodeColor(nodeAPI, nodeNext, COLOR_GREEN); + } + } + auto node2 = nodeAPI->getChildAt(column1, 0); + if (node2 != nullptr) { + auto nodePre = nodeAPI->getPreviousSibling(node2); + if (nodePre != nullptr) { + setNodeColor(nodeAPI, nodePre, COLOR_GREEN); + } + } + auto node3 = nodeAPI->getLastChild(column1); + if (node3 != nullptr) { + auto nodeNext = nodeAPI->getNextSibling(node3); + if (nodeNext != nullptr) { + setNodeColor(nodeAPI, nodeNext, COLOR_GREEN); + } + } + if (column3 != nullptr) { + auto nodePre = nodeAPI->getPreviousSibling(column3); + if (nodePre != nullptr) { + setNodeColor(nodeAPI, nodePre, COLOR_GREEN); + } + auto nodeNext = nodeAPI->getNextSibling(column3); + if (nodeNext != nullptr) { + setNodeColor(nodeAPI, nodeNext, COLOR_GREEN); + } + } + if (column6 != nullptr) { + auto nodePre = nodeAPI->getPreviousSibling(column6); + if (nodePre != nullptr) { + setNodeColor(nodeAPI, nodePre, COLOR_GREEN); + } + auto nodeNext = nodeAPI->getNextSibling(column6); + if (nodeNext != nullptr) { + setNodeColor(nodeAPI, nodeNext, COLOR_GREEN); + } + } + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetPreviousNextSiblingTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getpreviousnetsibling_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getpreviousnetsibling_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3a337c6a1fe4ff95ee33f8197b8ef136a46b5b07 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_getpreviousnetsibling_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETPREVIOUSNEXTSIBLING_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETPREVIOUSNEXTSIBLING_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentGetPreviousNextSiblingTest { +public: + ~CustomComponentGetPreviousNextSiblingTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETPREVIOUSNEXTSIBLING_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_gettotalchildcount_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_gettotalchildcount_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7e7f6af735938ddb8fbb11c44395349c25f7ed62 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_gettotalchildcount_test.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_gettotalchildcount_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 120 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + return nodeHandle; +} +static auto createTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* text) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set text content + ArkUI_AttributeItem content_item = {}; + content_item.string = text; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + return nodeHandle; +} +static auto setTextNodeContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, const char* text) +{ + // set text content + ArkUI_AttributeItem content_item = {}; + content_item.string = text; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + return nodeHandle; +} +static auto setTextNodeColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return nodeHandle; +} + +napi_value CustomComponentGetTotalChildCountTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetTotalChildCoutTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetTotalChildCoutTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto column1 = createColumnNode(nodeAPI); + auto column2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textCout1 = createTextNode(nodeAPI, "getTotalChildCount has child count"); + auto textCout2 = createTextNode(nodeAPI, "getTotalChildCount has no child at column count"); + auto textCout3 = createTextNode(nodeAPI, "getTotalChildCount at text count"); + nodeAPI->addChild(parentColumn, column1); + nodeAPI->addChild(parentColumn, column2); + nodeAPI->addChild(parentColumn, textCout1); + nodeAPI->addChild(parentColumn, textCout2); + nodeAPI->addChild(parentColumn, textCout3); + + int32_t nodeCount1 = nodeAPI->getTotalChildCount(column1); + int32_t nodeCount2 = nodeAPI->getTotalChildCount(column2); + int32_t nodeCount3 = nodeAPI->getTotalChildCount(textCout1); + if (nodeCount1 == 3) { + setTextNodeColor(nodeAPI, textCout1, COLOR_GREEN); + } else { + setTextNodeColor(nodeAPI, textCout1, COLOR_RED); + setTextNodeContent(nodeAPI, textCout1, + ("getTotalChildCount has child count. Child count: " + std::to_string(nodeCount1)).c_str()); + } + if (nodeCount2 == 0) { + setTextNodeColor(nodeAPI, textCout2, COLOR_GREEN); + } else { + setTextNodeColor(nodeAPI, textCout2, COLOR_RED); + setTextNodeContent(nodeAPI, textCout2, + ("getTotalChildCount has no child at column count. Child count: " + std::to_string(nodeCount2)).c_str()); + } + if (nodeCount3 == 0) { + setTextNodeColor(nodeAPI, textCout3, COLOR_GREEN); + } else { + setTextNodeColor(nodeAPI, textCout3, COLOR_RED); + setTextNodeContent(nodeAPI, textCout3, + ("getTotalChildCount at text count. Child count: " + std::to_string(nodeCount3)).c_str()); + } + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentGetTotalChildCoutTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_gettotalchildcount_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_gettotalchildcount_test.h new file mode 100644 index 0000000000000000000000000000000000000000..4a4e722dbf13428267ce6f7e0290c377338a0cfd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_gettotalchildcount_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETTOTALCHILDCOUT_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETTOTALCHILDCOUT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentGetTotalChildCountTest { +public: + ~CustomComponentGetTotalChildCountTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_GETTOTALCHILDCOUT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutagain_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutagain_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ae3c8c64f13fdce14f5be2209c0dba9bb1c6ebdd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutagain_test.cpp @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_layoutagain_test.h" + +#include + +#include "../component/column_component.h" +#include "../component/component.h" +#include "../component/custom_component.h" +#include "../component/row_component.h" +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static ArkUI_IntSize size1_1 = { 0, 0 }; +static ArkUI_IntSize size1_2 = { 0, 0 }; +static ArkUI_IntSize size2_1 = { 0, 0 }; +static ArkUI_IntSize size2_2 = { 0, 0 }; +static ArkUI_IntSize size3_1 = { 0, 0 }; +static ArkUI_IntSize size3_2 = { 0, 0 }; +static ArkUI_IntSize size4_1 = { 0, 0 }; +static ArkUI_IntSize size4_2 = { 0, 0 }; +static void OnMeasureReceive(ArkUI_NodeCustomEvent* event) +{ + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", "OnMeasureReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", + "OnMeasureReceive eventId: %{public}d", eventId); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + if (eventId == ON_CUSTOM_EVENT_2_ID) { + // 获取约束条件 + auto layoutConstraintMaxWith = 250; + auto layoutConstraintMinWith = 40; + auto layoutConstraintMaxHeight = 200; + auto layoutConstraintMinHeight = 30; + auto resultWidth = nodeAPI->getAttribute(nodeHandler, NODE_WIDTH); + if (resultWidth == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", + "Failed to get NODE_WIDTH attribute"); + return; + } + float nodeWidth = resultWidth->value[0].f32; + auto resultHeight = nodeAPI->getAttribute(nodeHandler, NODE_HEIGHT); + if (resultHeight == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", + "Failed to get NODE_HEIGHT attribute"); + return; + } + float nodeHeight = resultHeight->value[0].f32; + if (nodeWidth > layoutConstraintMaxWith) { + nodeWidth = layoutConstraintMaxWith; + } else if (nodeWidth < layoutConstraintMinWith) { + nodeWidth = layoutConstraintMinWith; + } + if (nodeHeight > layoutConstraintMaxHeight) { + nodeHeight = layoutConstraintMaxHeight; + } else if (nodeHeight < layoutConstraintMinHeight) { + nodeHeight = layoutConstraintMinHeight; + } + nodeAPI->setMeasuredSize(nodeHandler, nodeWidth, nodeHeight); + return; + } +} + +static void OnLayoutReceive(ArkUI_NodeCustomEvent* event) +{ + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", "OnLayoutReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", + "OnLayoutReceive eventId: %{public}d", eventId); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + if (eventId == ON_LAYOUT_EVENT_ID) { + // 获取测算大小,将测算大小设置为布局大小 + auto size = nodeAPI->getMeasuredSize(nodeHandler); + ArkUI_NumberValue with[] = { { .f32 = (float)size.width } }; + ArkUI_AttributeItem withItem = { with, 1 }; + ArkUI_NumberValue height[] = { { .f32 = (float)size.height } }; + ArkUI_AttributeItem heightItem = { height, 1 }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &withItem); + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &heightItem); + // 触发子节点的布局 + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + nodeAPI->layoutNode(child, 0, 0); + } + return; + } +} +static auto addTestNodes(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentColumn) +{ + // 创建4个Row组件,分别测试4种情况 + auto row1 = std::make_shared(); + nodeAPI->addChild(parentColumn, row1->GetComponent()); + row1->SetPercentWidth(0.8); + row1->SetPercentHeight(0.44); + row1->SetBackgroundColor(COLOR_GRAY); + row1->SetMargin(5); + auto row2 = std::make_shared(); + nodeAPI->addChild(parentColumn, row2->GetComponent()); + row2->SetPercentWidth(0.8); + row2->SetPercentHeight(0.44); + row2->SetBackgroundColor(COLOR_GRAY); + row2->SetMargin(5); + + // case 1 + auto custom1_1 = std::make_shared(); + custom1_1->SetBackgroundColor(COLOR_RED); + custom1_1->SetWidth(250); + custom1_1->SetHeight(200); + nodeAPI->addChild(row1->GetComponent(), custom1_1->GetComponent()); + // custom1_3、custom1_4 是 custom1_1 的孩子 + auto custom1_3 = std::make_shared(); + custom1_3->SetBackgroundColor(COLOR_BLUE); + custom1_3->SetWidth(300); + custom1_3->SetHeight(15); + nodeAPI->addChild(custom1_1->GetComponent(), custom1_3->GetComponent()); + auto custom1_4 = std::make_shared(); + custom1_4->SetBackgroundColor(COLOR_GREEN); + custom1_4->SetWidth(10); + custom1_4->SetHeight(500); + nodeAPI->addChild(custom1_1->GetComponent(), custom1_4->GetComponent()); + + // 在测算回调中与约束条件比较,计较结果作为测算大小,然后在布局回调中根据测试大小设置布局大小 + nodeAPI->addNodeCustomEventReceiver(custom1_3->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom1_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_2_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom1_3->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom1_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom1_4->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom1_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_2_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom1_4->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom1_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + // case 2 + auto custom2_1 = std::make_shared(); + custom2_1->SetBackgroundColor(COLOR_RED); + custom2_1->SetWidth(250); + custom2_1->SetHeight(200); + nodeAPI->addChild(row2->GetComponent(), custom2_1->GetComponent()); + auto custom2_3 = std::make_shared(); + custom2_3->SetBackgroundColor(COLOR_BLUE); + custom2_3->SetWidth(300); + custom2_3->SetHeight(15); + nodeAPI->addChild(custom2_1->GetComponent(), custom2_3->GetComponent()); + auto custom2_4 = std::make_shared(); + custom2_4->SetBackgroundColor(COLOR_GREEN); + custom2_4->SetWidth(10); + custom2_4->SetHeight(500); + nodeAPI->addChild(custom2_1->GetComponent(), custom2_4->GetComponent()); + + nodeAPI->addNodeCustomEventReceiver(custom2_3->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom2_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_2_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom2_3->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom2_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom2_4->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom2_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_2_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom2_4->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom2_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + custom2_3->SetWidth(80); + custom2_3->SetHeight(200); + + custom2_4->SetWidth(200); + custom2_4->SetHeight(80); +} + +napi_value CustomComponentLayoutAgainTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + addTestNodes(nodeAPI, parentColumn); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutAgainTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutagain_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutagain_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a3f077718209275872eadd587485adfb1185289d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutagain_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_CUSTOMCOMPONENT_LAYOUTAGAIN_TEST_H +#define CAPIDEMO_CUSTOMCOMPONENT_LAYOUTAGAIN_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class CustomComponentLayoutAgainTest { +public: + ~CustomComponentLayoutAgainTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_CUSTOMCOMPONENT_LAYOUTAGAIN_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutconstraint_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutconstraint_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..78ce09c5ade1be75e75eb74ad5dfefa2ae5d0ad0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutconstraint_test.cpp @@ -0,0 +1,591 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_layoutconstraint_test.h" + +#include + +#include "../component/column_component.h" +#include "../component/component.h" +#include "../component/custom_component.h" +#include "../component/row_component.h" +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static ArkUI_IntSize size1_1 = { 0, 0 }; +static ArkUI_IntSize size1_2 = { 0, 0 }; +static ArkUI_IntSize size2_1 = { 0, 0 }; +static ArkUI_IntSize size2_2 = { 0, 0 }; +static ArkUI_IntSize size3_1 = { 0, 0 }; +static ArkUI_IntSize size3_2 = { 0, 0 }; +static ArkUI_IntSize size4_1 = { 0, 0 }; +static ArkUI_IntSize size4_2 = { 0, 0 }; +static void OnMeasureReceive(ArkUI_NodeCustomEvent* event) +{ + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", + "OnMeasureReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", + "OnMeasureReceive eventId: %{public}d", eventId); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + if (eventId == ON_CUSTOM_EVENT_1_ID) { + // 红色的custom回调 + // 自定义一个约束条件,将约束条件设置给子节点 + auto layoutConstraint = OH_ArkUI_LayoutConstraint_Create(); + OH_ArkUI_LayoutConstraint_SetMaxWidth(layoutConstraint, 220); + OH_ArkUI_LayoutConstraint_SetMinWidth(layoutConstraint, 40); + OH_ArkUI_LayoutConstraint_SetMaxHeight(layoutConstraint, 250); + OH_ArkUI_LayoutConstraint_SetMinHeight(layoutConstraint, 30); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(layoutConstraint, 500); + OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight(layoutConstraint, 130); + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, layoutConstraint); + } + nodeAPI->setMeasuredSize(nodeHandler, 220, 250); + return; + } else if (eventId == ON_CUSTOM_EVENT_2_ID) { + // 红色的custom回调 + // 自定义一个约束条件,将约束条件设置给子节点 + auto layoutConstraint = OH_ArkUI_LayoutConstraint_Create(); + OH_ArkUI_LayoutConstraint_SetMaxWidth(layoutConstraint, -40); + OH_ArkUI_LayoutConstraint_SetMinWidth(layoutConstraint, -220); + OH_ArkUI_LayoutConstraint_SetMaxHeight(layoutConstraint, -150); + OH_ArkUI_LayoutConstraint_SetMinHeight(layoutConstraint, -30); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(layoutConstraint, -500); + OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight(layoutConstraint, -130); + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, layoutConstraint); + } + nodeAPI->setMeasuredSize(nodeHandler, 220, 250); + return; + } else if (eventId == ON_CUSTOM_EVENT_3_ID) { + // 红色的custom回调 + // 自定义一个约束条件,将约束条件设置给子节点 + auto layoutConstraint = OH_ArkUI_LayoutConstraint_Create(); + OH_ArkUI_LayoutConstraint_SetMaxWidth(layoutConstraint, 0); + OH_ArkUI_LayoutConstraint_SetMinWidth(layoutConstraint, 0); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(layoutConstraint, 0); + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, layoutConstraint); + } + nodeAPI->setMeasuredSize(nodeHandler, 220, 250); + return; + } else if (eventId == ON_CUSTOM_EVENT_4_ID) { + // 红色的custom回调 + // 自定义一个约束条件,将约束条件设置给子节点 + auto layoutConstraint = OH_ArkUI_LayoutConstraint_Create(); + OH_ArkUI_LayoutConstraint_SetMaxWidth(layoutConstraint, 10); + OH_ArkUI_LayoutConstraint_SetMinWidth(layoutConstraint, 10); + OH_ArkUI_LayoutConstraint_SetMaxHeight(layoutConstraint, 10); + OH_ArkUI_LayoutConstraint_SetMinHeight(layoutConstraint, 10); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(layoutConstraint, 500); + OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight(layoutConstraint, 130); + OH_ArkUI_LayoutConstraint_Dispose(layoutConstraint); + layoutConstraint = nullptr; + if (!layoutConstraint) { + layoutConstraint = OH_ArkUI_LayoutConstraint_Create(); + OH_ArkUI_LayoutConstraint_SetMaxWidth(layoutConstraint, 220); + OH_ArkUI_LayoutConstraint_SetMinWidth(layoutConstraint, 40); + OH_ArkUI_LayoutConstraint_SetMaxHeight(layoutConstraint, 250); + OH_ArkUI_LayoutConstraint_SetMinHeight(layoutConstraint, 30); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(layoutConstraint, 500); + OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight(layoutConstraint, 130); + } + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, layoutConstraint); + } + nodeAPI->setMeasuredSize(nodeHandler, 220, 250); + return; + } else if (eventId == ON_CUSTOM_EVENT_11_ID) { + // 黄色的custom回调 + // 获取约束条件,根据约束条件设置子节点的测算大小 + auto layoutConstraint = OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(event); + auto childLayoutConstraint = OH_ArkUI_LayoutConstraint_Copy(layoutConstraint); + auto layoutConstraintMaxWith = OH_ArkUI_LayoutConstraint_GetMaxWidth(layoutConstraint) - 10; + auto layoutConstraintMaxHeight = OH_ArkUI_LayoutConstraint_GetMaxHeight(layoutConstraint) - 10; + OH_ArkUI_LayoutConstraint_SetMaxWidth(childLayoutConstraint, layoutConstraintMaxWith); + OH_ArkUI_LayoutConstraint_SetMaxHeight(childLayoutConstraint, layoutConstraintMaxHeight); + // 测算子节点获取子节点最大值。 + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + int32_t maxWidth = 0; + int32_t maxHeight = 0; + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, childLayoutConstraint); + auto size = nodeAPI->getMeasuredSize(child); + if (size.width > maxWidth) { + maxWidth = size.width; + } + if (size.height > maxHeight) { + maxHeight = size.height; + } + } + // 设置测算大小 + nodeAPI->setMeasuredSize(nodeHandler, maxWidth, maxHeight); + return; + } else if (eventId == ON_CUSTOM_EVENT_12_ID) { + // 黄色的custom回调 + // 获取约束条件,根据约束条件设置子节点的测算大小 + auto layoutConstraint = OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(event); + auto childLayoutConstraint = OH_ArkUI_LayoutConstraint_Copy(layoutConstraint); + auto layoutConstraintMaxWith = OH_ArkUI_LayoutConstraint_GetMaxWidth(layoutConstraint); + auto layoutConstraintMaxHeight = OH_ArkUI_LayoutConstraint_GetMaxHeight(layoutConstraint); + auto layoutConstraintMinWith = OH_ArkUI_LayoutConstraint_GetMinWidth(layoutConstraint); + auto layoutConstraintMinHeight = OH_ArkUI_LayoutConstraint_GetMinHeight(layoutConstraint); + auto layoutConstraintPercentReferenceWidth = + OH_ArkUI_LayoutConstraint_GetPercentReferenceWidth(layoutConstraint); + auto layoutConstraintPercentReferenceHeight = + OH_ArkUI_LayoutConstraint_GetPercentReferenceHeight(layoutConstraint); + if (layoutConstraintMaxWith == -40) { + layoutConstraintMaxWith = 100; + } + if (layoutConstraintMaxHeight == -150) { + layoutConstraintMaxHeight = 50; + } + if (layoutConstraintMinWith == -220) { + layoutConstraintMinWith = 20; + } + if (layoutConstraintMinHeight == -30) { + layoutConstraintMinHeight = 30; + } + if (layoutConstraintPercentReferenceWidth == -500) { + layoutConstraintPercentReferenceWidth = 500; + } + if (layoutConstraintPercentReferenceHeight == -130) { + layoutConstraintPercentReferenceHeight = 130; + } + OH_ArkUI_LayoutConstraint_SetMaxWidth(childLayoutConstraint, layoutConstraintMaxWith); + OH_ArkUI_LayoutConstraint_SetMaxHeight(childLayoutConstraint, layoutConstraintMaxHeight); + OH_ArkUI_LayoutConstraint_SetMinWidth(childLayoutConstraint, layoutConstraintMinWith); + OH_ArkUI_LayoutConstraint_SetMinHeight(childLayoutConstraint, layoutConstraintMinHeight); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth( + childLayoutConstraint, layoutConstraintPercentReferenceWidth); + OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight( + childLayoutConstraint, layoutConstraintPercentReferenceHeight); + // 测算子节点获取子节点最大值。 + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + int32_t maxWidth = 0; + int32_t maxHeight = 0; + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, childLayoutConstraint); + auto size = nodeAPI->getMeasuredSize(child); + if (size.width > maxWidth) { + maxWidth = size.width; + } + if (size.height > maxHeight) { + maxHeight = size.height; + } + } + // 设置测算大小 + nodeAPI->setMeasuredSize(nodeHandler, maxWidth, maxHeight); + return; + } else if (eventId == ON_CUSTOM_EVENT_13_ID) { + // 黄色的custom回调 + // 获取约束条件,根据约束条件设置子节点的测算大小 + auto layoutConstraint = OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(event); + auto childLayoutConstraint = OH_ArkUI_LayoutConstraint_Copy(layoutConstraint); + auto layoutConstraintMaxWith = OH_ArkUI_LayoutConstraint_GetMaxWidth(layoutConstraint); + auto layoutConstraintMaxHeight = OH_ArkUI_LayoutConstraint_GetMaxHeight(layoutConstraint); + auto layoutConstraintMinWith = OH_ArkUI_LayoutConstraint_GetMinWidth(layoutConstraint); + auto layoutConstraintMinHeight = OH_ArkUI_LayoutConstraint_GetMinHeight(layoutConstraint); + auto layoutConstraintPercentReferenceWidth = + OH_ArkUI_LayoutConstraint_GetPercentReferenceWidth(layoutConstraint); + auto layoutConstraintPercentReferenceHeight = + OH_ArkUI_LayoutConstraint_GetPercentReferenceHeight(layoutConstraint); + if (layoutConstraintMaxWith == 0) { + layoutConstraintMaxWith = 50; + } + if (layoutConstraintMaxHeight == 0) { + layoutConstraintMaxHeight = 60; + } + if (layoutConstraintMinWith == 0) { + layoutConstraintMinWith = 10; + } + if (layoutConstraintMinHeight == 0) { + layoutConstraintMinHeight = 20; + } + if (layoutConstraintPercentReferenceWidth == 0) { + layoutConstraintPercentReferenceWidth = 200; + } + if (layoutConstraintPercentReferenceHeight == 0) { + layoutConstraintPercentReferenceHeight = 100; + } + OH_ArkUI_LayoutConstraint_SetMaxWidth(childLayoutConstraint, layoutConstraintMaxWith); + OH_ArkUI_LayoutConstraint_SetMaxHeight(childLayoutConstraint, layoutConstraintMaxHeight); + OH_ArkUI_LayoutConstraint_SetMinWidth(childLayoutConstraint, layoutConstraintMinWith); + OH_ArkUI_LayoutConstraint_SetMinHeight(childLayoutConstraint, layoutConstraintMinHeight); + OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth( + childLayoutConstraint, layoutConstraintPercentReferenceWidth); + OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight( + childLayoutConstraint, layoutConstraintPercentReferenceHeight); + // 测算子节点获取子节点最大值。 + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + int32_t maxWidth = 0; + int32_t maxHeight = 0; + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 调用测算接口测算Native组件。 + nodeAPI->measureNode(child, childLayoutConstraint); + auto size = nodeAPI->getMeasuredSize(child); + if (size.width > maxWidth) { + maxWidth = size.width; + } + if (size.height > maxHeight) { + maxHeight = size.height; + } + } + // 设置测算大小 + nodeAPI->setMeasuredSize(nodeHandler, maxWidth, maxHeight); + return; + } else if (eventId == ON_CUSTOM_EVENT_6_ID) { + // 获取约束条件 + auto layoutConstraint = OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(event); + auto layoutConstraintMaxWith = OH_ArkUI_LayoutConstraint_GetMaxWidth(layoutConstraint); + auto layoutConstraintMinWith = OH_ArkUI_LayoutConstraint_GetMinWidth(layoutConstraint); + auto layoutConstraintMaxHeight = OH_ArkUI_LayoutConstraint_GetMaxHeight(layoutConstraint); + auto layoutConstraintMinHeight = OH_ArkUI_LayoutConstraint_GetMinHeight(layoutConstraint); + auto layoutConstraintPercentReferenceWidth = + OH_ArkUI_LayoutConstraint_GetPercentReferenceWidth(layoutConstraint); + auto layoutConstraintPercentReferenceHeight = + OH_ArkUI_LayoutConstraint_GetPercentReferenceHeight(layoutConstraint); + // 通过用户传入的大小与约束条件进行比较,设置测算大小 + auto dataIntTemp = OH_ArkUI_NodeCustomEvent_GetUserData(event); + ArkUI_IntSize size = *static_cast(dataIntTemp); + if (size.width > layoutConstraintMaxWith || size.width > layoutConstraintPercentReferenceWidth * 0.9) { + size.width = layoutConstraintMaxWith; + } else if (size.width < layoutConstraintMinWith) { + size.width = layoutConstraintMinWith; + } + if (size.height > layoutConstraintMaxHeight || size.height > layoutConstraintPercentReferenceHeight * 0.9) { + size.height = layoutConstraintMaxHeight; + } else if (size.height < layoutConstraintMinHeight) { + size.height = layoutConstraintMinHeight; + } + nodeAPI->setMeasuredSize(nodeHandler, size.width, size.height); + return; + } +} + +static void OnLayoutReceive(ArkUI_NodeCustomEvent* event) +{ + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", + "OnLayoutReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", + "OnLayoutReceive eventId: %{public}d", eventId); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + if (eventId == ON_LAYOUT_EVENT_ID) { + // 获取测算大小,将测算大小设置为布局大小 + auto size = nodeAPI->getMeasuredSize(nodeHandler); + ArkUI_NumberValue with[] = { { .f32 = (float)size.width } }; + ArkUI_AttributeItem withItem = { with, 1 }; + ArkUI_NumberValue height[] = { { .f32 = (float)size.height } }; + ArkUI_AttributeItem heightItem = { height, 1 }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &withItem); + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &heightItem); + // 触发子节点的布局 + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + nodeAPI->layoutNode(child, 0, 0); + } + return; + } +} +static auto addTestNodes(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentColumn) +{ + // 创建4个Row组件,分别测试4种情况 + auto row1 = std::make_shared(); + nodeAPI->addChild(parentColumn, row1->GetComponent()); + row1->SetPercentWidth(0.8); + row1->SetPercentHeight(0.24); + row1->SetBackgroundColor(COLOR_GRAY); + row1->SetMargin(5); + auto row2 = std::make_shared(); + nodeAPI->addChild(parentColumn, row2->GetComponent()); + row2->SetPercentWidth(0.8); + row2->SetPercentHeight(0.24); + row2->SetBackgroundColor(COLOR_GRAY); + row2->SetMargin(5); + auto row3 = std::make_shared(); + nodeAPI->addChild(parentColumn, row3->GetComponent()); + row3->SetPercentWidth(0.8); + row3->SetPercentHeight(0.24); + row3->SetBackgroundColor(COLOR_GRAY); + row3->SetMargin(5); + auto row4 = std::make_shared(); + nodeAPI->addChild(parentColumn, row4->GetComponent()); + row4->SetPercentWidth(0.8); + row4->SetPercentHeight(0.24); + row4->SetBackgroundColor(COLOR_GRAY); + row4->SetMargin(5); + + // case 1 + auto custom1_1 = std::make_shared(); + custom1_1->SetBackgroundColor(COLOR_RED); + custom1_1->SetWidth(200); + custom1_1->SetHeight(200); + nodeAPI->addChild(row1->GetComponent(), custom1_1->GetComponent()); + // custom1_2 是 custom1_1 的孩子 + auto custom1_2 = std::make_shared(); + custom1_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(custom1_1->GetComponent(), custom1_2->GetComponent()); + // custom1_3、custom1_4 是 custom1_2 的孩子 + auto custom1_3 = std::make_shared(); + custom1_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom1_2->GetComponent(), custom1_3->GetComponent()); + auto custom1_4 = std::make_shared(); + custom1_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom1_2->GetComponent(), custom1_4->GetComponent()); + // 注册事件,在测算事件中添加约束条件 + nodeAPI->addNodeCustomEventReceiver(custom1_1->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom1_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_1_ID, nullptr); + // 注册事件,在布局事件中根据测试大小修改布局大小 + nodeAPI->addNodeCustomEventReceiver(custom1_1->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom1_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + nodeAPI->addNodeCustomEventReceiver(custom1_2->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom1_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_11_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom1_2->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom1_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + // 指定大小,在测算回调中与约束条件比较,计较结果作为测算大小,然后在布局回调中根据测试大小设置布局大小 + size1_1 = { 5, 380 }; + nodeAPI->addNodeCustomEventReceiver(custom1_3->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom1_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size1_1); + nodeAPI->addNodeCustomEventReceiver(custom1_3->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom1_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + size1_2 = { 300, 10 }; + nodeAPI->addNodeCustomEventReceiver(custom1_4->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom1_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size1_2); + nodeAPI->addNodeCustomEventReceiver(custom1_4->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom1_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + // case 2 + auto custom2_1 = std::make_shared(); + custom2_1->SetBackgroundColor(COLOR_RED); + custom2_1->SetWidth(200); + custom2_1->SetHeight(200); + nodeAPI->addChild(row2->GetComponent(), custom2_1->GetComponent()); + // custom2_2 是 custom2_1 的孩子 + auto custom2_2 = std::make_shared(); + custom2_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(custom2_1->GetComponent(), custom2_2->GetComponent()); + // custom2_3、custom2_4 是 custom2_2 的孩子 + auto custom2_3 = std::make_shared(); + custom2_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom2_2->GetComponent(), custom2_3->GetComponent()); + auto custom2_4 = std::make_shared(); + custom2_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom2_2->GetComponent(), custom2_4->GetComponent()); + // 注册事件,在测算事件中添加约束条件 + nodeAPI->addNodeCustomEventReceiver(custom2_1->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom2_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_2_ID, nullptr); + // 注册事件,在布局事件中根据测试大小修改布局大小 + nodeAPI->addNodeCustomEventReceiver(custom2_1->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom2_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + nodeAPI->addNodeCustomEventReceiver(custom2_2->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom2_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_12_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom2_2->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom2_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + // 指定大小,在测算回调中与约束条件比较,计较结果作为测算大小,然后在布局回调中根据测试大小设置布局大小 + size2_1 = { 10, 280 }; + nodeAPI->addNodeCustomEventReceiver(custom2_3->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom2_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size2_1); + nodeAPI->addNodeCustomEventReceiver(custom2_3->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom2_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + size2_2 = { 300, 5 }; + nodeAPI->addNodeCustomEventReceiver(custom2_4->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom2_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size2_2); + nodeAPI->addNodeCustomEventReceiver(custom2_4->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom2_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + // case 3 + auto custom3_1 = std::make_shared(); + custom3_1->SetBackgroundColor(COLOR_RED); + custom3_1->SetWidth(200); + custom3_1->SetHeight(200); + nodeAPI->addChild(row3->GetComponent(), custom3_1->GetComponent()); + // custom3_2 是 custom3_1 的孩子 + auto custom3_2 = std::make_shared(); + custom3_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(custom3_1->GetComponent(), custom3_2->GetComponent()); + // custom3_3、custom3_4 是 custom3_2 的孩子 + auto custom3_3 = std::make_shared(); + custom3_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom3_2->GetComponent(), custom3_3->GetComponent()); + auto custom3_4 = std::make_shared(); + custom3_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom3_2->GetComponent(), custom3_4->GetComponent()); + // 注册事件,在测算事件中添加约束条件 + nodeAPI->addNodeCustomEventReceiver(custom3_1->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom3_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_3_ID, nullptr); + // 注册事件,在布局事件中根据测试大小修改布局大小 + nodeAPI->addNodeCustomEventReceiver(custom3_1->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom3_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + nodeAPI->addNodeCustomEventReceiver(custom3_2->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom3_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_13_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom3_2->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom3_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + // 指定大小,在测算回调中与约束条件比较,计较结果作为测算大小,然后在布局回调中根据测试大小设置布局大小 + size3_1 = { 5, 280 }; + nodeAPI->addNodeCustomEventReceiver(custom3_3->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom3_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size3_1); + nodeAPI->addNodeCustomEventReceiver(custom3_3->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom3_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + size3_2 = { 300, 10 }; + nodeAPI->addNodeCustomEventReceiver(custom3_4->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom3_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size3_2); + nodeAPI->addNodeCustomEventReceiver(custom3_4->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom3_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + // case 4 + auto custom4_1 = std::make_shared(); + custom4_1->SetBackgroundColor(COLOR_RED); + custom4_1->SetWidth(200); + custom4_1->SetHeight(200); + nodeAPI->addChild(row4->GetComponent(), custom4_1->GetComponent()); + // custom4_2 是 custom4_1 的孩子 + auto custom4_2 = std::make_shared(); + custom4_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(custom4_1->GetComponent(), custom4_2->GetComponent()); + // custom4_3、custom4_4 是 custom4_2 的孩子 + auto custom4_3 = std::make_shared(); + custom4_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom4_2->GetComponent(), custom4_3->GetComponent()); + auto custom4_4 = std::make_shared(); + custom4_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom4_2->GetComponent(), custom4_4->GetComponent()); + // 注册事件,在测算事件中添加约束条件 + nodeAPI->addNodeCustomEventReceiver(custom4_1->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom4_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_4_ID, nullptr); + // 注册事件,在布局事件中根据测试大小修改布局大小 + nodeAPI->addNodeCustomEventReceiver(custom4_1->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom4_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + + nodeAPI->addNodeCustomEventReceiver(custom4_2->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom4_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_11_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom4_2->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom4_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + // 指定大小,在测算回调中与约束条件比较,计较结果作为测算大小,然后在布局回调中根据测试大小设置布局大小 + size4_1 = { 5, 380 }; + nodeAPI->addNodeCustomEventReceiver(custom4_3->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom4_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size4_1); + nodeAPI->addNodeCustomEventReceiver(custom4_3->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom4_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); + size4_2 = { 300, 10 }; + nodeAPI->addNodeCustomEventReceiver(custom4_4->GetComponent(), &OnMeasureReceive); + nodeAPI->registerNodeCustomEvent( + custom4_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, ON_CUSTOM_EVENT_6_ID, &size4_2); + nodeAPI->addNodeCustomEventReceiver(custom4_4->GetComponent(), &OnLayoutReceive); + nodeAPI->registerNodeCustomEvent( + custom4_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, nullptr); +} + +napi_value CustomComponentLayoutConstraintTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + addTestNodes(nodeAPI, parentColumn); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutConstraintTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutconstraint_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutconstraint_test.h new file mode 100644 index 0000000000000000000000000000000000000000..5f2310c3746bb33215cf4849f9c238b4615e523d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutconstraint_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_CUSTOMCOMPONENT_LAYOUTCONSTRAINT_TEST_H +#define CAPIDEMO_CUSTOMCOMPONENT_LAYOUTCONSTRAINT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class CustomComponentLayoutConstraintTest { +public: + ~CustomComponentLayoutConstraintTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_CUSTOMCOMPONENT_LAYOUTCONSTRAINT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutposition_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutposition_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ce04d4c56655e73eb5ff3275757cf1439a93b803 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutposition_test.cpp @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customcomponent_layoutposition_test.h" + +#include +#include + +#include "../component/column_component.h" +#include "../component/component.h" +#include "../component/custom_component.h" +#include "../component/row_component.h" +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static ArkUI_IntOffset position1 = { 0, 0 }; +static ArkUI_IntOffset position2 = { 0, 0 }; +static ArkUI_IntOffset position3 = { 0, 0 }; +static ArkUI_IntOffset position4 = { 0, 0 }; +static void OnEventReceive(ArkUI_NodeCustomEvent* event) +{ + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutPositionTest", "OnEventReceive: event is null"); + return; + } + int32_t eventId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutPositionTest", + "OnEventReceive eventId: %{public}d", eventId); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeCustomEvent_GetNodeHandle(event); + if (eventId == ON_CUSTOM_EVENT_1_ID) { + position1 = nodeAPI->getLayoutPosition(nodeHandler); + return; + } else if (eventId == ON_CUSTOM_EVENT_2_ID) { + position2 = nodeAPI->getLayoutPosition(nodeHandler); + return; + } else if (eventId == ON_CUSTOM_EVENT_3_ID) { + position3 = nodeAPI->getLayoutPosition(nodeHandler); + return; + } else if (eventId == ON_CUSTOM_EVENT_4_ID) { + position4 = nodeAPI->getLayoutPosition(nodeHandler); + return; + } else if (eventId == ON_LAYOUT_EVENT_ID) { + auto dataIntTemp = OH_ArkUI_NodeCustomEvent_GetUserData(event); + ArkUI_IntOffset offset = *static_cast(dataIntTemp); + nodeAPI->setLayoutPosition(nodeHandler, offset.x, offset.y); + // 设置子组件与自己相同的位置 + auto totalSize = nodeAPI->getTotalChildCount(nodeHandler); + for (uint32_t i = 0; i < totalSize; i++) { + auto child = nodeAPI->getChildAt(nodeHandler, i); + // 通过layoutNode子组件位置。 + nodeAPI->layoutNode(child, offset.x, offset.y); + } + return; + } else if (eventId == ON_CUSTOM_EVENT_5_ID) { + // 子组件是通过layoutNode传递过来的位置设置自己的位置的 + auto offset = OH_ArkUI_NodeCustomEvent_GetPositionInLayout(event); + nodeAPI->setLayoutPosition(nodeHandler, offset.x, offset.y); + return; + } +} + +static auto addTestNodes(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentColumn) +{ + // 创建4个Row组件,分别测试4种情况 + auto row1 = std::make_shared(); + nodeAPI->addChild(parentColumn, row1->GetComponent()); + row1->SetPercentWidth(0.8); + row1->SetPercentHeight(0.24); + row1->SetBackgroundColor(COLOR_GRAY); + row1->SetMargin(5); + auto row2 = std::make_shared(); + nodeAPI->addChild(parentColumn, row2->GetComponent()); + row2->SetPercentWidth(0.8); + row2->SetPercentHeight(0.24); + row2->SetBackgroundColor(COLOR_GRAY); + row2->SetMargin(5); + auto row3 = std::make_shared(); + nodeAPI->addChild(parentColumn, row3->GetComponent()); + row3->SetPercentWidth(0.8); + row3->SetPercentHeight(0.24); + row3->SetBackgroundColor(COLOR_GRAY); + row3->SetMargin(5); + auto row4 = std::make_shared(); + nodeAPI->addChild(parentColumn, row4->GetComponent()); + row4->SetPercentWidth(0.8); + row4->SetPercentHeight(0.24); + row4->SetBackgroundColor(COLOR_GRAY); + row4->SetMargin(5); + + // case 1 + auto custom1_1 = std::make_shared(); + custom1_1->SetBackgroundColor(COLOR_RED); + custom1_1->SetLayoutRect(5, 10, 200, 200); + nodeAPI->addChild(row1->GetComponent(), custom1_1->GetComponent()); + // custom1_2 与 custom1_1 是兄弟关系 + auto custom1_2 = std::make_shared(); + custom1_2->SetWidth(100); + custom1_2->SetHeight(100); + custom1_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(row1->GetComponent(), custom1_2->GetComponent()); + // custom1_3、custom1_4 是 custom1_2 的孩子 + auto custom1_3 = std::make_shared(); + custom1_3->SetWidth(80); + custom1_3->SetHeight(80); + custom1_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom1_2->GetComponent(), custom1_3->GetComponent()); + auto custom1_4 = std::make_shared(); + custom1_4->SetWidth(50); + custom1_4->SetHeight(50); + custom1_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom1_2->GetComponent(), custom1_4->GetComponent()); + // 注册事件,在custom1_1的布局发生变化时,获取custom1_1的位置 + nodeAPI->addNodeCustomEventReceiver(custom1_1->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom1_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_1_ID, nullptr); + // 注册事件,设置custom1_2的位置 + nodeAPI->addNodeCustomEventReceiver(custom1_2->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom1_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, &position1); + // 子组件是通过layoutNode传递过来的位置设置自己的位置的 + nodeAPI->addNodeCustomEventReceiver(custom1_3->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom1_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom1_4->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom1_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + + // case 2 + auto custom2_1 = std::make_shared(); + custom2_1->SetLayoutRect(-10, -15, 200, 200); + custom2_1->SetBackgroundColor(COLOR_RED); + nodeAPI->addChild(row2->GetComponent(), custom2_1->GetComponent()); + // custom2_2 与 custom2_1 是兄弟关系 + auto custom2_2 = std::make_shared(); + custom2_2->SetWidth(100); + custom2_2->SetHeight(100); + custom2_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(row2->GetComponent(), custom2_2->GetComponent()); + // custom2_3、custom2_4 是 custom2_2 的孩子 + auto custom2_3 = std::make_shared(); + custom2_3->SetWidth(80); + custom2_3->SetHeight(80); + custom2_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom2_2->GetComponent(), custom2_3->GetComponent()); + auto custom2_4 = std::make_shared(); + custom2_4->SetWidth(50); + custom2_4->SetHeight(50); + custom2_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom2_2->GetComponent(), custom2_4->GetComponent()); + // 注册事件,在custom2_1的布局发生变化时,获取custom2_1的位置 + nodeAPI->addNodeCustomEventReceiver(custom2_1->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom2_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_2_ID, nullptr); + // 注册事件,设置custom2_2的位置 + nodeAPI->addNodeCustomEventReceiver(custom2_2->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom2_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, &position2); + // 子组件是通过layoutNode传递过来的位置设置自己的位置的 + nodeAPI->addNodeCustomEventReceiver(custom2_3->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom2_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom2_4->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom2_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + + // case 3 + auto custom3_1 = std::make_shared(); + custom3_1->SetBackgroundColor(COLOR_RED); + custom3_1->SetLayoutRect(0, 0, 200, 200); + nodeAPI->addChild(row3->GetComponent(), custom3_1->GetComponent()); + // custom3_2 与 custom3_1 是兄弟关系 + auto custom3_2 = std::make_shared(); + custom3_2->SetWidth(100); + custom3_2->SetHeight(100); + custom3_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(row3->GetComponent(), custom3_2->GetComponent()); + // custom3_3、custom3_4 是 custom3_2 的孩子 + auto custom3_3 = std::make_shared(); + custom3_3->SetWidth(80); + custom3_3->SetHeight(80); + custom3_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom3_2->GetComponent(), custom3_3->GetComponent()); + auto custom3_4 = std::make_shared(); + custom3_4->SetWidth(50); + custom3_4->SetHeight(50); + custom3_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom3_2->GetComponent(), custom3_4->GetComponent()); + // 注册事件,在custom3_1的布局发生变化时,获取custom3_1的位置 + nodeAPI->addNodeCustomEventReceiver(custom3_1->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom3_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_3_ID, nullptr); + // 注册事件,设置custom3_2的位置 + nodeAPI->addNodeCustomEventReceiver(custom3_2->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom3_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, &position3); + // 子组件是通过layoutNode传递过来的位置设置自己的位置的 + nodeAPI->addNodeCustomEventReceiver(custom3_3->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom3_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom3_4->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom3_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + + // case 4 + auto custom4_1 = std::make_shared(); + custom4_1->SetBackgroundColor(COLOR_RED); + custom4_1->SetLayoutRect(600, 200, 200, 200); + nodeAPI->addChild(row4->GetComponent(), custom4_1->GetComponent()); + // custom4_2 与 custom4_1 是兄弟关系 + auto custom4_2 = std::make_shared(); + custom4_2->SetWidth(100); + custom4_2->SetHeight(100); + custom4_2->SetBackgroundColor(COLOR_YELLOW); + nodeAPI->addChild(row4->GetComponent(), custom4_2->GetComponent()); + // custom4_3、custom4_4 是 custom4_2 的孩子 + auto custom4_3 = std::make_shared(); + custom4_3->SetWidth(80); + custom4_3->SetHeight(80); + custom4_3->SetBackgroundColor(COLOR_BLUE); + nodeAPI->addChild(custom4_2->GetComponent(), custom4_3->GetComponent()); + auto custom4_4 = std::make_shared(); + custom4_4->SetWidth(50); + custom4_4->SetHeight(50); + custom4_4->SetBackgroundColor(COLOR_GREEN); + nodeAPI->addChild(custom4_2->GetComponent(), custom4_4->GetComponent()); + // 注册事件,在custom4_1的布局发生变化时,获取custom4_1的位置 + nodeAPI->addNodeCustomEventReceiver(custom4_1->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom4_1->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_4_ID, nullptr); + // 注册事件,设置custom4_2的位置 + nodeAPI->addNodeCustomEventReceiver(custom4_2->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom4_2->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_LAYOUT_EVENT_ID, &position4); + // 子组件是通过layoutNode传递过来的位置设置自己的位置的 + nodeAPI->addNodeCustomEventReceiver(custom4_3->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom4_3->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); + nodeAPI->addNodeCustomEventReceiver(custom4_4->GetComponent(), &OnEventReceive); + nodeAPI->registerNodeCustomEvent( + custom4_4->GetComponent(), ARKUI_NODE_CUSTOM_EVENT_ON_LAYOUT, ON_CUSTOM_EVENT_5_ID, nullptr); +} + +napi_value CustomComponentLayoutPositionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentLayoutPositionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutPositionTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + addTestNodes(nodeAPI, parentColumn); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentLayoutPositionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutposition_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutposition_test.h new file mode 100644 index 0000000000000000000000000000000000000000..015c2edfdd51b89536307857a85d6be755464141 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_layoutposition_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_LAYOUTPOSITION_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_LAYOUTPOSITION_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class CustomComponentLayoutPositionTest { +public: + ~CustomComponentLayoutPositionTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_LAYOUTPOSITION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_measuredsize_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_measuredsize_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..36aa467e74b3c19ac589b7c2641621e20c4ea974 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_measuredsize_test.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "customcomponent_measuredsize_test.h" + +#include + +#include "../component/column_component.h" +#include "../component/component.h" +#include "../component/custom_component.h" +#include "../component/row_component.h" +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto addTestNodes(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentColumn) +{ + // 创建4个Row组件,分别测试4种情况 + auto row1 = std::make_shared(); + nodeAPI->addChild(parentColumn, row1->GetComponent()); + row1->SetPercentWidth(0.8); + row1->SetPercentHeight(0.24); + row1->SetBackgroundColor(COLOR_GRAY); + row1->SetMargin(5); + auto row2 = std::make_shared(); + nodeAPI->addChild(parentColumn, row2->GetComponent()); + row2->SetPercentWidth(0.8); + row2->SetPercentHeight(0.24); + row2->SetBackgroundColor(COLOR_GRAY); + row2->SetMargin(5); + auto row3 = std::make_shared(); + nodeAPI->addChild(parentColumn, row3->GetComponent()); + row3->SetPercentWidth(0.8); + row3->SetPercentHeight(0.24); + row3->SetBackgroundColor(COLOR_GRAY); + row3->SetMargin(5); + auto row4 = std::make_shared(); + nodeAPI->addChild(parentColumn, row4->GetComponent()); + row4->SetPercentWidth(0.8); + row4->SetPercentHeight(0.24); + row4->SetBackgroundColor(COLOR_GRAY); + row4->SetMargin(5); + + // case 1 + auto custom1_1 = std::make_shared(); + custom1_1->SetWidth(100); + custom1_1->SetHeight(100); + custom1_1->SetBackgroundColor(COLOR_RED); + // 设定custom1_1的测量尺寸 + nodeAPI->setMeasuredSize(custom1_1->GetComponent(), 150, 180); + nodeAPI->addChild(row1->GetComponent(), custom1_1->GetComponent()); + // 获取测量尺寸 + auto measuredSize = nodeAPI->getMeasuredSize(custom1_1->GetComponent()); + auto width = (float)measuredSize.width; + auto height = (float)measuredSize.height; + auto custom1_2 = std::make_shared(); + nodeAPI->addChild(row1->GetComponent(), custom1_2->GetComponent()); + // 设置custom1_2的宽高,设定的测量比custom1_1的大 + custom1_2->SetWidth(width); + custom1_2->SetHeight(height); + custom1_2->SetBackgroundColor(COLOR_GREEN); + + // case 2 + auto custom2_1 = std::make_shared(); + custom2_1->SetWidth(100); + custom2_1->SetHeight(100); + custom2_1->SetBackgroundColor(COLOR_RED); + // 设定custom2_1的测量尺寸 + nodeAPI->setMeasuredSize(custom2_1->GetComponent(), -200, -200); + nodeAPI->addChild(row2->GetComponent(), custom2_1->GetComponent()); + // 获取测量尺寸 + measuredSize = nodeAPI->getMeasuredSize(custom2_1->GetComponent()); + width = (float)measuredSize.width; + height = (float)measuredSize.height; + auto custom2_2 = std::make_shared(); + nodeAPI->addChild(row2->GetComponent(), custom2_2->GetComponent()); + // 设置custom2_2的宽高 + custom2_2->SetWidth(width); + custom2_2->SetHeight(height); + custom2_2->SetBackgroundColor(COLOR_GREEN); + + // case 3 + auto custom3_1 = std::make_shared(); + custom3_1->SetWidth(100); + custom3_1->SetHeight(100); + custom3_1->SetBackgroundColor(COLOR_RED); + // 设定custom3_1的测量尺寸 + nodeAPI->setMeasuredSize(custom3_1->GetComponent(), 0, 0); + nodeAPI->addChild(row3->GetComponent(), custom3_1->GetComponent()); + // 获取测量尺寸 + measuredSize = nodeAPI->getMeasuredSize(custom3_1->GetComponent()); + width = (float)measuredSize.width; + height = (float)measuredSize.height; + auto custom3_2 = std::make_shared(); + nodeAPI->addChild(row3->GetComponent(), custom3_2->GetComponent()); + // 设置custom3_2的宽高 + custom3_2->SetWidth(width); + custom3_2->SetHeight(height); + custom3_2->SetBackgroundColor(COLOR_GREEN); + + // case 4 + auto custom4_1 = std::make_shared(); + custom4_1->SetWidth(100); + custom4_1->SetHeight(100); + custom4_1->SetBackgroundColor(COLOR_RED); + // 设定custom4_1的测量尺寸 + nodeAPI->setMeasuredSize(custom4_1->GetComponent(), 900, 400); + nodeAPI->addChild(row4->GetComponent(), custom4_1->GetComponent()); + // 获取测量尺寸 + measuredSize = nodeAPI->getMeasuredSize(custom4_1->GetComponent()); + width = (float)measuredSize.width; + height = (float)measuredSize.height; + auto custom4_2 = std::make_shared(); + nodeAPI->addChild(row4->GetComponent(), custom4_2->GetComponent()); + // 设置custom4_2的宽高 + custom4_2->SetWidth(width); + custom4_2->SetHeight(height); + custom4_2->SetBackgroundColor(COLOR_GREEN); +} + +napi_value CustomComponentMeasuredSizeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomComponentMeasuredSizeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentMeasuredSizeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + addTestNodes(nodeAPI, parentColumn); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomComponentMeasuredSizeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_measuredsize_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_measuredsize_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f5f57089b641f1ede889a7b49a958debe845190d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customcomponent/customcomponent_measuredsize_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_MEASUREDSIZE_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_MEASUREDSIZE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +namespace ArkUICApiDemo { +class CustomComponentMeasuredSizeTest { +public: + ~CustomComponentMeasuredSizeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_CUSTOMCOMPONENT_MEASUREDSIZE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customdialog/customdialog_content_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/customdialog/customdialog_content_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..68a750128af1b418c20bf68e687441879ecd0d4e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customdialog/customdialog_content_test.cpp @@ -0,0 +1,977 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "customdialog_content_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NativeDialogAPI_1* dialogAPI_global = nullptr; +ArkUI_NativeDialogHandle dialog_global; + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetWidthPercent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + return nodeHandle; +} + +static auto SetHeightPercent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto SetDialog(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_200); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_BLUE); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetId(nodeAPI, nodeHandle, id); + return nodeHandle; +} + +static auto SetColumn(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidthPercent(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetHeightPercent(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + return nodeHandle; +} + +static auto CreateChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentNode, ArkUI_NodeType type) +{ + auto childNode = nodeAPI->createNode(type); + nodeAPI->addChild(parentNode, childNode); + return childNode; +} + +static bool OnWillDismissEvent(int32_t reason) +{ + if (reason == DIALOG_DISMISS_TOUCH_OUTSIDE) { + if (dialog_global) { + dialogAPI_global->close(dialog_global); + } + return true; + } + return true; +} + +static auto CreateCustomDialog1(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test setContent,setBackgroundColor, and create + if (eventId == ON_CLICK_EVENT_ID_1) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->show(customDialog, false); + } + // Test removeContent + if (eventId == ON_CLICK_EVENT_ID_2) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->removeContent(customDialog); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->show(customDialog, false); + } + // Test setCornerRadius + if (eventId == ON_CLICK_EVENT_ID_3) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_PURPLE); + dialogAPI->setCornerRadius(customDialog, SIZE_100, SIZE_30, PARAM_0, PARAM_NEGATIVE_100); + dialogAPI->show(customDialog, false); + } + // Test dispose + if (eventId == ON_CLICK_EVENT_ID_4) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->dispose(customDialog); + customDialog = nullptr; + dialogAPI->show(customDialog, false); + } +} + +static auto CreateCustomDialog2(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test setContentAlignment with ARKUI_ALIGNMENT_TOP_START, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_5) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_TOP_START, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_TOP, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_6) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_TOP, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_TOP_END, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_7) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_TOP_END, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_START, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_8) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_START, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_CENTER, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_9) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_CENTER, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_END, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_10) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_END, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_BOTTOM_START, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_11) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_BOTTOM_START, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_BOTTOM, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_12) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_BOTTOM, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_BOTTOM_END, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_13) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_BOTTOM_END, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment -1, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_14) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, PARAM_NEGATIVE_1, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment 9, and offsetX = 0 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_15) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, PARAM_9, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + } +} + +static auto CreateCustomDialog3(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test setContentAlignment resetContentAlignment + if (eventId == ON_CLICK_EVENT_ID_16) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_BOTTOM_END, PARAM_0, PARAM_0); + dialogAPI->resetContentAlignment(customDialog); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_CENTER and offsetX = 200 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_17) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_CENTER, SIZE_200, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_CENTER and offsetX = 0 offsetY = 200 + if (eventId == ON_CLICK_EVENT_ID_18) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_CENTER, PARAM_0, SIZE_200); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_CENTER and offsetX = -200 offsetY = 0 + if (eventId == ON_CLICK_EVENT_ID_19) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_CENTER, PARAM_NEGATIVE_200, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setContentAlignment with ARKUI_ALIGNMENT_CENTER and offsetX = 0 offsetY = -200 + if (eventId == ON_CLICK_EVENT_ID_20) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_CENTER, PARAM_0, PARAM_NEGATIVE_200); + dialogAPI->show(customDialog, false); + } +} + +static auto CreateCustomDialog4(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test setModalMode with true + if (eventId == ON_CLICK_EVENT_ID_21) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, true); + dialogAPI->show(customDialog, false); + } + // Test setModalMode with false + if (eventId == ON_CLICK_EVENT_ID_22) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, false); + dialogAPI->show(customDialog, false); + } + // Test setAutoCancel with true (if setModalMode is not set, it defaults to true) + if (eventId == ON_CLICK_EVENT_ID_23) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setAutoCancel(customDialog, true); + dialogAPI->show(customDialog, false); + } + // Test setAutoCancel with false (if setModalMode is not set, it defaults to true) + if (eventId == ON_CLICK_EVENT_ID_24) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setAutoCancel(customDialog, false); + dialogAPI->show(customDialog, false); + } + // Test setAutoCancel with true (setModalMode is set to true) + if (eventId == ON_CLICK_EVENT_ID_25) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setAutoCancel(customDialog, true); + dialogAPI->setModalMode(customDialog, true); + dialogAPI->show(customDialog, false); + } + // Test setAutoCancel with false (setModalMode is set to true) + if (eventId == ON_CLICK_EVENT_ID_26) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setAutoCancel(customDialog, false); + dialogAPI->setModalMode(customDialog, true); + dialogAPI->show(customDialog, false); + } + // Test setAutoCancel with true (setModalMode is set to false) + if (eventId == ON_CLICK_EVENT_ID_27) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setAutoCancel(customDialog, true); + dialogAPI->setModalMode(customDialog, false); + dialogAPI->show(customDialog, false); + } + // Test setAutoCancel with false (setModalMode is set to false) + if (eventId == ON_CLICK_EVENT_ID_28) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setAutoCancel(customDialog, false); + dialogAPI->setModalMode(customDialog, false); + dialogAPI->show(customDialog, false); + } +} + +static auto CreateCustomDialog5(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test enableCustomAnimation is set to true + if (eventId == ON_CLICK_EVENT_ID_29) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->enableCustomAnimation(customDialog, true); + dialogAPI->show(customDialog, false); + } + // Test enableCustomAnimation is set to false + if (eventId == ON_CLICK_EVENT_ID_30) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->enableCustomAnimation(customDialog, false); + dialogAPI->show(customDialog, false); + } + // Test setMask with maskColor + if (eventId == ON_CLICK_EVENT_ID_31) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = SIZE_500; + maskRect.height = SIZE_800; + dialogAPI->setMask(customDialog, 0x77550000, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with maskColor + if (eventId == ON_CLICK_EVENT_ID_32) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = SIZE_500; + maskRect.height = SIZE_800; + dialogAPI->setMask(customDialog, 0x77005500, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height + if (eventId == ON_CLICK_EVENT_ID_33) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = SIZE_250; + maskRect.height = SIZE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height, and setModalMode is set to false + if (eventId == ON_CLICK_EVENT_ID_34) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, false); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = SIZE_250; + maskRect.height = SIZE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height, and set to negative values + if (eventId == ON_CLICK_EVENT_ID_35) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = PARAM_NEGATIVE_250; + maskRect.height = PARAM_NEGATIVE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask's width and height, set to 0 + if (eventId == ON_CLICK_EVENT_ID_36) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = PARAM_0; + maskRect.height = PARAM_0; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height, and x set to -100 + if (eventId == ON_CLICK_EVENT_ID_37) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_NEGATIVE_100; + maskRect.y = PARAM_0; + maskRect.width = SIZE_250; + maskRect.height = SIZE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height, and y set to -100 + if (eventId == ON_CLICK_EVENT_ID_38) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_NEGATIVE_100; + maskRect.width = SIZE_250; + maskRect.height = SIZE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height, and x set to 100 + if (eventId == ON_CLICK_EVENT_ID_39) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = SIZE_100; + maskRect.y = PARAM_0; + maskRect.width = SIZE_250; + maskRect.height = SIZE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } + // Test setMask with half width and height, and y set to 100 + if (eventId == ON_CLICK_EVENT_ID_40) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = SIZE_100; + maskRect.width = SIZE_250; + maskRect.height = SIZE_400; + dialogAPI->setMask(customDialog, 0x77000055, &maskRect); + dialogAPI->show(customDialog, false); + } +} + +static auto CreateCustomDialog6(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test setGridColumnCount with default value (not set) + if (eventId == ON_CLICK_EVENT_ID_41) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->show(customDialog, false); + } + // Test setGridColumnCount set to 1 + if (eventId == ON_CLICK_EVENT_ID_42) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setGridColumnCount(customDialog, PARAM_1); + dialogAPI->show(customDialog, false); + } + // Test setGridColumnCount set to 2 + if (eventId == ON_CLICK_EVENT_ID_43) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setGridColumnCount(customDialog, PARAM_2); + dialogAPI->show(customDialog, false); + } + // Test setGridColumnCount set to 100 + if (eventId == ON_CLICK_EVENT_ID_44) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setGridColumnCount(customDialog, SIZE_100); + dialogAPI->show(customDialog, false); + } + // Test setGridColumnCount set to 0 + if (eventId == ON_CLICK_EVENT_ID_45) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setGridColumnCount(customDialog, PARAM_0); + dialogAPI->show(customDialog, false); + } + // Test setGridColumnCount set to -1 + if (eventId == ON_CLICK_EVENT_ID_46) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setGridColumnCount(customDialog, PARAM_NEGATIVE_1); + dialogAPI->show(customDialog, false); + } +} + +static auto CreateCustomDialog7(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NativeDialogAPI_1* dialogAPI, int32_t eventId) +{ + // Test show as true with setModalMode as true + if (eventId == ON_CLICK_EVENT_ID_47) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, true); + dialogAPI->show(customDialog, true); + } + // Test show as false with setModalMode as true + if (eventId == ON_CLICK_EVENT_ID_48) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, true); + dialogAPI->show(customDialog, false); + } + // Test show as true with setModalMode as false + if (eventId == ON_CLICK_EVENT_ID_49) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, false); + dialogAPI->show(customDialog, true); + } + // Test show as false with setModalMode as false + if (eventId == ON_CLICK_EVENT_ID_50) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setModalMode(customDialog, false); + dialogAPI->show(customDialog, false); + } + // Test the scenario of nesting two layers of pop-up customDialog (pop up two customDialog at the same time) + if (eventId == ON_CLICK_EVENT_ID_51) { + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + auto customDialog = dialogAPI->create(); + dialogAPI->setContent(customDialog, column1); + dialogAPI->setBackgroundColor(customDialog, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog, ARKUI_ALIGNMENT_TOP, PARAM_0, PARAM_0); + dialogAPI->show(customDialog, false); + + auto column2 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column2 = SetDialog(nodeAPI, column2); + auto customDialog2 = dialogAPI->create(); + dialogAPI->setContent(customDialog2, column2); + dialogAPI->setBackgroundColor(customDialog2, COLOR_GREEN); + dialogAPI->setContentAlignment(customDialog2, ARKUI_ALIGNMENT_BOTTOM, PARAM_0, PARAM_0); + dialogAPI->show(customDialog2, false); + } + // Test registerOnWillDismiss + if (eventId == ON_CLICK_EVENT_ID_52) { + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_DIALOG, ArkUI_NativeDialogAPI_1, dialogAPI_global); + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + column1 = SetDialog(nodeAPI, column1); + dialog_global = dialogAPI->create(); + dialogAPI->setContent(dialog_global, column1); + dialogAPI->setBackgroundColor(dialog_global, COLOR_GREEN); + ArkUI_Rect maskRect = {}; + maskRect.x = PARAM_0; + maskRect.y = PARAM_0; + maskRect.width = SIZE_400; + maskRect.height = SIZE_500; + dialogAPI->setMask(dialog_global, 0x77000055, &maskRect); + dialogAPI->registerOnWillDismiss(dialog_global, &OnWillDismissEvent); + dialogAPI->show(dialog_global, false); + } +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomDialogContentTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomDialogContentTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CustomDialogContentTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ArkUI_NativeDialogAPI_1* dialogAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_DIALOG, ArkUI_NativeDialogAPI_1, dialogAPI); + + CreateCustomDialog1(nodeAPI, dialogAPI, eventId); + CreateCustomDialog2(nodeAPI, dialogAPI, eventId); + CreateCustomDialog3(nodeAPI, dialogAPI, eventId); + CreateCustomDialog4(nodeAPI, dialogAPI, eventId); + CreateCustomDialog5(nodeAPI, dialogAPI, eventId); + CreateCustomDialog6(nodeAPI, dialogAPI, eventId); + CreateCustomDialog7(nodeAPI, dialogAPI, eventId); +} + +napi_value CustomDialogContentTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomDialogContentTest", "CreateNativeNode"); + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomDialogContentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = CreateChildNode(nodeAPI, column, ARKUI_NODE_COLUMN); + auto row1 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_ROW); + auto row2 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_ROW); + auto row3 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_ROW); + auto row4 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_ROW); + auto row5 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_ROW); + auto row6 = CreateChildNode(nodeAPI, column1, ARKUI_NODE_ROW); + auto button1 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button2 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button3 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button4 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button5 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button6 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button7 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button8 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button9 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button10 = CreateChildNode(nodeAPI, row1, ARKUI_NODE_BUTTON); + auto button11 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button12 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button13 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button14 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button15 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button16 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button17 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button18 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button19 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button20 = CreateChildNode(nodeAPI, row2, ARKUI_NODE_BUTTON); + auto button21 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button22 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button23 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button24 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button25 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button26 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button27 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button28 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button29 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button30 = CreateChildNode(nodeAPI, row3, ARKUI_NODE_BUTTON); + auto button31 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button32 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button33 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button34 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button35 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button36 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button37 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button38 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button39 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button40 = CreateChildNode(nodeAPI, row4, ARKUI_NODE_BUTTON); + auto button41 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button42 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button43 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button44 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button45 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button46 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button47 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button48 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button49 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button50 = CreateChildNode(nodeAPI, row5, ARKUI_NODE_BUTTON); + auto button51 = CreateChildNode(nodeAPI, row6, ARKUI_NODE_BUTTON); + auto button52 = CreateChildNode(nodeAPI, row6, ARKUI_NODE_BUTTON); + + column = SetColumn(nodeAPI, column); + column1 = SetMargin(nodeAPI, column1, SIZE_50); + button1 = SetButton(nodeAPI, button1, "button1"); + button2 = SetButton(nodeAPI, button2, "button2"); + button3 = SetButton(nodeAPI, button3, "button3"); + button4 = SetButton(nodeAPI, button4, "button4"); + button5 = SetButton(nodeAPI, button5, "button5"); + button6 = SetButton(nodeAPI, button6, "button6"); + button7 = SetButton(nodeAPI, button7, "button7"); + button8 = SetButton(nodeAPI, button8, "button8"); + button9 = SetButton(nodeAPI, button9, "button9"); + button10 = SetButton(nodeAPI, button10, "button10"); + button11 = SetButton(nodeAPI, button11, "button11"); + button12 = SetButton(nodeAPI, button12, "button12"); + button13 = SetButton(nodeAPI, button13, "button13"); + button14 = SetButton(nodeAPI, button14, "button14"); + button15 = SetButton(nodeAPI, button15, "button15"); + button16 = SetButton(nodeAPI, button16, "button16"); + button17 = SetButton(nodeAPI, button17, "button17"); + button18 = SetButton(nodeAPI, button18, "button18"); + button19 = SetButton(nodeAPI, button19, "button19"); + button20 = SetButton(nodeAPI, button20, "button20"); + button21 = SetButton(nodeAPI, button21, "button21"); + button22 = SetButton(nodeAPI, button22, "button22"); + button23 = SetButton(nodeAPI, button23, "button23"); + button24 = SetButton(nodeAPI, button24, "button24"); + button25 = SetButton(nodeAPI, button25, "button25"); + button26 = SetButton(nodeAPI, button26, "button26"); + button27 = SetButton(nodeAPI, button27, "button27"); + button28 = SetButton(nodeAPI, button28, "button28"); + button29 = SetButton(nodeAPI, button29, "button29"); + button30 = SetButton(nodeAPI, button30, "button30"); + button31 = SetButton(nodeAPI, button31, "button31"); + button32 = SetButton(nodeAPI, button32, "button32"); + button33 = SetButton(nodeAPI, button33, "button33"); + button34 = SetButton(nodeAPI, button34, "button34"); + button35 = SetButton(nodeAPI, button35, "button35"); + button36 = SetButton(nodeAPI, button36, "button36"); + button37 = SetButton(nodeAPI, button37, "button37"); + button38 = SetButton(nodeAPI, button38, "button38"); + button39 = SetButton(nodeAPI, button39, "button39"); + button40 = SetButton(nodeAPI, button40, "button40"); + button41 = SetButton(nodeAPI, button41, "button41"); + button42 = SetButton(nodeAPI, button42, "button42"); + button43 = SetButton(nodeAPI, button43, "button43"); + button44 = SetButton(nodeAPI, button44, "button44"); + button45 = SetButton(nodeAPI, button45, "button45"); + button46 = SetButton(nodeAPI, button46, "button46"); + button47 = SetButton(nodeAPI, button47, "button47"); + button48 = SetButton(nodeAPI, button48, "button48"); + button49 = SetButton(nodeAPI, button49, "button49"); + button50 = SetButton(nodeAPI, button50, "button50"); + button51 = SetButton(nodeAPI, button51, "button51"); + button52 = SetButton(nodeAPI, button52, "button52"); + + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_EVENT_ID_1, nullptr); + nodeAPI->registerNodeEvent(button2, NODE_ON_CLICK, ON_CLICK_EVENT_ID_2, nullptr); + nodeAPI->registerNodeEvent(button3, NODE_ON_CLICK, ON_CLICK_EVENT_ID_3, nullptr); + nodeAPI->registerNodeEvent(button4, NODE_ON_CLICK, ON_CLICK_EVENT_ID_4, nullptr); + nodeAPI->registerNodeEvent(button5, NODE_ON_CLICK, ON_CLICK_EVENT_ID_5, nullptr); + nodeAPI->registerNodeEvent(button6, NODE_ON_CLICK, ON_CLICK_EVENT_ID_6, nullptr); + nodeAPI->registerNodeEvent(button7, NODE_ON_CLICK, ON_CLICK_EVENT_ID_7, nullptr); + nodeAPI->registerNodeEvent(button8, NODE_ON_CLICK, ON_CLICK_EVENT_ID_8, nullptr); + nodeAPI->registerNodeEvent(button9, NODE_ON_CLICK, ON_CLICK_EVENT_ID_9, nullptr); + nodeAPI->registerNodeEvent(button10, NODE_ON_CLICK, ON_CLICK_EVENT_ID_10, nullptr); + nodeAPI->registerNodeEvent(button11, NODE_ON_CLICK, ON_CLICK_EVENT_ID_11, nullptr); + nodeAPI->registerNodeEvent(button12, NODE_ON_CLICK, ON_CLICK_EVENT_ID_12, nullptr); + nodeAPI->registerNodeEvent(button13, NODE_ON_CLICK, ON_CLICK_EVENT_ID_13, nullptr); + nodeAPI->registerNodeEvent(button14, NODE_ON_CLICK, ON_CLICK_EVENT_ID_14, nullptr); + nodeAPI->registerNodeEvent(button15, NODE_ON_CLICK, ON_CLICK_EVENT_ID_15, nullptr); + nodeAPI->registerNodeEvent(button16, NODE_ON_CLICK, ON_CLICK_EVENT_ID_16, nullptr); + nodeAPI->registerNodeEvent(button17, NODE_ON_CLICK, ON_CLICK_EVENT_ID_17, nullptr); + nodeAPI->registerNodeEvent(button18, NODE_ON_CLICK, ON_CLICK_EVENT_ID_18, nullptr); + nodeAPI->registerNodeEvent(button19, NODE_ON_CLICK, ON_CLICK_EVENT_ID_19, nullptr); + nodeAPI->registerNodeEvent(button20, NODE_ON_CLICK, ON_CLICK_EVENT_ID_20, nullptr); + nodeAPI->registerNodeEvent(button21, NODE_ON_CLICK, ON_CLICK_EVENT_ID_21, nullptr); + nodeAPI->registerNodeEvent(button22, NODE_ON_CLICK, ON_CLICK_EVENT_ID_22, nullptr); + nodeAPI->registerNodeEvent(button23, NODE_ON_CLICK, ON_CLICK_EVENT_ID_23, nullptr); + nodeAPI->registerNodeEvent(button24, NODE_ON_CLICK, ON_CLICK_EVENT_ID_24, nullptr); + nodeAPI->registerNodeEvent(button25, NODE_ON_CLICK, ON_CLICK_EVENT_ID_25, nullptr); + nodeAPI->registerNodeEvent(button26, NODE_ON_CLICK, ON_CLICK_EVENT_ID_26, nullptr); + nodeAPI->registerNodeEvent(button27, NODE_ON_CLICK, ON_CLICK_EVENT_ID_27, nullptr); + nodeAPI->registerNodeEvent(button28, NODE_ON_CLICK, ON_CLICK_EVENT_ID_28, nullptr); + nodeAPI->registerNodeEvent(button29, NODE_ON_CLICK, ON_CLICK_EVENT_ID_29, nullptr); + nodeAPI->registerNodeEvent(button30, NODE_ON_CLICK, ON_CLICK_EVENT_ID_30, nullptr); + nodeAPI->registerNodeEvent(button31, NODE_ON_CLICK, ON_CLICK_EVENT_ID_31, nullptr); + nodeAPI->registerNodeEvent(button32, NODE_ON_CLICK, ON_CLICK_EVENT_ID_32, nullptr); + nodeAPI->registerNodeEvent(button33, NODE_ON_CLICK, ON_CLICK_EVENT_ID_33, nullptr); + nodeAPI->registerNodeEvent(button34, NODE_ON_CLICK, ON_CLICK_EVENT_ID_34, nullptr); + nodeAPI->registerNodeEvent(button35, NODE_ON_CLICK, ON_CLICK_EVENT_ID_35, nullptr); + nodeAPI->registerNodeEvent(button36, NODE_ON_CLICK, ON_CLICK_EVENT_ID_36, nullptr); + nodeAPI->registerNodeEvent(button37, NODE_ON_CLICK, ON_CLICK_EVENT_ID_37, nullptr); + nodeAPI->registerNodeEvent(button38, NODE_ON_CLICK, ON_CLICK_EVENT_ID_38, nullptr); + nodeAPI->registerNodeEvent(button39, NODE_ON_CLICK, ON_CLICK_EVENT_ID_39, nullptr); + nodeAPI->registerNodeEvent(button40, NODE_ON_CLICK, ON_CLICK_EVENT_ID_40, nullptr); + nodeAPI->registerNodeEvent(button41, NODE_ON_CLICK, ON_CLICK_EVENT_ID_41, nullptr); + nodeAPI->registerNodeEvent(button42, NODE_ON_CLICK, ON_CLICK_EVENT_ID_42, nullptr); + nodeAPI->registerNodeEvent(button43, NODE_ON_CLICK, ON_CLICK_EVENT_ID_43, nullptr); + nodeAPI->registerNodeEvent(button44, NODE_ON_CLICK, ON_CLICK_EVENT_ID_44, nullptr); + nodeAPI->registerNodeEvent(button45, NODE_ON_CLICK, ON_CLICK_EVENT_ID_45, nullptr); + nodeAPI->registerNodeEvent(button46, NODE_ON_CLICK, ON_CLICK_EVENT_ID_46, nullptr); + nodeAPI->registerNodeEvent(button47, NODE_ON_CLICK, ON_CLICK_EVENT_ID_47, nullptr); + nodeAPI->registerNodeEvent(button48, NODE_ON_CLICK, ON_CLICK_EVENT_ID_48, nullptr); + nodeAPI->registerNodeEvent(button49, NODE_ON_CLICK, ON_CLICK_EVENT_ID_49, nullptr); + nodeAPI->registerNodeEvent(button50, NODE_ON_CLICK, ON_CLICK_EVENT_ID_50, nullptr); + nodeAPI->registerNodeEvent(button51, NODE_ON_CLICK, ON_CLICK_EVENT_ID_51, nullptr); + nodeAPI->registerNodeEvent(button52, NODE_ON_CLICK, ON_CLICK_EVENT_ID_52, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CustomDialogContentTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/customdialog/customdialog_content_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/customdialog/customdialog_content_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ba7efff84a9d2624e2eed10169e6b2b0cc4c8668 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/customdialog/customdialog_content_test.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_CUSTOMDIALOG_CONTENT_TEST_H +#define ARKUI_CAPI_DEMO_CUSTOMDIALOG_CONTENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define PARAM_NEGATIVE_200 (-200) +#define PARAM_NEGATIVE_250 (-250) +#define PARAM_NEGATIVE_400 (-400) +#define SIZE_250 250 +#define SIZE_800 800 +#define ON_CLICK_EVENT_ID_1 6014 +#define ON_CLICK_EVENT_ID_2 6015 +#define ON_CLICK_EVENT_ID_3 6016 +#define ON_CLICK_EVENT_ID_4 6017 +#define ON_CLICK_EVENT_ID_5 6018 +#define ON_CLICK_EVENT_ID_6 6019 +#define ON_CLICK_EVENT_ID_7 6020 +#define ON_CLICK_EVENT_ID_8 6021 +#define ON_CLICK_EVENT_ID_9 6022 +#define ON_CLICK_EVENT_ID_10 6023 +#define ON_CLICK_EVENT_ID_11 6024 +#define ON_CLICK_EVENT_ID_12 6025 +#define ON_CLICK_EVENT_ID_13 6026 +#define ON_CLICK_EVENT_ID_14 6027 +#define ON_CLICK_EVENT_ID_15 6028 +#define ON_CLICK_EVENT_ID_16 6029 +#define ON_CLICK_EVENT_ID_17 6030 +#define ON_CLICK_EVENT_ID_18 6031 +#define ON_CLICK_EVENT_ID_19 6032 +#define ON_CLICK_EVENT_ID_20 6033 +#define ON_CLICK_EVENT_ID_21 6034 +#define ON_CLICK_EVENT_ID_22 6035 +#define ON_CLICK_EVENT_ID_23 6036 +#define ON_CLICK_EVENT_ID_24 6037 +#define ON_CLICK_EVENT_ID_25 6038 +#define ON_CLICK_EVENT_ID_26 6039 +#define ON_CLICK_EVENT_ID_27 6040 +#define ON_CLICK_EVENT_ID_28 6041 +#define ON_CLICK_EVENT_ID_29 6042 +#define ON_CLICK_EVENT_ID_30 6043 +#define ON_CLICK_EVENT_ID_31 6044 +#define ON_CLICK_EVENT_ID_32 6045 +#define ON_CLICK_EVENT_ID_33 6046 +#define ON_CLICK_EVENT_ID_34 6047 +#define ON_CLICK_EVENT_ID_35 6048 +#define ON_CLICK_EVENT_ID_36 6049 +#define ON_CLICK_EVENT_ID_37 6050 +#define ON_CLICK_EVENT_ID_38 6051 +#define ON_CLICK_EVENT_ID_39 6052 +#define ON_CLICK_EVENT_ID_40 6053 +#define ON_CLICK_EVENT_ID_41 6054 +#define ON_CLICK_EVENT_ID_42 6055 +#define ON_CLICK_EVENT_ID_43 6056 +#define ON_CLICK_EVENT_ID_44 6057 +#define ON_CLICK_EVENT_ID_45 6058 +#define ON_CLICK_EVENT_ID_46 6059 +#define ON_CLICK_EVENT_ID_47 6060 +#define ON_CLICK_EVENT_ID_48 6061 +#define ON_CLICK_EVENT_ID_49 6062 +#define ON_CLICK_EVENT_ID_50 6063 +#define ON_CLICK_EVENT_ID_51 6064 +#define ON_CLICK_EVENT_ID_52 6065 +#define ON_CLICK_EVENT_ID_53 6066 + +class CustomDialogContentTest { +public: + ~CustomDialogContentTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_CUSTOMDIALOG_CONTENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/eventcallback/event_callback_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/eventcallback/event_callback_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23127d808a41fdf30529a8e41c0bf0f28ae5c78e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/eventcallback/event_callback_test.cpp @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "event_callback_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "text_component.h" + +#define COLUMN_ID 2020 +#define TEXT_ID 2121 + +namespace ArkUICApiDemo { +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); + + // 当触发Change事件,修改背景色 + if (COLUMN_ID == eventId && eventType == NODE_ON_CLICK) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GRAY } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + nodeAPI->unregisterNodeEventReceiver(); + } + if (TEXT_ID == eventId && eventType == NODE_ON_CLICK) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } +} + +napi_value EventCallbackTest::CreateNativeNodeForSpecifyNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EventCallbackTest", "CreateNativeNodeForSpecifyNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EventCallbackTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button2 = new ButtonComponent(); + button2->SetLable("Unregister"); + button2->SetId("Unregister"); + button2->SetMargin(10); + button2->SetWidth(200); + button2->SetHeight(100); + button2->RegisterOnClick([button2]() { button2->SetBackgroundColor(COLOR_PINK); }); + + auto button3 = new ButtonComponent(); + button3->SetLable("Remove"); + button3->SetId("Remove"); + button3->SetMargin(10); + button3->SetWidth(200); + button3->SetHeight(100); + button3->RegisterOnClick([button3]() { button3->SetBackgroundColor(COLOR_PINK); }); + + auto button1 = new ButtonComponent(); + button1->SetLable("UnregisterAndRemove"); + button1->SetId("UnregisterAndRemove"); + button1->SetMargin(10); + button1->SetWidth(200); + button1->SetHeight(100); + button1->RegisterOnClick([button1, button2, button3, nodeAPI]() { + button1->SetBackgroundColor(COLOR_PINK); + nodeAPI->unregisterNodeEvent(button2->GetComponent(), NODE_ON_CLICK); + nodeAPI->removeNodeEventReceiver(button3->GetComponent(), Component::NodeEventReceiver); + }); + + nodeAPI->addChild(parentColumn, button1->GetComponent()); + nodeAPI->addChild(parentColumn, button2->GetComponent()); + nodeAPI->addChild(parentColumn, button3->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EventCallbackTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value EventCallbackTest::CreateNativeNodeForGlobal(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EventCallbackTest", "CreateNativeNodeForGlobal"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EventCallbackTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + ArkUI_NumberValue column_width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem column_width_item = { column_width_value, + sizeof(column_width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue column_height_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem column_height_item = { column_height_value, + sizeof(column_height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue column_background_color_value[] = { { .u32 = COLOR_PINK } }; + ArkUI_AttributeItem column_background_color_item = { column_background_color_value, + sizeof(column_background_color_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem column_id_item = { nullptr, 0, "column" }; + nodeAPI->setAttribute(parentColumn, NODE_WIDTH, &column_width_item); + nodeAPI->setAttribute(parentColumn, NODE_HEIGHT, &column_height_item); + nodeAPI->setAttribute(parentColumn, NODE_BACKGROUND_COLOR, &column_background_color_item); + nodeAPI->setAttribute(parentColumn, NODE_ID, &column_id_item); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + nodeAPI->registerNodeEvent(parentColumn, NODE_ON_CLICK, COLUMN_ID, nullptr); + + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_NumberValue text_width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem text_width_item = { text_width_value, sizeof(text_width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue text_height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem text_height_item = { text_height_value, sizeof(text_height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue text_background_color_value[] = { { .u32 = COLOR_BLUE } }; + ArkUI_AttributeItem text_background_color_item = { text_background_color_value, + sizeof(text_background_color_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem text_id_item = { nullptr, 0, "text" }; + nodeAPI->setAttribute(text, NODE_WIDTH, &text_width_item); + nodeAPI->setAttribute(text, NODE_HEIGHT, &text_height_item); + nodeAPI->setAttribute(text, NODE_BACKGROUND_COLOR, &text_background_color_item); + nodeAPI->setAttribute(text, NODE_ID, &text_id_item); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + nodeAPI->registerNodeEvent(text, NODE_ON_CLICK, TEXT_ID, nullptr); + + nodeAPI->addChild(parentColumn, text); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EventCallbackTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/eventcallback/event_callback_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/eventcallback/event_callback_test.h new file mode 100644 index 0000000000000000000000000000000000000000..4059ea55e245427c72c8d66d4cf09c2f10755b86 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/eventcallback/event_callback_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_EVENT_CALLBACK_TEST_H +#define ARKUI_CAPI_DEMO_EVENT_CALLBACK_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class EventCallbackTest { +public: + ~EventCallbackTest(); + // testEventCallback001 + // addNodeEventReceiver,removeNodeEventReceiver,registerNodeEvent,unregisterNodeEvent + static napi_value CreateNativeNodeForSpecifyNode(napi_env env, napi_callback_info info); + // testEventCallback002 + // registerNodeEventReceiver,unregisterNodeEventReceiver + static napi_value CreateNativeNodeForGlobal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_EVENT_CALLBACK_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/flex/flex_options_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/flex/flex_options_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..029f0690b240551ca8445f52dd2e9ca8e2141dc4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/flex/flex_options_test.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "flex_options_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createFlexNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t* options) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 70 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_BLUE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, 0xFFC100FF)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_WHITE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_PURPLE)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_LIGHT_BLUE)); + // set options + ArkUI_NumberValue options_value[] = { { .i32 = options[0] }, { .i32 = options[1] }, { .i32 = options[2] }, + { .i32 = options[3] }, { .i32 = options[4] } }; + ArkUI_AttributeItem options_item = { options_value, sizeof(options_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FLEX_OPTION, &options_item); + return nodeHandle; +} + +static auto addFlexNodes(ArkUI_NativeNodeAPI_1 *nodeAPI, ArkUI_NodeHandle parentColumn) +{ + int32_t options1[] = {ARKUI_FLEX_DIRECTION_ROW, ARKUI_FLEX_WRAP_NO_WRAP, ARKUI_FLEX_ALIGNMENT_START, + ARKUI_ITEM_ALIGNMENT_AUTO, ARKUI_FLEX_ALIGNMENT_START}; + int32_t options2[] = {ARKUI_FLEX_DIRECTION_COLUMN, ARKUI_FLEX_WRAP_WRAP, ARKUI_FLEX_ALIGNMENT_CENTER, + ARKUI_ITEM_ALIGNMENT_START, ARKUI_FLEX_ALIGNMENT_CENTER}; + int32_t options3[] = {ARKUI_FLEX_DIRECTION_ROW_REVERSE, ARKUI_FLEX_WRAP_WRAP_REVERSE, ARKUI_FLEX_ALIGNMENT_END, + ARKUI_ITEM_ALIGNMENT_CENTER, ARKUI_FLEX_ALIGNMENT_END}; + int32_t options4[] = {ARKUI_FLEX_DIRECTION_COLUMN_REVERSE, ARKUI_FLEX_WRAP_WRAP, ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN, + ARKUI_ITEM_ALIGNMENT_END, ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN}; + int32_t options5[] = {ARKUI_FLEX_DIRECTION_COLUMN, ARKUI_FLEX_WRAP_WRAP, ARKUI_FLEX_ALIGNMENT_SPACE_AROUND, + ARKUI_ITEM_ALIGNMENT_STRETCH, ARKUI_FLEX_ALIGNMENT_SPACE_AROUND}; + int32_t options6[] = {ARKUI_FLEX_DIRECTION_COLUMN, ARKUI_FLEX_WRAP_NO_WRAP, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY, + ARKUI_ITEM_ALIGNMENT_BASELINE, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY}; + int32_t options7[] = {ARKUI_FLEX_DIRECTION_COLUMN, ARKUI_FLEX_WRAP_NO_WRAP, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY, + ARKUI_ITEM_ALIGNMENT_BASELINE, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY}; + int32_t options8[] = {ARKUI_FLEX_DIRECTION_COLUMN, ARKUI_FLEX_WRAP_NO_WRAP, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY, + ARKUI_ITEM_ALIGNMENT_BASELINE, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY}; + int32_t options9[] = {ARKUI_FLEX_DIRECTION_COLUMN, ARKUI_FLEX_WRAP_NO_WRAP, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY, + ARKUI_ITEM_ALIGNMENT_BASELINE, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY}; + int32_t options10[] = {-1, -1, -1, -1, -1}; + auto flex1 = createFlexNode(nodeAPI, options1); + auto flex2 = createFlexNode(nodeAPI, options2); + auto flex3 = createFlexNode(nodeAPI, options3); + auto flex4 = createFlexNode(nodeAPI, options4); + auto flex5 = createFlexNode(nodeAPI, options5); + auto flex6 = createFlexNode(nodeAPI, options6); + auto flex7 = createFlexNode(nodeAPI, options7); + auto flex8 = createFlexNode(nodeAPI, options8); + auto flex9 = createFlexNode(nodeAPI, options9); + auto flex10 = createFlexNode(nodeAPI, options10); + nodeAPI->addChild(parentColumn, flex1); + nodeAPI->addChild(parentColumn, flex2); + nodeAPI->addChild(parentColumn, flex3); + nodeAPI->addChild(parentColumn, flex4); + nodeAPI->addChild(parentColumn, flex5); + nodeAPI->addChild(parentColumn, flex6); + nodeAPI->addChild(parentColumn, flex7); + nodeAPI->addChild(parentColumn, flex8); + nodeAPI->addChild(parentColumn, flex9); + nodeAPI->addChild(parentColumn, flex10); +} + +napi_value FlexOptionsTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "FlexOptionsTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "FlexOptionsTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + addFlexNodes(nodeAPI, parentColumn); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "FlexOptionsTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/flex/flex_options_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/flex/flex_options_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d89236572f7f147f4b4740bc79d1f6b61bd75ff6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/flex/flex_options_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_FLEX_OPTIONS_TEST_H +#define ARKUI_CAPI_DEMO_FLEX_OPTIONS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class FlexOptionsTest { +public: + ~FlexOptionsTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_FLEX_OPTIONS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/gesture/gesture_gesture_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/gesture/gesture_gesture_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c2c3300fa3ff9661fcf919100772f39182557787 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/gesture/gesture_gesture_test.cpp @@ -0,0 +1,388 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gesture_gesture_test.h" + +#include + +namespace ArkUICApiDemo { + +ArkUI_NativeNodeAPI_1* GestureGestureTest::nodeAPI = nullptr; + +static void OnEventGesture(ArkUI_GestureEvent* event, void* extraParams) +{ + auto button = OH_ArkUI_GestureEvent_GetNode(event); + ArkUI_NumberValue color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + GestureGestureTest::nodeAPI->setAttribute(button, NODE_BACKGROUND_COLOR, &color_item); +} + +static std::shared_ptr CreateButtonToTapGestureNode( + ArkUI_NativeGestureAPI_1* gestureAPI, const std::string& id, int32_t countNum, int32_t fingersNum) +{ + auto button = std::make_shared(); + button->SetWidth(SIZE_150); + button->SetHeight(SIZE_100); + button->SetBackgroundColor(COLOR_RED); + button->SetId(id); + button->SetMargin(SIZE_5); + auto tapGesture = gestureAPI->createTapGesture(countNum, fingersNum); + gestureAPI->setGestureEventTarget(tapGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventGesture); + gestureAPI->addGestureToNode(button->GetComponent(), tapGesture, NORMAL, NORMAL_GESTURE_MASK); + return button; +} + +static std::shared_ptr CreateButtonToLongPressGestureNode(ArkUI_NativeGestureAPI_1* gestureAPI, + const std::string& id, int32_t fingersNum, bool repeatResult, int32_t durationNum) +{ + auto button = std::make_shared(); + button->SetWidth(SIZE_150); + button->SetHeight(SIZE_100); + button->SetBackgroundColor(COLOR_RED); + button->SetId(id); + button->SetMargin(SIZE_5); + auto longPressGesture = gestureAPI->createLongPressGesture(fingersNum, repeatResult, durationNum); + gestureAPI->setGestureEventTarget(longPressGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventGesture); + gestureAPI->addGestureToNode(button->GetComponent(), longPressGesture, NORMAL, NORMAL_GESTURE_MASK); + return button; +} + +static std::shared_ptr CreateColumnToPanGestureNode(ArkUI_NativeGestureAPI_1* gestureAPI, + const std::string& id, int32_t fingersNum, ArkUI_GestureDirectionMask directions, double distanceNum) +{ + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_100); + column->SetBackgroundColor(COLOR_RED); + column->SetId(id); + column->SetMargin(DEFAULT_MARGIN); + auto panGesture = gestureAPI->createPanGesture(fingersNum, directions, distanceNum); + gestureAPI->setGestureEventTarget(panGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventGesture); + gestureAPI->addGestureToNode(column->GetComponent(), panGesture, NORMAL, NORMAL_GESTURE_MASK); + return column; +} + +static std::shared_ptr CreateColumnToPinchGestureNode( + ArkUI_NativeGestureAPI_1* gestureAPI, const std::string& id, int32_t fingersNum, double durationNum) +{ + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_100); + column->SetBackgroundColor(COLOR_RED); + column->SetId(id); + column->SetMargin(DEFAULT_MARGIN); + auto pinchGesture = gestureAPI->createPinchGesture(fingersNum, durationNum); + gestureAPI->setGestureEventTarget(pinchGesture, GESTURE_EVENT_ACTION_UPDATE, nullptr, &OnEventGesture); + gestureAPI->addGestureToNode(column->GetComponent(), pinchGesture, NORMAL, NORMAL_GESTURE_MASK); + return column; +} + +static std::shared_ptr CreateColumnToRotationGestureNode( + ArkUI_NativeGestureAPI_1* gestureAPI, const std::string& id, int32_t fingersNum, double angleNum) +{ + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_100); + column->SetBackgroundColor(COLOR_RED); + column->SetId(id); + column->SetMargin(DEFAULT_MARGIN); + auto rotationGesture = gestureAPI->createRotationGesture(fingersNum, angleNum); + gestureAPI->setGestureEventTarget(rotationGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventGesture); + gestureAPI->addGestureToNode(column->GetComponent(), rotationGesture, NORMAL, NORMAL_GESTURE_MASK); + return column; +} + +static std::shared_ptr CreateColumnToSwipeGestureNode(ArkUI_NativeGestureAPI_1* gestureAPI, + const std::string& id, int32_t fingersNum, ArkUI_GestureDirectionMask directions, double speedNum) +{ + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_100); + column->SetBackgroundColor(COLOR_RED); + column->SetId(id); + column->SetMargin(DEFAULT_MARGIN); + auto swipeGesture = gestureAPI->createSwipeGesture(fingersNum, directions, speedNum); + gestureAPI->setGestureEventTarget(swipeGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventGesture); + gestureAPI->addGestureToNode(column->GetComponent(), swipeGesture, NORMAL, NORMAL_GESTURE_MASK); + return column; +} + +static auto CreateRowFirstNode(ArkUI_NativeGestureAPI_1* gestureAPI) +{ + auto row = GestureGestureTest::nodeAPI->createNode(ARKUI_NODE_ROW); + auto Column1 = std::make_shared(); + auto Column2 = std::make_shared(); + auto button1 = CreateButtonToTapGestureNode(gestureAPI, "button1", 1, 1); + auto button2 = CreateButtonToTapGestureNode(gestureAPI, "button2", 1, 11); + auto button3 = CreateButtonToTapGestureNode(gestureAPI, "button3", -1, -1); + auto button4 = CreateButtonToLongPressGestureNode(gestureAPI, "button4", 1, true, 1000); + auto button5 = CreateButtonToLongPressGestureNode(gestureAPI, "button5", 1, true, 1000); + auto button6 = CreateButtonToLongPressGestureNode(gestureAPI, "button6", 1, false, 1000); + auto button7 = CreateButtonToLongPressGestureNode(gestureAPI, "button7", 11, true, -1); + auto button8 = CreateButtonToLongPressGestureNode(gestureAPI, "button8", -1, -1, -1); + std::vector> buttons1 = { button1, button2, button3, button4 }; + std::vector> buttons2 = { button5, button6, button7, button8 }; + for (auto button : buttons1) { + Column1->AddChild(button); + } + for (auto button : buttons2) { + Column2->AddChild(button); + } + GestureGestureTest::nodeAPI->addChild(row, Column1->GetComponent()); + GestureGestureTest::nodeAPI->addChild(row, Column2->GetComponent()); + return row; +} + +static auto CreateRowSecondNode(ArkUI_NativeGestureAPI_1* gestureAPI) +{ + auto row = GestureGestureTest::nodeAPI->createNode(ARKUI_NODE_ROW); + auto Column1 = std::make_shared(); + auto Column2 = std::make_shared(); + auto column1 = CreateColumnToPanGestureNode(gestureAPI, "column1", 1, GESTURE_DIRECTION_ALL, 10); + auto column2 = CreateColumnToPanGestureNode(gestureAPI, "column2", 1, GESTURE_DIRECTION_HORIZONTAL, 10); + auto column3 = CreateColumnToPanGestureNode(gestureAPI, "column3", 1, GESTURE_DIRECTION_VERTICAL, 10); + auto column4 = CreateColumnToPanGestureNode(gestureAPI, "column4", 1, GESTURE_DIRECTION_LEFT, 10); + auto column5 = CreateColumnToPanGestureNode(gestureAPI, "column5", 1, GESTURE_DIRECTION_RIGHT, 10); + auto column6 = CreateColumnToPanGestureNode(gestureAPI, "column6", 1, GESTURE_DIRECTION_UP, 10); + auto column7 = CreateColumnToPanGestureNode(gestureAPI, "column7", 1, GESTURE_DIRECTION_DOWN, 10); + auto column8 = CreateColumnToPanGestureNode(gestureAPI, "column8", 1, GESTURE_DIRECTION_NONE, 10); + auto column9 = CreateColumnToPanGestureNode(gestureAPI, "column9", -1, -1, -1); + auto column10 = CreateColumnToPanGestureNode(gestureAPI, "column10", 11, GESTURE_DIRECTION_ALL, 10); + auto column11 = CreateColumnToPanGestureNode(gestureAPI, "column11", 1, GESTURE_DIRECTION_ALL, 10); + auto column12 = CreateColumnToPanGestureNode(gestureAPI, "column12", 1, GESTURE_DIRECTION_ALL, 10); + std::vector> columns1 = { column1, column2, column3, column4, column5, column6 }; + std::vector> columns2 = { column7, column8, column9, column10, column11, + column12 }; + for (auto column : columns1) { + Column1->AddChild(column); + } + for (auto column : columns2) { + Column2->AddChild(column); + } + GestureGestureTest::nodeAPI->addChild(row, Column1->GetComponent()); + GestureGestureTest::nodeAPI->addChild(row, Column2->GetComponent()); + return row; +} + +static auto CreateRowThirdNode(ArkUI_NativeGestureAPI_1* gestureAPI) +{ + auto row = GestureGestureTest::nodeAPI->createNode(ARKUI_NODE_ROW); + auto Column1 = std::make_shared(); + auto Column2 = std::make_shared(); + auto column1 = CreateColumnToPinchGestureNode(gestureAPI, "column1", 2, 5); + auto column2 = CreateColumnToPinchGestureNode(gestureAPI, "column2", 6, 5); + auto column3 = CreateColumnToPinchGestureNode(gestureAPI, "column3", -1, -1); + auto column4 = CreateColumnToRotationGestureNode(gestureAPI, "column4", 2, 1); + auto column5 = CreateColumnToRotationGestureNode(gestureAPI, "column5", 2, 0); + auto column6 = CreateColumnToRotationGestureNode(gestureAPI, "column6", 2, 500); + auto column7 = CreateColumnToRotationGestureNode(gestureAPI, "column7", 6, 1); + auto column8 = CreateColumnToRotationGestureNode(gestureAPI, "column8", -1, -1); + std::vector> columns1 = { column1, column2, column3, column4 }; + std::vector> columns2 = { column5, column6, column7, column8 }; + for (auto columnChild : columns1) { + Column1->AddChild(columnChild); + } + for (auto columnChild : columns2) { + Column2->AddChild(columnChild); + } + GestureGestureTest::nodeAPI->addChild(row, Column1->GetComponent()); + GestureGestureTest::nodeAPI->addChild(row, Column2->GetComponent()); + return row; +} + +static auto CreateRowFourthNode(ArkUI_NativeGestureAPI_1* gestureAPI) +{ + auto row = GestureGestureTest::nodeAPI->createNode(ARKUI_NODE_ROW); + auto Column1 = std::make_shared(); + auto Column2 = std::make_shared(); + auto column1 = CreateColumnToSwipeGestureNode(gestureAPI, "column1", 1, GESTURE_DIRECTION_ALL, 100); + auto column2 = CreateColumnToSwipeGestureNode(gestureAPI, "column2", 1, GESTURE_DIRECTION_HORIZONTAL, 100); + auto column3 = CreateColumnToSwipeGestureNode(gestureAPI, "column3", 1, GESTURE_DIRECTION_VERTICAL, 100); + auto column4 = CreateColumnToSwipeGestureNode(gestureAPI, "column4", 1, GESTURE_DIRECTION_LEFT, 100); + auto column5 = CreateColumnToSwipeGestureNode(gestureAPI, "column5", 1, GESTURE_DIRECTION_RIGHT, 100); + auto column6 = CreateColumnToSwipeGestureNode(gestureAPI, "column6", 1, GESTURE_DIRECTION_UP, 100); + auto column7 = CreateColumnToSwipeGestureNode(gestureAPI, "column7", 1, GESTURE_DIRECTION_DOWN, 100); + auto column8 = CreateColumnToSwipeGestureNode(gestureAPI, "column8", 1, GESTURE_DIRECTION_NONE, 100); + auto column9 = CreateColumnToSwipeGestureNode(gestureAPI, "column9", -1, -1, -1); + auto column10 = CreateColumnToSwipeGestureNode(gestureAPI, "column10", 11, GESTURE_DIRECTION_ALL, 100); + auto column11 = CreateColumnToSwipeGestureNode(gestureAPI, "column11", 1, GESTURE_DIRECTION_ALL, 100); + auto column12 = CreateColumnToSwipeGestureNode(gestureAPI, "column12", 1, GESTURE_DIRECTION_ALL, 100); + std::vector> columns1 = { column1, column2, column3, column4, column5, column6 }; + std::vector> columns2 = { column7, column8, column9, column10, column11, + column12 }; + for (auto column : columns1) { + Column1->AddChild(column); + } + for (auto column : columns2) { + Column2->AddChild(column); + } + GestureGestureTest::nodeAPI->addChild(row, Column1->GetComponent()); + GestureGestureTest::nodeAPI->addChild(row, Column2->GetComponent()); + return row; +} + +napi_value GestureGestureTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, GestureGestureTest::nodeAPI); + ArkUI_NativeGestureAPI_1* gestureAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_GESTURE, ArkUI_NativeGestureAPI_1, gestureAPI); + + auto column = CreateRowFirstNode(gestureAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value GestureGestureTest::CreateNativeNode1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "CreateNativeNode1"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, GestureGestureTest::nodeAPI); + ArkUI_NativeGestureAPI_1* gestureAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_GESTURE, ArkUI_NativeGestureAPI_1, gestureAPI); + + auto row = CreateRowSecondNode(gestureAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value GestureGestureTest::CreateNativeNode2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "CreateNativeNode2"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, GestureGestureTest::nodeAPI); + ArkUI_NativeGestureAPI_1* gestureAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_GESTURE, ArkUI_NativeGestureAPI_1, gestureAPI); + + auto row = CreateRowThirdNode(gestureAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value GestureGestureTest::CreateNativeNode3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "CreateNativeNode3"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, GestureGestureTest::nodeAPI); + ArkUI_NativeGestureAPI_1* gestureAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_GESTURE, ArkUI_NativeGestureAPI_1, gestureAPI); + + auto row = CreateRowFourthNode(gestureAPI); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GestureGestureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/gesture/gesture_gesture_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/gesture/gesture_gesture_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ac9b5a7683cd52b9e38550dac95c7a532ac5d3fe --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/gesture/gesture_gesture_test.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_GUESTURE_GESTURE_TEST_H +#define ARKUI_CAPI_DEMO_GUESTURE_GESTURE_TEST_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../common/common.h" +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" +#include "multimedia/image_framework/image/pixelmap_native.h" + +namespace ArkUICApiDemo { + +class GestureGestureTest { +public: + ~GestureGestureTest(); + // GestureGestureTest:testGestureGesture001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // GestureGestureTest:testGestureGesture002 + static napi_value CreateNativeNode1(napi_env env, napi_callback_info info); + // GestureGestureTest:testGestureGesture003 + static napi_value CreateNativeNode2(napi_env env, napi_callback_info info); + // GestureGestureTest:testGestureGesture004 + static napi_value CreateNativeNode3(napi_env env, napi_callback_info info); + static ArkUI_NativeNodeAPI_1* nodeAPI; +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_GUESTURE_GESTURE_TEST_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/grid/grid_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/grid/grid_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5ac93d0f325520da80661aa7f5556f6c5ea5f560 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/grid/grid_test.cpp @@ -0,0 +1,472 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "grid_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "component.h" +#include "flowitem_component.h" +#include "grid_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +constexpr int32_t GRID_ITEM_COUNT = 24; +constexpr int32_t GRID_ITEM_COUNT_80 = 80; +static void OnAdapterEventReceive(ArkUI_NodeAdapterEvent* event) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + int type = OH_ArkUI_NodeAdapterEvent_GetType(event); + if (type == NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER) { + int32_t index = OH_ArkUI_NodeAdapterEvent_GetItemIndex(event); + auto gridItem = new Component(ARKUI_NODE_GRID_ITEM); + auto text = new TextComponent(); + if (index == GRID_ITEM_COUNT_80 - 1) { + gridItem->SetBackgroundColor(COLOR_RED); + } else { + gridItem->SetBackgroundColor(COLOR_YELLOW); + } + gridItem->SetBorderWidth(SIZE_5); + gridItem->SetBorderColor(COLOR_GRAY, COLOR_GRAY, COLOR_GRAY, COLOR_GRAY); + gridItem->SetWidth(SIZE_50); + gridItem->SetHeight(SIZE_50); + nodeAPI->addChild(gridItem->GetComponent(), text->GetComponent()); + OH_ArkUI_NodeAdapterEvent_SetItem(event, gridItem->GetComponent()); + } +} +void CreateGridItem(const std::shared_ptr>& adapter, bool isShowText = false) +{ + for (int i = 0; i < GRID_ITEM_COUNT; i++) { + auto item = std::make_shared(); + item->SetWidth(100); + item->SetHeight(100); + item->SetBackgroundColor(COLOR_YELLOW); + item->SetBorderWidth(1); + item->SetMargin(10); + auto text = std::make_shared(); + if (isShowText) { + text->SetTextContent(std::to_string(i)); + } + item->AddChild(text); + adapter->InsertItem(i, item); + } +} + +ArkUI_NodeHandle CreateGridExample1() +{ + // 创建grid组件懒加载回调 + auto adapter = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter, GRID_ITEM_COUNT_80); + ArkUI_AttributeItem adapterItem { .object = adapter }; + + // 创建grid组件,同时设置NODE_GRID_COLUMN_TEMPLATE,NODE_GRID_ROW_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP + auto grid = new GridComponent(); + grid->SetWidth(SIZE_450); + grid->SetHeight(SIZE_180); + // 设置columnsTemplate:NODE_GRID_COLUMN_TEMPLATE + grid->SetGridColumnsTemplate("1fr 1fr 1fr 1fr 1fr"); + // 设置columnsTemplate:NODE_GRID_ROW_TEMPLATE + grid->SetGridRowsTemplate("1fr 1fr 1fr 1fr"); + // 设置columnsGap:NODE_GRID_COLUMN_GAP + grid->SetGridColumnsGap(SIZE_10); + // 设置rowGap:NODE_GRID_ROW_GAP + grid->SetGridRowsGap(SIZE_5); + grid->SetBorderWidth(SIZE_5); + grid->SetMargin(SIZE_5); + grid->setAttribute(NODE_GRID_NODE_ADAPTER, &adapterItem); + return grid->GetComponent(); +} + +ArkUI_NodeHandle CreategridColumnExample1() +{ + auto adapter = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter, GRID_ITEM_COUNT_80); + ArkUI_AttributeItem adapterItem { .object = adapter }; + + // 创建grid组件,只设置NODE_GRID_COLUMN_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP,,NODE_GRID_CACHED_COUNT异常值 + auto grid1Column = new ColumnComponent(); + grid1Column->SetId("grid1"); + auto grid = new GridComponent(); + grid->SetWidth(SIZE_450); + grid->SetHeight(SIZE_180); + // 设置columnsTemplate:NODE_GRID_COLUMN_TEMPLATE + grid->SetGridColumnsTemplate("1fr 1fr 1fr 1fr 1fr"); + // 设置columnsGap:NODE_GRID_COLUMN_GAP + grid->SetGridColumnsGap(SIZE_10); + // 设置rowGap:NODE_GRID_ROW_GAP + grid->SetGridRowsGap(SIZE_5); + grid->SetBorderWidth(SIZE_5); + grid->SetMargin(SIZE_5); + grid->setAttribute(NODE_GRID_NODE_ADAPTER, &adapterItem); + grid1Column->AddChild(std::shared_ptr(grid)); + return grid1Column->GetComponent(); +} +ArkUI_NodeHandle CreategridColumnExample2() +{ + auto adapter2 = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter2, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter2, GRID_ITEM_COUNT_80); + ArkUI_AttributeItem adapterItem2 { .object = adapter2 }; + + // 创建grid组件,只设置NODE_GRID_ROW_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP,NODE_GRID_CACHED_COUNT正常值 + auto grid2Column = new ColumnComponent(); + grid2Column->SetId("grid2"); + auto grid = new GridComponent(); + grid->SetWidth(SIZE_450); + grid->SetHeight(SIZE_180); + // 设置columnsTemplate:NODE_GRID_ROW_TEMPLATE + grid->SetGridRowsTemplate("1fr 1fr 1fr 1fr"); + // 设置columnsGap:NODE_GRID_COLUMN_GAP + grid->SetGridColumnsGap(SIZE_10); + // 设置rowGap:NODE_GRID_ROW_GAP + grid->SetGridRowsGap(SIZE_5); + + grid->SetGridRowsGap(SIZE_5); + grid->SetBorderWidth(SIZE_5); + grid->SetMargin(SIZE_5); + grid->setAttribute(NODE_GRID_NODE_ADAPTER, &adapterItem2); + grid2Column->AddChild(std::shared_ptr(grid)); + return grid2Column->GetComponent(); +} +ArkUI_NodeHandle CreategridExample3() +{ + auto adapter3 = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter3, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter3, GRID_ITEM_COUNT_80); + ArkUI_AttributeItem adapterItem3 { .object = adapter3 }; + + // 创建grid组件,设置异常值:NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_TEMPLATE + auto grid = new GridComponent(); + grid->SetWidth(SIZE_230); + grid->SetHeight(SIZE_180); + // 设置columnsTemplate异常值,NODE_GRID_COLUMN_TEMPLATE + grid->SetGridColumnsTemplate("abc"); + // 设置rowTemplate异常值,NODE_GRID_ROW_TEMPLATE + grid->SetGridRowsTemplate("ddd,ccc"); + grid->setAttribute(NODE_GRID_NODE_ADAPTER, &adapterItem3); + grid->SetBorderWidth(SIZE_5); + grid->SetMargin(SIZE_5); + return grid->GetComponent(); +} +ArkUI_NodeHandle CreategridExample4() +{ + auto adapter4 = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter4, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter4, GRID_ITEM_COUNT_80); + ArkUI_AttributeItem adapterItem4 { .object = adapter4 }; + + // 创建grid组件,设置异常值:NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP + auto grid = new GridComponent(); + grid->SetWidth(SIZE_230); + grid->SetHeight(SIZE_180); + // 设置columnsGap异常值,NODE_GRID_COLUMN_GAP + grid->SetGridColumnsGap(PARAM_NEGATIVE_1); + // 设置rowGap异常值,NODE_GRID_ROW_GAP + grid->SetGridRowsGap(PARAM_NEGATIVE_1); + + grid->setAttribute(NODE_GRID_NODE_ADAPTER, &adapterItem4); + grid->SetBorderWidth(SIZE_5); + grid->SetMargin(SIZE_5); + return grid->GetComponent(); +} + +napi_value GridTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建grid组件,同时设置NODE_GRID_COLUMN_TEMPLATE,NODE_GRID_ROW_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP + auto grid = CreateGridExample1(); + // 创建grid组件,只设置NODE_GRID_COLUMN_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP,,NODE_GRID_CACHED_COUNT异常值 + auto grid1Column = CreategridColumnExample1(); + // 创建grid组件,只设置NODE_GRID_ROW_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP,NODE_GRID_CACHED_COUNT正常值 + auto grid2Column = CreategridColumnExample2(); + // 创建grid组件,设置异常值:NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_TEMPLATE + auto grid3 = CreategridExample3(); + // 创建grid组件,设置异常值:NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP + auto grid4 = CreategridExample4(); + + // parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + nodeAPI->addChild(parentColumn, grid); + nodeAPI->addChild(parentColumn, grid1Column); + nodeAPI->addChild(parentColumn, grid2Column); + nodeAPI->addChild(parentColumn, row); + nodeAPI->addChild(row, grid3); + nodeAPI->addChild(row, grid4); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value GridTest::CreateNativeNodeForCachedCount(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "CreateNativeNodeForCachedCount"); + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto grid1Column = new ColumnComponent(); + grid1Column->SetId("gridCachedCount1"); + auto grid1 = new GridComponent(); + grid1->SetWidth(450); + grid1->SetHeight(200); + grid1->SetGridRowsTemplate("1fr 1fr 1fr 1fr"); + grid1->SetBorderWidth(5); + + std::vector> input1; + auto adapter1 = std::make_shared>(input1); + grid1->SetLazyAdapter(adapter1); + // 设置cacheCount异常值:-1 + grid1->SetGridCachedCount(-1); + CreateGridItem(adapter1); + + auto grid2 = new GridComponent(); + auto grid2Column = new ColumnComponent(); + grid2Column->SetId("gridCachedCount2"); + grid2->SetWidth(450); + grid2->SetHeight(200); + grid2->SetGridColumnsTemplate("1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr"); + grid2->SetBorderWidth(5); + std::vector> input2; + auto adapter2 = std::make_shared>(input2); + grid2->SetLazyAdapter(adapter2); + // 设置cacheCount异常值:0 + grid2->SetGridCachedCount(0); + CreateGridItem(adapter2); + + auto grid3 = new GridComponent(); + auto grid3Column = new ColumnComponent(); + grid3Column->SetId("gridCachedCount3"); + grid3->SetWidth(450); + grid3->SetHeight(200); + grid3->SetBorderWidth(5); + grid3->SetGridRowsTemplate("1fr 1fr 1fr"); + std::vector> input3; + auto adapter3 = std::make_shared>(input3); + grid3->SetLazyAdapter(adapter3); + // 设置cacheCount正常值2 + grid3->SetGridCachedCount(2); + CreateGridItem(adapter3); + + auto button = new ButtonComponent(); + button->SetWidth(100); + button->SetHeight(50); + button->SetMargin(10); + button->SetId("gridClick"); + button->RegisterOnClick([adapter1, adapter2, adapter3]() { + adapter1->SetAllItem([](std::shared_ptr item, uint32_t index) { + auto children = item->GetChildren(); + if (!children.empty()) { + children.front()->SetBackgroundColor(COLOR_GREEN); + } + }); + adapter2->SetAllItem([](std::shared_ptr item, uint32_t index) { + auto children = item->GetChildren(); + if (!children.empty()) { + children.front()->SetBackgroundColor(COLOR_GREEN); + } + }); + adapter3->SetAllItem([](std::shared_ptr item, uint32_t index) { + auto children = item->GetChildren(); + if (!children.empty()) { + children.front()->SetBackgroundColor(COLOR_GREEN); + } + }); + }); + + parentColumn->AddChild(std::shared_ptr(grid1Column)); + grid1Column->AddChild(std::shared_ptr(grid1)); + + parentColumn->AddChild(std::shared_ptr(grid2Column)); + grid2Column->AddChild(std::shared_ptr(grid2)); + + parentColumn->AddChild(std::shared_ptr(grid3Column)); + grid3Column->AddChild(std::shared_ptr(grid3)); + + parentColumn->AddChild(std::shared_ptr(button)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value GridTest::CreateNativeNodeForResetAttribute(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "CreateNativeNodeForResetAttribute"); + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto grid1Column = new ColumnComponent(); + auto grid1 = new GridComponent(); + grid1->SetWidth(400); + grid1->SetHeight(180); + grid1->SetGridRowsTemplate("1fr 1fr 1fr 1fr"); + grid1->SetBorderWidth(5); + + std::vector> input1; + auto adapter1 = std::make_shared>(input1); + grid1->SetLazyAdapter(adapter1); + CreateGridItem(adapter1, false); + + auto grid2 = new GridComponent(); + auto grid2Column = new ColumnComponent(); + grid2->SetWidth(400); + grid2->SetHeight(180); + grid2->SetGridColumnsTemplate("1fr 1fr 1fr 1fr 1fr"); + grid2->SetBorderWidth(5); + std::vector> input2; + auto adapter2 = std::make_shared>(input2); + grid2->SetLazyAdapter(adapter2); + CreateGridItem(adapter2, false); + + auto grid3 = new GridComponent(); + auto grid3Column = new ColumnComponent(); + grid3->SetWidth(400); + grid3->SetHeight(180); + grid3->SetBorderWidth(5); + grid3->SetGridColumnsTemplate("1fr 1fr 1fr 1fr 1fr"); + grid3->SetGridRowsGap(10); + grid3->SetGridColumnsGap(10); + std::vector> input3; + auto adapter3 = std::make_shared>(input3); + grid3->SetLazyAdapter(adapter3); + CreateGridItem(adapter3, false); + + auto grid4 = new GridComponent(); + auto grid4Column = new ColumnComponent(); + grid4->SetWidth(400); + grid4->SetHeight(180); + grid4->SetBorderWidth(5); + grid4->SetGridRowsGap(10); + grid4->SetGridRowsTemplate("1fr 1fr 1fr 1fr"); + std::vector> input4; + auto adapter4 = std::make_shared>(input4); + grid4->SetLazyAdapter(adapter4); + CreateGridItem(adapter4, false); + + auto button = new ButtonComponent(); + button->SetWidth(100); + button->SetHeight(50); + button->SetMargin(10); + button->SetId("GridReset"); + button->RegisterOnClick([grid1, grid2, grid3, grid4]() { + grid1->resetAttribute(NODE_GRID_ROW_TEMPLATE); // 默认值:"1r" + grid2->resetAttribute(NODE_GRID_COLUMN_TEMPLATE); // 默认值:"1r" + grid3->resetAttribute(NODE_GRID_COLUMN_GAP); // 默认值:0 + grid4->resetAttribute(NODE_GRID_ROW_GAP); // 默认值:0 + }); + + parentColumn->AddChild(std::shared_ptr(grid1Column)); + grid1Column->AddChild(std::shared_ptr(grid1)); + + parentColumn->AddChild(std::shared_ptr(grid2Column)); + grid2Column->AddChild(std::shared_ptr(grid2)); + + parentColumn->AddChild(std::shared_ptr(grid3Column)); + grid3Column->AddChild(std::shared_ptr(grid3)); + + parentColumn->AddChild(std::shared_ptr(grid4Column)); + grid3Column->AddChild(std::shared_ptr(grid4)); + + parentColumn->AddChild(std::shared_ptr(button)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "GridTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/grid/grid_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/grid/grid_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3b1e4a4c30362471c5c578add4dbf8f767616e81 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/grid/grid_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_GRID_TEST_H +#define ARKUI_CAPI_DEMO_GRID_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class GridTest { +public: + ~GridTest(); + // GridTest:testGrid001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // Testcase:testGrid002 + static napi_value CreateNativeNodeForCachedCount(napi_env env, napi_callback_info info); + // Testcase:testGrid003 + static napi_value CreateNativeNodeForResetAttribute(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_GRID_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_downprogress_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_downprogress_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af5583e19ddec8984a7665cd193f2b4df840a103 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_downprogress_test.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_downprogress_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "column_component.h" +#include "image_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +ColumnComponent* column; +TextComponent* textShow; +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageDownProgressTest", + "OnEventReceive eventType: %{public}d,NODE_IMAGE_ON_DOWNLOAD_PROGRESS=%{public}d", eventType, + NODE_IMAGE_ON_DOWNLOAD_PROGRESS); + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + int32_t dlNow = result->data[0].u32; + int32_t dlTotal = result->data[1].u32; + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageDownProgressTest", "dlNow: %{public}d,dlTotal=%{public}d", + dlNow, dlTotal); + textShow->SetBackgroundColor(COLOR_RED); +} + +napi_value ImageDownProgressTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageDownProgressTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageDownProgressTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + column = new ColumnComponent(); + auto image = new ImageComponent(); + image->SetWidth(SIZE_300); + image->SetHeight(SIZE_300); + image->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE); + // 相同网络图片加载过一次后,如果hap包不重新安装会优先加载缓存的图片,不会重新下载。 + // 这时不会收到NODE_IMAGE_ON_DOWNLOAD_PROGRESS的回调事件。 + image->SetImageSrc("https://gitee.com/openharmony/docs/raw/master/zh-cn/application-dev/reference/apis-arkui/" + "arkui-ts/figures/edgewidths.png"); + nodeAPI->registerNodeEvent(image->GetComponent(), NODE_IMAGE_ON_DOWNLOAD_PROGRESS, 0, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + textShow = new TextComponent(); + textShow->SetBackgroundColor(COLOR_GRAY); + textShow->SetWidth(SIZE_100); + textShow->SetHeight(SIZE_100); + + // 添加组件到容器 + column->AddChild(std::shared_ptr(image)); + column->AddChild(std::shared_ptr(textShow)); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageDownProgressTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_downprogress_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_downprogress_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e8ffed4bf9c311482f8e80c8e285129dcf5d12e5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_downprogress_test.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_IMAGE_DOWNRROGRESS_TEST_H +#define ARKUI_CAPI_DEMO_IMAGE_DOWNRROGRESS_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImageDownProgressTest { +public: + ~ImageDownProgressTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_DOWNRROGRESS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_draggable_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_draggable_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..46a14132b9ec229818791c6003cc25f57db91abe --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_draggable_test.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_draggable_test.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "column_component.h" +#include "image_component.h" +#include "row_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +ImageComponent* dropImageAreaTrue; +TextComponent* textTrue; +ImageComponent* dropImageAreaFalse; +TextComponent* textFalse; +ImageComponent* dropImageAreaReset; +TextComponent* textReset; +napi_value ImageDraggableTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "imageNODEIMAGEDRAGGABLETest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "imageNODEIMAGEDRAGGABLETest", "GetConimage env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // image设置NODE_IMAGE_DRAGGABLE为true, 可以拖动,在落入区可以通过设置的回调设置对应text变为红色 + auto row1 = new RowComponent(); + auto imageTrue = new ImageComponent(); + imageTrue->SetImageSrc("./resources/base/media/icon.png"); + imageTrue->SetWidth(SIZE_100); + imageTrue->SetHeight(SIZE_100); + imageTrue->SetImageDraggable(true); + imageTrue->SetId("imageDragTrue"); + dropImageAreaTrue = new ImageComponent(); + dropImageAreaTrue->SetWidth(SIZE_200); + dropImageAreaTrue->SetHeight(SIZE_200); + dropImageAreaTrue->SetBorderWidth(SIZE_5); + dropImageAreaTrue->SetMargin(SIZE_10); + dropImageAreaTrue->SetId("dropImageAreaTrue"); + textTrue = new TextComponent(); + textTrue->SetWidth(SIZE_100); + textTrue->SetHeight(SIZE_100); + textTrue->SetBackgroundColor(COLOR_GRAY); + textTrue->SetMargin(SIZE_10); + nodeAPI->registerNodeEvent(imageTrue->GetComponent(), NODE_ON_DRAG_START, 0, nullptr); + + // image设置NODE_IMAGE_DRAGGABLE为false, 不可拖动,没有落入区的落入回调事件。 + auto row2 = new RowComponent(); + auto imageFalse = new ImageComponent(); + imageFalse->SetImageSrc("./resources/base/media/icon.png"); + imageFalse->SetWidth(SIZE_100); + imageFalse->SetHeight(SIZE_100); + imageFalse->SetImageDraggable(false); + imageFalse->SetId("imageDragFalse"); + dropImageAreaFalse = new ImageComponent(); + dropImageAreaFalse->SetWidth(SIZE_200); + dropImageAreaFalse->SetHeight(SIZE_200); + dropImageAreaFalse->SetBorderWidth(SIZE_5); + dropImageAreaFalse->SetMargin(SIZE_10); + dropImageAreaFalse->SetId("dropImageAreaFalse"); + textFalse = new TextComponent(); + textFalse->SetWidth(SIZE_100); + textFalse->SetHeight(SIZE_100); + textFalse->SetBackgroundColor(COLOR_GRAY); + textFalse->SetMargin(SIZE_10); + nodeAPI->registerNodeEvent(imageFalse->GetComponent(), NODE_ON_DRAG_START, 1, nullptr); + // image设置NODE_IMAGE_DRAGGABLE为false, 调用Reset设置Reset属性,默认属性为true,有落入区的落入回调事件。 + auto row3 = new RowComponent(); + auto imageReset = new ImageComponent(); + imageReset->SetImageSrc("./resources/base/media/icon.png"); + imageReset->SetWidth(SIZE_100); + imageReset->SetHeight(SIZE_100); + imageReset->SetImageDraggable(true); + imageReset->SetId("imageDragReset"); + dropImageAreaReset = new ImageComponent(); + dropImageAreaReset->SetWidth(SIZE_200); + dropImageAreaReset->SetHeight(SIZE_200); + dropImageAreaReset->SetBorderWidth(SIZE_5); + dropImageAreaReset->SetMargin(SIZE_10); + dropImageAreaReset->SetId("dropImageAreaReset"); + textReset = new TextComponent(); + textReset->SetWidth(SIZE_100); + textReset->SetHeight(SIZE_100); + textReset->SetBackgroundColor(COLOR_GRAY); + textReset->SetMargin(SIZE_10); + imageReset->resetAttribute(NODE_IMAGE_DRAGGABLE); + nodeAPI->registerNodeEvent(imageReset->GetComponent(), NODE_ON_DRAG_START, 2, nullptr); + // 设置落入区回调 + nodeAPI->registerNodeEventReceiver([](ArkUI_NodeEvent* event) { + auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); + auto targetId = OH_ArkUI_NodeEvent_GetTargetId(event); + auto* dragEvent = OH_ArkUI_NodeEvent_GetDragEvent(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "imageNODEIMAGEDRAGGABLETest", + "dragEvent = %{public}p,eventType=%{public}d,", dragEvent, eventType); + switch (eventType) { + case NODE_ON_DRAG_START: { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "imageNODEIMAGEDRAGGABLETest", + "dragTest image_DROP NODE_ON_DROP EventReceiver"); + if (targetId == 0) { + textTrue->SetBackgroundColor(COLOR_RED); + } else if (targetId == 1) { + textFalse->SetBackgroundColor(COLOR_RED); + } else if (targetId == 2) { + textReset->SetBackgroundColor(COLOR_RED); + } + } + default: { + return; + } + } + }); + + row1->AddChild(std::shared_ptr(imageTrue)); + row1->AddChild(std::shared_ptr(dropImageAreaTrue)); + row1->AddChild(std::shared_ptr(textTrue)); + + row2->AddChild(std::shared_ptr(imageFalse)); + row2->AddChild(std::shared_ptr(dropImageAreaFalse)); + row2->AddChild(std::shared_ptr(textFalse)); + + row3->AddChild(std::shared_ptr(imageReset)); + row3->AddChild(std::shared_ptr(dropImageAreaReset)); + row3->AddChild(std::shared_ptr(textReset)); + + nodeAPI->addChild(column, row1->GetComponent()); + nodeAPI->addChild(column, row2->GetComponent()); + nodeAPI->addChild(column, row3->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "imageNODEIMAGEDRAGGABLETest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_draggable_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_draggable_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ae816e90151202b07aedf36d484bd5ea8bc3e166 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_draggable_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_DRAGGABLE_TEST_H +#define ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_DRAGGABLE_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImageDraggableTest { +public: + ~ImageDraggableTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_DRAGGABLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fillcolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fillcolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ebab774332527d4c32e6fbce0c522ab8aaac833d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fillcolor_test.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_fillcolor_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" + +namespace ArkUICApiDemo { +napi_value ImageFillColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFillColorTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFillColorTest", "GetConimage env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto columnParent = new ColumnComponent(); + auto image = new ImageComponent(); + image->SetWidth(SIZE_200); + image->SetHeight(SIZE_200); + image->SetImageSrc("./resources/base/media/maskL1_133.svg"); + image->SetImageFillColor(COLOR_RED); + image->SetMargin(SIZE_10); + + // Reset fillColor + auto image1 = new ImageComponent(); + image1->SetWidth(SIZE_200); + image1->SetHeight(SIZE_200); + + image1->SetImageSrc("./resources/base/media/maskL1_133.svg"); + image1->SetImageFillColor(COLOR_BLUE); + image1->SetMargin(SIZE_10); + auto resetButton = new ButtonComponent(); + resetButton->SetWidth(SIZE_100); + resetButton->SetHeight(SIZE_50); + resetButton->SetId("resetFillColor"); + resetButton->RegisterOnClick([image1]() { + // reset fillColor 属性 + image1->resetAttribute(NODE_IMAGE_FILL_COLOR); + }); + + // 添加组件到容器 + columnParent->AddChild(std::shared_ptr(image)); + columnParent->AddChild(std::shared_ptr(image1)); + columnParent->AddChild(std::shared_ptr(resetButton)); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), columnParent->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFillColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fillcolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fillcolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..dbc874cf311adec50ed1903c9bb42d90b0e47286 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fillcolor_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGE_FILLCOLOR_H +#define ARKUI_CAPI_DEMO_IMAGE_FILLCOLOR_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImageFillColorTest { +public: + ~ImageFillColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_FILLCOLOR_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fitoriginalSize_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fitoriginalSize_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..06bd4c05adf2d49179ec48266847f2033763799b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fitoriginalSize_test.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_fitoriginalSize_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { +napi_value ImageFitOriginalSizeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFitOriginalSizeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFitOriginalSizeTest", "GetConimage env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto columnParent = new ColumnComponent(); + // 设置fitOriginalSize正常值1,跟随原图片大小 + auto row1 = new RowComponent(); + row1->SetWidth(SIZE_400); + row1->SetHeight(SIZE_200); + auto image = new ImageComponent(); + image->SetImageSrc("./resources/base/media/icon.png"); + image->SetImageFitOriginalSize(1); + image->SetMargin(SIZE_10); + // 设置fitOriginalSize正常值0,不跟随原图片大小 + auto image1 = new ImageComponent(); + image1->SetImageSrc("./resources/base/media/icon.png"); + image1->SetImageFitOriginalSize(0); + image1->SetMargin(SIZE_10); + + // 设置fitOriginalSize正常值1,reset该属性,默认值为0 + auto row2 = new RowComponent(); + row2->SetWidth(SIZE_400); + row2->SetHeight(SIZE_200); + auto image2 = new ImageComponent(); + image2->SetImageSrc("./resources/base/media/icon.png"); + image2->SetImageFitOriginalSize(1); + image2->SetMargin(SIZE_10); + auto resetButton = new ButtonComponent(); + resetButton->SetWidth(SIZE_100); + resetButton->SetHeight(SIZE_50); + resetButton->SetId("resetFitOriginalSize"); + resetButton->RegisterOnClick([image2]() { + // 设置fitOriginalSize正常值1,reset该属性,默认值为0 + image2->resetAttribute(NODE_IMAGE_FIT_ORIGINAL_SIZE); + }); + + // 设置fitOriginalSize异常值-1,应为默认值为0的效果 + auto row3 = new RowComponent(); + row3->SetWidth(SIZE_400); + row3->SetHeight(SIZE_200); + auto image3 = new ImageComponent(); + image3->SetImageSrc("./resources/base/media/icon.png"); + image3->SetImageFitOriginalSize(PARAM_NEGATIVE_1); + image3->SetMargin(SIZE_10); + + // 添加组件到容器 + row1->AddChild(std::shared_ptr(image)); + row1->AddChild(std::shared_ptr(image1)); + columnParent->AddChild(std::shared_ptr(row1)); + + row2->AddChild(std::shared_ptr(image2)); + row2->AddChild(std::shared_ptr(resetButton)); + columnParent->AddChild(std::shared_ptr(row2)); + + row3->AddChild(std::shared_ptr(image3)); + columnParent->AddChild(std::shared_ptr(row3)); + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), columnParent->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFitOriginalSizeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fitoriginalSize_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fitoriginalSize_test.h new file mode 100644 index 0000000000000000000000000000000000000000..eda0045b94629a66991f15850da220a2baa49376 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_fitoriginalSize_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IAMGE_FITORIGINALSIZE_TEST_H +#define ARKUI_CAPI_DEMO_IAMGE_FITORIGINALSIZE_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImageFitOriginalSizeTest { +public: + ~ImageFitOriginalSizeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IAMGE_FITORIGINALSIZE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_objectfit_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_objectfit_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ae7574c4a8f77330da562468928e85ed64615bab --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_objectfit_test.cpp @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_objectfit_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +napi_value ImageObjectFitTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageObjectFitTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageObjectFitTest", "GetConimage env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto columnParent = new ColumnComponent(); + // 设置objectFit属性值为正常值:ArkUI_ObjectFit的枚举 + auto row1 = new RowComponent(); + auto image = new ImageComponent(); + image->SetWidth(SIZE_100); + image->SetHeight(SIZE_120); + image->SetImageSrc("./resources/base/media/icon.png"); + image->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_CONTAIN); + image->SetMargin(SIZE_5); + image->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image->SetBorderWidth(2); + + auto image1 = new ImageComponent(); + image1->SetWidth(SIZE_100); + image1->SetHeight(SIZE_120); + image1->SetImageSrc("./resources/base/media/icon.png"); + image1->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_COVER); + image1->SetMargin(SIZE_5); + image1->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image->SetBorderWidth(2); + + auto image2 = new ImageComponent(); + image2->SetWidth(SIZE_100); + image2->SetHeight(SIZE_120); + image2->SetImageSrc("./resources/base/media/icon.png"); + image2->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_AUTO); + image2->SetMargin(SIZE_5); + image2->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image2->SetBorderWidth(2); + + auto row2 = new RowComponent(); + auto image3 = new ImageComponent(); + image3->SetWidth(SIZE_100); + image3->SetHeight(SIZE_120); + image3->SetImageSrc("./resources/base/media/icon.png"); + image3->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_FILL); + image3->SetMargin(SIZE_5); + image3->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image3->SetBorderWidth(2); + + auto image4 = new ImageComponent(); + image4->SetWidth(SIZE_100); + image4->SetHeight(SIZE_120); + image4->SetImageSrc("./resources/base/media/icon.png"); + image4->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_SCALE_DOWN); + image4->SetMargin(SIZE_5); + image4->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image4->SetBorderWidth(2); + + auto image5 = new ImageComponent(); + image5->SetWidth(SIZE_100); + image5->SetHeight(SIZE_120); + image5->SetImageSrc("./resources/base/media/icon.png"); + image5->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE); + image5->SetMargin(SIZE_5); + image5->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image5->SetBorderWidth(2); + + auto row3 = new RowComponent(); + auto image6 = new ImageComponent(); + image6->SetWidth(SIZE_100); + image6->SetHeight(SIZE_120); + image6->SetImageSrc("./resources/base/media/icon.png"); + image6->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_TOP_START); + image6->SetMargin(SIZE_5); + image6->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image6->SetBorderWidth(2); + + auto image7 = new ImageComponent(); + image7->SetWidth(SIZE_100); + image7->SetHeight(SIZE_120); + image7->SetImageSrc("./resources/base/media/icon.png"); + image7->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_TOP); + image7->SetMargin(SIZE_5); + image7->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image7->SetBorderWidth(2); + + auto image8 = new ImageComponent(); + image8->SetWidth(SIZE_100); + image8->SetHeight(SIZE_120); + image8->SetImageSrc("./resources/base/media/icon.png"); + image8->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_TOP_END); + image8->SetMargin(SIZE_5); + image8->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image8->SetBorderWidth(2); + + auto row4 = new RowComponent(); + auto image9 = new ImageComponent(); + image9->SetWidth(SIZE_100); + image9->SetHeight(SIZE_120); + image9->SetImageSrc("./resources/base/media/icon.png"); + image9->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_START); + image9->SetMargin(SIZE_5); + image9->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image9->SetBorderWidth(2); + + auto image10 = new ImageComponent(); + image10->SetWidth(SIZE_100); + image10->SetHeight(SIZE_120); + image10->SetImageSrc("./resources/base/media/icon.png"); + image10->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_CENTER); + image10->SetMargin(SIZE_5); + image10->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image10->SetBorderWidth(2); + + auto image11 = new ImageComponent(); + image11->SetWidth(SIZE_100); + image11->SetHeight(SIZE_120); + image11->SetImageSrc("./resources/base/media/icon.png"); + image11->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_END); + image11->SetMargin(SIZE_5); + image11->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image11->SetBorderWidth(2); + + auto row5 = new RowComponent(); + auto image12 = new ImageComponent(); + image12->SetWidth(SIZE_100); + image12->SetHeight(SIZE_120); + image12->SetImageSrc("./resources/base/media/icon.png"); + image12->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_BOTTOM_START); + image12->SetMargin(SIZE_5); + image12->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image12->SetBorderWidth(2); + + auto image13 = new ImageComponent(); + image13->SetWidth(SIZE_100); + image13->SetHeight(SIZE_120); + image13->SetImageSrc("./resources/base/media/icon.png"); + image13->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_BOTTOM); + image13->SetMargin(SIZE_5); + image13->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image13->SetBorderWidth(2); + + auto image14 = new ImageComponent(); + image14->SetWidth(SIZE_100); + image14->SetHeight(SIZE_120); + image14->SetImageSrc("./resources/base/media/icon.png"); + image14->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE_AND_ALIGN_BOTTOM_END); + image14->SetMargin(SIZE_5); + image14->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image14->SetBorderWidth(2); + + // 添加组件到容器 + row1->AddChild(std::shared_ptr(image)); + row1->AddChild(std::shared_ptr(image1)); + row1->AddChild(std::shared_ptr(image2)); + + row2->AddChild(std::shared_ptr(image3)); + row2->AddChild(std::shared_ptr(image4)); + row2->AddChild(std::shared_ptr(image5)); + + row3->AddChild(std::shared_ptr(image6)); + row3->AddChild(std::shared_ptr(image7)); + row3->AddChild(std::shared_ptr(image8)); + + row4->AddChild(std::shared_ptr(image9)); + row4->AddChild(std::shared_ptr(image10)); + row4->AddChild(std::shared_ptr(image11)); + + row5->AddChild(std::shared_ptr(image12)); + row5->AddChild(std::shared_ptr(image13)); + row5->AddChild(std::shared_ptr(image14)); + + columnParent->AddChild(std::shared_ptr(row1)); + columnParent->AddChild(std::shared_ptr(row2)); + columnParent->AddChild(std::shared_ptr(row3)); + columnParent->AddChild(std::shared_ptr(row4)); + columnParent->AddChild(std::shared_ptr(row5)); + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), columnParent->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageObjectFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value ImageObjectFitTest::CreateNativeNodeForResetAndAbnormal(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageObjectFitTest", "CreateNativeNodeForResetAndAbnormal"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageObjectFitTest", "GetConimage env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto columnParent = new ColumnComponent(); + // Reset objectFit属性值 + auto row2 = new RowComponent(); + auto image2 = new ImageComponent(); + image2->SetWidth(SIZE_100); + image2->SetHeight(SIZE_200); + image2->SetImageSrc("./resources/base/media/icon.png"); + image2->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_CONTAIN); + image2->SetMargin(SIZE_10); + image2->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image2->SetBorderWidth(2); + auto resetButton = new ButtonComponent(); + resetButton->SetWidth(SIZE_100); + resetButton->SetHeight(SIZE_50); + resetButton->SetId("resetObjectFit"); + resetButton->RegisterOnClick([image2]() { + // reset object_fit 属性,默认属性值为:ArkUI_ObjectFit::ARKUI_OBJECT_FIT_COVER + image2->resetAttribute(NODE_IMAGE_OBJECT_FIT); + }); + + // 设置objectFit属性值为异常值:-1 + auto image3 = new ImageComponent(); + image3->SetWidth(SIZE_100); + image3->SetHeight(SIZE_200); + image3->SetImageSrc("./resources/base/media/icon.png"); + image3->SetObjectFit(PARAM_NEGATIVE_1); + image3->SetMargin(SIZE_10); + image3->SetBorderColor(COLOR_RED, COLOR_RED, COLOR_RED, COLOR_RED); + image3->SetBorderWidth(2); + + columnParent->AddChild(std::shared_ptr(resetButton)); + columnParent->AddChild(std::shared_ptr(image2)); + columnParent->AddChild(std::shared_ptr(image3)); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), columnParent->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageObjectFitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_objectfit_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_objectfit_test.h new file mode 100644 index 0000000000000000000000000000000000000000..175f4469d51f30af289491b04b28e10606b2b132 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_objectfit_test.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_OBJECT_FIT_TEST_H +#define ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_OBJECT_FIT_TEST_H +#include +#include +#include + +#include "../common/common.h" +namespace ArkUICApiDemo { +class ImageObjectFitTest { +public: + ~ImageObjectFitTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeForResetAndAbnormal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_OBJECT_FIT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_onfinish_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_onfinish_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..97a5d4c9627f9d725f5c0efe191ff890a9b4f64d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_onfinish_test.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_onfinish_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +ImageComponent* image; +TextComponent* text; +ColumnComponent* columnParent; +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageOnFinishTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageOnFinishTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageOnFinishTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + if (eventId == 1) { + nodeAPI->removeChild(columnParent->GetComponent(), image->GetComponent()); + } else if (eventId == 0) { + text->SetBackgroundColor(COLOR_RED); + } +} + +napi_value ImageOnFinishTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageOnFinishTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageOnFinishTest", "GetConimage env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + columnParent = new ColumnComponent(); + // 设置不停止动画的svg,期待onfinish不回调 + image = new ImageComponent(); + image->SetWidth(SIZE_200); + image->SetHeight(SIZE_200); + image->SetImageSrc("./resources/base/media/animated_circle.svg"); + image->SetMargin(SIZE_10); + text = new TextComponent(); + text->SetWidth(SIZE_200); + text->SetHeight(SIZE_200); + text->SetBackgroundColor(COLOR_GRAY); + // 设置动画完成后的onfinish回调 + nodeAPI->registerNodeEvent(image->GetComponent(), NODE_IMAGE_ON_SVG_PLAY_FINISH, 0, nullptr); + + // 设置5秒后停止的svg,期待onfinish回调,并隐藏第一个image + auto image1 = new ImageComponent(); + image1->SetWidth(SIZE_200); + image1->SetHeight(SIZE_200); + image1->SetImageSrc("./resources/base/media/animated_circle_stop.svg"); + image1->SetMargin(SIZE_10); + // 设置动画完成后的onfinish回调 + nodeAPI->registerNodeEvent(image1->GetComponent(), NODE_IMAGE_ON_SVG_PLAY_FINISH, 1, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // 添加组件到容器 + columnParent->AddChild(std::shared_ptr(image)); + columnParent->AddChild(std::shared_ptr(text)); + columnParent->AddChild(std::shared_ptr(image1)); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), columnParent->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageOnFinishTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_onfinish_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_onfinish_test.h new file mode 100644 index 0000000000000000000000000000000000000000..086f84692a94b68bd3be4b4e0491ccd00d774fcd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_onfinish_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGE_ONFINISH_H +#define ARKUI_CAPI_DEMO_IMAGE_ONFINISH_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImageOnFinishTest { +public: + ~ImageOnFinishTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_ONFINISH_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_rendermode_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_rendermode_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b33e6808a8d9e6b83c3b1d0430f47e95f3982d75 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_rendermode_test.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_rendermode_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +napi_value ImageRenderModeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRenderModeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRenderModeTest", "GetConimage env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto columnParent = new ColumnComponent(); + auto row1 = new RowComponent(); + // 设置renderMode属性值为正常值:ARKUI_IMAGE_RENDER_MODE_ORIGINAL + auto image = new ImageComponent(); + image->SetWidth(SIZE_200); + image->SetHeight(SIZE_200); + image->SetImageSrc("./resources/base/media/icon.png"); + image->SetImageRenderMode(ARKUI_IMAGE_RENDER_MODE_ORIGINAL); + image->SetMargin(SIZE_10); + + auto image1 = new ImageComponent(); + image1->SetWidth(SIZE_200); + image1->SetHeight(SIZE_200); + image1->SetImageSrc("./resources/base/media/icon.png"); + // 设置renderMode属性值为正常值:ARKUI_IMAGE_RENDER_MODE_TEMPLATE + image1->SetImageRenderMode(ARKUI_IMAGE_RENDER_MODE_TEMPLATE); + image1->SetMargin(SIZE_10); + + // Reset renderMode属性值 + auto row2 = new RowComponent(); + auto image2 = new ImageComponent(); + image2->SetWidth(SIZE_200); + image2->SetHeight(SIZE_200); + image2->SetImageSrc("./resources/base/media/icon.png"); + image2->SetImageRenderMode(ARKUI_IMAGE_RENDER_MODE_TEMPLATE); + image2->SetMargin(SIZE_10); + auto resetButton = new ButtonComponent(); + resetButton->SetWidth(SIZE_100); + resetButton->SetHeight(SIZE_50); + resetButton->SetId("resetRenderMode"); + resetButton->RegisterOnClick([image2]() { + // reset renderMode 属性,应该是ARKUI_IMAGE_RENDER_MODE_ORIGINAL + image2->resetAttribute(NODE_IMAGE_RENDER_MODE); + }); + + // 设置renderMode属性值为正常值:-1 + auto image3 = new ImageComponent(); + image3->SetWidth(SIZE_200); + image3->SetHeight(SIZE_200); + image3->SetImageSrc("./resources/base/media/icon.png"); + image3->SetImageRenderMode(PARAM_NEGATIVE_1); + image3->SetMargin(SIZE_10); + + // 添加组件到容器 + row1->AddChild(std::shared_ptr(image)); + row1->AddChild(std::shared_ptr(image1)); + columnParent->AddChild(std::shared_ptr(row1)); + + row2->AddChild(std::shared_ptr(image2)); + row2->AddChild(std::shared_ptr(resetButton)); + columnParent->AddChild(std::shared_ptr(row2)); + + columnParent->AddChild(std::shared_ptr(image3)); + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), columnParent->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageRenderModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_rendermode_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_rendermode_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3779c491d880cae1bbc05817da03279353bed94a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_rendermode_test.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_RENDER_MODE_TEST_H +#define ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_RENDER_MODE_TEST_H +#include +#include +#include + +#include "../common/common.h" +namespace ArkUICApiDemo { +class ImageRenderModeTest { +public: + ~ImageRenderModeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_NODE_IMAGE_RENDER_MODE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_resizable_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_resizable_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c5de19585a39385f8346ac9af69184354f206211 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_resizable_test.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_resizable_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "image_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateImageComponent( + const float left, const float top, const float right, const float bottom) +{ + auto image = new ImageComponent(); + image->SetImageSrc("resource://media/icon.png"); + image->SetHeight(SIZE_150); + image->SetHeight(SIZE_150); + image->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_CONTAIN); + image->SetResizable(left, top, right, bottom); + image->SetMargin(SIZE_10); + return std::shared_ptr(image); +} +static void CreateExample1(ColumnComponent* parentColumn) +{ + auto row1 = new RowComponent(); + // 正常值,可以按照设置正常拉伸 + auto image = CreateImageComponent(SIZE_40, SIZE_40, SIZE_10, SIZE_5); + // 异常值 top 异常值-1, 可以正常拉伸(结果是不能拉伸:fail) + auto image1 = CreateImageComponent(SIZE_40, PARAM_NEGATIVE_1, SIZE_10, SIZE_5); + auto row2 = new RowComponent(); + // 异常值 right 异常值-1, 不能正常拉伸 + auto image2 = CreateImageComponent(SIZE_40, SIZE_40, PARAM_NEGATIVE_1, SIZE_5); + // 异常值 bottom 异常值-1, 不能正常拉伸 + auto image3 = CreateImageComponent(SIZE_40, SIZE_40, SIZE_10, PARAM_NEGATIVE_1); + auto row3 = new RowComponent(); + // top+ bottom 大于原图高,不能正常拉伸 + auto image4 = CreateImageComponent(SIZE_40, SIZE_100, SIZE_10, SIZE_50); + // right+ left 大于原图宽,不能正常拉伸 + auto image5 = CreateImageComponent(SIZE_100, SIZE_40, SIZE_50, SIZE_5); + + row1->AddChild(image); + row1->AddChild(image1); + parentColumn->AddChild(std::shared_ptr(row1)); + row2->AddChild(image2); + row2->AddChild(image3); + parentColumn->AddChild(std::shared_ptr(row2)); + row3->AddChild(image4); + row3->AddChild(image5); + parentColumn->AddChild(std::shared_ptr(row3)); +} + +static void CreateExampleReset(ColumnComponent* parentColumn) +{ + auto row4 = new RowComponent(); + auto image6 = CreateImageComponent(SIZE_40, SIZE_40, SIZE_10, SIZE_5); + auto button = new ButtonComponent(); + button->SetWidth(SIZE_50); + button->SetHeight(SIZE_50); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->RegisterOnClick([image6]() { image6->resetAttribute(NODE_IMAGE_RESIZABLE); }); + button->SetId("ImageResizableReset"); + row4->AddChild(std::shared_ptr(button)); + row4->AddChild(image6); + parentColumn->AddChild(std::shared_ptr(row4)); +} + +napi_value ImageResizableTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "CreateNativeNode"); + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "GetContext env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto parentColumn = new ColumnComponent(); + CreateExample1(parentColumn); + CreateExampleReset(parentColumn); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_resizable_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_resizable_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3702871afdbfb5fcd30240bcda44f7e2621dccb1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_resizable_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGE_RESIZABLE_TEST_H +#define ARKUI_CAPI_DEMO_IMAGE_RESIZABLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ImageResizableTest { +public: + ~ImageResizableTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_RESIZABLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_src_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_src_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..755392ef4bd1d7620c6d021f40a44c74009c4146 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_src_test.cpp @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_src_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "column_component.h" +#include "image_component.h" + +namespace ArkUICApiDemo { + +static ImageComponent* CreatePixelMapImageNode( + ArkUI_NativeNodeAPI_1* node_api, bool isPixelMapArray, bool isNullptr = false) +{ + auto image = new ImageComponent(); + image->SetWidth(150); + image->SetHeight(200); + image->SetObjectFit(ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE); + + if (isNullptr) { + auto ret = image->SetImageSrc(nullptr); + if (ret == INVALID_PARAM) { + image->SetBackgroundColor(COLOR_GRAY); + } + return image; + } + + OH_PixelmapNativeHandle pixelMap = nullptr; + OH_PixelmapNativeHandle pixelMap1 = nullptr; + ArkUI_DrawableDescriptor* descriptorAnimated = nullptr; + OH_PixelmapNativeHandle array[2]; + + size_t dataSize = 960000; + uint8_t data[dataSize]; + + for (int i = 0; i < dataSize; i++) { + data[i] = i + 1; + } + + uint8_t data1[dataSize]; + for (auto i = 0; i < 960000; i = i + 4) { + data1[i] = uint8_t(0); + data1[i + 1] = uint8_t(i + 1); + data1[i + 2] = uint8_t(i + 2); + data1[i + 3] = uint8_t(255); + } + + OH_Pixelmap_InitializationOptions* options = nullptr; + OH_PixelmapInitializationOptions_Create(&options); + OH_PixelmapInitializationOptions_SetWidth(options, 200); + OH_PixelmapInitializationOptions_SetHeight(options, 300); + OH_PixelmapInitializationOptions_SetPixelFormat(options, PIXEL_FORMAT_BGRA_8888); + OH_PixelmapInitializationOptions_SetAlphaType(options, PIXELMAP_ALPHA_TYPE_UNKNOWN); + // 创建pixelMap并设置pixelMap的Options,例如旋转等. + OH_PixelmapNative_CreatePixelmap(data, dataSize, options, &pixelMap); + OH_PixelmapNative_Rotate(pixelMap, 90.0); + OH_PixelmapNative_Opacity(pixelMap, 0.2); + OH_PixelmapNative_Scale(pixelMap, 0.8, 1.0); + OH_PixelmapNative_Flip(pixelMap, true, true); + // 创建pixelMap1 + OH_PixelmapNative_CreatePixelmap(data1, dataSize, options, &pixelMap1); + + array[0] = pixelMap1; + array[1] = pixelMap; + auto descriptor = OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(pixelMap); + // 根据pixelMap数组创建ArkUI_DrawableDescriptor数组 + descriptorAnimated = OH_ArkUI_DrawableDescriptor_CreateFromAnimatedPixelMap(array, 2); + // 设置动画效果 + OH_ArkUI_DrawableDescriptor_SetAnimationDuration(descriptorAnimated, 200); + OH_ArkUI_DrawableDescriptor_SetAnimationIteration(descriptorAnimated, 5); + + ArkUI_AttributeItem srcItem = {}; + if (isPixelMapArray) { + // 支持pixelMap数组 + image->SetImageSrc(descriptorAnimated); + } else { + // 支持单个pixelMap + image->SetImageSrc(descriptor); + } + return image; +} +ArkUI_NodeHandle ImageSrcTest::CreateSubImageNode(ArkUI_NativeNodeAPI_1* node_api, const char* value) +{ + float width = SIZE_100; + float height = SIZE_100; + int32_t objectFit = ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE; + auto image = node_api->createNode(ARKUI_NODE_IMAGE); + // 设置组件大小 + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + node_api->setAttribute(image, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + node_api->setAttribute(image, NODE_HEIGHT, &heightItem); + + // 设置组件背景图片 + ArkUI_AttributeItem srcItem = {}; + srcItem.string = value; + node_api->setAttribute(image, NODE_IMAGE_SRC, &srcItem); + + // 设置组件图片填充效果属性 + ArkUI_NumberValue objectFitValue[] = { { .i32 = objectFit } }; + ArkUI_AttributeItem objectFitItem = { objectFitValue, sizeof(objectFitValue) / sizeof(ArkUI_NumberValue) }; + node_api->setAttribute(image, NODE_IMAGE_OBJECT_FIT, &objectFitItem); + + return image; +} + +napi_value ImageSrcTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "GetContext env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + const char* value = "resource://media/icon.png"; + auto image = CreateSubImageNode(nodeAPI, value); + // 添加组件到容器 + nodeAPI->addChild(column, image); + + value = "resource://media/src.jpg"; + image = CreateSubImageNode(nodeAPI, value); + // 添加组件到容器 + nodeAPI->addChild(column, image); + + value = "resource://rawfile/background_yellow.png"; + image = CreateSubImageNode(nodeAPI, value); + // 添加组件到容器 + nodeAPI->addChild(column, image); + + value = "resource://src/rectIcon.png"; + image = CreateSubImageNode(nodeAPI, value); + // 添加组件到容器 + nodeAPI->addChild(column, image); + + value = ""; + image = CreateSubImageNode(nodeAPI, value); + // 添加组件到容器 + nodeAPI->addChild(column, image); + + value = "https://gitee.com/openharmony/docs/raw/master/zh-cn/application-dev/" + "reference/apis-arkui/arkui-ts/figures/edgewidths.png"; + image = CreateSubImageNode(nodeAPI, value); + // 添加组件到容器 + nodeAPI->addChild(column, image); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value ImageSrcTest::CreateNativeNodeForPixelMap(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "CreateNativeNodeForPixemap"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "GetContext env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto parentColumn = new ColumnComponent(); + // 设置pixelMap + auto imagePixelmap = CreatePixelMapImageNode(nodeAPI, false); + // 设置pixelMap数组 + auto imageMultiPixelmap = CreatePixelMapImageNode(nodeAPI, true); + // 设置pixelMap空指针 + auto imageNullptr = CreatePixelMapImageNode(nodeAPI, false, true); + imagePixelmap->SetMargin(10); + imageMultiPixelmap->SetMargin(10); + parentColumn->AddChild(std::shared_ptr(imagePixelmap)); + parentColumn->AddChild(std::shared_ptr(imageMultiPixelmap)); + parentColumn->AddChild(std::shared_ptr(imageNullptr)); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSrcTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/image/image_src_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_src_test.h new file mode 100644 index 0000000000000000000000000000000000000000..33f4848dd0aae1ee0aa23d2f97f8e435784190e6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/image/image_src_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGE_SRC_TEST_H +#define ARKUI_CAPI_DEMO_IMAGE_SRC_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ImageSrcTest { +public: + ~ImageSrcTest(); + static ArkUI_NodeHandle CreateSubImageNode(ArkUI_NativeNodeAPI_1* node_api, const char* value); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeForPixelMap(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGE_SRC_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_common.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_common.cpp new file mode 100644 index 0000000000000000000000000000000000000000..62a1b0e23def139640b154d71b7eb40b48426ef2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_common.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "imageanimator_common.h" +#include +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +void ImageAnimatorCommon::SetImageFrameInfo( + ArkUI_ImageAnimatorFrameInfo* frameInfo, const ImageFrameProps& props) +{ + if (frameInfo == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorCommon", "frame info is null"); + return; + } + + // set width + OH_ArkUI_ImageAnimatorFrameInfo_SetWidth(frameInfo, props.width); + // set height + OH_ArkUI_ImageAnimatorFrameInfo_SetHeight(frameInfo, props.height); + // set top + OH_ArkUI_ImageAnimatorFrameInfo_SetTop(frameInfo, props.top); + // set left + OH_ArkUI_ImageAnimatorFrameInfo_SetLeft(frameInfo, props.left); + // set duration + OH_ArkUI_ImageAnimatorFrameInfo_SetDuration(frameInfo, props.duration); +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_common.h b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_common.h new file mode 100644 index 0000000000000000000000000000000000000000..c649e2b2fe9da6dac879920dac3f9a9ed815cd66 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_common.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMMON_H +#define ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMMON_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +struct ImageFrameProps { + int32_t width; + int32_t height; + int32_t top; + int32_t left; + int32_t duration; +}; +class ImageAnimatorCommon { +public: + ~ImageAnimatorCommon(); + static void SetImageFrameInfo(ArkUI_ImageAnimatorFrameInfo* frameInfo, const ImageFrameProps& props); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMMON_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_frameinfo_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_frameinfo_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f896796786aedeb4e8ec5791a1f40f6c70b5a83c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_frameinfo_test.cpp @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "imageanimator_frameinfo_test.h" + +#include "../manager/plugin_manager.h" +#include "column_component.h" +#include "imageanimator_common.h" +#include "imageanimator_component.h" + +namespace ArkUICApiDemo { +#define PARAM_96 96 + +static std::shared_ptr CreateImageAnimator(std::vector& vector) +{ + auto imageAnimator = std::make_shared(); + imageAnimator->SetState(ARKUI_ANIMATION_STATUS_RUNNING); + imageAnimator->SetIteration(1); + imageAnimator->SetFixedSize(false); + imageAnimator->SetMargin(PARAM_10); + imageAnimator->SetImage(vector); + return imageAnimator; +} + +static ArkUI_DrawableDescriptor* CreateDescriptorFromPixelMap( + OH_Pixelmap_InitializationOptions* createOpts, OH_PixelmapNative* pixelmap) +{ + uint8_t data[PARAM_96]; + size_t dataSize = PARAM_96; + for (int i = 0; i < dataSize; i++) { + data[i] = i + 1; + } + // initialization Options + OH_PixelmapInitializationOptions_Create(&createOpts); + OH_PixelmapInitializationOptions_SetWidth(createOpts, PARAM_4); + OH_PixelmapInitializationOptions_SetHeight(createOpts, PARAM_6); + OH_PixelmapInitializationOptions_SetPixelFormat(createOpts, PIXEL_FORMAT_BGRA_8888); + OH_PixelmapInitializationOptions_SetAlphaType(createOpts, PIXELMAP_ALPHA_TYPE_PREMULTIPLIED); + // create Pixelmap instance + Image_ErrorCode errCode = OH_PixelmapNative_CreatePixelmap(data, dataSize, createOpts, &pixelmap); + if (errCode != IMAGE_SUCCESS) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateDescriptorFromPixelMap", "errCode is not IMAGE_SUCCESS"); + return nullptr; + } + if (pixelmap == nullptr) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CreateDescriptorFromPixelMap", "pixelmap is null"); + return nullptr; + } + return OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(pixelmap); +} + +static ArkUI_ImageAnimatorFrameInfo* SetDrawableBasicData(ArkUI_DrawableDescriptor* drawable, ImageFrameProps& props) +{ + auto imageFrame = OH_ArkUI_ImageAnimatorFrameInfo_CreateFromDrawableDescriptor(drawable); + ImageAnimatorCommon::SetImageFrameInfo(imageFrame, props); + return imageFrame; +} + +napi_value ImageAnimatorFrameInfoTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + char* imageUrls[] = { + "./resources/base/media/background_red.png", + "./resources/base/media/background_green.png", + "./resources/base/media/background_blue.png", + }; + ImageFrameProps props = { SIZE_300, SIZE_300, SIZE_10, SIZE_30, SIZE_3000 }; + std::vector vec; + for (char* url : imageUrls) { + auto item = OH_ArkUI_ImageAnimatorFrameInfo_CreateFromString(url); + vec.push_back(item); + ImageAnimatorCommon::SetImageFrameInfo(vec.back(), props); + } + auto imageAnimator = CreateImageAnimator(vec); + // parent node + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorFrameInfoTest::CreateNativeNodeAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageFrameInfoTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + char* urlFirst = "./resources/base/media/background_red.png"; + auto frameFirst = OH_ArkUI_ImageAnimatorFrameInfo_CreateFromString(urlFirst); + ImageFrameProps propsFirst = { SIZE_150, SIZE_150, 0, PARAM_NEGATIVE_5, SIZE_3000 }; + ImageAnimatorCommon::SetImageFrameInfo(frameFirst, propsFirst); + char* urlSecond = "./resources/base/media/background_green.png"; + auto frameSecond = OH_ArkUI_ImageAnimatorFrameInfo_CreateFromString(urlSecond); + ImageFrameProps propsSecond = { PARAM_NEGATIVE_100, PARAM_NEGATIVE_100, PARAM_NEGATIVE_100, PARAM_NEGATIVE_100, + napi_undefined }; + ImageAnimatorCommon::SetImageFrameInfo(frameSecond, propsSecond); + char* urlThird = "./resources/base/media/icon.png"; + auto frameThird = OH_ArkUI_ImageAnimatorFrameInfo_CreateFromString(urlThird); + ImageFrameProps propsThird = { SIZE_500, SIZE_800, 0, 0, SIZE_3000 }; + ImageAnimatorCommon::SetImageFrameInfo(frameThird, propsThird); + std::vector vec = { frameFirst, frameSecond, frameThird }; + auto imageAnimator = CreateImageAnimator(vec); + // parent node + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorFrameInfoTest::CreateNativeNodeDrawable(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + OH_Pixelmap_InitializationOptions* createOpts = nullptr; + OH_PixelmapNative* pixelmap = nullptr; + auto drawDes = CreateDescriptorFromPixelMap(createOpts, pixelmap); + if (drawDes == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", "Descriptor is null"); + return nullptr; + } + + ImageFrameProps propsFirst = { SIZE_50, SIZE_300, SIZE_10, SIZE_100, SIZE_3000 }; + auto frameFirst = SetDrawableBasicData(drawDes, propsFirst); + ImageFrameProps propsSecond = { SIZE_100, SIZE_100, SIZE_10, SIZE_10, SIZE_3000 }; + auto frameSecond = SetDrawableBasicData(drawDes, propsSecond); + ImageFrameProps propsThird = { SIZE_300, SIZE_100, SIZE_10, SIZE_10, SIZE_3000 }; + auto frameThird = SetDrawableBasicData(drawDes, propsThird); + std::vector vec = { frameFirst, frameSecond, frameThird }; + auto imageAnimator = CreateImageAnimator(vec); + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + OH_PixelmapNative_Release(pixelmap); + OH_PixelmapInitializationOptions_Release(createOpts); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorFrameInfoTest::CreateNativeNodeDrawableAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + OH_Pixelmap_InitializationOptions* createOpts = nullptr; + OH_PixelmapNative* pixelmap = nullptr; + auto drawDes = CreateDescriptorFromPixelMap(createOpts, pixelmap); + ImageFrameProps propsFirst = { SIZE_500, SIZE_800, SIZE_10, SIZE_100, SIZE_3000 }; + auto frameFirst = SetDrawableBasicData(drawDes, propsFirst); + ImageFrameProps propsSecond = { PARAM_NEGATIVE_5, SIZE_150, SIZE_10, SIZE_10, SIZE_3000 }; + auto frameSecond = SetDrawableBasicData(drawDes, propsSecond); + ImageFrameProps propsThird = { SIZE_300, SIZE_300, SIZE_10, SIZE_10, SIZE_3000 }; + auto frameThird = SetDrawableBasicData(drawDes, propsThird); + std::vector vec = { frameFirst, frameSecond, frameThird }; + auto imageAnimator = CreateImageAnimator(vec); + // parent node + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + OH_PixelmapNative_Release(pixelmap); + OH_PixelmapInitializationOptions_Release(createOpts); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorFrameInfoTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_frameinfo_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_frameinfo_test.h new file mode 100644 index 0000000000000000000000000000000000000000..08c3d1b35cdccbaa20965ca374a6f34db4759f48 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_frameinfo_test.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGEANIMATOR_FRAMEINFO_TEST_H +#define ARKUI_CAPI_DEMO_IMAGEANIMATOR_FRAMEINFO_TEST_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../common/common.h" +#include "napi/native_api.h" + +namespace ArkUICApiDemo { + +class ImageAnimatorFrameInfoTest { +public: + ~ImageAnimatorFrameInfoTest(); + // ImageAnimatorFrameInfoTest:testImageAnimatorFrameInfoTest001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // ImageAnimatorFrameInfoTest:testImageAnimatorFrameInfoTest002 + static napi_value CreateNativeNodeAbnormal(napi_env env, napi_callback_info info); + // ImageAnimatorFrameInfoTest:testImageAnimatorFrameInfoTest003 + static napi_value CreateNativeNodeDrawable(napi_env env, napi_callback_info info); + // ImageAnimatorFrameInfoTest:testImageAnimatorFrameInfoTest004 + static napi_value CreateNativeNodeDrawableAbnormal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGEANIMATOR_FRAMEINFO_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..17a9e6803494d409fb8d569e5cb5f1bc2212ba8b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_test.cpp @@ -0,0 +1,401 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "imageanimator_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "imageanimator_common.h" +#include "imageanimator_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateImageAnimator(ImageFrameProps& properties, bool fixed = false) +{ + std::vector vec; + char* imageUrls[] = { + "./resources/base/media/icon.png", + "./resources/base/media/background_green.png", + "./resources/base/media/background_red.png", + "./resources/base/media/background_yellow.png", + "./resources/base/media/background_blue.png", + }; + for (char* url : imageUrls) { + auto item = OH_ArkUI_ImageAnimatorFrameInfo_CreateFromString(url); + vec.push_back(item); + if (!fixed) { + ImageAnimatorCommon::SetImageFrameInfo(vec.back(), properties); + } + } + auto imageAnimator = std::make_shared(); + imageAnimator->SetState(ARKUI_ANIMATION_STATUS_RUNNING); + imageAnimator->SetIteration(1); + imageAnimator->SetMargin(PARAM_10); + imageAnimator->SetFixedSize(fixed); + imageAnimator->SetReverse(false); + imageAnimator->SetFillMode(ARKUI_ANIMATION_FILL_MODE_FORWARDS); + imageAnimator->SetImage(vec); + return imageAnimator; +} + +napi_value ImageAnimatorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ImageFrameProps props = { SIZE_300, SIZE_100, SIZE_10, SIZE_30, SIZE_3000 }; + auto imageAnimator = CreateImageAnimator(props); + imageAnimator->SetState(ARKUI_ANIMATION_STATUS_INITIAL); + + auto imageAnimatorSecond = CreateImageAnimator(props); + imageAnimatorSecond->SetState(ARKUI_ANIMATION_STATUS_RUNNING); + + auto imageAnimatorThird = CreateImageAnimator(props); + imageAnimatorThird->SetState(ARKUI_ANIMATION_STATUS_PAUSED); + + auto imageAnimatorFourth = CreateImageAnimator(props); + imageAnimatorFourth->SetState(ARKUI_ANIMATION_STATUS_STOPPED); + + auto imageAnimatorFifth = CreateImageAnimator(props); + imageAnimatorFifth->SetState(PARAM_NEGATIVE_1); + + auto imageAnimatorSixth = CreateImageAnimator(props); + imageAnimatorSixth->SetState(PARAM_4); + + // parent node + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + column->AddChild(imageAnimatorSecond); + column->AddChild(imageAnimatorThird); + column->AddChild(imageAnimatorFourth); + column->AddChild(imageAnimatorFifth); + column->AddChild(imageAnimatorSixth); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorTest::CreateNativeNodeDuration(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ImageFrameProps props = { SIZE_300, SIZE_300, SIZE_10, SIZE_30 }; + auto imageAnimator = CreateImageAnimator(props, true); + imageAnimator->SetDuration(SIZE_3000); + imageAnimator->SetWidth(SIZE_200); + imageAnimator->SetHeight(SIZE_100); + + auto imageAnimatorSecond = CreateImageAnimator(props, true); + imageAnimatorSecond->SetDuration(0); + imageAnimatorSecond->SetWidth(SIZE_200); + imageAnimatorSecond->SetHeight(SIZE_100); + + auto imageAnimatorThird = CreateImageAnimator(props, true); + imageAnimatorThird->SetDuration(PARAM_NEGATIVE_5); + imageAnimatorThird->SetWidth(SIZE_200); + imageAnimatorThird->SetHeight(SIZE_100); + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + column->AddChild(imageAnimatorSecond); + column->AddChild(imageAnimatorThird); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorTest::CreateNativeNodeReverse(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ImageFrameProps props = { SIZE_300, SIZE_300, SIZE_10, SIZE_30, SIZE_2000 }; + auto animator = CreateImageAnimator(props); + animator->SetState(ARKUI_ANIMATION_STATUS_RUNNING); + animator->SetReverse(false); + animator->SetFillMode(ARKUI_ANIMATION_FILL_MODE_FORWARDS); + + auto animatorSecond = CreateImageAnimator(props); + animatorSecond->SetState(ARKUI_ANIMATION_STATUS_RUNNING); + animatorSecond->SetReverse(true); + animatorSecond->SetFillMode(ARKUI_ANIMATION_FILL_MODE_BACKWARDS); + + auto column = new ColumnComponent(); + column->AddChild(animator); + column->AddChild(animatorSecond); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorTest::CreateNativeNodeFixedSize(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ImageFrameProps props = { SIZE_300, SIZE_300, SIZE_10, SIZE_30, SIZE_1000 }; + auto animator = CreateImageAnimator(props); + auto animatorSecond = CreateImageAnimator(props, true); + animatorSecond->SetWidth(SIZE_200); + animatorSecond->SetHeight(SIZE_100); + animatorSecond->SetDuration(SIZE_2000); + auto column = new ColumnComponent(); + column->AddChild(animator); + column->AddChild(animatorSecond); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorTest::CreateNativeNodeFillMode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ImageFrameProps props = { SIZE_300, SIZE_100, SIZE_10, SIZE_30, SIZE_1000 }; + auto imageAnimator = CreateImageAnimator(props); + imageAnimator->SetFillMode(ARKUI_ANIMATION_FILL_MODE_NONE); + auto imageAnimatorSecond = CreateImageAnimator(props); + imageAnimatorSecond->SetFillMode(ARKUI_ANIMATION_FILL_MODE_FORWARDS); + auto imageAnimatorThird = CreateImageAnimator(props); + imageAnimatorThird->SetFillMode(ARKUI_ANIMATION_FILL_MODE_BACKWARDS); + auto imageAnimatorFourth = CreateImageAnimator(props); + imageAnimatorFourth->SetFillMode(ARKUI_ANIMATION_FILL_MODE_BOTH); + auto imageAnimatorFifth = CreateImageAnimator(props); + imageAnimatorFifth->SetFillMode(PARAM_NEGATIVE_1); + auto imageAnimatorSixth = CreateImageAnimator(props); + imageAnimatorSixth->SetFillMode(PARAM_4); + + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + column->AddChild(imageAnimatorSecond); + column->AddChild(imageAnimatorThird); + column->AddChild(imageAnimatorFourth); + column->AddChild(imageAnimatorFifth); + column->AddChild(imageAnimatorSixth); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorTest::CreateNativeNodeIteration(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ImageFrameProps props = { SIZE_300, SIZE_100, SIZE_10, SIZE_30, SIZE_3000 }; + auto animator = CreateImageAnimator(props); + animator->SetIteration(1); + auto animatorSecond = CreateImageAnimator(props); + animatorSecond->SetIteration(0); + auto animatorThird = CreateImageAnimator(props); + animatorThird->SetIteration(PARAM_NEGATIVE_1); + + auto column = new ColumnComponent(); + column->AddChild(animator); + column->AddChild(animatorSecond); + column->AddChild(animatorThird); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value ImageAnimatorTest::CreateNativeNodeResetAttribute(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ImageFrameProps props = { SIZE_300, SIZE_300, SIZE_10, SIZE_10, SIZE_3000 }; + auto imageAnimator = CreateImageAnimator(props, true); + imageAnimator->SetFillMode(ARKUI_ANIMATION_FILL_MODE_BACKWARDS); + imageAnimator->SetReverse(true); + imageAnimator->SetIteration(PARAM_NEGATIVE_1); + imageAnimator->SetDuration(SIZE_3000); + imageAnimator->SetWidth(SIZE_300); + imageAnimator->SetHeight(SIZE_200); + auto note = std::make_shared(); + note->SetWidth(SIZE_300); + note->SetHeight(SIZE_100); + note->SetBackgroundColor(COLOR_PINK); + auto button = std::make_shared(); + button->SetId("ResetImageAnimator"); + button->SetWidth(PARAM_32); + button->SetHeight(PARAM_32); + button->SetMargin(PARAM_10); + button->RegisterOnClick([imageAnimator, note]() { + imageAnimator->resetAttribute(NODE_IMAGE_ANIMATOR_FILL_MODE); + imageAnimator->resetAttribute(NODE_IMAGE_ANIMATOR_FIXED_SIZE); + imageAnimator->resetAttribute(NODE_IMAGE_ANIMATOR_ITERATION); + imageAnimator->resetAttribute(NODE_IMAGE_ANIMATOR_REVERSE); + imageAnimator->resetAttribute(NODE_IMAGE_ANIMATOR_DURATION); + auto iterationItem = imageAnimator->getAttribute(NODE_IMAGE_ANIMATOR_ITERATION); + auto stateItem = imageAnimator->getAttribute(NODE_IMAGE_ANIMATOR_STATE); + auto fillItem = imageAnimator->getAttribute(NODE_IMAGE_ANIMATOR_FILL_MODE); + auto fixedSizeItem = imageAnimator->getAttribute(NODE_IMAGE_ANIMATOR_FIXED_SIZE); + std::string str = "iterationItem:" + std::to_string(iterationItem->value[0].i32) + "\n" + + "stateItem:" + std::to_string(stateItem->value[0].i32) + "\n" + + "fillItem:" + std::to_string(fillItem->value[0].i32) + "\n" + + "fixedSizeItem:" + std::to_string(fixedSizeItem->value[0].i32) + "\n"; + note->SetTextContent(str); + }); + auto column = new ColumnComponent(); + column->AddChild(imageAnimator); + column->AddChild(button); + column->AddChild(note); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAnimatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_test.h new file mode 100644 index 0000000000000000000000000000000000000000..03013ce15c61f118c497ed199f9de9e4845b909b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imageanimator/imageanimator_test.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGEANIMATOR_TEST_H +#define ARKUI_CAPI_DEMO_IMAGEANIMATOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImageAnimatorTest { +public: + ~ImageAnimatorTest(); + // ImageAnimatorTest:testImageAnimatorTest001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // ImageAnimatorTest:testImageAnimatorTest002 + static napi_value CreateNativeNodeDuration(napi_env env, napi_callback_info info); + // ImageAnimatorTest:testImageAnimatorTest003 + static napi_value CreateNativeNodeReverse(napi_env env, napi_callback_info info); + // ImageAnimatorTest:testImageAnimatorTest004 + static napi_value CreateNativeNodeFixedSize(napi_env env, napi_callback_info info); + // ImageAnimatorTest:testImageAnimatorTest005 + static napi_value CreateNativeNodeFillMode(napi_env env, napi_callback_info info); + // ImageAnimatorTest:testImageAnimatorTest006 + static napi_value CreateNativeNodeIteration(napi_env env, napi_callback_info info); + // ImageAnimatorTest:testImageAnimatorTest007 + static napi_value CreateNativeNodeResetAttribute(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGEANIMATOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_alt_onclick_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_alt_onclick_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0ffb6098a433a355dbc9bc251c2dcaef4ad5da8e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_alt_onclick_test.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "imagespan_alt_onclick_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "imagespan_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +napi_value ImagespanAltAndOnClickTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImagespanAltTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImagespanAltTest", "GetContext env or info is null"); + return nullptr; + } + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto text = new TextComponent(); + text->SetWidth(SIZE_200); + text->SetHeight(SIZE_200); + text->SetBackgroundColor(COLOR_GRAY); + + // 设置组件背景图片正常值 + auto imageSpan = new ImageSpanComponent(); + imageSpan->SetWidth(SIZE_200); + imageSpan->SetHeight(SIZE_200); + imageSpan->SetBorderWidth(SIZE_10); + imageSpan->SetMargin(SIZE_10); + imageSpan->SetImageSpanAlt("resource://media/green.jgp"); + imageSpan->SetId("imageSpanClick"); + imageSpan->RegisterOnClick([text]() { text->SetBackgroundColor(COLOR_RED); }); + // 设置组件背景图片异常值 + auto imageSpan1 = new ImageSpanComponent(); + imageSpan1->SetWidth(SIZE_200); + imageSpan1->SetHeight(SIZE_200); + imageSpan1->SetBorderWidth(SIZE_10); + imageSpan1->SetMargin(SIZE_10); + imageSpan1->SetImageSpanAlt("abcabc"); + + // 添加组件到容器 + nodeAPI->addChild(column, text->GetComponent()); + nodeAPI->addChild(column, imageSpan->GetComponent()); + nodeAPI->addChild(column, imageSpan1->GetComponent()); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageAltTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_alt_onclick_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_alt_onclick_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d10f42f36fd45be63a5a5ffe6606c530d8320f91 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_alt_onclick_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CAPIDEMO_IMAGESPAN_ALT_ONCLICK_TEST_H +#define CAPIDEMO_IMAGESPAN_ALT_ONCLICK_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +class ImagespanAltAndOnClickTest { +public: + ~ImagespanAltAndOnClickTest(); + static ArkUI_NodeHandle CreateSubImageNode(ArkUI_NativeNodeAPI_1* node_api, const char* value); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_IMAGESPAN_ALT_ONCLICK_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_src_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_src_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c670a101b0ce44e76abcc54beb4450749699117 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_src_test.cpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "imagespan/imagespan_src_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "column_component.h" +#include "imagespan_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +static ImageSpanComponent* CreatePixelMapImageNode( + ArkUI_NativeNodeAPI_1* node_api, bool isPixelMapArray, bool isNullptr = false) +{ + auto image = new ImageSpanComponent(); + image->SetWidth(150); + image->SetHeight(200); + + if (isNullptr) { + auto ret = image->SetImageSpanSrc(nullptr); + if (ret == INVALID_PARAM) { + image->SetBackgroundColor(COLOR_GRAY); + } + return image; + } + + OH_PixelmapNativeHandle pixelMap = nullptr; + OH_PixelmapNativeHandle pixelMap1 = nullptr; + ArkUI_DrawableDescriptor* descriptorAnimated = nullptr; + OH_PixelmapNativeHandle array[2]; + + size_t dataSize = 960000; + uint8_t data[dataSize]; + + for (int i = 0; i < dataSize; i++) { + data[i] = i + 1; + } + + uint8_t data1[dataSize]; + for (auto i = 0; i < 960000; i = i + 4) { + data1[i] = uint8_t(0); + data1[i + 1] = uint8_t(i + 1); + data1[i + 2] = uint8_t(i + 2); + data1[i + 3] = uint8_t(255); + } + + OH_Pixelmap_InitializationOptions* options = nullptr; + OH_PixelmapInitializationOptions_Create(&options); + OH_PixelmapInitializationOptions_SetWidth(options, 200); + OH_PixelmapInitializationOptions_SetHeight(options, 300); + OH_PixelmapInitializationOptions_SetPixelFormat(options, PIXEL_FORMAT_BGRA_8888); + OH_PixelmapInitializationOptions_SetAlphaType(options, PIXELMAP_ALPHA_TYPE_UNKNOWN); + // 创建pixelMap并设置pixelMap的Options,例如旋转等. + OH_PixelmapNative_CreatePixelmap(data, dataSize, options, &pixelMap); + OH_PixelmapNative_Rotate(pixelMap, 90.0); + OH_PixelmapNative_Opacity(pixelMap, 0.2); + OH_PixelmapNative_Scale(pixelMap, 0.8, 1.0); + OH_PixelmapNative_Flip(pixelMap, true, true); + // 创建pixelMap1 + OH_PixelmapNative_CreatePixelmap(data1, dataSize, options, &pixelMap1); + + array[0] = pixelMap1; + array[1] = pixelMap; + auto descriptor = OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(pixelMap); + // 根据pixelMap数组创建ArkUI_DrawableDescriptor数组 + descriptorAnimated = OH_ArkUI_DrawableDescriptor_CreateFromAnimatedPixelMap(array, 2); + // 设置动画效果 + OH_ArkUI_DrawableDescriptor_SetAnimationDuration(descriptorAnimated, 200); + OH_ArkUI_DrawableDescriptor_SetAnimationIteration(descriptorAnimated, 5); + + ArkUI_AttributeItem srcItem = {}; + if (isPixelMapArray) { + // 支持pixelMap数组 + image->SetImageSpanSrc(descriptorAnimated); + } else { + // 支持单个pixelMap + image->SetImageSpanSrc(descriptor); + } + return image; +} + +napi_value ImageSpanSrcTest::CreateNativeNodeForPixelMap(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSpanSrcTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSpanSrcTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + // 设置pixelMap + auto imageSpanPixelmap = CreatePixelMapImageNode(nodeAPI, false); + imageSpanPixelmap->SetMargin(10); + // 设置pixelMap数组 + auto imageSpanMultiPixelmap = CreatePixelMapImageNode(nodeAPI, true); + imageSpanMultiPixelmap->SetMargin(10); + // 设置pixelMap空指针 + auto imageSpanNullptr = CreatePixelMapImageNode(nodeAPI, false, true); + imageSpanNullptr->SetMargin(10); + + // parent node + parentColumn->AddChild(std::shared_ptr(imageSpanPixelmap)); + parentColumn->AddChild(std::shared_ptr(imageSpanMultiPixelmap)); + parentColumn->AddChild(std::shared_ptr(imageSpanNullptr)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSpanSrcTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +ArkUI_NodeHandle CreateSubImageSpanNode(ArkUI_NativeNodeAPI_1* node_api, const char* value) +{ + float width = SIZE_100; + float height = SIZE_100; + int32_t objectFit = ArkUI_ObjectFit::ARKUI_OBJECT_FIT_NONE; + auto imagespan = node_api->createNode(ARKUI_NODE_IMAGE_SPAN); + // 设置组件大小 + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + node_api->setAttribute(imagespan, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + node_api->setAttribute(imagespan, NODE_HEIGHT, &heightItem); + + // 设置组件背景图片 + ArkUI_AttributeItem srcItem = {}; + srcItem.string = value; + node_api->setAttribute(imagespan, NODE_IMAGE_SPAN_SRC, &srcItem); + + // 设置组件图片填充效果属性 + ArkUI_NumberValue objectFitValue[] = { { .i32 = objectFit } }; + ArkUI_AttributeItem objectFitItem = { objectFitValue, sizeof(objectFitValue) / sizeof(ArkUI_NumberValue) }; + node_api->setAttribute(imagespan, NODE_IMAGE_OBJECT_FIT, &objectFitItem); + + return imagespan; +} + +napi_value ImageSpanSrcTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ImageSpanSrcTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSpanSrcTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = new RowComponent(); + row1->SetMargin(SIZE_10); + const char* value = "resource://media/green.jpg"; + auto imageSpanFirst = CreateSubImageSpanNode(nodeAPI, value); + value = "resource://media/yellow.bmp"; + auto imageSpanSecond = CreateSubImageSpanNode(nodeAPI, value); + value = "resource://media/pink.heif"; + auto imageSpanThird = CreateSubImageSpanNode(nodeAPI, value); + value = "resource://media/red.gif"; + auto imageSpanFourth = CreateSubImageSpanNode(nodeAPI, value); + + auto row2 = new RowComponent(); + row2->SetMargin(SIZE_10); + value = "resource://media/blue.png"; + auto imageSpanFifth = CreateSubImageSpanNode(nodeAPI, value); + value = "resource://media/animated_circle_stop.svg"; + auto imageSpanSixth = CreateSubImageSpanNode(nodeAPI, value); + + value = "resource://rawfile/background_yellow.png"; + auto imageSpanSeven = CreateSubImageSpanNode(nodeAPI, value); + + value = "https://gitee.com/openharmony/docs/raw/master/zh-cn/application-dev/" + "reference/apis-arkui/arkui-ts/figures/edgewidths.png"; + auto imageSpanEight = CreateSubImageSpanNode(nodeAPI, value); + + nodeAPI->addChild(row1->GetComponent(), imageSpanFirst); + nodeAPI->addChild(row1->GetComponent(), imageSpanSecond); + nodeAPI->addChild(row1->GetComponent(), imageSpanThird); + nodeAPI->addChild(row1->GetComponent(), imageSpanFourth); + + nodeAPI->addChild(row2->GetComponent(), imageSpanFifth); + nodeAPI->addChild(row2->GetComponent(), imageSpanSixth); + nodeAPI->addChild(row2->GetComponent(), imageSpanSeven); + nodeAPI->addChild(row2->GetComponent(), imageSpanEight); + + nodeAPI->addChild(column, row1->GetComponent()); + nodeAPI->addChild(column, row2->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ImageSpanSrcTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_src_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_src_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e87b0d545c82b4858bac54f822a71483919d43f8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/imagespan/imagespan_src_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_IMAGESPAN_SRC_TEST_H +#define ARKUI_CAPI_DEMO_IMAGESPAN_SRC_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ImageSpanSrcTest { +public: + ~ImageSpanSrcTest(); + static napi_value CreateNativeNodeForPixelMap(napi_env env, napi_callback_info info); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_IMAGESPAN_SRC_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/inputevent/input_event_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/inputevent/input_event_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e94f6346aaba92f0904dd93f4fa08bc5034e4327 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/inputevent/input_event_test.cpp @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "input_event_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "radio_component.h" +#include "row_component.h" +#include "text_component.h" + +#define COLUMN_ID 2020 +#define TEXT_ID 2121 +#define Dotted 0 +#define Dashed 1 +#define Solid 2 + +namespace ArkUICApiDemo { +constexpr int32_t SOURCETYPE_NONE = 0; +constexpr int32_t SOURCETYPE_MOUSE = 1; +constexpr int32_t SOURCETYPE_TOUCH = 2; +constexpr int32_t SOURCETOLL_UNKNOWN = 0; +constexpr int32_t SOURCETOLL_FINGER = 1; +constexpr int32_t SOURCETOLL_MOUSE = 7; + +void PrintHistoryPointEventLogByPointIndex(ArkUI_UIInputEvent* inputEvent, uint32_t pointerIndex, uint32_t historyIndex) +{ + auto getHistorySize = OH_ArkUI_PointerEvent_GetHistorySize(inputEvent); + auto getHistoryEventTime = OH_ArkUI_PointerEvent_GetHistoryEventTime(inputEvent, historyIndex); + auto getHistoryPointerCount = OH_ArkUI_PointerEvent_GetHistoryPointerCount(inputEvent, historyIndex); + auto getHistoryPointerId = OH_ArkUI_PointerEvent_GetHistoryPointerId(inputEvent, pointerIndex, historyIndex); + auto getHistoryX = OH_ArkUI_PointerEvent_GetHistoryX(inputEvent, pointerIndex, historyIndex); + auto getHistoryY = OH_ArkUI_PointerEvent_GetHistoryY(inputEvent, pointerIndex, historyIndex); + auto getHistoryWindowX = OH_ArkUI_PointerEvent_GetHistoryWindowX(inputEvent, pointerIndex, historyIndex); + auto getHistoryWindowY = OH_ArkUI_PointerEvent_GetHistoryWindowY(inputEvent, pointerIndex, historyIndex); + auto getHistoryDisplayX = OH_ArkUI_PointerEvent_GetHistoryDisplayX(inputEvent, pointerIndex, historyIndex); + auto getHistoryDisplayY = OH_ArkUI_PointerEvent_GetHistoryDisplayY(inputEvent, pointerIndex, historyIndex); + auto getHistoryPressure = OH_ArkUI_PointerEvent_GetHistoryPressure(inputEvent, pointerIndex, historyIndex); + auto getHistoryTiltX = OH_ArkUI_PointerEvent_GetHistoryTiltX(inputEvent, pointerIndex, historyIndex); + auto getHistoryTiltY = OH_ArkUI_PointerEvent_GetHistoryTiltY(inputEvent, pointerIndex, historyIndex); + auto getHistoryTouchAreaWidth = + OH_ArkUI_PointerEvent_GetHistoryTouchAreaWidth(inputEvent, pointerIndex, historyIndex); + auto getHistoryTouchAreaHeight = + OH_ArkUI_PointerEvent_GetHistoryTouchAreaHeight(inputEvent, pointerIndex, historyIndex); + + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest HistoryPointEventLogByPointIndex %{public}d, pointIndex=%{public}u, historyIndex=%{public}u", + !!inputEvent, pointerIndex, historyIndex); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistorySize %{public}d", + getHistorySize); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest getHistoryEventTime %{public}lf", getHistoryEventTime); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest getHistoryPointerCount %{public}u", getHistoryPointerCount); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest getHistoryPointerId %{public}d", getHistoryPointerId); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryX %{public}f", getHistoryX); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryY %{public}f", getHistoryY); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryWindowX %{public}f", + getHistoryWindowX); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryWindowY %{public}f", + getHistoryWindowY); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryDisplayX %{public}f", + getHistoryDisplayX); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryDisplayY %{public}f", + getHistoryDisplayY); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryPressure %{public}f", + getHistoryPressure); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryTiltX %{public}f", + getHistoryTiltX); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getHistoryTiltY %{public}f", + getHistoryTiltY); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest getHistoryTouchAreaWidth %{public}f", getHistoryTouchAreaWidth); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest getHistoryTouchAreaHeight %{public}f", getHistoryTouchAreaHeight); +} +void PrintPointEventLogByPointIndex(ArkUI_UIInputEvent* uiInputEvent, uint32_t pointIndex) +{ + auto getPointerCount = OH_ArkUI_PointerEvent_GetPointerCount(uiInputEvent); + auto getPintId = OH_ArkUI_PointerEvent_GetPointerId(uiInputEvent, pointIndex); + auto getX = OH_ArkUI_PointerEvent_GetX(uiInputEvent); + auto getY = OH_ArkUI_PointerEvent_GetY(uiInputEvent); + auto getXByIndex = OH_ArkUI_PointerEvent_GetXByIndex(uiInputEvent, pointIndex); + auto getYByIndex = OH_ArkUI_PointerEvent_GetYByIndex(uiInputEvent, pointIndex); + auto getWindowX = OH_ArkUI_PointerEvent_GetWindowX(uiInputEvent); + auto getWindowY = OH_ArkUI_PointerEvent_GetWindowY(uiInputEvent); + auto getWindowXByIndex = OH_ArkUI_PointerEvent_GetWindowXByIndex(uiInputEvent, pointIndex); + auto getWindowYByIndex = OH_ArkUI_PointerEvent_GetWindowYByIndex(uiInputEvent, pointIndex); + auto getDisplayX = OH_ArkUI_PointerEvent_GetDisplayX(uiInputEvent); + auto getDisplayY = OH_ArkUI_PointerEvent_GetDisplayY(uiInputEvent); + auto getDisplayXByIndex = OH_ArkUI_PointerEvent_GetDisplayXByIndex(uiInputEvent, pointIndex); + auto getDisplayYByIndex = OH_ArkUI_PointerEvent_GetDisplayYByIndex(uiInputEvent, pointIndex); + // touch + auto getPressure = OH_ArkUI_PointerEvent_GetPressure(uiInputEvent, pointIndex); + auto getTiltX = OH_ArkUI_PointerEvent_GetTiltX(uiInputEvent, pointIndex); + auto getTiltY = OH_ArkUI_PointerEvent_GetTiltY(uiInputEvent, pointIndex); + auto getTouchAreaWidth = OH_ArkUI_PointerEvent_GetTouchAreaWidth(uiInputEvent, pointIndex); + auto getTouchAreaHeight = OH_ArkUI_PointerEvent_GetTouchAreaHeight(uiInputEvent, pointIndex); + + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEventTest PointEventLogByPointIndex %{public}d, pointIndex=%{public}d", !!uiInputEvent, pointIndex); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getPointerCount %{public}d", + getPointerCount); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getPintId %{public}d", getPintId); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getX %{public}f", getX); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getY %{public}f", getY); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getXByIndex %{public}f", getXByIndex); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getYByIndex %{public}f", getYByIndex); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getWindowX %{public}f", getWindowX); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getWindowY %{public}f", getWindowY); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getWindowXByIndex %{public}f", + getWindowXByIndex); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getWindowYByIndex %{public}f", + getWindowYByIndex); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getDisplayX %{public}f", getDisplayX); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getDisplayY %{public}f", getDisplayY); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getDisplayXByIndex %{public}f", + getDisplayXByIndex); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getDisplayYByIndex %{public}f", + getDisplayYByIndex); + // touch + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getPressure %{public}f", getPressure); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getTiltX %{public}f", getTiltX); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getTiltY %{public}f", getTiltY); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getTouchAreaWidth %{public}f", + getTouchAreaWidth); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "InputEventTest", "InputEventTest getTouchAreaHeight %{public}f", + getTouchAreaHeight); +} +napi_value InputEventTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "InputEventTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "InputEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto columnMouse = new ColumnComponent(); + columnMouse->SetWidth(400); + columnMouse->SetHeight(300); + columnMouse->SetBorderWidth(5); + auto buttonMouse = new ButtonComponent(); + buttonMouse->SetWidth(200); + buttonMouse->SetHeight(100); + buttonMouse->SetMargin(10); + buttonMouse->SetId("buttonMouse"); + auto textShow = new TextComponent(); + textShow->SetWidth(300); + textShow->SetHeight(150); + textShow->SetBackgroundColor(COLOR_PINK); + buttonMouse->RegisterOnMouse([textShow, buttonMouse](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + // ARKUI_UIINPUTEVENT_TYPE_UNKNOWN = 0, + // ARKUI_UIINPUTEVENT_TYPE_TOUCH = 1, + // ARKUI_UIINPUTEVENT_TYPE_AXIS = 2, + // ARKUI_UIINPUTEVENT_TYPE_MOUSE = 3, + auto type = OH_ArkUI_UIInputEvent_GetType(uiInputEvent); + auto action = OH_ArkUI_UIInputEvent_GetAction(uiInputEvent); + // NONE = 0, MOUSE = 1,TOUCH = 2, TOUCH_PAD = 3, KEYBOARD = 4 + // mouse事件中没有设置sourceType和toolType,均为0 + auto sourceType = OH_ArkUI_UIInputEvent_GetSourceType(uiInputEvent); + auto toolType = OH_ArkUI_UIInputEvent_GetToolType(uiInputEvent); + auto eventTime = OH_ArkUI_UIInputEvent_GetEventTime(uiInputEvent); + eventTime = (eventTime == 0) ? 0 : 1; + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "InputEventTest", + "type=%{public}d, action=%{public}d,sourceType=%{public}d, toolType=%{public}d,eventTime=%{public}d", type, + action, sourceType, toolType, eventTime); + std::string str = "type:" + std::to_string(type) + "\n" + "action:" + std::to_string(action) + "\n" + + "sourceType:" + std::to_string(sourceType) + "\n" + "toolType:" + std::to_string(toolType) + + "\n" + "eventTime:" + std::to_string(eventTime) + "\n"; + textShow->SetFontSize(20); + textShow->SetTextContent(str); + + PrintPointEventLogByPointIndex(uiInputEvent, 0); + PrintPointEventLogByPointIndex(uiInputEvent, -1); + PrintPointEventLogByPointIndex(uiInputEvent, 1); + + PrintHistoryPointEventLogByPointIndex(uiInputEvent, 0, 0); + PrintHistoryPointEventLogByPointIndex(uiInputEvent, 0, -1); + PrintHistoryPointEventLogByPointIndex(uiInputEvent, 0, 2); + + if (type == ArkUI_UIInputEvent_Type::ARKUI_UIINPUTEVENT_TYPE_MOUSE && sourceType == SOURCETYPE_NONE && + toolType == OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN) { + buttonMouse->SetBackgroundColor(COLOR_GREEN); + } + }); + + auto columnTouch = new ColumnComponent(); + columnTouch->SetWidth(400); + columnTouch->SetHeight(300); + columnTouch->SetBorderWidth(5); + columnTouch->SetMargin(10); + auto textTouch = new TextComponent(); + textTouch->SetWidth(300); + textTouch->SetHeight(200); + textTouch->SetBackgroundColor(COLOR_PINK); + textTouch->SetMargin(10); + textTouch->SetId("textTouch"); + textTouch->RegisterOnTouch([textTouch](ArkUI_NodeEvent* event) { + auto* uiInputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event); + auto type = OH_ArkUI_UIInputEvent_GetType(uiInputEvent); + auto action = OH_ArkUI_UIInputEvent_GetAction(uiInputEvent); + auto sourceType = OH_ArkUI_UIInputEvent_GetSourceType(uiInputEvent); + auto toolType = OH_ArkUI_UIInputEvent_GetToolType(uiInputEvent); + auto eventTime = OH_ArkUI_UIInputEvent_GetEventTime(uiInputEvent); + eventTime = (eventTime == 0) ? 0 : 1; + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "InputEventTest", + "InputEvent type=%{public}d, action=%{public}d,type=%{public}d, action=%{public}d,eventTime=%{public}d", + type, action, sourceType, toolType, eventTime); + + std::string str = "type:" + std::to_string(type) + "\n" + "action:" + std::to_string(action) + "\n" + + "sourceType:" + std::to_string(sourceType) + "\n" + "toolType:" + std::to_string(toolType) + + "\n" + "eventTime:" + std::to_string(eventTime) + "\n"; + + textTouch->SetFontSize(20); + textTouch->SetTextContent(str); + + PrintPointEventLogByPointIndex(uiInputEvent, 0); + PrintPointEventLogByPointIndex(uiInputEvent, -1); + PrintPointEventLogByPointIndex(uiInputEvent, 1); + + PrintHistoryPointEventLogByPointIndex(uiInputEvent, 0, 0); + PrintHistoryPointEventLogByPointIndex(uiInputEvent, 0, -1); + PrintHistoryPointEventLogByPointIndex(uiInputEvent, 0, 2); + + if (type == ArkUI_UIInputEvent_Type::ARKUI_UIINPUTEVENT_TYPE_TOUCH && sourceType == SOURCETYPE_TOUCH && + toolType == SOURCETOLL_FINGER) { + textTouch->SetBackgroundColor(COLOR_GRAY); + } + }); + + parentColumn->AddChild(std::shared_ptr(columnMouse)); + parentColumn->AddChild(std::shared_ptr(columnTouch)); + columnMouse->AddChild(std::shared_ptr(buttonMouse)); + columnMouse->AddChild(std::shared_ptr(textShow)); + columnTouch->AddChild(std::shared_ptr(textTouch)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "AttributeSettingTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/inputevent/input_event_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/inputevent/input_event_test.h new file mode 100644 index 0000000000000000000000000000000000000000..060ecb00edfea496dde20df5ad0a404e77bcef81 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/inputevent/input_event_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_INPUT_EVENT_TEST_H +#define ARKUI_CAPI_DEMO_INPUT_EVENT_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class InputEventTest { +public: + ~InputEventTest(); + // OH_ArkUI_UIInputEvent_GetType + // OH_ArkUI_UIInputEvent_GetAction + // OH_ArkUI_UIInputEvent_GetSourceType + // OH_ArkUI_UIInputEvent_GetToolType + // OH_ArkUI_UIInputEvent_GetEventTime + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_INPUT_EVENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/lazyforeach/lazyforeach_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/lazyforeach/lazyforeach_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..177605d5c1b81c7ac2b6905728aa4c14a0d93343 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/lazyforeach/lazyforeach_test.cpp @@ -0,0 +1,1369 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "lazyforeach_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "component/grid_component.h" +#include "row_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +constexpr int32_t GRID_COUNT = 14; +std::shared_ptr> getNodeAdapter(std::shared_ptr column) +{ + auto temp = dynamic_cast(column->GetChildren().front().get()); + return temp->GetAdapter(); +} + +std::shared_ptr CreateNewColumn() +{ + auto col = std::make_shared(); + col->SetWidth(100); + col->SetHeight(80); + col->SetBackgroundColor(COLOR_YELLOW); + return col; +} + +static void OnAdapterEventReceive(ArkUI_NodeAdapterEvent* event) +{ + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + int type = OH_ArkUI_NodeAdapterEvent_GetType(event); + if (type == NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER) { + int32_t index = OH_ArkUI_NodeAdapterEvent_GetItemIndex(event); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER", + "index is %{public}d", index); + auto gridItem = nodeAPI->createNode(ARKUI_NODE_GRID_ITEM); + + ArkUI_NumberValue width_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + + uint32_t color = COLOR_YELLOW; + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue border_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem border_item = { border_value, sizeof(border_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue border_color_value[] = { { .u32 = COLOR_GRAY } }; + ArkUI_AttributeItem border_color_item = { border_color_value, + sizeof(border_color_value) / sizeof(ArkUI_NumberValue) }; + + nodeAPI->setAttribute(gridItem, NODE_BORDER_WIDTH, &border_item); + nodeAPI->setAttribute(gridItem, NODE_BORDER_COLOR, &border_color_item); + nodeAPI->setAttribute(gridItem, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(gridItem, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(gridItem, NODE_BACKGROUND_COLOR, &background_color_item); + OH_ArkUI_NodeAdapterEvent_SetItem(event, gridItem); + if (OH_ArkUI_NodeAdapterEvent_SetNodeId(event, index) != ARKUI_ERROR_CODE_NO_ERROR || + OH_ArkUI_NodeAdapterEvent_SetNodeId(nullptr, index) != ARKUI_ERROR_CODE_PARAM_INVALID) { + ArkUI_NumberValue error_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem error_item = { error_value, sizeof(error_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(gridItem, NODE_BACKGROUND_COLOR, &error_item); + } + } +} + +// OH_ArkUI_NodeAdapter_GetAllItems +// OH_ArkUI_NodeAdapter_Create +// OH_ArkUI_NodeAdapter_RegisterEventReceiver +// OH_ArkUI_NodeAdapterEvent_GetUserData +// OH_ArkUI_NodeAdapterEvent_GetType +// OH_ArkUI_NodeAdapterEvent_SetItem +// OH_ArkUI_NodeAdapterEvent_GetItemIndex +napi_value LazyForEachTest::CreateNativeNodeGetAllItem(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto col1 = CreateGrid([](std::shared_ptr) {}); + auto btn1 = std::make_shared(); + col1->SetId("col1"); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row2->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + + btn1->RegisterOnClick([col1]() { + auto adapter = getNodeAdapter(col1); + adapter->SetAllItem([](std::shared_ptr gridItem, uint32_t index) { + auto children = gridItem->GetChildren(); + if (!children.empty()) { + children.front()->SetBackgroundColor(COLOR_GREEN); + } + }); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// OH_ArkUI_NodeAdapter_UnregisterEventReceiver +napi_value LazyForEachTest::CreateNativeNodeUnregister(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col1 = CreateGrid([](std::shared_ptr grid) { + auto adapter = grid->GetAdapter(); + adapter->UnregisterEventReceiver(); + }); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_SetTotalNodeCount +// OH_ArkUI_NodeAdapter_GetTotalNodeCount +napi_value LazyForEachTest::CreateNativeNodeTotalCount(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto change = [](std::shared_ptr grid) { + auto adapter = grid->GetAdapter(); + if (adapter->GetTotalNodeCount() != ITEM_COUNT) { + grid->SetBackgroundColor(COLOR_RED); + } + }; + auto col1 = CreateGrid(change); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapterEvent_SetNodeId +napi_value LazyForEachTest::CreateNativeNodeNodeId(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置背景色 + ArkUI_NumberValue background_color_value[] = { { .u32 = 0xFAEEE0 } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + // 设置Grid宽 + ArkUI_NumberValue width_value[] = { { .f32 = 450 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Grid高 + ArkUI_NumberValue height_value[] = { { .f32 = 180 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + + // 设置margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue border_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem border_item = { border_value, sizeof(border_value) / sizeof(ArkUI_NumberValue) }; + //------------------------------------------------------------------------------------------------------ + // 设置columnsTemplate:NODE_GRID_COLUMN_TEMPLATE + ArkUI_AttributeItem columnsTemplate_item = { .string = "1fr 1fr 1fr 1fr 1fr" }; + // 设置rowTemplate:NODE_GRID_ROW_TEMPLATE + ArkUI_AttributeItem rowTemplate_item = { .string = "1fr 1fr 1fr 1fr" }; + // 设置columnsGap:NODE_GRID_COLUMN_GAP + ArkUI_NumberValue columnsGap_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem columnsGap_item = { columnsGap_value, sizeof(columnsGap_value) / sizeof(ArkUI_NumberValue) }; + // 设置rowGap:NODE_GRID_ROW_GAP + ArkUI_NumberValue rowsGap_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem rowsGap_item = { rowsGap_value, sizeof(rowsGap_value) / sizeof(ArkUI_NumberValue) }; + + // 设置columnsTemplate异常值,NODE_GRID_COLUMN_TEMPLATE + ArkUI_AttributeItem outlier_columnsTemplate_item = { .string = "abc" }; + // 设置rowTemplate异常值,NODE_GRID_ROW_TEMPLATE + ArkUI_AttributeItem outlier_rowTemplate_item = { .string = "ddd,ccc" }; + // 设置columnsGap异常值,NODE_GRID_COLUMN_GAP + ArkUI_NumberValue outlier_columnsGap_value[] = { { .f32 = -1 } }; + ArkUI_AttributeItem outlier_columnsGap_item = { outlier_columnsGap_value, + sizeof(outlier_columnsGap_value) / sizeof(ArkUI_NumberValue) }; + // 设置rowGap异常值,NODE_GRID_ROW_GAP + ArkUI_NumberValue outlier_rowsGap_value[] = { { .f32 = -1 } }; + ArkUI_AttributeItem outlier_rowsGap_item = { outlier_rowsGap_value, + sizeof(outlier_rowsGap_value) / sizeof(ArkUI_NumberValue) }; + + // 设置cached count + ArkUI_NumberValue cachedValue[] = { { .i32 = 6 } }; + ArkUI_AttributeItem cachedItem = { cachedValue, sizeof(cachedValue) / sizeof(ArkUI_NumberValue) }; + + // 设置cached count + ArkUI_NumberValue outlier_cachedValue[] = { { .i32 = -1 } }; + ArkUI_AttributeItem outlier_cachedItem = { outlier_cachedValue, + sizeof(outlier_cachedValue) / sizeof(ArkUI_NumberValue) }; + + // 创建grid组件懒加载回调 + auto adapter = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter, GRID_COUNT); + ArkUI_AttributeItem adapterItem { .object = adapter }; + + // 创建grid组件,同时设置NODE_GRID_COLUMN_TEMPLATE,NODE_GRID_ROW_TEMPLATE,NODE_GRID_COLUMN_GAP,NODE_GRID_ROW_GAP + auto grid = nodeAPI->createNode(ARKUI_NODE_GRID); + nodeAPI->setAttribute(grid, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(grid, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(grid, NODE_BACKGROUND_COLOR, &background_color_item); + nodeAPI->setAttribute(grid, NODE_GRID_COLUMN_TEMPLATE, &columnsTemplate_item); + nodeAPI->setAttribute(grid, NODE_GRID_ROW_TEMPLATE, &rowTemplate_item); + nodeAPI->setAttribute(grid, NODE_GRID_COLUMN_GAP, &columnsGap_item); + nodeAPI->setAttribute(grid, NODE_GRID_ROW_GAP, &rowsGap_item); + nodeAPI->setAttribute(grid, NODE_GRID_NODE_ADAPTER, &adapterItem); + nodeAPI->setAttribute(grid, NODE_BORDER_WIDTH, &border_item); + nodeAPI->setAttribute(grid, NODE_MARGIN, &margin_item); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(std::make_shared(grid)); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_Dispose +napi_value LazyForEachTest::CreateNativeNodeDispose(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto change = [](std::shared_ptr grid) { grid->ReleaseAdapter(); }; + auto col1 = CreateGrid(change); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapterEvent_GetHostNode +napi_value LazyForEachTest::CreateNativeNodeHostNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto change = [](std::shared_ptr grid) { + auto adapter = grid->GetAdapter(); + adapter->SetNodeAdapterEvent([](ArkUI_NodeAdapterEvent* event) { + auto node = OH_ArkUI_NodeAdapterEvent_GetHostNode(event); + if (!node) + return; + auto component = std::make_shared(node); + component->SetBackgroundColor(COLOR_RED); + }); + }; + auto col1 = CreateGrid(change); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_ReloadAllItems +napi_value LazyForEachTest::CreateNativeNodeReloadAllItems(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto col1 = CreateGrid<6>([](std::shared_ptr) {}); + auto col2 = CreateGrid<20>([](std::shared_ptr) {}); + auto col3 = CreateGrid<30>([](std::shared_ptr) {}); + auto btn = std::make_shared(); + col1->SetId("col1"); + col2->SetId("col2"); + col3->SetId("col3"); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetId("btn"); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row2->AddChild(col2); + row3->AddChild(col3); + row3->AddChild(btn); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + btn->RegisterOnClick([col1, col2, col3]() { + auto adapter1 = getNodeAdapter(col1); + auto adapter2 = getNodeAdapter(col2); + auto adapter3 = getNodeAdapter(col3); + adapter1->ReloadAllItem(); + adapter2->ReloadAllItem(); + adapter3->ReloadAllItem(); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_ReloadItem +// 数量少 +napi_value LazyForEachTest::CreateNativeNodeReloadItem(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(3); + }; + // 测试reload一个item的情况 + auto col1 = CreateGrid<9>(customGrid); + auto col2 = CreateGrid<9>(customGrid); + auto col3 = CreateGrid<9>(customGrid); + // 测试reload多个个item的情况 + auto col4 = CreateGrid<9>(customGrid); + auto col5 = CreateGrid<9>(customGrid); + auto col6 = CreateGrid<9>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + // startPosition, count + std::vector> reloadItems = { + { 0, 1 }, // 显示区域 reload一个item + { 4, 1 }, // 缓存区 reload一个item + { 8, 1 }, // 缓存区之外 reload一个item + { 0, 3 }, // 显示区域 reload三个item + { 4, 3 }, // 缓存区 reload三个item + { 6, 3 } // 缓存区之外 reload三个item + }; + std::vector> columns = { col1, col2, col3, col4, col5, col6 }; + + btn1->RegisterOnClick([reloadItems, columns]() { + for (int32_t i = 0; i < reloadItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + auto reloadItem = reloadItems[i]; + if (reloadItem.second == 1) { + // reload 位置为reloadItem.first的item + adapter->ReloadItem(reloadItem.first, CreateNewColumn()); + } else { + // reload 位置为reloadItem.first的reloadItem.second个item + std::vector> dataSource(reloadItem.second); + for (int j = 0; j < reloadItem.second; j++) { + dataSource[j] = CreateNewColumn(); + } + adapter->ReloadItems(reloadItem.first, dataSource); + } + } + auto grid2 = dynamic_cast(columns[1]->GetChildren().front().get()); + auto grid3 = dynamic_cast(columns[2]->GetChildren().front().get()); + auto grid5 = dynamic_cast(columns[4]->GetChildren().front().get()); + auto grid6 = dynamic_cast(columns[5]->GetChildren().front().get()); + grid2->SetScrollTo(0, 80 * 3, {}); + grid3->SetScrollTo(0, 80 * 83, {}); + grid5->SetScrollTo(0, 80 * 4, {}); + grid6->SetScrollTo(0, 80 * 6, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_ReloadItem +// 数量大 +napi_value LazyForEachTest::CreateNativeNodeReloadItemBig(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(60); + }; + // 测试reload多个个item的情况 + auto col1 = CreateGrid<400>(customGrid); + auto col2 = CreateGrid<400>(customGrid); + auto col3 = CreateGrid<400>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + + // startPosition, count + std::vector> reloadItems = { + { 0, 3 }, // 显示区域 reload三个item + { 4, 40 }, // 缓存区 reload四十个item + { 80, 100 } // 缓存区之外 reload一百个item + }; + std::vector> columns = { col1, col2, col3 }; + btn1->RegisterOnClick([reloadItems, columns]() { + for (int32_t i = 0; i < reloadItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + auto reloadItem = reloadItems[i]; + // reload 位置为reloadItem.first的reloadItem.second个item + std::vector> dataSource(reloadItem.second); + for (int j = 0; j < reloadItem.second; j++) { + dataSource[j] = CreateNewColumn(); + } + adapter->ReloadItems(reloadItem.first, dataSource); + } + auto grid2 = dynamic_cast(columns[1]->GetChildren().front().get()); + auto grid3 = dynamic_cast(columns[2]->GetChildren().front().get()); + grid2->SetScrollTo(0, 80 * 4, {}); + grid3->SetScrollTo(0, 80 * 84, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_RemoveItem +// 数量少 +napi_value LazyForEachTest::CreateNativeNodeRemoveItem(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(3); + }; + // 测试remove一个item的情况 + auto col1 = CreateGrid<9>(customGrid); + auto col2 = CreateGrid<9>(customGrid); + auto col3 = CreateGrid<9>(customGrid); + // 测试remove多个个item的情况 + auto col4 = CreateGrid<9>(customGrid); + auto col5 = CreateGrid<9>(customGrid); + auto col6 = CreateGrid<9>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + // startPosition, count + std::vector> removeItems = { + { 0, 1 }, // 显示区域 remove一个item + { 4, 1 }, // 缓存区 remove一个item + { 8, 1 }, // 缓存区之外 remove一个item + { 0, 3 }, // 显示区域 remove三个item + { 4, 3 }, // 缓存区 remove三个item + { 6, 3 } // 缓存区之外 remove三个item + }; + std::vector> columns = { col1, col2, col3, col4, col5, col6 }; + + btn1->RegisterOnClick([removeItems, columns]() { + for (int32_t i = 0; i < removeItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + auto removeItem = removeItems[i]; + if (removeItem.second == 1) { + // reload 位置为removeItem.first的item + adapter->RemoveItem(removeItem.first); + } else { + // reload 位置为reloadItem.first的reloadItem.second个item + adapter->RemoveItems(removeItem.first, removeItem.second); + } + } + auto grid2 = dynamic_cast(columns[1]->GetChildren().front().get()); + auto grid3 = dynamic_cast(columns[2]->GetChildren().front().get()); + auto grid5 = dynamic_cast(columns[4]->GetChildren().front().get()); + auto grid6 = dynamic_cast(columns[5]->GetChildren().front().get()); + grid2->SetScrollTo(0, 80 * 3, {}); + grid3->SetScrollTo(0, 80 * 83, {}); + grid5->SetScrollTo(0, 80 * 3, {}); + grid6->SetScrollTo(0, 80 * 4, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_RemoveItem +// 数量大 +napi_value LazyForEachTest::CreateNativeNodeRemoveItemBig(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(60); + }; + // 测试reload多个个item的情况 + auto col1 = CreateGrid<400>(customGrid); + auto col2 = CreateGrid<400>(customGrid); + auto col3 = CreateGrid<400>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + + // startPosition, count + std::vector> removeItems = { + { 0, 3 }, // 显示区域 remove三个item + { 4, 40 }, // 缓存区 remove四十个item + { 80, 100 } // 缓存区之外 remove一百个item + }; + std::vector> columns = { col1, col2, col3 }; + btn1->RegisterOnClick([removeItems, columns]() { + for (int32_t i = 0; i < removeItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + adapter->RemoveItems(removeItems[i].first, removeItems[i].second); + } + auto grid2 = dynamic_cast(columns[1]->GetChildren().front().get()); + auto grid3 = dynamic_cast(columns[2]->GetChildren().front().get()); + grid2->SetScrollTo(0, 80 * 3, {}); + grid3->SetScrollTo(0, 80 * 83, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_InsertItem +// 数量小 +napi_value LazyForEachTest::CreateNativeNodeInsertItem(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(3); + }; + // 测试insert一个item的情况 + auto col1 = CreateGrid<9>(customGrid); + auto col2 = CreateGrid<9>(customGrid); + auto col3 = CreateGrid<9>(customGrid); + // 测试insert多个item的情况 + auto col4 = CreateGrid<9>(customGrid); + auto col5 = CreateGrid<9>(customGrid); + auto col6 = CreateGrid<9>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + // startPosition, count + std::vector> insertItems = { + { 0, 1 }, // 显示区域 insert一个item + { 4, 1 }, // 缓存区 insert一个item + { 8, 1 }, // 缓存区之外 insert一个item + { 0, 3 }, // 显示区域 insert三个item + { 4, 3 }, // 缓存区 insert三个item + { 6, 3 } // 缓存区之外 insert三个item + }; + std::vector> columns = { col1, col2, col3, col4, col5, col6 }; + + btn1->RegisterOnClick([insertItems, columns]() { + for (int32_t i = 0; i < insertItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + auto insertItem = insertItems[i]; + if (insertItem.second == 1) { + adapter->InsertItem(insertItem.first, CreateNewColumn()); + } else { + std::vector> dataSource(insertItem.second); + for (int j = 0; j < insertItem.second; j++) { + dataSource[j] = CreateNewColumn(); + } + adapter->InsertItems(insertItem.first, dataSource); + } + } + auto grid2 = dynamic_cast(columns[1]->GetChildren().front().get()); + auto grid3 = dynamic_cast(columns[2]->GetChildren().front().get()); + auto grid5 = dynamic_cast(columns[4]->GetChildren().front().get()); + auto grid6 = dynamic_cast(columns[5]->GetChildren().front().get()); + grid2->SetScrollTo(0, 80 * 3, {}); + grid3->SetScrollTo(0, 80 * 83, {}); + grid5->SetScrollTo(0, 80 * 4, {}); + grid6->SetScrollTo(0, 80 * 6, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_InsertItem +// 数量大 +napi_value LazyForEachTest::CreateNativeNodeInsertItemBig(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(60); + }; + // 测试reload多个个item的情况 + auto col1 = CreateGrid<400>(customGrid); + auto col2 = CreateGrid<400>(customGrid); + auto col3 = CreateGrid<400>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + + // startPosition, count + std::vector> insertItems = { + { 0, 3 }, // 显示区域 insert三个item + { 4, 40 }, // 缓存区 insert四十个item + { 80, 100 } // 缓存区之外 insert一百个item + }; + std::vector> columns = { col1, col2, col3 }; + btn1->RegisterOnClick([insertItems, columns]() { + for (int32_t i = 0; i < insertItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + auto insertItem = insertItems[i]; + std::vector> dataSource(insertItem.second); + for (int j = 0; j < insertItem.second; j++) { + dataSource[j] = CreateNewColumn(); + } + adapter->InsertItems(insertItem.first, dataSource); + } + auto grid2 = dynamic_cast(columns[1]->GetChildren().front().get()); + auto grid3 = dynamic_cast(columns[2]->GetChildren().front().get()); + grid2->SetScrollTo(0, 80 * 3, {}); + grid3->SetScrollTo(0, 80 * 83, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_MoveItem +// 数量小 +napi_value LazyForEachTest::CreateNativeNodeMoveItem(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(3); + }; + auto col1 = CreateGrid<9>(customGrid); + auto col2 = CreateGrid<9>(customGrid); + auto col3 = CreateGrid<9>(customGrid); + auto col4 = CreateGrid<9>(customGrid); + auto col5 = CreateGrid<9>(customGrid); + auto col6 = CreateGrid<9>(customGrid); + auto col7 = CreateGrid<9>(customGrid); + auto col8 = CreateGrid<9>(customGrid); + auto col9 = CreateGrid<9>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + auto row4 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + row4->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(row4); + + // startPosition, count + std::vector> moveItems = { + // 移动到显示区域 + { 0, 1 }, // 显示区域 0 move到1 + { 4, 1 }, // 缓存区 4 move到1 + { 8, 1 }, // 缓存区之外 8 move到1 + // 移动到缓存区 + { 0, 4 }, // 显示区域 0 move到4 + { 5, 4 }, // 缓存区 5 move到4 + { 8, 4 }, // 缓存区之外 8 move到4 + // 移动到缓存区之外 + { 0, 8 }, // 显示区域 0 move到8 + { 4, 8 }, // 缓存区 4 move到8 + { 8, 7 } // 缓存区之外 8 move到7 + }; + std::vector> columns = { col1, col2, col3, col4, col5, col6, col7, col8, col9 }; + + btn1->RegisterOnClick([moveItems, columns]() { + for (int32_t i = 0; i < moveItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + adapter->MoveItem(moveItems[i].first, moveItems[i].second); + } + for (int32_t i = 3; i < columns.size(); i++) { + auto grid = dynamic_cast(columns[i]->GetChildren().front().get()); + grid->SetScrollTo(0, 80 * moveItems[i].second, {}); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapter_MoveItem +// 数量大 +napi_value LazyForEachTest::CreateNativeNodeMoveItemBig(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(60); + }; + auto col1 = CreateGrid<400>(customGrid); + auto col2 = CreateGrid<400>(customGrid); + auto col3 = CreateGrid<400>(customGrid); + auto col4 = CreateGrid<400>(customGrid); + auto col5 = CreateGrid<400>(customGrid); + auto col6 = CreateGrid<400>(customGrid); + auto col7 = CreateGrid<400>(customGrid); + auto col8 = CreateGrid<400>(customGrid); + auto col9 = CreateGrid<400>(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + auto row4 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + row4->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(row4); + + // startPosition, count + std::vector> moveItems = { + // 移动到显示区域 + { 0, 1 }, // 显示区域 0 move到1 + { 20, 1 }, // 缓存区 20 move到1 + { 80, 1 }, // 缓存区之外 80 move到1 + // 移动到缓存区 + { 0, 10 }, // 显示区域 0 move到10 + { 20, 10 }, // 缓存区 20 move到10 + { 80, 10 }, // 缓存区之外 80 move到10 + // 移动到缓存区之外 + { 0, 90 }, // 显示区域 0 move到90 + { 20, 90 }, // 缓存区 20 move到90 + { 90, 100 } // 缓存区之外 90 move到100 + }; + std::vector> columns = { col1, col2, col3, col4, col5, col6, col7, col8, col9 }; + + btn1->RegisterOnClick([moveItems, columns]() { + for (int32_t i = 0; i < moveItems.size(); i++) { + auto adapter = getNodeAdapter(columns[i]); + adapter->MoveItem(moveItems[i].first, moveItems[i].second); + } + auto grid3 = dynamic_cast(columns[3]->GetChildren().front().get()); + auto grid4 = dynamic_cast(columns[4]->GetChildren().front().get()); + auto grid5 = dynamic_cast(columns[5]->GetChildren().front().get()); + auto grid6 = dynamic_cast(columns[6]->GetChildren().front().get()); + auto grid7 = dynamic_cast(columns[7]->GetChildren().front().get()); + auto grid8 = dynamic_cast(columns[8]->GetChildren().front().get()); + grid3->SetScrollTo(0, 80 * 10, {}); + grid4->SetScrollTo(0, 80 * 10, {}); + grid5->SetScrollTo(0, 80 * 8.5, {}); + grid6->SetScrollTo(0, 80 * 93, {}); + grid7->SetScrollTo(0, 80 * 93, {}); + grid8->SetScrollTo(0, 80 * 103, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +// OH_ArkUI_NodeAdapterEvent_GetRemovedNode +napi_value LazyForEachTest::CreateNativeNodeGetRemovedNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto customGrid = [](std::shared_ptr grid) { + grid->SetWidth(105); + grid->SetGridColumnsTemplate("1fr"); + grid->SetGridCachedCount(60); + grid->GetAdapter()->RegisterRemovedNodeCallback( + [grid](std::shared_ptr node) { grid->SetBackgroundColor(COLOR_RED); }); + }; + auto col1 = CreateGrid(customGrid); + auto btn1 = std::make_shared(); + btn1->SetId("btn1"); + btn1->SetWidth(100); + btn1->SetHeight(50); + btn1->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row2->AddChild(btn1); + column->AddChild(row1); + column->AddChild(row2); + + btn1->RegisterOnClick([col1]() { + auto grid = dynamic_cast(col1->GetChildren().front().get()); + auto adapter = grid->GetAdapter(); + adapter->ReloadItem(1, CreateNewColumn()); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "LazyForEachTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/lazyforeach/lazyforeach_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/lazyforeach/lazyforeach_test.h new file mode 100644 index 0000000000000000000000000000000000000000..4cd8bd2de9af7a5cba377077fc5f1c22bdd2f4ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/lazyforeach/lazyforeach_test.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LAZYFOREACH_TEST_H +#define ARKUI_CAPI_DEMO_LAZYFOREACH_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "grid_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +constexpr int32_t ITEM_COUNT = 15; + +class LazyForEachTest { +public: + ~LazyForEachTest(); + static napi_value CreateNativeNodeGetAllItem(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeUnregister(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeTotalCount(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeNodeId(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeDispose(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeHostNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeReloadAllItems(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeReloadItem(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeReloadItemBig(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeRemoveItem(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeRemoveItemBig(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeInsertItem(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeInsertItemBig(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeMoveItem(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeMoveItemBig(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeGetRemovedNode(napi_env env, napi_callback_info info); + +private: + static void UpdateGridProperty(std::shared_ptr grid, int32_t size) + { + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + grid->SetWidth(325); + grid->SetHeight(SIZE_200); + grid->SetBackgroundColor(COLOR_GRAY); + grid->SetBorderWidth(1, 1, 1, 1); + grid->SetGridColumnsTemplate("1fr 1fr 1fr"); + grid->SetGridRowsGap(4); + grid->SetGridColumnsGap(4); + grid->SetLazyAdapter(adapter); + + for (int i = 0; i < size; i++) { + auto col = std::make_shared(); + col->SetWidth(100); + col->SetHeight(80); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / size) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + col->SetBorderWidth(1, 1, 1, 1); + col->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + adapter->InsertItem(i, col); + } + } + + template + static std::shared_ptr CreateGrid(std::function)> change) + { + auto column = std::make_shared(); + auto grid = std::make_shared(); + UpdateGridProperty(grid, size); + column->AddChild(grid); + if (change) { + change(grid); + } + return column; + } + + template + static std::shared_ptr CreateGrid( + std::function, Args...)> change, Args... args) + { + auto column = std::make_shared(); + auto grid = std::make_shared(); + UpdateGridProperty(grid, size); + column->AddChild(grid); + if (change) { + change(grid, args...); + } + return column; + } +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LAZYFOREACH_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_childrenMainSize_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_childrenMainSize_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..997aa101370b70d25e97bece607ac246fe042bd9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_childrenMainSize_test.cpp @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "list_childrenMainSize_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +using namespace std; +static shared_ptr CreateListComponent( + int itemCount, int distance, int vertical = ArkUI_Axis::ARKUI_AXIS_VERTICAL) +{ + auto list = make_shared(); + list->SetWidth(vertical == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 200); + list->SetHeight(vertical == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 200 : 100); + list->SetListSpace(5); + list->SetBackgroundColor(COLOR_RED); + list->SetListDirection(vertical); + list->SetBorderWidth(5); + vector> input; + for (int i = 0; i < itemCount; i++) { + auto listItem = make_shared(); + listItem->SetWidth(vertical == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? distance * 2 : distance); + listItem->SetHeight(vertical == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? distance : distance * 2); + listItem->SetBackgroundColor(COLOR_GREEN); + if (i == itemCount) { + listItem->SetBackgroundColor(COLOR_BLUE); + } + input.push_back(listItem); + } + auto adapter = make_shared>(input); + list->SetLazyAdapter(adapter); + return list; +} +napi_value ListChildrenMainSizeTest::CreateNativeNodeChildrenMainSize(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ChildrenMainSizeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ChildrenMainSizeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto list = std::make_shared(); + list->SetWidth(100); + list->SetHeight(300); + std::vector> dataSource; + std::vector groupList = { 3, 1, 1, 1 }; + for (int i = 0; i < 6; i++) { + auto column = std::make_shared(); + column->SetWidth(100); + column->SetHeight(i > 2 ? 100 : 200); + column->SetBackgroundColor(i > 2 ? COLOR_BLUE : COLOR_RED); + dataSource.push_back(column); + } + auto adapter = std::make_shared(dataSource, groupList); + list->SetLazyAdapterByGroup(adapter); + list->SetHeight(200); + auto button1 = std::make_shared(); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetId("button1"); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + auto ChildrenMainSize1 = new ListChildrenMainSizeOption(); + ChildrenMainSize1->Resize(4); + ChildrenMainSize1->SetDefaultMainSize(100); + ChildrenMainSize1->Update(0, 1, { 600 }); + + list->SetListChildrenMainSize(ChildrenMainSize1); + auto groupChildrenMainSize1 = new ListChildrenMainSizeOption(); + groupChildrenMainSize1->Resize(3); + groupChildrenMainSize1->SetDefaultMainSize(100); + groupChildrenMainSize1->Update(0, 3, { 200, 200, 200 }); + button1->RegisterOnClick([list, adapter, groupChildrenMainSize1]() { + auto group1 = adapter->getGroup().begin(); + group1->second->SetListItemGroupChildrenMainSize(groupChildrenMainSize1); + list->SetListScrollToIndex({ 1, 0 }); + }); + + int32_t itemCount = 100; + int32_t distance = 50; + auto list2 = CreateListComponent(itemCount, distance); + auto childrenMainSize2 = new ListChildrenMainSizeOption(); + childrenMainSize2->Resize(itemCount); + childrenMainSize2->SetDefaultMainSize(distance); + list2->SetListChildrenMainSize(childrenMainSize2); + list2->SetListInitialIndex(5); + auto item1 = make_shared(); + item1->SetWidth(100); + item1->SetHeight(100); + item1->SetBackgroundColor(COLOR_BLUE); + + auto button2 = std::make_shared(); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetId("button2"); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + button2->RegisterOnClick([list2, item1, itemCount, childrenMainSize2]() { + list2->GetAdapter()->InsertItem(0, item1); + childrenMainSize2->Resize(itemCount + 1); + childrenMainSize2->Add(0, 1, { 100 }); + list2->SetListChildrenMainSize(childrenMainSize2); + list2->SetListScrollToIndex({ 0, 0 }); + }); + + auto list3 = CreateListComponent(itemCount, distance); + auto childrenMainSize3 = new ListChildrenMainSizeOption(); + childrenMainSize3->Resize(itemCount); + childrenMainSize3->SetDefaultMainSize(distance); + list3->SetListChildrenMainSize(childrenMainSize3); + list3->SetListInitialIndex(5); + + auto button3 = std::make_shared(); + button3->SetWidth(50); + button3->SetHeight(50); + button3->SetId("button3"); + button3->SetBackgroundColor(COLOR_TRANSPARENT); + button3->RegisterOnClick([list3, itemCount, childrenMainSize3]() { + list3->GetAdapter()->RemoveItem(itemCount - 1); + childrenMainSize3->Resize(itemCount - 1); + childrenMainSize3->Delete(itemCount - 1, 1); + list3->SetListChildrenMainSize(childrenMainSize3); + list3->SetListScrollToIndex({ itemCount - 2, 0 }); + }); + + // parent node + auto column = new ColumnComponent(); + auto row1 = make_shared(); + auto row2 = make_shared(); + row1->AddChild(list); + row1->AddChild(list2); + row1->AddChild(list3); + + row2->AddChild(button1); + row2->AddChild(button2); + row2->AddChild(button3); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ChildrenMainSizeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_childrenMainSize_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_childrenMainSize_test.h new file mode 100644 index 0000000000000000000000000000000000000000..8421e90e8a9d46a6ddd3614813afa23da79fdcb7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_childrenMainSize_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LIST_CHILDRENMAINSIZE_TEST_H +#define ARKUI_CAPI_DEMO_LIST_CHILDRENMAINSIZE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ListChildrenMainSizeTest { +public: + ~ListChildrenMainSizeTest(); + static napi_value CreateNativeNodeChildrenMainSize(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LIST_CHILDRENMAINSIZE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_closeAllAction_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_closeAllAction_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..537a5276508ae9cc6beb665ad2de49d193612cde --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_closeAllAction_test.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "list_closeAllAction_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "component/button_component.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; +static void SetAction(std::shared_ptr listItem, + ArkUI_ListItemSwipeEdgeEffect setEdgeEffect = + ArkUI_ListItemSwipeEdgeEffect::ARKUI_LIST_ITEM_SWIPE_EDGE_EFFECT_SPRING) +{ + auto option = new ListItemSwipeActionOption(); + auto col1 = std::make_shared(); + col1->SetWidth(50); + col1->SetHeight(50); + col1->SetBackgroundColor(COLOR_GREEN); + auto col2 = std::make_shared(); + col2->SetWidth(50); + col2->SetHeight(50); + col2->SetBackgroundColor(COLOR_YELLOW); + + auto item1 = OH_ArkUI_ListItemSwipeActionItem_Create(); + auto item2 = OH_ArkUI_ListItemSwipeActionItem_Create(); + + OH_ArkUI_ListItemSwipeActionItem_SetContent(item1, col1->GetComponent()); + OH_ArkUI_ListItemSwipeActionItem_SetContent(item2, col2->GetComponent()); + option->SetStart(item1); + option->SetEnd(item2); + option->SetEdgeEffect(setEdgeEffect); + listItem->SetListItemSwiperAction(option); +} + +static std::shared_ptr CreateButton(std::vector> list) +{ + auto row = make_shared(); + for (int i = 0; i < list.size(); i++) { + auto eachList = list[i]; + auto button1 = make_shared(); + button1->SetWidth(50); + button1->SetHeight(50); + button1->SetId("callbackButton" + std::to_string(i + 1)); + button1->SetBackgroundColor(COLOR_TRANSPARENT); + button1->RegisterOnClick([eachList]() { + void* userData = reinterpret_cast(eachList.get()); + OH_ArkUI_List_CloseAllSwipeActions(eachList->GetComponent(), userData, [](void* userData) { + auto list = reinterpret_cast(userData); + list->SetBackgroundColor(COLOR_RED); + }); + }); + auto button2 = make_shared(); + button2->SetWidth(50); + button2->SetHeight(50); + button2->SetId("nullCallbackButton" + std::to_string(i + 1)); + button2->SetBackgroundColor(COLOR_TRANSPARENT); + button2->RegisterOnClick( + [eachList]() { OH_ArkUI_List_CloseAllSwipeActions(eachList->GetComponent(), nullptr, nullptr); }); + row->AddChild(button1); + row->AddChild(button2); + } + return row; +} + +static std::shared_ptr CreateListWithAction(int32_t num, int32_t vertical, string firstIitemId) +{ + auto list = make_shared(); + list->SetMargin(10); + list->SetWidth(150); + list->SetHeight(150); + list->SetListDirection(vertical); + list->SetListDivider(COLOR_BLACK, 2, 0, 0); + for (int i = 0; i < num; i++) { + auto listItem = make_shared(); + if (i == 0) { + listItem->SetId(firstIitemId); + } + listItem->SetWidth(80); + listItem->SetHeight(80); + listItem->SetBackgroundColor(COLOR_BLUE); + SetAction(listItem); + list->AddChild(listItem); + } + return list; +} + +napi_value ListCloseAllTest::CreateNativeNodeCloseAll(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeCloseAll", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeCloseAll", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = new ColumnComponent(); + auto list1 = CreateListWithAction(1000, ArkUI_Axis::ARKUI_AXIS_VERTICAL, "list1"); + auto list2 = CreateListWithAction(1000, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL, "list2"); + auto list3 = CreateListWithAction(1000, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL, "list3"); + auto row = CreateButton({ list1, list2, list3 }); + column->AddChild(list1); + column->AddChild(list2); + column->AddChild(list3); + column->AddChild(row); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeCloseAll", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_closeAllAction_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_closeAllAction_test.h new file mode 100644 index 0000000000000000000000000000000000000000..97393e3fc94a3690d2ea2a03aad727afb1673b3a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_closeAllAction_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LIST_CLOSEALLACTION_TEST_H +#define ARKUI_CAPI_DEMO_LIST_CLOSEALLACTION_TEST_H + +#include "../common/common.h" +#include "list_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +class ListCloseAllTest { +public: + ~ListCloseAllTest(); + static napi_value CreateNativeNodeCloseAll(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LIST_CLOSEALLACTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_divider_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_divider_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de622c47a6847ada80fab915700a266cfa5cf478 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_divider_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "list_divider_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "arkui/native_node.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; +static void AddListItem(shared_ptr list, int index, int num) +{ + vector> input; + for (int i = 0; i < num; i++) { + auto item = make_shared(); + item->SetWidth(100); + item->SetHeight(50); + if (i == 0) { + item->SetBackgroundColor(COLOR_YELLOW); + } else { + item->SetBackgroundColor(COLOR_GREEN); + } + if (i == index) { + item->SetBackgroundColor(COLOR_BLUE); + } + input.push_back(item); + } + auto adapter = make_shared>(input); + list->SetLazyAdapter(adapter); +} + +static shared_ptr CreateListComponent(int index, int itemCount) +{ + auto list = make_shared(); + list->SetListInitialIndex(index); + list->SetListSpace(5); + list->SetWidth(105); + list->SetHeight(200); + list->SetBackgroundColor(COLOR_RED); + AddListItem(list, index, itemCount); + return list; +} +static shared_ptr CreateColumn(shared_ptr list) +{ + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(200); + column->SetMargin(5); + column->AddChild(list); + return column; +} + +napi_value ListDividerTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListSpaceTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto list1 = CreateListComponent(9, 10); + list1->SetListDivider(COLOR_BLUE, 0, 0, 0); + auto list2 = CreateListComponent(0, 10); + list2->SetListDivider(COLOR_BLUE, -1, -1, -1); + auto list3 = CreateListComponent(12, 10); + list3->SetListDivider(COLOR_BLUE, 5, 10, 10); + auto list4 = CreateListComponent(200, 1000); + list4->SetListDivider(COLOR_BLUE, 1000, 200, 200); + auto list5 = CreateListComponent(-1, 10); + auto list6 = CreateListComponent(12, 10); + list6->SetListDivider(COLOR_BLUE, 5, 10, 10); + list6->resetAttribute(NODE_LIST_DIVIDER); + auto list7 = CreateListComponent(10, 10); + list7->resetAttribute(NODE_LIST_INITIAL_INDEX); + + auto row1 = make_shared(); + row1->AddChild(CreateColumn(list1)); + row1->AddChild(CreateColumn(list2)); + row1->AddChild(CreateColumn(list3)); + + auto row2 = make_shared(); + row2->AddChild(CreateColumn(list4)); + row2->AddChild(CreateColumn(list5)); + row2->AddChild(CreateColumn(list6)); + + auto row3 = make_shared(); + row3->AddChild(CreateColumn(list7)); + auto column = new ColumnComponent(); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_divider_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_divider_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0ba72078f065487b46d4aebd0409a39f169ba705 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_divider_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LIST_DIVIDER_TEST_H +#define ARKUI_CAPI_DEMO_LIST_DIVIDER_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ListDividerTest { +public: + ~ListDividerTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LIST_DIVIDER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_nested_scroll_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_nested_scroll_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..17a98855df9b8e06401d3de920fe81cb3603e591 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_nested_scroll_test.cpp @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "list_nested_scroll_test.h" + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +napi_value ListNestedScrollTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListNestedScrollTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListFlowNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto mode0 = -1; + auto mode1 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_ONLY; + auto mode2 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_FIRST; + auto mode3 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST; + auto mode4 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARALLEL; + auto mode5 = 4; + + // NODE_SCROLL_NESTED_SCROLL + // 测试向下滑动 + auto scroll1 = CreateListByNestedScroll("scroll1", mode2, mode0); + auto scroll2 = CreateListByNestedScroll("scroll2", mode2, mode1); + auto scroll3 = CreateListByNestedScroll("scroll3", mode2, mode2); + auto scroll4 = CreateListByNestedScroll("scroll4", mode2, mode3); + auto scroll5 = CreateListByNestedScroll("scroll5", mode2, mode4); + auto scroll6 = CreateListByNestedScroll("scroll6", mode2, mode5); + // 测试向左滑动 + auto scroll7 = CreateListByNestedScroll("scroll7", mode0, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll8 = CreateListByNestedScroll("scroll8", mode1, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll9 = CreateListByNestedScroll("scroll9", mode2, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll10 = CreateListByNestedScroll("scroll10", mode3, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll11 = CreateListByNestedScroll("scroll11", mode4, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll12 = CreateListByNestedScroll("scroll12", mode5, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + auto column3 = std::make_shared(); + row1->AddChild(scroll1); + row1->AddChild(scroll2); + row1->AddChild(scroll3); + row1->AddChild(scroll4); + row2->AddChild(scroll5); + row2->AddChild(scroll6); + column1->AddChild(scroll7); + column1->AddChild(scroll8); + row2->AddChild(column1); + column2->AddChild(scroll9); + column2->AddChild(scroll10); + column3->AddChild(scroll11); + column3->AddChild(scroll12); + row3->AddChild(column2); + row3->AddChild(column3); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ListNestedScrollTest::CreateNativeNodeSmall(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListNestedScrollTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto mode0 = -1; + auto mode1 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_ONLY; + auto mode2 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_FIRST; + auto mode3 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST; + auto mode4 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARALLEL; + auto mode5 = 4; + + // NODE_SCROLL_NESTED_SCROLL + // 测试向下滑动 + auto scroll1 = CreateListByNestedScroll<7>("scroll1", mode2, mode0); + auto scroll2 = CreateListByNestedScroll<7>("scroll2", mode2, mode1); + auto scroll3 = CreateListByNestedScroll<7>("scroll3", mode2, mode2); + auto scroll4 = CreateListByNestedScroll<7>("scroll4", mode2, mode3); + auto scroll5 = CreateListByNestedScroll<7>("scroll5", mode2, mode4); + auto scroll6 = CreateListByNestedScroll<7>("scroll6", mode2, mode5); + // 测试向左滑动<8> + auto scroll7 = CreateListByNestedScroll<7>("scroll7", mode0, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll8 = CreateListByNestedScroll<7>("scroll8", mode1, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll9 = CreateListByNestedScroll<7>("scroll9", mode2, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll10 = CreateListByNestedScroll<7>("scroll10", mode3, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll11 = CreateListByNestedScroll<7>("scroll11", mode4, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + auto scroll12 = CreateListByNestedScroll<7>("scroll12", mode5, mode2, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(scroll1); + row1->AddChild(scroll2); + row1->AddChild(scroll3); + row1->AddChild(scroll4); + row2->AddChild(scroll5); + row2->AddChild(scroll6); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + auto column3 = std::make_shared(); + column1->AddChild(scroll7); + column1->AddChild(scroll8); + row2->AddChild(column1); + column2->AddChild(scroll9); + column2->AddChild(scroll10); + column3->AddChild(scroll11); + column3->AddChild(scroll12); + row3->AddChild(column2); + row3->AddChild(column3); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_nested_scroll_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_nested_scroll_test.h new file mode 100644 index 0000000000000000000000000000000000000000..1eba5ebbab95f847e719b8faec1bd293976bea2d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_nested_scroll_test.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_LIST_NESTED_SCROLL_TEST_H +#define CAPIDEMO_LIST_NESTED_SCROLL_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "list_component.h" +#include "scroll_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +class ListNestedScrollTest { +public: + ~ListNestedScrollTest() = default; + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeSmall(napi_env env, napi_callback_info info); + +private: + template + static std::shared_ptr CreateListByNestedScroll( + std::string index, int32_t forward, int32_t backward, int32_t direction = ArkUI_Axis::ARKUI_AXIS_VERTICAL) + { + auto list1 = std::make_shared(); + auto column1 = std::make_shared(); + column1->SetWidth((direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL) ? 100 : 50); + column1->SetHeight((direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL) ? 50 : 100); + column1->SetBackgroundColor(COLOR_RED); + auto column2 = std::make_shared(); + column2->SetWidth((direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL) ? 100 : 50); + column2->SetHeight((direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL) ? 50 : 100); + column2->SetBackgroundColor(COLOR_RED); + auto list2 = std::make_shared(); + auto input = std::vector>(); + for (int i = 0; i < size; i++) { + auto listItem = std::make_shared(); + listItem->SetWidth((direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL) ? 100 : 20); + listItem->SetHeight((direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL) ? 20 : 100); + listItem->SetBackgroundColor(COLOR_GREEN); + if (i == 0) { + listItem->SetBackgroundColor(COLOR_YELLOW); + } + if (i == size - 1) { + listItem->SetBackgroundColor(COLOR_BLUE); + } + input.push_back(listItem); + } + auto adapter = std::make_shared>(input); + + list2->SetWidth(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 200); + list2->SetHeight(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 200 : 100); + list2->SetListDirection(direction); + list2->SetListSpace(10); + list2->SetBackgroundColor(COLOR_GRAY); + list2->SetLazyAdapter(adapter); + list2->SetScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + list2->SetScrollEdgeEffect(ArkUI_EdgeEffect::ARKUI_EDGE_EFFECT_NONE, true); + list2->SetBorderWidth(1, 1, 1, 1); + list2->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + list2->SetNestedScroll(forward, backward); + list2->SetId(index); + + list1->SetWidth(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 200); + list1->SetHeight(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 200 : 100); + list1->SetNestedScroll(forward, backward); + list1->SetListDirection(direction); + list1->SetScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + list1->AddChild(column1); + list1->AddChild(list2); + list1->AddChild(column2); + list1->SetBorderWidth(1, 1, 1, 1); + list1->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + return list1; + } +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_LIST_NESTED_SCROLL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scroll_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scroll_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..937640e1b6c9234ee7d8946ec85634bb28cc8ea4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scroll_test.cpp @@ -0,0 +1,662 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "list_scroll_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "component/button_component.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; +using ScrollTo2CallBack = std::function, float, float, int32_t)>; +using ScrollTo7CallBack = std::function, float, float, const std::vector)>; +using ByCallBack = std::function, float, float)>; +using EdgeCallBack = std::function, int32_t)>; +using PageWithoutAnimationCallBack = std::function, bool, int32_t)>; +using PageWithAnimationCallBack = std::function, bool, bool, int32_t)>; +using ScrollToIndex1CallBack = std::function, int32_t)>; +using ScrollToIndex3CallBack = std::function, int32_t, bool, int32_t)>; +napi_value ListScrollTest::CreateNativeNodeOffset2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeOffset2", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeOffset2", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ScrollTo2CallBack change = [](std::shared_ptr list, float hOffset, float vOffset, int32_t index) { + list->SetScrollTo(hOffset, vOffset, {}); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + list->GetAdapter()->ReloadItem(index, column); + }; + float offset1 = -20; + float offset2 = 0; + float offset3 = 130; + float offset4 = 100000; + // NODE_SCROLL_OFFSET + // row + auto col1 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset1, offset2, 0); + auto col2 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset2, offset2, 0); + auto col3 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset3, offset2, 2); + auto col4 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset4, offset2, 59); + // column + auto col5 = CreateList<60>(change, offset2, offset1, 0); + auto col6 = CreateList<60>(change, offset2, offset2, 0); + auto col7 = CreateList<60>(change, offset2, offset3, 2); + auto col8 = CreateList<60>(change, offset2, offset4, 59); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + column1->AddChild(col1); + column1->AddChild(col3); + column2->AddChild(col2); + column2->AddChild(col4); + row1->AddChild(column1); + row1->AddChild(column2); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeOffset2", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ListScrollTest::CreateNativeNodeOffset6(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeOffset7", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeOffset7", "GetContext env or info isnull"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + typedef std::tuple, float, float, std::vector> ClickParam; + std::vector clickVector; + ScrollTo7CallBack change = [&clickVector](std::shared_ptr list, float hOffset, float vOffset, + const std::vector optionalParams) { + if (optionalParams.size() == 4) { + list->SetScrollEdgeEffect(ArkUI_EdgeEffect::ARKUI_EDGE_EFFECT_SPRING, true); + } + clickVector.emplace_back(list, hOffset, vOffset, optionalParams); + }; + float offset = 200; + std::vector optionalParams1 = { -1000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE }; + std::vector optionalParams2 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE }; + std::vector optionalParams3 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR }; + std::vector optionalParams4 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR, true }; + std::vector optionalParams5 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR, true, true }; + // NODE_SCROLL_OFFSET + // row + auto col1 = CreateList(change, 0.0f, offset, optionalParams1); + auto col2 = CreateList(change, 0.0f, offset, optionalParams2); + auto col3 = CreateList(change, 0.0f, offset, optionalParams3); + auto col4 = CreateList(change, 0.0f, offset, optionalParams4); + auto col5 = CreateList(change, 0.0f, offset, optionalParams5); + // column + auto col6 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset, 0.0f, optionalParams1); + auto col7 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset, 0.0f, optionalParams2); + auto col8 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset, 0.0f, optionalParams3); + auto col9 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset, 0.0f, optionalParams4); + auto col10 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, offset, 0.0f, optionalParams5); + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + auto column3 = std::make_shared(); + column1->AddChild(col6); + column1->AddChild(col7); + row2->AddChild(column1); + column2->AddChild(col8); + column2->AddChild(col9); + column3->AddChild(col10); + row3->AddChild(column2); + row3->AddChild(column3); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + + btn->RegisterOnClick([clickVector]() { + for (auto&& item : clickVector) { + auto list = std::get<0>(item); + auto hOffset = std::get<1>(item); + auto vOffset = std::get<2>(item); + auto optionalParams = std::get<3>(item); + list->SetScrollTo(hOffset, vOffset, optionalParams); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + list->GetAdapter()->ReloadItem(4, column); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeOffset7", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// scrollEdge +napi_value ListScrollTest::CreateNativeNodeEdge(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeEdge", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeEdge", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + EdgeCallBack change = [](std::shared_ptr list, int32_t type) { + list->SetListScrollToIndex({ 3, 0, 0 }); + list->SetScrollEdge(type); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + auto adapter = list->GetAdapter(); + if (!adapter) { + return; + } + if (type == ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_BOTTOM || type == ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_END) { + adapter->ReloadItem(14, column); + } else { + adapter->ReloadItem(0, column); + } + }; + int32_t type1 = -2; + int32_t type2 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_TOP; + int32_t type3 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_BOTTOM; + int32_t type4 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_START; + int32_t type5 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_END; + int32_t type6 = 4; + + // NODE_SCROLL_EDGE + // column + auto col1 = CreateList(change, type1); + auto col2 = CreateList(change, type2); + auto col3 = CreateList(change, type3); + auto col4 = CreateList(change, type6); + // row + auto col5 = CreateList<15, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, type1); + auto col6 = CreateList<15, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, type4); + auto col7 = CreateList<15, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, type5); + auto col8 = CreateList<15, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, type6); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + column1->AddChild(col5); + column1->AddChild(col6); + column2->AddChild(col7); + column2->AddChild(col8); + + row2->AddChild(column1); + row2->AddChild(column2); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeEdge", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// PAGE +napi_value ListScrollTest::CreateNativeNodePage(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodePage", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodePage", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // 收集测试滚动参数,待button点击滚动 + typedef std::tuple, int32_t, bool> ClickWithoutAnimation; + typedef std::tuple, int32_t, bool, bool> ClickWithAnimation; + std::vector clickWithoutAnimation; + std::vector clickWithAnimation; + + PageWithoutAnimationCallBack changeWithoutAnimation = [&clickWithoutAnimation](std::shared_ptr list, + bool next, int32_t targetIndex) { + list->SetScrollTo(50 * targetIndex, 50 * targetIndex, {}); + clickWithoutAnimation.emplace_back(list, targetIndex, next); + }; + PageWithAnimationCallBack changeWithAnimation = [&clickWithAnimation](std::shared_ptr list, + bool next, bool animation, int32_t targetIndex) { + list->SetScrollTo(50 * targetIndex, 50 * targetIndex, {}); + clickWithAnimation.emplace_back(list, targetIndex, next, animation); + }; + bool pre = true, next = false; + + // NODE_SCROLL_PAGE + // column + auto col1 = CreateList<40>(changeWithoutAnimation, pre, 10); // 正常 预置位置为10 + auto col2 = CreateList<40>(changeWithoutAnimation, next, 10); // 正常 预置位置为10 + auto col3 = CreateList<40>(changeWithoutAnimation, pre, 0); // 已达边界 预置位置为0 + auto col4 = CreateList<40>(changeWithoutAnimation, next, 39); // 已达边界 预置位置为39 + // row + // 正常 预置位置为10 + auto col5 = CreateList<40, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(changeWithAnimation, pre, true, 10); + // 正常 预置位置为10 + auto col6 = CreateList<40, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(changeWithAnimation, next, true, 10); + // 已达边界 预置位置为0 + auto col7 = CreateList<40, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(changeWithAnimation, pre, true, 0); + // 已达边界 预置位置为39 + auto col8 = CreateList<40, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(changeWithAnimation, next, true, 39); + auto btn = std::make_shared(); + btn->SetHeight(50); + btn->SetWidth(100); + btn->SetId("btn"); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + column1->AddChild(col5); + column1->AddChild(col6); + column2->AddChild(col7); + column2->AddChild(col8); + row2->AddChild(column1); + row2->AddChild(column2); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(btn); + btn->RegisterOnClick([clickWithoutAnimation, clickWithAnimation]() { + for (auto&& item : clickWithoutAnimation) { + auto list = std::get<0>(item); + auto targetIndex = std::get<1>(item); + auto next = std::get<2>(item); + list->SetScrollPage(next); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + if (next) { + list->GetAdapter()->ReloadItem(targetIndex == 0 ? 0 : targetIndex - 1, column); + } else if (!next) { + list->GetAdapter()->ReloadItem(targetIndex == 39 ? 39 : targetIndex + 4, column); + } + } + for (auto&& item : clickWithAnimation) { + auto list = std::get<0>(item); + auto targetIndex = std::get<1>(item); + auto next = std::get<2>(item); + auto animation = std::get<3>(item); + list->SetScrollPage(next, animation); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + if (next) { + list->GetAdapter()->ReloadItem(targetIndex == 0 ? 0 : targetIndex - 1, column); + } else if (!next) { + list->GetAdapter()->ReloadItem(targetIndex == 39 ? 39 : targetIndex + 4, column); + } + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodePage", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ListScrollTest::CreateNativeNodeBy(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeBy", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeBy", "GetContext env or info isnull"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ByCallBack change = [](std::shared_ptr list, float hDistance, float vDistance) { + std::thread scrollPage([list, hDistance, vDistance]() { + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + list->SetScrollBy(hDistance, vDistance); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + if (hDistance < 0 || vDistance < 0) { + list->GetAdapter()->ReloadItem(0, column); + } else if (hDistance > 30000 || vDistance > 30000) { + list->GetAdapter()->ReloadItem(59, column); + } else { + list->GetAdapter()->ReloadItem(2, column); + } + }); + scrollPage.detach(); + }; + float distance1 = -100000; + float distance2 = 0; + float distance3 = 100; + float distance4 = 100000; + float distance5 = 0; + + // NODE_SCROLL_BY + // column + auto col1 = CreateList<60>(change, distance5, distance1); + auto col2 = CreateList<60>(change, distance5, distance2); + auto col3 = CreateList<60>(change, distance5, distance3); + auto col4 = CreateList<60>(change, distance5, distance4); + // row + auto col5 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, distance1, distance5); + auto col6 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, distance2, distance5); + auto col7 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, distance3, distance5); + auto col8 = CreateList<60, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, distance4, distance5); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto column1 = std::make_shared(); + auto column2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + column1->AddChild(col5); + column1->AddChild(col6); + column2->AddChild(col7); + column2->AddChild(col8); + row2->AddChild(column1); + row2->AddChild(column2); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeBy", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ListScrollTest::CreateNativeNodeScrollToIndex(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeScrollToIndex", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeScrollToIndex", "GetContext env or info isnull"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // 收集测试滚动参数,待button点击滚动 + typedef std::tuple, int32_t> ClickParam1; + typedef std::tuple, int32_t, bool> ClickParam2; + typedef std::tuple, int32_t, bool, int32_t> ClickParam3; + std::vector clickVector1; + std::vector clickVector3; + ScrollToIndex1CallBack change1Param = [&clickVector1](std::shared_ptr List, int32_t index) { + clickVector1.emplace_back(List, index); + }; + ScrollToIndex3CallBack change3Param = [&clickVector3](std::shared_ptr List, int32_t index, + bool animation, int32_t alignment) { + clickVector3.emplace_back(List, index, animation, alignment); + }; + + int32_t alignment0 = -1; + int32_t alignment1 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_START; + int32_t alignment2 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_CENTER; + int32_t alignment3 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_END; + int32_t alignment4 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_AUTO; + int32_t alignment5 = 4; + // NODE_SCROLL_TO_INDEX + // column + auto col1 = CreateList<500>(change1Param, -1); + auto col2 = CreateList<500>(change1Param, 0); + auto col3 = CreateList<500>(change1Param, 499); + auto col4 = CreateList<500>(change1Param, 1000); + auto col5 = CreateList<60>(change3Param, 30, true, alignment0); + auto col6 = CreateList<60>(change3Param, 30, true, alignment1); + auto col7 = CreateList<60>(change3Param, 30, true, alignment2); + auto col8 = CreateList<60>(change3Param, 30, false, alignment3); + auto col9 = CreateList<60>(change3Param, 30, false, alignment4); + auto col10 = CreateList<60>(change3Param, 30, false, alignment5); + + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + btn->SetId("btn"); + btn->RegisterOnClick([clickVector1, clickVector3]() { + for (auto item : clickVector1) { + auto list = std::get<0>(item); + auto index = std::get<1>(item); + list->SetListScrollToIndex({ index }); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + if (index > 0 && index < 500) { + list->GetAdapter()->ReloadItem(index, column); + } else { + list->GetAdapter()->ReloadItem(0, column); + } + } + for (auto item : clickVector3) { + auto list = std::get<0>(item); + auto index = std::get<1>(item); + auto animation = std::get<2>(item); + auto alignment = std::get<3>(item); + list->SetListScrollToIndex({ index, animation, alignment }); + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(100); + column->SetBackgroundColor(COLOR_YELLOW); + if (index > 0 && index < 500) { + list->GetAdapter()->ReloadItem(index, column); + } else { + list->GetAdapter()->ReloadItem(0, column); + } + } + }); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNodeScrollToIndex", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scroll_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scroll_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9ab3b97a8aa9ea1d656cccfda7797c7170ea77fa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scroll_test.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LIST_SCROLL_TEST_H +#define ARKUI_CAPI_DEMO_LIST_SCROLL_TEST_H + +#include "../common/common.h" +#include "list_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +constexpr int32_t LIST_ITEM_COUNT = 15; + +class ListScrollTest { +public: + ~ListScrollTest(); + static napi_value CreateNativeNodeOffset2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOffset6(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeEdge(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeBy(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeScrollToIndex(napi_env env, napi_callback_info info); + +private: + template + static std::shared_ptr CreateList( + std::function, Args...)> change, Args... args) + { + auto col = std::make_shared(); + auto list = std::make_shared(); + list->SetListDirection(direction); + list->SetBorderWidth(1); + list->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + list->SetWidth(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 200); + list->SetHeight(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 200 : 100); + std::vector> input; + for (int i = 0; i < size; i++) { + auto column = std::make_shared(); + column->SetWidth(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 50); + column->SetHeight(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 50 : 100); + // When debugging, this code should be enabled to display the code number. + // auto text = std::make_shared(); + // text->SetAlign(ARKUI_ALIGNMENT_CENTER); + // text->SetTextContent("Text" + std::to_string(i)); + // column->AddChild(text); + column->SetBackgroundColor(COLOR_LIGHT_BLUE); + input.push_back(column); + } + auto adapter = make_shared>(input); + list->SetLazyAdapter(adapter); + auto childrenMainSize = new ListChildrenMainSizeOption(); + childrenMainSize->Resize(size); + childrenMainSize->SetDefaultMainSize(50); + col->AddChild(list); + if (change) { + change(list, args...); + } + return col; + } +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LIST_SCROLL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scrollbar_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scrollbar_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e8f23df69a1e2914d3156fdf2cff2ed7e0369c88 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scrollbar_test.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "list_scrollbar_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; +static void AddListItem(shared_ptr list, uint32_t color, int num) +{ + vector> input; + for (int i = 0; i < num; i++) { + auto listItem = make_shared(); + listItem->SetWidth(100); + listItem->SetHeight(50); + listItem->SetBackgroundColor(color); + input.push_back(listItem); + } + auto adapter = make_shared>(input); + list->SetLazyAdapter(adapter); +} + +static shared_ptr CreateColumn(shared_ptr list) +{ + auto column = make_shared(); + column->SetMargin(5); + column->AddChild(list); + return column; +} + +static shared_ptr CreateListComponent( + int listSpace, int itemCount, int vertical = ArkUI_Axis::ARKUI_AXIS_VERTICAL) +{ + auto list = make_shared(); + list->SetWidth(100); + list->SetHeight(150); + list->SetListSpace(listSpace); + list->SetBackgroundColor(COLOR_RED); + list->SetListDirection(vertical); + list->SetScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_ON); + AddListItem(list, COLOR_GREEN, itemCount); + return list; +} + +napi_value ListScrollBarTest::CreateNativeNodeScrollBar(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListScrollBarTest", "CreateNativeNodeScrollBar"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto list1 = CreateListComponent(20, 5); + list1->SetScrollBarColor(COLOR_BLUE); + list1->SetScrollBarWidth(0); + auto list2 = CreateListComponent(20, 5); + list2->SetScrollBarColor(COLOR_BLUE); + list2->SetScrollBarWidth(-1); + auto list3 = CreateListComponent(20, 20); + list3->SetScrollBarColor(COLOR_BLUE); + list3->SetScrollBarWidth(1000); + auto list4 = CreateListComponent(20, 20); + list4->SetScrollBarColor(COLOR_BLUE); + list4->SetScrollBarWidth(10); + list4->resetAttribute(NODE_SCROLL_BAR_COLOR); + auto list5 = CreateListComponent(20, 20); + list5->SetScrollBarColor(COLOR_BLUE); + list5->SetScrollBarWidth(20); + list5->resetAttribute(NODE_SCROLL_BAR_WIDTH); + + auto list6 = CreateListComponent(20, 5, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + list6->SetScrollBarColor(COLOR_BLUE); + list6->SetScrollBarWidth(0); + auto list7 = CreateListComponent(20, 5, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + list7->SetScrollBarColor(COLOR_BLUE); + list7->SetScrollBarWidth(-1); + auto list8 = CreateListComponent(20, 20, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + list8->SetScrollBarColor(COLOR_BLUE); + list8->SetScrollBarWidth(1000); + auto list9 = CreateListComponent(20, 5, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + list9->SetScrollBarColor(COLOR_RED); + list9->SetScrollBarWidth(10); + list9->resetAttribute(NODE_SCROLL_BAR_COLOR); + auto list10 = CreateListComponent(20, 5, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL); + list10->SetScrollBarColor(COLOR_RED); + list10->SetScrollBarWidth(20); + list10->resetAttribute(NODE_SCROLL_BAR_WIDTH); + + auto column = new ColumnComponent(); + auto row1 = make_shared(); + row1->AddChild(CreateColumn(list1)); + row1->AddChild(CreateColumn(list2)); + + auto row2 = make_shared(); + row2->AddChild(CreateColumn(list3)); + row2->AddChild(CreateColumn(list4)); + + auto row3 = make_shared(); + row3->AddChild(CreateColumn(list5)); + row3->AddChild(CreateColumn(list6)); + + auto row4 = make_shared(); + row4->AddChild(CreateColumn(list7)); + row4->AddChild(CreateColumn(list8)); + + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(row4); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scrollbar_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scrollbar_test.h new file mode 100644 index 0000000000000000000000000000000000000000..fbc4fbc451aae02037e00925da9b51f4f523473f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_scrollbar_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LIST_SCROLLBAR_TEST_H +#define ARKUI_CAPI_DEMO_LIST_SCROLLBAR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ListScrollBarTest { +public: + ~ListScrollBarTest(); + static napi_value CreateNativeNodeScrollBar(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LIST_SCROLLBAR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_space_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_space_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4712d97586e0d93f65ac461881ec697086d73fa2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_space_test.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "list_space_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "arkui/native_node.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; + +static void AddListItem(shared_ptr list, uint32_t color, int num) +{ + vector> input; + for (int i = 0; i < num; i++) { + auto item = make_shared(); + item->SetWidth(80); + item->SetHeight(50); + item->SetBackgroundColor(color); + input.push_back(item); + } + auto adapter = make_shared>(input); + list->SetLazyAdapter(adapter); +} + +static shared_ptr CreateColumn(shared_ptr list) +{ + auto column = make_shared(); + column->SetWidth(100); + column->SetHeight(200); + column->SetMargin(5); + column->AddChild(list); + return column; +} + +static shared_ptr CreateListComponent(int listSpace, int itemCount) +{ + auto list = make_shared(); + list->SetWidth(100); + list->SetHeight(200); + list->SetListSpace(listSpace); + list->SetBackgroundColor(COLOR_RED); + AddListItem(list, COLOR_GREEN, itemCount); + return list; +} + +napi_value ListSpaceTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ListSpaceTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto list1 = CreateListComponent(20, 5); + list1->SetListAlignListItem(ArkUI_ListItemAlignment::ARKUI_LIST_ITEM_ALIGNMENT_START); + auto list2 = CreateListComponent(0, 5); + list2->SetListAlignListItem(ArkUI_ListItemAlignment::ARKUI_LIST_ITEM_ALIGNMENT_CENTER); + auto list3 = CreateListComponent(-1, 5); + list3->SetListAlignListItem(ArkUI_ListItemAlignment::ARKUI_LIST_ITEM_ALIGNMENT_END); + auto list4 = CreateListComponent(1000, 5); + list4->SetListAlignListItem(-1); + auto list5 = CreateListComponent(2, 5); + list5->SetListAlignListItem(3); + list5->SetListDivider(COLOR_BLUE, 5, 0, 0); + auto list6 = CreateListComponent(20, 5); + list6->SetListAlignListItem(ArkUI_ListItemAlignment::ARKUI_LIST_ITEM_ALIGNMENT_CENTER); + list6->resetAttribute(NODE_LIST_ALIGN_LIST_ITEM); + list6->ResetListSpace(); + + auto column = new ColumnComponent(); + auto row1 = make_shared(); + row1->AddChild(CreateColumn(list1)); + row1->AddChild(CreateColumn(list2)); + + auto row2 = make_shared(); + row2->AddChild(CreateColumn(list3)); + row2->AddChild(CreateColumn(list4)); + + auto row3 = make_shared(); + row3->AddChild(CreateColumn(list5)); + row3->AddChild(CreateColumn(list6)); + + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/list/list_space_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_space_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d5896af08703b50083a40218a6588d1036fb1926 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/list/list_space_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LIST_SPACE_TEST_H +#define ARKUI_CAPI_DEMO_LIST_SPACE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ListSpaceTest { +public: + ~ListSpaceTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LIST_SPACE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/listitemgroup/listItemGroup_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/listitemgroup/listItemGroup_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b86ffbc4f6730a02bc48af1733fa388e23b55f8d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/listitemgroup/listItemGroup_test.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "listItemGroup_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "arkui/native_node.h" +#include "component/column_component.h" +#include "component/list_component.h" +#include "component/row_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +using namespace std; +struct DividerOption { + uint32_t color; + float width; + float distanceStart; + float distanceEnd; +}; +using HeaderAndFooterCallBack = std::function, bool, bool, bool, bool)>; +using DividerCallBack = std::function, DividerOption, bool)>; + +napi_value ListItemGroupTest::CreateNativeNodeHeaderAndFooter(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNode", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNode", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + HeaderAndFooterCallBack change = [](std::shared_ptr listItemGroup, bool hasHeader, + bool hasFooter, bool reset, bool isRow) { + listItemGroup->SetListItemGroupDivider(COLOR_BLACK, 2, 0, 0); + if (hasFooter) { + auto footer = new ColumnComponent(); + footer->SetWidth(isRow ? 50 : 100); + footer->SetHeight(isRow ? 100 : 50); + footer->SetBackgroundColor(COLOR_YELLOW); + listItemGroup->SetListItemGroupFooter(footer); + } + if (hasHeader) { + auto header = new ColumnComponent(); + header->SetWidth(isRow ? 50 : 100); + header->SetHeight(isRow ? 100 : 50); + header->SetBackgroundColor(COLOR_BLUE); + listItemGroup->SetListItemGroupHeader(header); + } + if (reset) { + listItemGroup->resetAttribute(NODE_LIST_ITEM_GROUP_SET_HEADER); + listItemGroup->resetAttribute(NODE_LIST_ITEM_GROUP_SET_FOOTER); + } + }; + // column + auto list1 = CreateListWithGroup<3>(change, true, true, false, false); + auto list2 = CreateListWithGroup<3>(change, true, false, false, false); + auto list3 = CreateListWithGroup<3>(change, false, true, false, false); + auto list4 = CreateListWithGroup<3>(change, true, true, true, false); + // row + auto list5 = CreateListWithGroup<3, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, true, true, false, true); + auto list6 = CreateListWithGroup<3, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, true, false, false, true); + auto list7 = CreateListWithGroup<3, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, false, true, false, true); + auto list8 = CreateListWithGroup<3, ArkUI_Axis::ARKUI_AXIS_HORIZONTAL>(change, true, true, true, true); + + auto row1 = make_shared(); + auto row2 = make_shared(); + row1->AddChild(list1); + row1->AddChild(list2); + row1->AddChild(list3); + row1->AddChild(list4); + + auto column1 = make_shared(); + auto column2 = make_shared(); + column1->AddChild(list5); + column1->AddChild(list6); + column2->AddChild(list7); + column2->AddChild(list8); + row2->AddChild(column1); + row2->AddChild(column2); + + auto column = new ColumnComponent(); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNode", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ListItemGroupTest::CreateNativeNodeDivider(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNode", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNode", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + DividerCallBack change = [](std::shared_ptr listItemGroup, DividerOption option, + bool reset) { + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + listItemGroup->SetListItemGroupDivider(option.color, option.width, option.distanceStart, option.distanceEnd); + if (reset) { + listItemGroup->resetAttribute(NODE_LIST_ITEM_GROUP_SET_DIVIDER); + } + }; + auto dividerOption2 = DividerOption { COLOR_BLUE, -1, -1, -1 }; + auto dividerOption1 = DividerOption { COLOR_BLUE, 0, 0, 0 }; + auto dividerOption3 = DividerOption { COLOR_BLUE, 5, 10, 10 }; + auto dividerOption4 = DividerOption { COLOR_BLUE, 1000, 200, 200 }; + auto dividerOption5 = DividerOption { COLOR_GREEN, 5, 0, 0 }; + + auto list1 = CreateListWithGroup<10>(change, dividerOption1, false); + auto list2 = CreateListWithGroup<10>(change, dividerOption2, false); + auto list3 = CreateListWithGroup<10>(change, dividerOption3, false); + auto list4 = CreateListWithGroup<10>(change, dividerOption4, false); + auto list5 = CreateListWithGroup<10>(change, dividerOption5, false); + auto list6 = CreateListWithGroup<10>(change, dividerOption5, true); + auto row1 = make_shared(); + auto row2 = make_shared(); + + row1->AddChild(list1); + row1->AddChild(list2); + row1->AddChild(list3); + row1->AddChild(list4); + row2->AddChild(list5); + row2->AddChild(list6); + + auto column = new ColumnComponent(); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CreateNativeNode", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/listitemgroup/listItemGroup_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/listitemgroup/listItemGroup_test.h new file mode 100644 index 0000000000000000000000000000000000000000..b68bc04b260bbd9283cce880a0822775c56c6fc4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/listitemgroup/listItemGroup_test.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_LISTITEMGROUP_TEST_H +#define ARKUI_CAPI_DEMO_LISTITEMGROUP_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "list_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { +using namespace std; +class ListItemGroupTest { +public: + ~ListItemGroupTest(); + static napi_value CreateNativeNodeHeaderAndFooter(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeDivider(napi_env env, napi_callback_info info); + +private: + template + static std::shared_ptr CreateListWithGroup( + std::function, Args...)> change, Args... args) + { + auto col = std::make_shared(); + auto group = make_shared(); + for (int i = 0; i < size; i++) { + auto item = make_shared(); + item->SetWidth(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 50); + item->SetHeight(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 50 : 100); + item->SetBackgroundColor(COLOR_RED); + group->AddChild(item); + } + auto list = std::make_shared(); + list->SetWidth(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 100 : 200); + list->SetHeight(direction == ArkUI_Axis::ARKUI_AXIS_VERTICAL ? 200 : 100); + list->SetListDirection(direction); + list->SetMargin(5); + list->SetScrollTo(20, 20, { 0, 0 }); + list->AddChild(group); + col->AddChild(list); + if (change) { + change(group, args...); + } + return col; + } +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_LISTITEMGROUP_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/manager/plugin_manager.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/manager/plugin_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a052cd14a2d4faf31964e32ee40181ec8eac383 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/manager/plugin_manager.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "plugin_manager.h" + +#include +#include +#include + +#include "./common/common.h" + +namespace ArkUICApiDemo { +PluginManager PluginManager::pluginManager_; + +PluginManager::~PluginManager() +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", "~PluginManager"); + for (auto iter = nativeXComponentMap_.begin(); iter != nativeXComponentMap_.end(); ++iter) { + if (iter->second != nullptr) { + delete iter->second; + iter->second = nullptr; + } + } + nativeXComponentMap_.clear(); +} + +napi_value PluginManager::GetContext(napi_env env, napi_callback_info info) +{ + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "GetContext env or info is null"); + return nullptr; + } + + size_t argCnt = 1; + napi_value args[1] = { nullptr }; + if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "GetContext napi_get_cb_info failed"); + } + + if (argCnt != 1) { + napi_throw_type_error(env, NULL, "Wrong number of arguments"); + return nullptr; + } + + napi_valuetype valuetype; + if (napi_typeof(env, args[0], &valuetype) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_typeof failed"); + return nullptr; + } + + if (valuetype != napi_number) { + napi_throw_type_error(env, NULL, "Wrong type of arguments"); + return nullptr; + } + + int64_t value; + if (napi_get_value_int64(env, args[0], &value) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_get_value_int64 failed"); + return nullptr; + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +void PluginManager::Export(napi_env env, napi_value exports) +{ + if ((env == nullptr) || (exports == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "Export: env or exports is null"); + return; + } + + napi_value exportInstance = nullptr; + if (napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "Export: napi_get_named_property fail"); + return; + } + + OH_NativeXComponent* nativeXComponent = nullptr; + if (napi_unwrap(env, exportInstance, reinterpret_cast(&nativeXComponent)) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "Export: napi_unwrap fail"); + return; + } else { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "Export: napi_unwrap success"); + } + + char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = { '\0' }; + uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1; + if (OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize) != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "Export: OH_NativeXComponent_GetXComponentId fail"); + return; + } + + std::string id(idStr); + auto context = PluginManager::GetInstance(); + if ((context != nullptr) && (nativeXComponent != nullptr)) { + context->SetNativeXComponent(id, nativeXComponent); + } +} + +void PluginManager::SetNativeXComponent(std::string& id, OH_NativeXComponent* nativeXComponent) +{ + if (nativeXComponent == nullptr) { + return; + } + + if (nativeXComponentMap_.find(id) == nativeXComponentMap_.end()) { + nativeXComponentMap_[id] = nativeXComponent; + return; + } + + if (nativeXComponentMap_[id] != nativeXComponent) { + OH_NativeXComponent* tmp = nativeXComponentMap_[id]; + delete tmp; + tmp = nullptr; + nativeXComponentMap_[id] = nativeXComponent; + } +} + +OH_NativeXComponent* PluginManager::GetNativeXComponent(std::string& id) +{ + if (nativeXComponentMap_.find(id) == nativeXComponentMap_.end()) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "GetNativeXComponent.%{public}s == nullptr", + id.c_str()); + return nullptr; + } + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", + "nativeXComponentMap_[%{public}s] == %{public}p", id.c_str(), nativeXComponentMap_[id]); + return nativeXComponentMap_[id]; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/manager/plugin_manager.h b/function/ui_compare/capidemo/entry/src/main/cpp/manager/plugin_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..6ee79d601f5b1512be5baee3d3628e43691b9474 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/manager/plugin_manager.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef NATIVE_XCOMPONENT_PLUGIN_MANAGER_H +#define NATIVE_XCOMPONENT_PLUGIN_MANAGER_H + +#include +#include +#include +#include +#include + +namespace ArkUICApiDemo { +class PluginManager { +public: + ~PluginManager(); + + static PluginManager* GetInstance() + { + return &PluginManager::pluginManager_; + } + + static napi_value GetContext(napi_env env, napi_callback_info info); + + void SetNativeXComponent(std::string& id, OH_NativeXComponent* nativeXComponent); + OH_NativeXComponent* GetNativeXComponent(std::string& id); + void Export(napi_env env, napi_value exports); + +private: + static PluginManager pluginManager_; + + std::unordered_map nativeXComponentMap_; +}; +} // namespace ArkUICApiDemo +#endif // NATIVE_XCOMPONENT_PLUGIN_MANAGER_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/mix/mix_getnodehandle_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/mix/mix_getnodehandle_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3efd1d3d4ba118da84ae1688f7418302a569ac05 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/mix/mix_getnodehandle_test.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mix_getnodehandle_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +napi_value MixGetNodeHandleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "MixGetNodeHandleTest", "CreateNativeNode"); + + size_t argc = 3; + napi_value args[3] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "MixGetNodeHandleTest", "GetContext env or info is null"); + return nullptr; + } + napi_ref refer; + // 创建引用之后保存,防止释放。 + napi_create_reference(env, args[1], 1, &refer); + + napi_value result = nullptr; + napi_value createRow = nullptr; + // 调用ArkTS的Create函数创建ArkTS的ComponentContent。 + napi_get_reference_value(env, refer, &createRow); + napi_call_function(env, nullptr, createRow, 1, &args[2], &result); + // 获取ArkTS的Row组件。 + ArkUI_NodeHandle rowHandle; + OH_ArkUI_GetNodeHandleFromNapiValue(env, result, &rowHandle); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(parentColumn, rowHandle); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "MixGetNodeHandleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/mix/mix_getnodehandle_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/mix/mix_getnodehandle_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f8d9210273c7c3f92ebe6732806cc3d059c647ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/mix/mix_getnodehandle_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_MIX_GETNODEHANDLE_TEST_H +#define ARKUI_CAPI_DEMO_MIX_GETNODEHANDLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class MixGetNodeHandleTest { +public: + ~MixGetNodeHandleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_MIX_GETNODEHANDLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/napi_init.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ee744555b45fd837edb831af54bbb4a7fe66a1e5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,1038 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "animation/animate_animateoption_test.h" +#include "animation/animate_animatoroption_test.h" +#include "animation/animate_curve_test.h" +#include "animation/animate_geometrytransition_test.h" +#include "animation/animate_keyframeanimateoption_test.h" +#include "list/list_scrollbar_test.h" +#include "list/list_divider_test.h" +#include "list/list_nested_scroll_test.h" +#include "list/list_space_test.h" +#include "list/list_childrenMainSize_test.h" +#include "list/list_closeAllAction_test.h" +#include "list/list_scroll_test.h" +#include "listitemgroup/listItemGroup_test.h" +#include "column/column_align_items_test.h" +#include "column/column_justify_content_test.h" +#include "flex/flex_options_test.h" +#include "grid/grid_test.h" +#include "gesture/gesture_gesture_test.h" +#include "requirement/requirement_pangesture_test.h" +#include "requirement/requirement_pinchandpangesture_test.h" +#include "requirement/requirement_routerpagestate_test.h" +#include "resourcenapivalue/resourcenapivalue_test.h" +#include "lazyforeach/lazyforeach_test.h" +#include "manager/plugin_manager.h" +#include "radio/radio_checked_test.h" +#include "radio/radio_reset_attribute_test.h" +#include "radio/radio_style_test.h" +#include "radio/radio_value_group_test.h" +#include "refresh/refresh_test.h" +#include "row/row_align_items_test.h" +#include "row/row_justify_content_test.h" +#include "relativeContainer/relativecontainer_guideLine_test.h" +#include "relativeContainer/relativecontainer_barrier_test.h" +#include "relativeContainer/rule_option_test.h" +#include "imageanimator/imageanimator_frameinfo_test.h" +#include "imageanimator/imageanimator_test.h" +#include "span/span_textbackgroundstyle_test.h" +#include "span/span_baselineoffset_test.h" +#include "span/span_value_test.h" +#include "span/span_textshadow_test.h" +#include "span/span_fontfamily_test.h" +#include "text/text_content_test.h" +#include "text/text_decorationstyle_test.h" +#include "text/text_wordbreak_test.h" +#include "text/text_ellipsismode_test.h" +#include "text/text_linespacing_test.h" +#include "text/text_fontfeature_test.h" +#include "text/text_selectedbackgroundcolor_test.h" +#include "text/text_datadetectorconfig_test.h" +#include "text/text_enabledatadetector_test.h" +#include "text/text_paragraph.h" +#include "textarea/textarea_bluronsubmit_test.h" +#include "textarea/textarea_caretposition_test.h" +#include "textarea/textarea_contenttype_test.h" +#include "textarea/textarea_controller_test.h" +#include "textarea/textarea_enableautofill_test.h" +#include "textarea/textarea_enablekeyboardonfocus_test.h" +#include "textarea/textarea_enterkeytype_test.h" +#include "textarea/textarea_fontfeature_test.h" +#include "textarea/textarea_getcaretoffset_test.h" +#include "textarea/textarea_inputfilter_test.h" +#include "textarea/textarea_maxlines_test.h" +#include "textarea/textarea_numberoflines_test.h" +#include "textarea/textarea_selectedbackgroundcolor_test.h" +#include "textarea/textarea_selectionmenuhidden_test.h" +#include "textarea/textarea_settextselection_test.h" +#include "textarea/textarea_showcounter_test.h" +#include "textarea/textarea_showkeyboardonfocus_test.h" +#include "textarea/textarea_textplaceholder_test.h" +#include "textarea/textarea_type_test.h" +#include "textinput/textinput_bluronsubmit_test.h" +#include "textinput/textinput_cancelbutton_test.h" +#include "textinput/textinput_caretposition_test.h" +#include "textinput/textinput_content_type_test.h" +#include "textinput/textinput_controller_test.h" +#include "textinput/textinput_custom_keyboard_test.h" +#include "textinput/textinput_enable_auto_fill_test.h" +#include "textinput/textinput_fontfeature_test.h" +#include "textinput/textinput_getcaretoffset_test.h" +#include "textinput/textinput_inputfilter_test.h" +#include "textinput/textinput_maxlines_test.h" +#include "textinput/textinput_minfontsizeandmaxfontsize.h" +#include "textinput/textinput_numberoflines_test.h" +#include "textinput/textinput_password_rules_test.h" +#include "textinput/textinput_selectall_test.h" +#include "textinput/textinput_selection_menu_hidden_test.h" +#include "textinput/textinput_settextselection_test.h" +#include "textinput/textinput_showkeyboardonfocus_test.h" +#include "textinput/textinput_style_test.h" +#include "textinput/textinput_textplaceholder_test.h" +#include "textinput/textinput_underlinecolor_test.h" +#include "textinput/textinput_wordbreak_test.h" +#include "toggle/toggle_unselectedcolor_test.h" +#include "swiper/swiper_adapter_test.h" +#include "swiper/swiper_change_index_test.h" +#include "swiper/swiper_dot_indicator_test.h" +#include "swiper/swiper_effectmode_test.h" +#include "swiper/swiper_event_test.h" +#include "swiper/swiper_margin_test.h" +#include "swiper/swiper_nestedscroll_test.h" +#include "swiper/swiper_onanimation_test.h" +#include "swiper/swiper_onchange_test.h" +#include "swiper/swiper_reset_attribute_test.h" +#include "customdialog/customdialog_content_test.h" +#include "button/button_type_test.h" +#include "calendarpicker/calendarpicker_hint_radius_test.h" +#include "calendarpicker/calendarpicker_selected_date_test.h" +#include "slider/slider_track_thickness_test.h" +#include "stack/stack_align_content_test.h" +#include "waterflow/waterflow_cached_count_test.h" +#include "waterflow/waterflow_section_test.h" +#include "waterflow/waterflow_layout_direction_test.h" +#include "waterflow/waterflow_columns_rows_template_test.h" +#include "waterflow/waterflow_columns_rows_gap.h" +#include "waterflow/waterflow_nested_scroll_test.h" +#include "waterflow/waterflow_scroll_test.h" +#include "waterflow/waterflow_item_constraint_size_test.h" +#include "waterflow/waterflow_footer_test.h" +#include "waterflow/waterflow_event_test.h" +#include "xcomponent/xcomponent_id_test.h" +#include "scroll/scroll_scrollbarwidth_test.h" +#include "scroll/scroll_scrollby_test.h" +#include "scroll/scroll_enablepaging_test.h" +#include "scroll/scroll_scrolloffset_test.h" +#include "scroll/scroll_scrollpage_test.h" +#include "scroll/scroll_scrolledge_test.h" +#include "progress/progress_total_test.h" +#include "progress/progress_type_test.h" +#include "commonattrs/commonattrs_backgroundblurstyle_test.h" +#include "commonattrs/commonattrs_backgroundimage_test.h" +#include "commonattrs/commonattrs_backgroundimagesize_test.h" +#include "commonattrs/commonattrs_backgroundimageposition_test.h" +#include "commonattrs/commonattrs_brightness_test.h" +#include "commonattrs/commonattrs_saturate_test.h" +#include "commonattrs/commonattrs_blur_test.h" +#include "commonattrs/commonattrs_clipshape_test.h" +#include "commonattrs/commonattrs_customshadow_test.h" +#include "commonattrs/commonattrs_visibility_test.h" +#include "commonattrs/commonattrs_defaultfocus_test.h" +#include "commonattrs/commonattrs_focusstatus_test.h" +#include "commonattrs/commonattrs_aspectratio_test.h" +#include "commonattrs/commonattrs_foregroundcolor_test.h" +#include "commonattrs/commonattrs_markanchor_test.h" +#include "commonattrs/commonattrs_offset_test.h" +#include "commonattrs/commonattrs_overlay_test.h" +#include "commonattrs/commonattrs_responseregion_test.h" +#include "commonattrs/commonattrs_scale_test.h" +#include "commonattrs/commonattrs_transformcenter_test.h" +#include "commonattrs/commonattrs_transitionmove_test.h" +#include "commonattrs/commonattrs_transitionopacity_test.h" +#include "commonattrs/commonattrs_transitionrotate_test.h" +#include "commonattrs/commonattrs_transitionscale_test.h" +#include "commonattrs/commonattrs_transitiontranslate_test.h" +#include "commonattrs/commonattrs_transitionasymmetric_test.h" +#include "commonattrs/commonattrs_translate_test.h" +#include "commonattrs/commonattrs_touchable_test.h" +#include "commonattrs/commonattrs_rotate_test.h" +#include "commonattrs/commonattrs_rendergroup_test.h" +#include "commonattrs/commonattrs_renderfit_test.h" +#include "commonattrs/commonattrs_layoutweight_test.h" +#include "commonattrs/commonattrs_displaypriority_test.h" +#include "commonattrs/commonattrs_outlinewidth_test.h" +#include "commonattrs/commonattrs_colorblend_test.h" +#include "commonattrs/commonattrs_chainmode_test.h" +#include "commonattrs/commonattrs_expand_safe_area_test.h" +#include "commonattrs/commonattrs_zindex_test.h" +#include "commonattrs/commonattrs_accessibilityrole_test.h" +#include "commonattrs/commonattrs_accessibilitystate_test.h" +#include "commonattrs/commonattrs_accessibilityvalue_test.h" +#include "commonattrs/commonattrs_focus_on_touch_test.h" +#include "commonattrs/commonattrs_alignment_test.h" +#include "commonattrs/commonattrs_padding_test.h" +#include "commonattrs/commonattrs_outlinecolor_test.h" +#include "commonattrs/commonattrs_size_test.h" +#include "commonevent/common_event.h" +#include "nodetree/node_tree_test.h" +#include "eventcallback/event_callback_test.h" +#include "attributesetting/attribute_setting_test.h" +#include "inputevent/input_event_test.h" +#include "image/image_src_test.h" +#include "image/image_resizable_test.h" +#include "image/image_draggable_test.h" +#include "image/image_rendermode_test.h" +#include "image/image_fitoriginalSize_test.h" +#include "image/image_fillcolor_test.h" +#include "image/image_onfinish_test.h" +#include "image/image_downprogress_test.h" +#include "image/image_objectfit_test.h" +#include "imagespan/imagespan_src_test.h" +#include "imagespan/imagespan_alt_onclick_test.h" +#include "unit/unit_length_metrics_test.h" +#include "unit/unit_Percent_test.h" +#include "mix/mix_getnodehandle_test.h" +#include "tools/tools_layout_rect_test.h" +#include "customcomponent/customcomponent_measuredsize_test.h" +#include "customcomponent/customcomponent_layoutposition_test.h" +#include "customcomponent/customcomponent_drawcontext_test.h" +#include "customcomponent/customcomponent_gettotalchildcount_test.h" +#include "customcomponent/customcomponent_getchildat_test.h" +#include "customcomponent/customcomponent_getfirstchild_test.h" +#include "customcomponent/customcomponent_getlastchild_test.h" +#include "customcomponent/customcomponent_getpreviousnetsibling_test.h" +#include "customcomponent/customcomponent_customevent_test.h" +#include "customcomponent/customcomponent_layoutconstraint_test.h" +#include "customcomponent/customcomponent_layoutagain_test.h" + +using namespace ArkUICApiDemo; + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", "Init begins"); + if ((env == nullptr) || (exports == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", "env or exports is null"); + return nullptr; + } + + napi_property_descriptor desc[] = { + { "animateAnimateOptionDurationTest", nullptr, AnimateOptionTest::CreateNativeNodeDuration, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "animateAnimateOptionDelayTest", nullptr, AnimateOptionTest::CreateNativeNodeDelay, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "animateAnimateOptionIterationsTest", nullptr, AnimateOptionTest::CreateNativeNodeIterations, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "animateAnimatorOptionDurationTest", nullptr, AnimatorOptionTest::CreateNativeNodeDuration, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "animateAnimatorOptionInterpolationTest", nullptr, AnimatorOptionTest::CreateNativeNodeInterpolation, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "animateAnimatorOptionIterationsTest", nullptr, AnimatorOptionTest::CreateNativeNodeIterations, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "animateAnimatorOptionStateTest", nullptr, AnimatorOptionTest::CreateNativeNodeState, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "animateCurveTest", nullptr, AnimateCurveTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "animateGeometryTransitionNormalTest", nullptr, AnimateGeometryTransitionTest::CreateNativeNodeNormal, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "animateGeometryTransitionMultiTest", nullptr, AnimateGeometryTransitionTest::CreateNativeNodeMulti, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "animateGeometryTransitionDoubleTest", nullptr, AnimateGeometryTransitionTest::CreateNativeNodeDouble, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "animateKeyframeAnimateOptionDurationTest", nullptr, KeyframeAnimateOptionTest::CreateNativeNodeDuration, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "animateKeyframeAnimateOptionDelayTest", nullptr, KeyframeAnimateOptionTest::CreateNativeNodeDelay, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "animateKeyframeAnimateOptionIterationsTest", nullptr, KeyframeAnimateOptionTest::CreateNativeNodeIterations, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "listItemGroupDividerTest", nullptr, ListItemGroupTest::CreateNativeNodeDivider, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listItemGroupHeaderAndFooterTest", nullptr, ListItemGroupTest::CreateNativeNodeHeaderAndFooter, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "listSpaceAndAlignmentTest", nullptr, ListSpaceTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listDividerAndInitialIndexTest", nullptr, ListDividerTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listNestedScrollTest", nullptr, ListNestedScrollTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listNestedScrollSmallTest", nullptr, ListNestedScrollTest::CreateNativeNodeSmall, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listScrollBarWidthAndColorTest", nullptr, ListScrollBarTest::CreateNativeNodeScrollBar, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "listChildrenMainSizeTest", nullptr, ListChildrenMainSizeTest::CreateNativeNodeChildrenMainSize, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "listCloseAllTest", nullptr, ListCloseAllTest::CreateNativeNodeCloseAll, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listScrollByTest", nullptr, ListScrollTest::CreateNativeNodeBy, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "listScrollEdgeTest", nullptr, ListScrollTest::CreateNativeNodeEdge, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "listScrollOffset2Test", nullptr, ListScrollTest::CreateNativeNodeOffset2, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listScrollOffset6Test", nullptr, ListScrollTest::CreateNativeNodeOffset6, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "listScrollPageTest", nullptr, ListScrollTest::CreateNativeNodePage, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "listScrollToIndexTest", nullptr, ListScrollTest::CreateNativeNodeScrollToIndex, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "columnJustifyContentTest", nullptr, ColumnJustifyContentTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "columnAlignItemsTest", nullptr, ColumnAlignItemsTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "columnAlignItemsMoreAttributeTest", nullptr, ColumnAlignItemsTest::CreateMoreAttributeNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "rowJustifyContentTest", nullptr, RowJustifyContentTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "rowAlignItemsTest", nullptr, RowAlignItemsTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "rowAlignItemsMoreAttributeTest", nullptr, RowAlignItemsTest::CreateMoreAttributeNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "flexOptionsTest", nullptr, FlexOptionsTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "radioCheckedTest", nullptr, RadioCheckedTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "radioStyleTest", nullptr, RadioStyleTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "radioValueAndGroupTest", nullptr, RadioValueAndGroupTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "radioResetAttributeTest", nullptr, RadioResetAttributeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "relativeContainerGuideLineTest", nullptr, RelativeContainerGuideLineTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "relativeContainerBarrierTest", nullptr, RelativeContainerBarrierTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "ruleOptionTest", nullptr, RuleOptionTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "gridTest", nullptr, GridTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "gridCachedCountTest", nullptr, GridTest::CreateNativeNodeForCachedCount, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "gridResetAttributeTest", nullptr, GridTest::CreateNativeNodeForResetAttribute, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "gestureGestureTest", nullptr, GestureGestureTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "gestureGesture1Test", nullptr, GestureGestureTest::CreateNativeNode1, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "gestureGesture2Test", nullptr, GestureGestureTest::CreateNativeNode2, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "gestureGesture3Test", nullptr, GestureGestureTest::CreateNativeNode3, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "requirementPanGestureTest", nullptr, RequirementPanGestureTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "requirementPinchAndPanGestureTest", nullptr, RequirementPinchAndPanGestureTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "requirementRouterPageStateTest", nullptr, RequirementRouterPageStateTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "resourceNapiValueTest", nullptr, ResourceNapiValueTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachGetAllItemTest", nullptr, LazyForEachTest::CreateNativeNodeGetAllItem, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachUnregisterTest", nullptr, LazyForEachTest::CreateNativeNodeUnregister, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachTotalCountTest", nullptr, LazyForEachTest::CreateNativeNodeTotalCount, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachNodeIdTest", nullptr, LazyForEachTest::CreateNativeNodeNodeId, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachDisposeTest", nullptr, LazyForEachTest::CreateNativeNodeDispose, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachHostNodeTest", nullptr, LazyForEachTest::CreateNativeNodeHostNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachReloadAllItemsTest", nullptr, LazyForEachTest::CreateNativeNodeReloadAllItems, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "lazyForEachReloadItemTest", nullptr, LazyForEachTest::CreateNativeNodeReloadItem, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachReloadItemBigTest", nullptr, LazyForEachTest::CreateNativeNodeReloadItemBig, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "lazyForEachRemoveItemTest", nullptr, LazyForEachTest::CreateNativeNodeRemoveItem, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachRemoveItemBigTest", nullptr, LazyForEachTest::CreateNativeNodeRemoveItemBig, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "lazyForEachInsertItemTest", nullptr, LazyForEachTest::CreateNativeNodeInsertItem, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachInsertItemBigTest", nullptr, LazyForEachTest::CreateNativeNodeInsertItemBig, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "lazyForEachMoveItemTest", nullptr, LazyForEachTest::CreateNativeNodeMoveItem, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "lazyForEachMoveItemBigTest", nullptr, LazyForEachTest::CreateNativeNodeMoveItemBig, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "lazyForEachGetRemovedNodeTest", nullptr, LazyForEachTest::CreateNativeNodeGetRemovedNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "refreshForContentAndRatioTest", nullptr, RefreshTest::CreateNativeNodeForRefreshContentAndRatio, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "refreshForRefreshingTest", nullptr, RefreshTest::CreateNativeNodeForRefreshing, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "refreshTest", nullptr, RefreshTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "refreshNestedScrollTest", nullptr, RefreshTest::CreateNativeNodeNestedScroll, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "refreshResetAttributeTest", nullptr, RefreshTest::CreateNativeNodeForResetAttribute, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "toggleUnSelectedColorTest", nullptr, ToggleUnSelectedColorTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "imageFrameInfoTest", nullptr, ImageAnimatorFrameInfoTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "imageFrameInfoAbnormalTest", nullptr, ImageAnimatorFrameInfoTest::CreateNativeNodeAbnormal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "imageFrameInfoDrawableTest", nullptr, ImageAnimatorFrameInfoTest::CreateNativeNodeDrawable, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "imageFrameInfoDrawableAbnormalTest", nullptr, ImageAnimatorFrameInfoTest::CreateNativeNodeDrawableAbnormal, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "imageAnimatorTest", nullptr, ImageAnimatorTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "imageAnimatorDurationTest", nullptr, ImageAnimatorTest::CreateNativeNodeDuration, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "imageAnimatorReverseTest", nullptr, ImageAnimatorTest::CreateNativeNodeReverse, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "imageAnimatorFixedSizeTest", nullptr, ImageAnimatorTest::CreateNativeNodeFixedSize, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "imageAnimatorFillModeTest", nullptr, ImageAnimatorTest::CreateNativeNodeFillMode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "imageAnimatorIterationsTest", nullptr, ImageAnimatorTest::CreateNativeNodeIteration, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "imageAnimatorResetAttributeTest", nullptr, ImageAnimatorTest::CreateNativeNodeResetAttribute, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "swiperEffectModeSpringTest", nullptr, SwiperEffectModeTest::CreateNativeModeSpring, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperEffectModeMultipleTest", nullptr, SwiperEffectModeTest::CreateNativeModeSpring, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperEffectModeFadeTest", nullptr, SwiperEffectModeTest::CreateNativeModeFade, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperEffectModeNoneTest", nullptr, SwiperEffectModeTest::CreateNativeModeNone, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperEffectModeAbnormalTest", nullptr, SwiperEffectModeTest::CreateNativeModeAbnormal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperEffectModeInterruptTest", nullptr, SwiperEffectModeTest::CreateNativeModeInterrupt, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperAdapterTest", nullptr, SwiperAdapterTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "swiperPrevMarginTest", nullptr, SwiperMarginTest::CreateNativePrevMargin, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperPrevMarginAbnormalTest", nullptr, SwiperMarginTest::CreateNativePrevMarginAbnormal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperNextMarginTest", nullptr, SwiperMarginTest::CreateNativeNextMargin, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperNextMarginAbnormalTest", nullptr, SwiperMarginTest::CreateNativeNextMarginAbnormal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperMarginTest", nullptr, SwiperMarginTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "swiperNestedScrollTest", nullptr, SwiperNestedScrollTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperNestedScrollChildTest", nullptr, SwiperNestedScrollTest::CreateNativeNodeChild, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperNestedScrollAbnormalTest", nullptr, SwiperNestedScrollTest::CreateNativeNodeAbnormal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperChangeIndexTest", nullptr, SwiperChangeIndexTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperDotIndicatorTest", nullptr, SwiperDotIndicatorTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperDotIndicatorAbnormalTest", nullptr, SwiperDotIndicatorTest::CreateNativeNodeAbnormal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "swiperEventOnGestureTest", nullptr, SwiperEventTest::CreateNativeNodeGesture, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperEventOnDidScrollTest", nullptr, SwiperEventTest::CreateNativeNodeDidScroll, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperEventOnDidScrollTest", nullptr, SwiperEventTest::CreateNativeNodeDidScroll, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperOnChangeTest", nullptr, SwiperOnChangeTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "swiperOnAnimationTest", nullptr, SwiperOnAnimationTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "swiperResetAttributeTest", nullptr, SwiperResetAttributeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "customDialogContentTest", nullptr, CustomDialogContentTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "buttonTypeTest", nullptr, ButtonTypeTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "calendarPickerHintRadiusPage1Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage1, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage2Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage2, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage3Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage3, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage4Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage4, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage5Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage5, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage6Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage6, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage7Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage7, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerHintRadiusPage8Test", nullptr, CalendarPickerHintRadiusTest::CreateNativeNodePage8, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerSelectedDatePage1Test", nullptr, CalendarPickerSelectedDateTest::CreateNativeNodePage1, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerSelectedDatePage2Test", nullptr, CalendarPickerSelectedDateTest::CreateNativeNodePage2, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerSelectedDatePage3Test", nullptr, CalendarPickerSelectedDateTest::CreateNativeNodePage3, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "calendarPickerSelectedDatePage4Test", nullptr, CalendarPickerSelectedDateTest::CreateNativeNodePage4, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "sliderTrackThicknessPage1Test", nullptr, SliderTrackThicknessTest::CreateNativeNodePage1, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "sliderTrackThicknessPage2Test", nullptr, SliderTrackThicknessTest::CreateNativeNodePage2, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "stackAlignContentTest", nullptr, StackAlignContentTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowCachedCountTest", nullptr, WaterFlowCachedCountTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowSectionTest1", nullptr, WaterFlowSectionTest::CreateNativeNode1, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowSectionTest2", nullptr, WaterFlowSectionTest::CreateNativeNode2, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowSectionTest3", nullptr, WaterFlowSectionTest::CreateNativeNode3, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowLayoutDirectionTest", nullptr, WaterFlowLayoutDirectionTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowColumnsRowsTemplateTest", nullptr, WaterFlowColumnsRowsTemplateTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "waterFlowColumnsRowsGapTest", nullptr, WaterFlowColumnsRowsGapTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowNestedScrollTest", nullptr, WaterFlowNestedScrollTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowNestedScrollSmallTest", nullptr, WaterFlowNestedScrollTest::CreateNativeNodeSmall, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowNestedScrollResetTest", nullptr, WaterFlowNestedScrollTest::CreateNativeNodeReset, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollBarDisplayModeTest", nullptr, WaterFlowScrollTest::CreateNativeNodeDisplayMode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "waterFlowScrollBarWidthTest", nullptr, WaterFlowScrollTest::CreateNativeNodeWidth, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowScrollBarColorTest", nullptr, WaterFlowScrollTest::CreateNativeNodeColor, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowScrollFrictionTest", nullptr, WaterFlowScrollTest::CreateNativeNodeFriction, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollEdgeEffectTest", nullptr, WaterFlowScrollTest::CreateNativeNodeEdgeEffect, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollOffset2Test", nullptr, WaterFlowScrollTest::CreateNativeNodeOffset2, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollOffset6Test", nullptr, WaterFlowScrollTest::CreateNativeNodeOffset6, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollOffsetCurveTest", nullptr, WaterFlowScrollTest::CreateNativeNodeOffsetCurve, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollEdgeTest", nullptr, WaterFlowScrollTest::CreateNativeNodeEdge, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowScrollPageTest", nullptr, WaterFlowScrollTest::CreateNativeNodePage, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowScrollByTest", nullptr, WaterFlowScrollTest::CreateNativeNodeBy, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowEnableScrollInteractionTest", nullptr, WaterFlowScrollTest::CreateNativeNodeEnableScrollInteraction, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "waterFlowScrollToIndexTest", nullptr, WaterFlowScrollTest::CreateNativeNodeScrollToIndex, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowScrollToIndex8Test", nullptr, WaterFlowScrollTest::CreateNativeNodeScrollToIndex8, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowItemConstraintSizeTest", nullptr, WaterFlowItemConstraintSizeTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "waterFlowFooterTest", nullptr, WaterFlowFooterTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "waterFlowOnWillScrollTest", nullptr, WaterFlowEventTest::CreateNativeNodeOnWillScroll, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowOnStartEndStopTest", nullptr, WaterFlowEventTest::CreateNativeNodeStartEndStop, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowOnDidScrollTest", nullptr, WaterFlowEventTest::CreateNativeNodeOnDidScroll, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "waterFlowOnScrollFrameBeginTest", nullptr, WaterFlowEventTest::CreateNativeNodeOnScrollFrameBegin, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "waterFlowOnScrollIndexTest", nullptr, WaterFlowEventTest::CreateNativeNodeOnScrollIndex, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "xComponentIdTest", nullptr, XComponentIdTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "scrollScrollBarWidthTest", nullptr, ScrollScrollBarWidthTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "scrollScrollByTest", nullptr, ScrollScrollByTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "scrollEnablePagingTest", nullptr, ScrollEnablePagingTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "scrollScrollOffsetTest", nullptr, ScrollScrollOffsetTest::CreateNativeNodeOffset, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "scrollScrollOffsetCurveTest", nullptr, ScrollScrollOffsetTest::CreateNativeNodeCurve, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "scrollScrollOffsetOtherTest", nullptr, ScrollScrollOffsetTest::CreateNativeNodeOther, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "scrollScrollPageTest", nullptr, ScrollScrollPageTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "scrollScrollEdgeHorizontalTest", nullptr, ScrollScrollEdgeTest::CreateNativeNodeHorizontal, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "scrollScrollEdgeVerticalTest", nullptr, ScrollScrollEdgeTest::CreateNativeNodeVertical, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "spanTextBackgroundStyleTest", nullptr, SpanTextBackgroundStyleTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "spanBaseLineOffsetTest", nullptr, SpanBaseLineOffsetTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "spanValueTest", nullptr, SpanValueTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "spanTextShadowTest", nullptr, SpanTextShadowTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "spanFontFamilyTest", nullptr, SpanFontFamilyTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "progressValueAndTotalTest", nullptr, ProgressValueAndTotalTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "progressTypeTest", nullptr, ProgressTypeTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textContentTest", nullptr, TextContentTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textDecorationStyleTest", nullptr, TextDecorationStyleTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textWordBreakTest", nullptr, TextWordBreakTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textEllipsisModeTest", nullptr, TextEllipsisModeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textLineSpacingTest", nullptr, TextLineSpacingTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textFontFeatureFirstTest", nullptr, TextFontFeatureTest::CreateNativeNodeFirst, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textFontFeatureSecondTest", nullptr, TextFontFeatureTest::CreateNativeNodeSecond, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textFontFeatureThirdTest", nullptr, TextFontFeatureTest::CreateNativeNodeThird, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textSelectedBackgroundColorTest", nullptr, TextSelectedBackgroundColorTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textDataDetectorConfigTest", nullptr, TextDataDetectorConfigTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textEnableDataDetectorTest", nullptr, TextEnableDataDetectorTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textParagraphTest", nullptr, TextParagraphTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textAreaTextPlaceholderTest", nullptr, TextAreaTextPlaceholderTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaTypeTest", nullptr, TextAreaTypeTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textAreaShowCounterTest", nullptr, TextAreaShowCounterTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaFontFeatureFirstTest", nullptr, TextAreaFontFeatureTest::CreateNativeNodeFirst, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaFontFeatureSecondTest", nullptr, TextAreaFontFeatureTest::CreateNativeNodeSecond, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaFontFeatureThirdTest", nullptr, TextAreaFontFeatureTest::CreateNativeNodeThird, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaMaxLinesTest", nullptr, TextAreaMaxLinesTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaSelectionMenuHiddenTest", nullptr, TextAreaSelectionMenuHiddenTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textAreaInputFilterTest", nullptr, TextAreaInputFilterTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaSelectedBackgroundColorTest", nullptr, TextAreaSelectedBackgroundColorTest::CreateNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "textAreaEnterKeyTypeTest", nullptr, TextAreaEnterKeyTypeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaEnableKeyboardOnFocusTest", nullptr, TextAreaEnableKeyboardOnFocusTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textAreaEnableKeyboardOnFocusDisableTest", nullptr, + TextAreaEnableKeyboardOnFocusTest::CreateNativeNodeDisableKeyBoard, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textAreaEnableKeyboardOnFocusAbnormalTest", nullptr, + TextAreaEnableKeyboardOnFocusTest::CreateNativeNodeAbnormal, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textAreaEnableKeyboardOnFocusResetTest", nullptr, TextAreaEnableKeyboardOnFocusTest::CreateNativeNodeReset, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "textAreaBlurOnSubmitTest", nullptr, TextAreaBlurOnSubmitTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaShowKeyboardOnFocusTest", nullptr, TextAreaShowKeyboardOnFocusTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textAreaShowKeyboardOnFocusAbnormalTest", nullptr, TextAreaShowKeyboardOnFocusTest::CreateAbnormalNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "textAreaGetCaretOffsetTest", nullptr, TextAreaGetCaretOffsetTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaCaretPositionTest", nullptr, TextAreaCaretPositionTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaControllerTest", nullptr, TextAreaControllerTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textAreaSetTextSelectionTest", nullptr, TextAreaSetTextSelectionTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaContentTypePageOneTest", nullptr, TextAreaContentTypeTest::CreateNativeNodePageOne, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaEnableAutoFillTest", nullptr, TextAreaEnableAutoFillTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textAreaNumberOfLinesTest", nullptr, TextAreaNumberOfLinesTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputCustomKeyboardPage1Test", nullptr, TextInputCustomKeyboardTest::CreateNativeNodePage1, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputCustomKeyboardPage2Test", nullptr, TextInputCustomKeyboardTest::CreateNativeNodePage2, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputCustomKeyboardPage3Test", nullptr, TextInputCustomKeyboardTest::CreateNativeNodePage3, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputCustomKeyboardPage4Test", nullptr, TextInputCustomKeyboardTest::CreateNativeNodePage4, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputCustomKeyboardPage5Test", nullptr, TextInputCustomKeyboardTest::CreateNativeNodePage5, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputCustomKeyboardPage6Test", nullptr, TextInputCustomKeyboardTest::CreateNativeNodePage6, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputSelectAllTest", nullptr, TextInputSelectAllTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputEnableAutoFillTest", nullptr, TextInputEnableAutoFillTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputContentTypePage1Test", nullptr, TextInputContentTypeTest::CreateNativeNodePage1, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputPasswordRulesPage1Test", nullptr, TextInputPasswordRulesTest::CreateNativeNodePage1, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputPasswordRulesPage2Test", nullptr, TextInputPasswordRulesTest::CreateNativeNodePage2, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputPasswordRulesPage3Test", nullptr, TextInputPasswordRulesTest::CreateNativeNodePage3, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputSelectionMenuHiddenTest", nullptr, TextInputSelectionMenuHiddenTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputFontFeaturePage1Test", nullptr, TextInputFontFeatureTest::CreateNativeNodePage1, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputFontFeaturePage2Test", nullptr, TextInputFontFeatureTest::CreateNativeNodePage2, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputFontFeaturePage3Test", nullptr, TextInputFontFeatureTest::CreateNativeNodePage3, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputTextPlaceholderTest", nullptr, TextInputTextPlaceholderTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputCancelButtonTest", nullptr, TextInputCancelButtonTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputSetTextSelectionTest", nullptr, TextInputSetTextSelectionTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputUnderlineColorTest", nullptr, TextInputUnderlineColorTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputWordBreakTest", nullptr, TextInputWordBreakTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputStyleTest", nullptr, TextInputStyleTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textInputMinFontSizeAndMaxFontSizeTest", nullptr, TextInputMinFontSizeAndMaxFontSizeTest::CreateNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "textInputMaxLinesTest", nullptr, TextInputMaxLinesTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputNumberOfLinesTest", nullptr, TextInputNumberOfLinesTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputInputFilterTest", nullptr, TextInputInputFilterTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputShowKeyboardOnFocusTest", nullptr, TextInputShowKeyboardOnFocusTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "textInputShowKeyboardOnFocusAbnormalTest", nullptr, + TextInputShowKeyboardOnFocusTest::CreateAbnormalNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "textInputBlurOnSubmitTest", nullptr, TextInputBlurOnSubmitTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "textInputGetCaretOffsetTest", nullptr, TextInputGetCaretOffsetTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputCaretPositionTest", nullptr, TextInputCaretPositionTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "textInputControllerTest", nullptr, TextInputControllerTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsZIndexPage1Test", nullptr, CommonAttrsZIndexTest::CreateNativeNodePage1, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsZIndexPage2Test", nullptr, CommonAttrsZIndexTest::CreateNativeNodePage2, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsZIndexPage3Test", nullptr, CommonAttrsZIndexTest::CreateNativeNodePage3, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage1Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage1, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage2Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage2, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage3Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage3, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage4Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage4, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage5Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage5, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage6Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage6, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage7Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage7, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage8Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage8, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage9Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage9, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage10Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage10, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage11Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage11, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage12Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage12, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage13Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage13, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage14Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage14, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage15Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage15, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsExpandSafeAreaPage16Test", nullptr, CommonAttrsExpandSafeAreaTest::CreateNativeNodePage16, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsSizeTest", nullptr, CommonAttrsSizeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsPaddingTest", nullptr, CommonAttrsPaddingTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsAccessibilityRoleTest", nullptr, CommonAttrsAccessibilityRoleTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsAccessibilityStateTest", nullptr, CommonAttrsAccessibilityStateTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsAccessibilityValueTest", nullptr, CommonAttrsAccessibilityValueTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsFocusOnTouchTest", nullptr, CommonAttrsFocusOnTouchTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsAlignmentPage1Test", nullptr, CommonAttrsAlignmentTest::CreateNativeNodePage1, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsAlignmentPage2Test", nullptr, CommonAttrsAlignmentTest::CreateNativeNodePage2, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsAlignmentPage3Test", nullptr, CommonAttrsAlignmentTest::CreateNativeNodePage3, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsOutlineColorTest", nullptr, CommonAttrsOutlineColorTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsTranslateTest", nullptr, CommonAttrsTranslateTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsTouchAbleTest", nullptr, CommonAttrsTouchAbleTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsRotateTest", nullptr, CommonAttrsRotateTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsRenderGroupTest", nullptr, CommonAttrsRenderGroupTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsRenderFit1Test", nullptr, CommonAttrsRenderFitTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsRenderFit2Test", nullptr, CommonAttrsRenderFitTest::CreateNativeNode1, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsRenderFit3Test", nullptr, CommonAttrsRenderFitTest::CreateNativeNode2, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsRenderFit4Test", nullptr, CommonAttrsRenderFitTest::CreateNativeNode3, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsRenderFit5Test", nullptr, CommonAttrsRenderFitTest::CreateNativeNode4, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsLayoutWeightTest", nullptr, CommonAttrsLayoutWeightTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsDisplayPriorityTest", nullptr, CommonAttrsDisplayPriorityTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsOutlineWidthTest", nullptr, CommonAttrsOutlineWidthTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsColorBlendTest", nullptr, CommonAttrsColorBlendTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsChainModeTest", nullptr, CommonAttrsChainModeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsChainMode1Test", nullptr, CommonAttrsChainModeTest::CreateNativeNode1, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsChainMode2Test", nullptr, CommonAttrsChainModeTest::CreateNativeNode2, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsBackgroundBlurStyleTest", nullptr, CommonAttrsBackgroundBlurStyleTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsBackgroundImageResourceStrTest", nullptr, + CommonAttrsBackgroundImageTest::CreateNativeNodeResourceStr, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "commonAttrsBackgroundImagePixelMapTest", nullptr, CommonAttrsBackgroundImageTest::CreateNativeNodePixelMap, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsBackgroundImageSizeTest", nullptr, CommonAttrsBackgroundImageSizeTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsBackgroundImagePositionTest", nullptr, CommonAttrsBackgroundImagePositionTest::CreateNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsBrightnessTest", nullptr, CommonAttrsBrightnessTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsSaturateTest", nullptr, CommonAttrsSaturateTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsBlurTest", nullptr, CommonAttrsBlurTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsClipShapeTest", nullptr, CommonAttrsClipShapeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsCustomShadowTest", nullptr, CommonAttrsCustomShadowTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsVisibilityTest", nullptr, CommonAttrsVisibilityTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsDefaultFocusSingleTest", nullptr, CommonAttrsDefaultFocusTest::CreateNativeNodeSingle, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsDefaultFocusNoneTest", nullptr, CommonAttrsDefaultFocusTest::CreateNativeNodeNone, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsDefaultFocusMultiTest", nullptr, CommonAttrsDefaultFocusTest::CreateNativeNodeMulti, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsDefaultFocusAbnormalTest", nullptr, CommonAttrsDefaultFocusTest::CreateNativeNodeAbnormal, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsFocusStatusTest", nullptr, CommonAttrsFocusStatusTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsAspectRatioTest", nullptr, CommonAttrsAspectRatioTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsForegroundColorTest", nullptr, CommonAttrsForegroundColorTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsMarkAnchorTest", nullptr, CommonAttrsMarkAnchorTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsOffsetTest", nullptr, CommonAttrsOffsetTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsOverlayTest", nullptr, CommonAttrsOverlayTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsResponseRegionTest", nullptr, CommonAttrsResponseRegionTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsScaleTest", nullptr, CommonAttrsScaleTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "commonAttrsTransformCenterTest", nullptr, CommonAttrsTransformCenterTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsTransitionMoveTest", nullptr, CommonAttrsTransitionMoveTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsTransitionOpacityTest", nullptr, CommonAttrsTransitionOpacityTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsTransitionRotateTest", nullptr, CommonAttrsTransitionRotateTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsTransitionScaleTest", nullptr, CommonAttrsTransitionScaleTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "commonAttrsTransitionTranslateTest", nullptr, CommonAttrsTransitionTranslateTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "commonAttrsTransitionAsymmetricTest", nullptr, CommonAttrsTransitionAsymmetricTest::CreateNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "unitLengthMetricsTest", nullptr, UnitLengthMetricsTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "unitPercentTest", nullptr, UnitPercentTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "unitPercentBorderRadiusTest", nullptr, UnitPercentTest::CreateBorderRadiusNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "unitPercentPaddingTest", nullptr, UnitPercentTest::CreatePaddingNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "mixGetNodeHandleTest", nullptr, MixGetNodeHandleTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "toolsLayoutRectTest", nullptr, ToolsLayoutRectTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "customComponentGetTotalChildCountTest", nullptr, CustomComponentGetTotalChildCountTest::CreateNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "customComponentGetChildAtTest", nullptr, CustomComponentGetChildAtTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "customComponentGetFirstChildTest", nullptr, CustomComponentGetFirstChildTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "customComponentGetLastChildTest", nullptr, CustomComponentGetLastChildTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "customComponentGetPreviousNextSiblingTest", nullptr, + CustomComponentGetPreviousNextSiblingTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "customComponentCustomEventTest", nullptr, CustomComponentCustomEventTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "customComponentUnregisterCustomEventTest", nullptr, + CustomComponentCustomEventTest::CreateUnregisterNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr }, + { "customComponentMeasuredSizeTest", nullptr, CustomComponentMeasuredSizeTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "customComponentLayoutPositionTest", nullptr, CustomComponentLayoutPositionTest::CreateNativeNode, nullptr, + nullptr, nullptr, napi_default, nullptr }, + { "customComponentLayoutConstraintTest", nullptr, CustomComponentLayoutConstraintTest::CreateNativeNode, + nullptr, nullptr, nullptr, napi_default, nullptr }, + { "customComponentDrawContextTest", nullptr, CustomComponentDrawContextTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "customComponentLayoutAgainTest", nullptr, CustomComponentLayoutAgainTest::CreateNativeNode, nullptr, nullptr, + nullptr, napi_default, nullptr }, + }; + if (napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", "napi_define_properties failed"); + return nullptr; + } + + // common event + napi_property_descriptor commonEvent_desc[] = { + // testCommonEventTest001 + {"commonEventTest", nullptr, CommonEventTest::CreateNativeNode001, nullptr, nullptr, nullptr, napi_default, + nullptr}, + // testCommonEventTest002 + {"commonHoverEventTest", nullptr, CommonEventTest::CreateNativeNodeForOnHover, nullptr, nullptr, nullptr, + napi_default, nullptr}, + // testCommonEventTest003 + {"commonOnVisibleAreaChangeEventTest", nullptr, CommonEventTest::CreateNativeNodeForOnVisibleAreaChange, + nullptr, nullptr, nullptr, napi_default, nullptr}, + // testCommonEventTest004 + {"commonOnMouseEventTest", nullptr, CommonEventTest::CreateNativeNodeForOnMouse, nullptr, nullptr, nullptr, + napi_default, nullptr}, + // testCommonEventTest005 + {"commonOnTouchInterceptEventTest", nullptr, CommonEventTest::CreateNativeNodeForOnTouchIntercept, nullptr, + nullptr, nullptr, napi_default, nullptr}, + }; + if (napi_define_properties(env, exports, sizeof(commonEvent_desc) / sizeof(commonEvent_desc[0]), + commonEvent_desc) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", + "napi_define_properties commonEvent_desc failed"); + return nullptr; + } + + // Node tree + napi_property_descriptor nodeTree_desc[] = { + {"nodeTreeInsertTest", nullptr, NodeTreeTest::CreateNativeNodeForInsert, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"nodeTreeXComponentTest", nullptr, NodeTreeTest::CreateNativeNodeForXComponent, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"nodeTreeRemoveTest", nullptr, NodeTreeTest::CreateNativeNodeForRemove, nullptr, nullptr, nullptr, + napi_default, nullptr}, + }; + if (napi_define_properties(env, exports, sizeof(nodeTree_desc) / sizeof(nodeTree_desc[0]), nodeTree_desc) != + napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", + "napi_define_properties nodeTree_desc failed"); + return nullptr; + } + + // Event Callback, Attribute Setting + napi_property_descriptor eventCallback_desc[] = { + {"eventCallbackSpecifyNodeTest", nullptr, EventCallbackTest::CreateNativeNodeForSpecifyNode, nullptr, nullptr, + nullptr, napi_default, nullptr}, + {"eventCallbackGlobalTest", nullptr, EventCallbackTest::CreateNativeNodeForGlobal, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"attributeSettingTest", nullptr, AttributeSettingTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr}, + }; + if (napi_define_properties(env, exports, sizeof(eventCallback_desc) / sizeof(eventCallback_desc[0]), + eventCallback_desc) != napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", + "napi_define_properties eventCallback_desc failed"); + return nullptr; + } + + // Input Event + napi_property_descriptor inputEvent_desc[] = { + {"inputEventTest", nullptr, InputEventTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, nullptr}, + + }; + if (napi_define_properties(env, exports, sizeof(inputEvent_desc) / sizeof(inputEvent_desc[0]), inputEvent_desc) != + napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", + "napi_define_properties inputEvent_desc failed"); + return nullptr; + } + // Image + napi_property_descriptor image_desc[] = { + {"imageSrcTest", nullptr, ImageSrcTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"imagePixelMapSrcTest", nullptr, ImageSrcTest::CreateNativeNodeForPixelMap, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"imageResizableTest", nullptr, ImageResizableTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageDraggableTest", nullptr, ImageDraggableTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageRenderModeTest", nullptr, ImageRenderModeTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageFitOriginalSizeTest", nullptr, ImageFitOriginalSizeTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"imageFillColorTest", nullptr, ImageFillColorTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageOnfinishTest", nullptr, ImageOnFinishTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageDownProgressTest", nullptr, ImageDownProgressTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"imageSpanSrcTest", nullptr, ImageSpanSrcTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageSpanPixelMapSrcTest", nullptr, ImageSpanSrcTest::CreateNativeNodeForPixelMap, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"imageSpanAltAndOnClickTest", nullptr, ImagespanAltAndOnClickTest::CreateNativeNode, nullptr, nullptr, nullptr, + napi_default, nullptr}, + {"imageObjectFitTest", nullptr, ImageObjectFitTest::CreateNativeNode, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"imageObjectFitResetAndAbnormalTest", nullptr, ImageObjectFitTest::CreateNativeNodeForResetAndAbnormal, + nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + if (napi_define_properties(env, exports, sizeof(image_desc) / sizeof(image_desc[0]), image_desc) != + napi_ok) { + OH_LOG_Print(LOG_APP, LOG_ERROR, ArkUICApiDemo::LOG_PRINT_DOMAIN, "Init", + "napi_define_properties inputEvent_desc failed"); + return nullptr; + } + ArkUICApiDemo::PluginManager::GetInstance()->Export(env, exports); + return exports; +} +EXTERN_C_END + +static napi_module nativerenderModule = { .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "nativerender", + .nm_priv = ((void*)0), + .reserved = { 0 } }; + +extern "C" __attribute__((constructor)) void RegisterModule(void) +{ + napi_module_register(&nativerenderModule); +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/nodetree/node_tree_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/nodetree/node_tree_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..742a9d030e44457073d49378cc03d37e11d565c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/nodetree/node_tree_test.cpp @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "node_tree_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "text_component.h" +namespace ArkUICApiDemo { +ButtonComponent* button1; +static ArkUI_NodeHandle parentColumnDetach; + +napi_value NodeTreeTest::CreateNativeNodeForInsert(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "CreateNativeNodeForInsert"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + parentColumnDetach = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto scroll = new Component(ARKUI_NODE_SCROLL); + scroll->SetWidth(400); + scroll->SetHeight(600); + scroll->SetBorderWidth(5); + auto column = new ColumnComponent(); + scroll->AddChild(std::shared_ptr(column)); + std::vector> textItems; + for (size_t i = 0; i < 5; i++) { + auto text = new TextComponent(); + text->SetWidth(300); + text->SetHeight(50); + text->SetBackgroundColor(COLOR_GRAY); + text->SetMargin(10); + textItems.push_back(std::shared_ptr(text)); + column->AddChild(textItems[i]); + } + button1 = new ButtonComponent(); + button1->SetLable("InsertChild"); + button1->SetId("InsertChild"); + button1->SetMargin(10); + button1->RegisterOnClick([nodeAPI, column, textItems]() { + auto text_insert1 = new TextComponent(); + text_insert1->SetWidth(200); + text_insert1->SetHeight(40); + text_insert1->SetBackgroundColor(COLOR_RED); + text_insert1->SetMargin(10); + nodeAPI->insertChildAt(column->GetComponent(), text_insert1->GetComponent(), 0); + + auto text_insert2 = new TextComponent(); + text_insert2->SetWidth(200); + text_insert2->SetHeight(40); + text_insert2->SetBackgroundColor(COLOR_RED); + text_insert2->SetMargin(10); + nodeAPI->insertChildAfter(column->GetComponent(), text_insert2->GetComponent(), textItems[0]->GetComponent()); + + auto text_insert3 = new TextComponent(); + text_insert3->SetWidth(200); + text_insert3->SetHeight(40); + text_insert3->SetBackgroundColor(COLOR_RED); + text_insert3->SetMargin(10); + nodeAPI->insertChildBefore(column->GetComponent(), text_insert3->GetComponent(), textItems[2]->GetComponent()); + }); + + auto button2 = new ButtonComponent(); + button2->SetLable("DisposeNode"); + button2->SetId("DisposeNode"); + button2->SetMargin(10); + button2->RegisterOnClick([nodeAPI, column]() { + if (button1) { + auto buttonParent = nodeAPI->getParent(button1->GetComponent()); + nodeAPI->removeChild(buttonParent, button1->GetComponent()); + nodeAPI->disposeNode(button1->GetComponent()); + delete button1; + button1 = nullptr; + } + + auto parent = nodeAPI->getParent(column->GetComponent()); + ArkUI_NumberValue value[] = { { .u32 = COLOR_PINK } }; + ArkUI_AttributeItem item = { value, 1 }; + nodeAPI->setAttribute(parent, NODE_BACKGROUND_COLOR, &item); + }); + + nodeAPI->addChild(parentColumnDetach, scroll->GetComponent()); + nodeAPI->addChild(parentColumnDetach, button1->GetComponent()); + nodeAPI->addChild(parentColumnDetach, button2->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumnDetach) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value NodeTreeTest::CreateNativeNodeForXComponent(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "CreateNativeNodeForXComponent"); + + size_t argc = 2; + napi_value args[2] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + char xComponentID_Detch[64] = { 0 }; + napi_get_value_string_utf8(env, args[1], xComponentID_Detch, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + parentColumn->SetBorderWidth(5); + auto button = new ButtonComponent(); + + button->SetId("DetachNativeRootNode"); + button->SetFontSize(20); + button->SetWidth(300); + button->SetHeight(50); + button->RegisterOnClick([xComponentID_Detch]() { + std::string IDParentContainerDetch(xComponentID_Detch); + if (OH_NativeXComponent_DetachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(IDParentContainerDetch), parentColumnDetach) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", + "OH_NativeXComponent_DetachNativeRootNode failed"); + } + }); + nodeAPI->addChild(parentColumn->GetComponent(), button->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +napi_value NodeTreeTest::CreateNativeNodeForRemove(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "CreateNativeNodeForRemove"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + parentColumnDetach = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto scroll = new Component(ARKUI_NODE_SCROLL); + scroll->SetWidth(400); + scroll->SetHeight(600); + scroll->SetBorderWidth(5); + auto column = new ColumnComponent(); + scroll->AddChild(std::shared_ptr(column)); + for (size_t i = 0; i < 5; i++) { + auto text = new TextComponent(); + text->SetWidth(300); + text->SetHeight(50); + text->SetBackgroundColor(COLOR_GRAY); + text->SetMargin(10); + column->AddChild(std::shared_ptr(text)); + } + auto button = new ButtonComponent(); + button->SetLable("RemoveAllChild"); + button->SetId("RemoveAllChild"); + button->SetMargin(10); + button->RegisterOnClick([nodeAPI, scroll]() { + nodeAPI->removeAllChildren(scroll->GetComponent()); + nodeAPI->removeAllChildren(nullptr); + }); + + nodeAPI->addChild(parentColumnDetach, scroll->GetComponent()); + nodeAPI->addChild(parentColumnDetach, button->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumnDetach) == INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeTreeTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/nodetree/node_tree_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/nodetree/node_tree_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e6fe6059d16183963c862f5cd37f6f9cb314f5cc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/nodetree/node_tree_test.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_NODE_TREE_TEST_H +#define ARKUI_CAPI_DEMO_NODE_TREE_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class NodeTreeTest { +public: + ~NodeTreeTest(); + // testNodeTree001 + // insertChildAt,insertChildAfter,insertChildBefore,disposeNode,getParent + static napi_value CreateNativeNodeForInsert(napi_env env, napi_callback_info info); + // testNodeTree002 + // OH_NativeXComponent_AttachNativeRootNode,OH_NativeXComponent_DetachNativeRootNode + static napi_value CreateNativeNodeForXComponent(napi_env env, napi_callback_info info); + // testNodeTree003 + // removeAllChildren + static napi_value CreateNativeNodeForRemove(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_NODE_TREE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_total_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_total_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6edbb192d71fa79c4f205e88ad2917d3ef82eae7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_total_test.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "progress_total_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateProgressWithValueAndTotal(float value, float total) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ProgressValueAndTotalTest", "CreateProgressWithValueAndTotal"); + + auto progress = std::make_shared(ARKUI_NODE_PROGRESS); + progress->SetWidth(SIZE_300); + progress->SetHeight(SIZE_30); + progress->SetMargin(5); + ArkUI_NumberValue progress_value[] = { { .f32 = value } }; + ArkUI_AttributeItem progress_value_item = { progress_value, sizeof(progress_value) / sizeof(ArkUI_NumberValue) }; + progress->setAttribute(NODE_PROGRESS_VALUE, &progress_value_item); + if (total != PARAM_NEGATIVE_100) { + ArkUI_NumberValue progress_total_value[] = { { .f32 = total } }; + ArkUI_AttributeItem progress_total_item = { progress_total_value, + sizeof(progress_total_value) / sizeof(ArkUI_NumberValue) }; + progress->setAttribute(NODE_PROGRESS_TOTAL, &progress_total_item); + } + + return progress; +} + +napi_value ProgressValueAndTotalTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ProgressValueAndTotalTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + auto column = new Component(ARKUI_NODE_COLUMN); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_50, PARAM_NEGATIVE_1)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_50, PARAM_0)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_50, SIZE_50)); + column->AddChild(CreateProgressWithValueAndTotal(PARAM_0, PARAM_NEGATIVE_1)); + column->AddChild(CreateProgressWithValueAndTotal(PARAM_0, SIZE_100)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_100, PARAM_NEGATIVE_1)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_100, SIZE_50)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_100, SIZE_200)); + column->AddChild(CreateProgressWithValueAndTotal(PARAM_NEGATIVE_1, PARAM_NEGATIVE_1)); + column->AddChild(CreateProgressWithValueAndTotal(PARAM_NEGATIVE_1, SIZE_50)); + column->AddChild(CreateProgressWithValueAndTotal(PARAM_NEGATIVE_1, PARAM_NEGATIVE_100)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_50, PARAM_NEGATIVE_100)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_200, PARAM_NEGATIVE_100)); + column->AddChild(CreateProgressWithValueAndTotal(SIZE_100, SIZE_50)); + auto column15 = CreateProgressWithValueAndTotal(SIZE_50, PARAM_NEGATIVE_100); + column15->resetAttribute(NODE_PROGRESS_VALUE); + auto column16 = CreateProgressWithValueAndTotal(SIZE_50, SIZE_200); + column16->resetAttribute(NODE_PROGRESS_TOTAL); + column->AddChild(column15); + column->AddChild(column16); + + std::string idProgress(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(idProgress), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ProgressValueAndTotalTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_total_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_total_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7cdebb3e3d2789066bce4fc160fe4e375defd6cb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_total_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_PROGRESS_VALUE_AND_TOTAL_TEST_H +#define ARKUI_CAPI_DEMO_PROGRESS_VALUE_AND_TOTAL_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "component.h" + +namespace ArkUICApiDemo { + +class ProgressValueAndTotalTest { +public: + ~ProgressValueAndTotalTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_PROGRESS_VALUE_AND_TOTAL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_type_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_type_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..da6561f0eddbaf45a68c6711ce5af7bec98693e0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_type_test.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "progress_type_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateProgressWithType(int32_t type) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ProgressTypeTest", "CreateProgressWithType"); + + auto progress = std::make_shared(ARKUI_NODE_PROGRESS); + progress->SetWidth(SIZE_300); + progress->SetHeight(SIZE_50); + progress->SetMargin(DEFAULT_MARGIN); + ArkUI_NumberValue type_value[] = { { .i32 = type } }; + ArkUI_AttributeItem progress_type_item = { type_value, sizeof(type_value) / sizeof(ArkUI_NumberValue) }; + progress->setAttribute(NODE_PROGRESS_TYPE, &progress_type_item); + ArkUI_NumberValue progress_value[] = { { .f32 = SIZE_30 } }; + ArkUI_AttributeItem progress_value_item = { progress_value, sizeof(progress_value) / sizeof(ArkUI_NumberValue) }; + progress->setAttribute(NODE_PROGRESS_VALUE, &progress_value_item); + + return progress; +} + +napi_value ProgressTypeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ProgressTypeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + auto column = new Component(ARKUI_NODE_COLUMN); + column->AddChild(CreateProgressWithType(-1)); + column->AddChild(CreateProgressWithType(ARKUI_PROGRESS_TYPE_LINEAR)); + column->AddChild(CreateProgressWithType(ARKUI_PROGRESS_TYPE_RING)); + column->AddChild(CreateProgressWithType(ARKUI_PROGRESS_TYPE_ECLIPSE)); + column->AddChild(CreateProgressWithType(ARKUI_PROGRESS_TYPE_SCALE_RING)); + column->AddChild(CreateProgressWithType(ARKUI_PROGRESS_TYPE_CAPSULE)); + column->AddChild(CreateProgressWithType(5)); + auto column8 = CreateProgressWithType(ARKUI_PROGRESS_TYPE_ECLIPSE); + column8->resetAttribute(NODE_PROGRESS_TYPE); + column->AddChild(column8); + + std::string idProgress(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(idProgress), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ProgressTypeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_type_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_type_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a2ccf30e8c6762cca0f8f8b700ec0b5fb5872e05 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/progress/progress_type_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_PROGRESS_TYPE_TEST_H +#define ARKUI_CAPI_DEMO_PROGRESS_TYPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "component.h" + +namespace ArkUICApiDemo { + +class ProgressTypeTest { +public: + ~ProgressTypeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_PROGRESS_TYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_checked_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_checked_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..465ebc7e267cdfa227eeb82ce578a0a67a8fff68 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_checked_test.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "radio_checked_test.h" + +#include + +#include "../manager/plugin_manager.h" +namespace ArkUICApiDemo { +napi_value RadioCheckedTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioCheckedTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioCheckedTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置Radio组件的Checked属性 + ArkUI_NumberValue true_checked_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem true_checked_item = { true_checked_value, + sizeof(true_checked_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件的Checked属性 + ArkUI_NumberValue false_checked_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem false_checked_item = { false_checked_value, + sizeof(false_checked_value) / sizeof(ArkUI_NumberValue) }; + // 设置Radio组件的Checked属性 + ArkUI_NumberValue outlier_checked_value[] = { { .i32 = -1 } }; + ArkUI_AttributeItem outlier_checked_item = { outlier_checked_value, + sizeof(outlier_checked_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件宽度 + ArkUI_NumberValue default_width_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem default_width_item = { default_width_value, + sizeof(default_width_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件高度 + ArkUI_NumberValue default_height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem default_height_item = { default_height_value, + sizeof(default_height_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件margin + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + // first radio, checked 属性为1,应该为选中状态 + auto radio = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio, NODE_RADIO_CHECKED, &true_checked_item); + + // second radio, checked 属性为0,应该为未选中状态 + auto radio_second = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_second, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_second, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_second, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio_second, NODE_RADIO_CHECKED, &false_checked_item); + + // third radio, 设置异常值-1, 返回错误,应该为未选中状态 + auto radio_third = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_third, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_third, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_third, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio_second, NODE_RADIO_CHECKED, &outlier_checked_item); + + // parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + + nodeAPI->addChild(parentColumn, row1); + nodeAPI->addChild(parentColumn, row2); + nodeAPI->addChild(parentColumn, row3); + nodeAPI->addChild(row1, radio); + nodeAPI->addChild(row2, radio_second); + nodeAPI->addChild(row3, radio_third); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioCheckedTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_checked_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_checked_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e03adbcbe780f09ba224d5fc6752ee2e1e8894cd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_checked_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RADIO_CHECKED_TEST_H +#define ARKUI_CAPI_DEMO_RADIO_CHECKED_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RadioCheckedTest { +public: + ~RadioCheckedTest(); + // RadioTest:testRadio001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RADIO_CHECKED_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_reset_attribute_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_reset_attribute_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b2bba8c2f90c2096938aa4458d4ead2a9373be6e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_reset_attribute_test.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "radio_reset_attribute_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "radio_component.h" +namespace ArkUICApiDemo { +napi_value RadioResetAttributeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioResetAttributeTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioResetAttributeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto radio1 = new RadioComponent(); + radio1->SetWidth(100); + radio1->SetHeight(100); + radio1->SetChecked(true); + // 设置Radio组件的RadioStyle属性,checkedBackgroundColor:绿色;uncheckedBorderColor:紫色,indicatorColor:红色 + radio1->SetStyled((uint32_t[]) { COLOR_GREEN, COLOR_PURPLE, COLOR_RED }, 3); + radio1->SetGroup("group1"); + radio1->SetValue("radio1"); + radio1->SetMargin(10); + + auto radio2 = new RadioComponent(); + radio2->SetWidth(100); + radio2->SetHeight(100); + radio2->SetChecked(true); + // 设置Radio组件的RadioStyle属性,checkedBackgroundColor:绿色;uncheckedBorderColor:紫色,indicatorColor:红色 + radio2->SetStyled((uint32_t[]) { COLOR_GREEN, COLOR_PURPLE, COLOR_RED }, 3); + radio2->SetGroup("group2"); + radio2->SetValue("radio2"); + radio2->SetMargin(10); + + auto radio3 = new RadioComponent(); + radio3->SetWidth(100); + radio3->SetHeight(100); + // 设置Radio组件的RadioStyle属性,checkedBackgroundColor:绿色;uncheckedBorderColor:紫色,indicatorColor:红色 + // radio 非选中状态下,border颜色为紫色 + radio3->SetStyled((uint32_t[]) { COLOR_GREEN, COLOR_PURPLE, COLOR_RED }, 3); + radio3->SetMargin(10); + + auto button = new ButtonComponent(); + button->SetWidth(200); + button->SetHeight(100); + button->RegisterOnClick([radio1, radio2, radio3]() { + // Reset radio1 NODE_RADIO_CHECKED,NODE_RADIO_GROUP,NODE_RADIO_STYLE,NODE_RADIO_VALUE + radio1->resetAttribute(NODE_RADIO_CHECKED); // 默认值:false + radio1->resetAttribute(NODE_RADIO_GROUP); // 默认值:无 + radio1->resetAttribute(NODE_RADIO_STYLE); // 默认值:theme主题 + radio1->resetAttribute(NODE_RADIO_VALUE); // 默认值:无 + // Reset radio3 NODE_RADIO_STYLE + radio3->resetAttribute(NODE_RADIO_STYLE); + auto groupItem1 = radio1->getAttribute(NODE_RADIO_GROUP); + auto valueItem1 = radio1->getAttribute(NODE_RADIO_VALUE); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioResetAttributeTest", + "group1=%{public}s,valueItem1=%{public}s", groupItem1->string, valueItem1->string); + }); + button->SetId("ResetRadio"); + button->SetLable("ResetRadio"); + parentColumn->AddChild(std::shared_ptr(radio1)); + parentColumn->AddChild(std::shared_ptr(radio2)); + parentColumn->AddChild(std::shared_ptr(radio3)); + parentColumn->AddChild(std::shared_ptr(button)); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioResetAttributeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_reset_attribute_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_reset_attribute_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3eab75969d45f7a8314225213bf84fd0ad9868ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_reset_attribute_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RADIO_RESETATTRIBUTE_TEST_H +#define ARKUI_CAPI_DEMO_RADIO_RESETATTRIBUTE_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RadioResetAttributeTest { +public: + ~RadioResetAttributeTest(); + // RadioTest:testRadio005 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RADIO_RESETATTRIBUTE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_style_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_style_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..35f8420cba847be4c57f6d54b4f1b7fd98ea1f59 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_style_test.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "radio_style_test.h" + +#include + +#include "../manager/plugin_manager.h" +namespace ArkUICApiDemo { +napi_value RadioStyleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioStyleTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioStyleTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置Radio组件的RadioStyle属性,checkedBackgroundColor:绿色;uncheckedBorderColor:黄色,indicatorColor:红色 + ArkUI_NumberValue radioStyle_value[] = { { .u32 = COLOR_GREEN }, { .u32 = COLOR_YELLOW }, { .u32 = COLOR_RED } }; + ArkUI_AttributeItem radioStyle_value_item = { radioStyle_value, + sizeof(radioStyle_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件宽度 + ArkUI_NumberValue default_width_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem default_width_item = { default_width_value, + sizeof(default_width_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件高度 + ArkUI_NumberValue default_height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem default_height_item = { default_height_value, + sizeof(default_height_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件margin + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件选中 + ArkUI_NumberValue true_checked_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem true_checked_item = { true_checked_value, + sizeof(true_checked_value) / sizeof(ArkUI_NumberValue) }; + + // first radio, 设置Radio Style 并且是uncheck状态 + auto radio = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio, NODE_RADIO_STYLE, &radioStyle_value_item); + + // second radio, 不设置置Radio Style,显示默认状态 + auto radio_second = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_second, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_second, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_second, NODE_MARGIN, &margin_item); + + // third radio, 设置Radio Style 并且check状态 + auto radio_third = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_third, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_third, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_third, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio_third, NODE_RADIO_CHECKED, &true_checked_item); + nodeAPI->setAttribute(radio_third, NODE_RADIO_STYLE, &radioStyle_value_item); + + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item = { .string = "Radio_unchecked" }; + ArkUI_NumberValue fontSize[] = { 20 }; + ArkUI_AttributeItem Font_Item = { fontSize, 1 }; + ArkUI_NumberValue marginValue[] = { 20 }; + ArkUI_AttributeItem marginItem = { marginValue, 1 }; + nodeAPI->setAttribute(text, NODE_TEXT_CONTENT, &LABEL_Item); + nodeAPI->setAttribute(text, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text, NODE_MARGIN, &marginItem); + + auto text2 = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item2 = { .string = "Radio_defalut" }; + nodeAPI->setAttribute(text2, NODE_TEXT_CONTENT, &LABEL_Item2); + nodeAPI->setAttribute(text2, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text2, NODE_MARGIN, &marginItem); + + auto text3 = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item3 = { .string = "Radio_checked" }; + nodeAPI->setAttribute(text3, NODE_TEXT_CONTENT, &LABEL_Item3); + nodeAPI->setAttribute(text3, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text3, NODE_MARGIN, &marginItem); + + // parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + + nodeAPI->addChild(parentColumn, row1); + nodeAPI->addChild(parentColumn, row2); + nodeAPI->addChild(parentColumn, row3); + nodeAPI->addChild(row1, text); + nodeAPI->addChild(row1, radio); + nodeAPI->addChild(row2, text2); + nodeAPI->addChild(row2, radio_second); + nodeAPI->addChild(row3, text3); + nodeAPI->addChild(row3, radio_third); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioStyleTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_style_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_style_test.h new file mode 100644 index 0000000000000000000000000000000000000000..55a50a5cf15a0167c3feac7f6083971880837676 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_style_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RADIO_STYLE_TEST_H +#define ARKUI_CAPI_DEMO_RADIO_STYLE_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RadioStyleTest { +public: + ~RadioStyleTest(); + // RadioTest:testRadio002 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RADIO_STYLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_value_group_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_value_group_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2be7ccdd2b36a07823078bc816c3328401e3e56 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_value_group_test.cpp @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "./radio_value_group_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#define COLOR_RED 0xFFFF0000 +#define INVALID_PARAM 401 +#define ON_RADIO_EVENT_ID 1414 + +namespace ArkUICApiDemo { +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + // 当触发Change事件,修改背景色 + if (eventId == ON_RADIO_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_YELLOW } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + auto text = static_cast(OH_ArkUI_NodeEvent_GetUserData(event)); + auto lable_Item = nodeAPI->getAttribute(nodeHandler, NODE_RADIO_VALUE); + nodeAPI->setAttribute(text, NODE_TEXT_CONTENT, lable_Item); + } +} + +napi_value RadioValueAndGroupTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioValueAndGroupTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioValueAndGroupTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置Radio组件的Checked属性 + ArkUI_NumberValue true_checked_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem true_checked_item = { true_checked_value, + sizeof(true_checked_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件宽度 + ArkUI_NumberValue default_width_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem default_width_item = { default_width_value, + sizeof(default_width_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件高度 + ArkUI_NumberValue default_height_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem default_height_item = { default_height_value, + sizeof(default_height_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件margin + ArkUI_NumberValue margin_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + //---------------------------------------------------------------------------------------------------- + // 设置Radio value + ArkUI_AttributeItem radio_value1_Item = { .string = "radio" }; + ArkUI_AttributeItem radio_value2_Item = { .string = "radio_value1.2" }; + ArkUI_AttributeItem radio_value3_Item = { .string = "radio_value2.1" }; + ArkUI_AttributeItem radio_value4_Item = { .string = "radio_value2.2" }; + // 设置Radio group + ArkUI_AttributeItem radio_group1_Item = { .string = "group1" }; + ArkUI_AttributeItem radio_group2_Item = { .string = "group2" }; + + // first radio, 设置Radio value,设置group属于group1,同一个group1有一个可以是选中状态 + auto radio = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio, NODE_RADIO_CHECKED, &true_checked_item); + nodeAPI->setAttribute(radio, NODE_RADIO_VALUE, &radio_value1_Item); + nodeAPI->setAttribute(radio, NODE_RADIO_GROUP, &radio_group1_Item); + + // second radio, 设置Radio value,设置group属于group1 + auto radio_second = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_second, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_second, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_second, NODE_RADIO_VALUE, &radio_value2_Item); + nodeAPI->setAttribute(radio_second, NODE_RADIO_GROUP, &radio_group1_Item); + + // third radio, 设置Radio value,设置group属于group2 + auto radio_third = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_third, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_third, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_third, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio_third, NODE_RADIO_CHECKED, &true_checked_item); + nodeAPI->setAttribute(radio_third, NODE_RADIO_VALUE, &radio_value3_Item); + nodeAPI->setAttribute(radio_third, NODE_RADIO_GROUP, &radio_group2_Item); + + // third radio,, 设置Radio value,设置group属于group2 + auto radio_forth = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio_forth, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio_forth, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio_forth, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(radio_forth, NODE_RADIO_VALUE, &radio_value4_Item); + nodeAPI->setAttribute(radio_forth, NODE_RADIO_GROUP, &radio_group2_Item); + + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item = { .string = "radio_value1.1" }; + ArkUI_NumberValue fontSize[] = { 20 }; + ArkUI_AttributeItem Font_Item = { fontSize, 1 }; + + ArkUI_NumberValue marginValue[] = { 20 }; + ArkUI_AttributeItem marginItem = { marginValue, 1 }; + nodeAPI->setAttribute(text, NODE_TEXT_CONTENT, &LABEL_Item); + nodeAPI->setAttribute(text, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text, NODE_MARGIN, &marginItem); + + auto text2 = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item2 = { .string = "radio_value1.2" }; + nodeAPI->setAttribute(text2, NODE_TEXT_CONTENT, &LABEL_Item2); + nodeAPI->setAttribute(text2, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text2, NODE_MARGIN, &marginItem); + + auto text3 = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item3 = { .string = "radio_value2.1" }; + nodeAPI->setAttribute(text3, NODE_TEXT_CONTENT, &LABEL_Item3); + nodeAPI->setAttribute(text3, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text3, NODE_MARGIN, &marginItem); + + auto text4 = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item4 = { .string = "radio_value2.2" }; + nodeAPI->setAttribute(text4, NODE_TEXT_CONTENT, &LABEL_Item4); + nodeAPI->setAttribute(text4, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text4, NODE_MARGIN, &marginItem); + + // parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = new RowComponent(); + auto row2 = new RowComponent(); + auto row3 = new RowComponent(); + auto row4 = new RowComponent(); + + nodeAPI->addChild(parentColumn, row1->GetComponent()); + nodeAPI->addChild(parentColumn, row2->GetComponent()); + nodeAPI->addChild(parentColumn, row3->GetComponent()); + nodeAPI->addChild(parentColumn, row4->GetComponent()); + nodeAPI->addChild(row1->GetComponent(), text); + nodeAPI->addChild(row1->GetComponent(), radio); + nodeAPI->addChild(row2->GetComponent(), text2); + nodeAPI->addChild(row2->GetComponent(), radio_second); + nodeAPI->addChild(row3->GetComponent(), text3); + nodeAPI->addChild(row3->GetComponent(), radio_third); + nodeAPI->addChild(row4->GetComponent(), text4); + nodeAPI->addChild(row4->GetComponent(), radio_forth); + + // 设置组件Id + ArkUI_AttributeItem idItem; + idItem.string = "radioOnChange"; + nodeAPI->setAttribute(radio_second, NODE_ID, &idItem); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + nodeAPI->registerNodeEvent(radio, NODE_RADIO_EVENT_ON_CHANGE, ON_RADIO_EVENT_ID, text); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RadioValueAndGroupTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_value_group_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_value_group_test.h new file mode 100644 index 0000000000000000000000000000000000000000..eca31582cb62bb0d4e9b62a9c665834f75b724d0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/radio/radio_value_group_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RADIO_VALUE_GROUP_TEST_H +#define ARKUI_CAPI_DEMO_RADIO_VALUE_GROUP_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RadioValueAndGroupTest { +public: + ~RadioValueAndGroupTest(); + // RadioTest:testRadio003,testRadio004 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RADIO_VALUE_GROUP_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/refresh/refresh_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/refresh/refresh_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0cc1295a6d787f80026fbe4aa275dc8b37a165bf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/refresh/refresh_test.cpp @@ -0,0 +1,542 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "refresh_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "refresh_component.h" +#include "scroll_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#define COLOR_RED 0xFFFF0000 +#define INVALID_PARAM 401 +#define ON_REFRESH_EVENT_ID 1314 +#define ON_REFRESH_EVENT_ID_SLEEP 1315 // content and radio +constexpr int32_t FLOW_ITEM_COUNT = 15; + +namespace ArkUICApiDemo { + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + int32_t eventType = OH_ArkUI_NodeEvent_GetEventType(event); + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 当触发刷新事件时,设置refreshing属性为0,并通过radio的checked属性展示 + if (eventType == NODE_REFRESH_ON_REFRESH) { + if (eventId == ON_REFRESH_EVENT_ID) { + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + auto radio = static_cast(OH_ArkUI_NodeEvent_GetUserData(event)); + ArkUI_NumberValue refreshing_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem refreshing_item = { refreshing_value, + sizeof(refreshing_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_REFRESH_REFRESHING, &refreshing_item); + + auto refreshing_attr = nodeAPI->getAttribute(nodeHandler, NODE_REFRESH_REFRESHING); + ArkUI_NumberValue checked_value[] = { { .i32 = static_cast(refreshing_attr->value[0].f32) } }; + ArkUI_AttributeItem checked_item = { checked_value, sizeof(checked_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(radio, NODE_RADIO_CHECKED, &checked_item); + } else if (eventId == ON_REFRESH_EVENT_ID_SLEEP) { + std::this_thread::sleep_for(std::chrono::seconds(4)); + } + } else if (ON_REFRESH_EVENT_ID == eventId && eventType == NODE_REFRESH_ON_OFFSET_CHANGE) { + auto refresh = OH_ArkUI_NodeEvent_GetNodeHandle(event); + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + float offset = result->data[0].f32; + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "refreshTest", "offset=%{public}f", offset); + // 设置背景色 + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_YELLOW } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(refresh, NODE_BACKGROUND_COLOR, &background_color_item); + } +} +static void CreateRefreshingComponent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& refreshingComponent) +{ + // clip + ArkUI_NumberValue clip_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem clip_item = { clip_value, sizeof(clip_value) / sizeof(ArkUI_NumberValue) }; + refreshingComponent = nodeAPI->createNode(ARKUI_NODE_STACK); + nodeAPI->setAttribute(refreshingComponent, NODE_CLIP, &clip_item); + + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + // process height + ArkUI_NumberValue height_value[] = { { .f32 = 32 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + + // margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + auto loadingProgress = nodeAPI->createNode(ARKUI_NODE_LOADING_PROGRESS); + nodeAPI->setAttribute(loadingProgress, NODE_HEIGHT, &height_item); + + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item = { .string = "refreshing..." }; + ArkUI_NumberValue fontSize[] = { 16 }; + ArkUI_AttributeItem Font_Item = { fontSize, 1 }; + nodeAPI->setAttribute(text, NODE_TEXT_CONTENT, &LABEL_Item); + nodeAPI->setAttribute(text, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text, NODE_MARGIN, &margin_item); + + nodeAPI->addChild(refreshingComponent, row); + nodeAPI->addChild(row, text); +} +static void CreateList(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& list, float width = 400, float height = 230) +{ + // 创建List + ArkUI_NumberValue list_width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem list_width_item = { list_width_value, sizeof(list_width_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue list_height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem list_height_item = { list_height_value, sizeof(list_height_value) / sizeof(ArkUI_NumberValue) }; + + list = nodeAPI->createNode(ARKUI_NODE_LIST); + nodeAPI->setAttribute(list, NODE_WIDTH, &list_width_item); + nodeAPI->setAttribute(list, NODE_HEIGHT, &list_height_item); + + // 设置list item border + ArkUI_NumberValue border_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem border_item = { border_value, sizeof(border_value) / sizeof(ArkUI_NumberValue) }; + // 设置设置list item margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + // 设置设置list item宽 + ArkUI_NumberValue listitem_width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem listitem_width_item = { listitem_width_value, + sizeof(listitem_width_value) / sizeof(ArkUI_NumberValue) }; + + // 设置设置list item高 + ArkUI_NumberValue listitem_height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem listitem_height_item = { listitem_height_value, + sizeof(listitem_height_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue listItme_value[] = { { .u32 = COLOR_PINK } }; + ArkUI_AttributeItem listItem_backgroundColor = { listItme_value, 1 }; + + ArkUI_NumberValue list_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem list_backgroundColor = { list_value, 1 }; + + for (int i = 0; i < 10; i++) { + auto listitem = nodeAPI->createNode(ARKUI_NODE_LIST_ITEM); + nodeAPI->setAttribute(listitem, NODE_WIDTH, &listitem_width_item); + nodeAPI->setAttribute(listitem, NODE_HEIGHT, &listitem_height_item); + nodeAPI->setAttribute(listitem, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(listitem, NODE_BACKGROUND_COLOR, &listItem_backgroundColor); + nodeAPI->addChild(list, listitem); + } + nodeAPI->setAttribute(list, NODE_BORDER_WIDTH, &border_item); + nodeAPI->setAttribute(list, NODE_MARGIN, &margin_item); +} +static void CreateRadio(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& radio) +{ + // 设置Radio组件宽度 + ArkUI_NumberValue default_width_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem default_width_item = { default_width_value, + sizeof(default_width_value) / sizeof(ArkUI_NumberValue) }; + + // 设置Radio组件高度 + ArkUI_NumberValue default_height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem default_height_item = { default_height_value, + sizeof(default_height_value) / sizeof(ArkUI_NumberValue) }; + // 设置Radio组件的Checked属性 + ArkUI_NumberValue true_checked_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem true_checked_item = { true_checked_value, + sizeof(true_checked_value) / sizeof(ArkUI_NumberValue) }; + + radio = nodeAPI->createNode(ARKUI_NODE_RADIO); + nodeAPI->setAttribute(radio, NODE_WIDTH, &default_width_item); + nodeAPI->setAttribute(radio, NODE_HEIGHT, &default_height_item); + nodeAPI->setAttribute(radio, NODE_RADIO_CHECKED, &true_checked_item); +} +static std::shared_ptr CreateWaterFlowByNestedScroll(int32_t forward, int32_t backward, bool up = true) +{ + auto scroll = std::make_shared(); + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + auto reserveTop = std::make_shared(); + auto reserveDown = std::make_shared(); + // 设置上占位框 + reserveTop->SetWidth(410); + reserveTop->SetHeight(60); + reserveTop->SetBackgroundColor(COLOR_GREEN); + reserveTop->SetBorderRadius(10, 10, 10, 10); + // 设置下占位框 + reserveDown->SetWidth(410); + reserveDown->SetHeight(60); + reserveDown->SetBackgroundColor(COLOR_RED); + reserveDown->SetBorderRadius(10, 10, 10, 10); + + waterFlow->SetWidth(410); + waterFlow->SetHeight(500); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetColumnsTemplate("1fr 1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr 1fr"); + waterFlow->SetWaterFlowNestedScroll(forward, backward); + waterFlow->SetId("refreshNested"); + + auto item = waterFlow->getAttribute(NODE_SCROLL_NESTED_SCROLL); + if (item->value[0].i32 != forward || item->value[1].i32 != backward) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(100); + col->SetHeight(100); + col->SetMargin(10); + if (i == 0) { + col->SetBackgroundColor(COLOR_PURPLE); + } else { + col->SetBackgroundColor(COLOR_WHITE); + } + adapter->InsertItem(i, col); + } + column->AddChild(reserveTop); + column->AddChild(waterFlow); + column->AddChild(reserveDown); + // 设置scroll选项 + scroll->SetHeight(600); + scroll->AddChild(column); + scroll->SetBorderWidth(1, 1, 1, 1); + scroll->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + if (up) { + scroll->SetScrollTo(0, 200, {}); + waterFlow->SetWaterFlowScrollToIndex(FLOW_ITEM_COUNT - 1, 0, 0); + } + return scroll; +} +napi_value RefreshTest::CreateNativeNodeForRefreshContentAndRatio(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "refreshTest", "CreateNativeNodeForRefreshContent"); + // 获取id + size_t argc = 2; + napi_value args[2] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "GetContext env or info is null"); + return nullptr; + } + + double ratio = 1; + napi_get_value_double(env, args[1], &ratio); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "ratio=%{public}lf", ratio); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置refresh pullToRefresh属性 + ArkUI_NumberValue pullToRefresh_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem pullToRefresh_item = { pullToRefresh_value, 1 }; + + // 创建refresh组件并添加到容器内 + auto refresh = nodeAPI->createNode(ARKUI_NODE_REFRESH); + nodeAPI->setAttribute(refresh, NODE_REFRESH_PULL_TO_REFRESH, &pullToRefresh_item); + ArkUI_NodeHandle refreshingComponent; + CreateRefreshingComponent(nodeAPI, refreshingComponent); + ArkUI_AttributeItem refreshingComponent_item { .object = refreshingComponent }; + nodeAPI->setAttribute(refresh, NODE_REFRESH_CONTENT, &refreshingComponent_item); + + // 设置refresh pullDownRatio属性正常值0~1:NODE_REFRESH_PULL_DOWN_RATIO + ArkUI_NumberValue pullDownRatio_value[] = { { .f32 = static_cast(ratio) } }; + ArkUI_AttributeItem pullDownRatio_item = { pullDownRatio_value, + sizeof(pullDownRatio_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(refresh, NODE_REFRESH_PULL_DOWN_RATIO, &pullDownRatio_item); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + nodeAPI->registerNodeEvent(refresh, NODE_REFRESH_ON_REFRESH, ON_REFRESH_EVENT_ID_SLEEP, nullptr); + + // 设置组件Id + ArkUI_AttributeItem idItem; + idItem.string = "refreshcontent"; + nodeAPI->setAttribute(refresh, NODE_ID, &idItem); + + ArkUI_NodeHandle list; + CreateList(nodeAPI, list); + + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(parentColumn, refresh); + nodeAPI->addChild(refresh, list); + // 挂载组件 + std::string id(xComponentID); + OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn); + + napi_value exports; + napi_create_object(env, &exports); + return exports; +} +napi_value RefreshTest::CreateNativeNodeForRefreshing(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "refreshTest", "CreateNativeNodeForRefreshing"); + // 获取id + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置refresh属性:NODE_REFRESH_REFRESHING + ArkUI_NumberValue refreshing_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem refreshing_item = { refreshing_value, sizeof(refreshing_value) / sizeof(ArkUI_NumberValue) }; + + // 创建refresh组件 + auto refresh = nodeAPI->createNode(ARKUI_NODE_REFRESH); + nodeAPI->setAttribute(refresh, NODE_REFRESH_REFRESHING, &refreshing_item); + // 设置refresh组件Id + ArkUI_AttributeItem idItem; + idItem.string = "refresh"; + nodeAPI->setAttribute(refresh, NODE_ID, &idItem); + // 创建list并放到refresh组件下 + ArkUI_NodeHandle list; + CreateList(nodeAPI, list); + nodeAPI->addChild(refresh, list); + // 创建list并放到radio组件下 + ArkUI_NodeHandle radio; + CreateRadio(nodeAPI, radio); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + nodeAPI->registerNodeEvent(refresh, NODE_REFRESH_ON_REFRESH, ON_REFRESH_EVENT_ID, radio); + nodeAPI->registerNodeEvent(refresh, NODE_REFRESH_ON_OFFSET_CHANGE, ON_REFRESH_EVENT_ID, nullptr); + + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(parentColumn, refresh); + nodeAPI->addChild(refresh, list); + nodeAPI->addChild(parentColumn, radio); + + // 挂载组件 + std::string id(xComponentID); + OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn); + + napi_value exports; + napi_create_object(env, &exports); + + return exports; +} +napi_value RefreshTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + // 获取id + size_t argc = 3; + napi_value args[3] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "GetContext env or info is null"); + return nullptr; + } + if (args[1] == nullptr || args[2] == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "args[1] == nullptr || args[2] == nullptr"); + } + double offset = 64; + napi_get_value_double(env, args[1], &offset); + + int32_t pullToRefresh = 1; + napi_get_value_int32(env, args[2], &pullToRefresh); + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "pullToRefresh = %{public}d,offset=%{public}lf", + pullToRefresh, offset); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 设置refreshOffset属性:NODE_REFRESH_OFFSET + ArkUI_NumberValue refreshOffset_value[] = { { .f32 = static_cast(offset) } }; + ArkUI_AttributeItem refreshOffset_item = { refreshOffset_value, + sizeof(refreshOffset_value) / sizeof(ArkUI_NumberValue) }; + + // 设置refresh pullToRefresh属性 + ArkUI_NumberValue pullToRefresh_value[] = { { .i32 = pullToRefresh } }; + ArkUI_AttributeItem pullToRefresh_item = { pullToRefresh_value, + sizeof(pullToRefresh_value) / sizeof(ArkUI_NumberValue) }; + + // 创建refresh组件并添加到容器内,设置NODE_REFRESH_OFFSET,NODE_REFRESH_PULL_TO_REFRESH + auto refresh = nodeAPI->createNode(ARKUI_NODE_REFRESH); + nodeAPI->setAttribute(refresh, NODE_REFRESH_OFFSET, &refreshOffset_item); + nodeAPI->setAttribute(refresh, NODE_REFRESH_PULL_TO_REFRESH, &pullToRefresh_item); + // 设置组件Id + ArkUI_AttributeItem idItem; + idItem.string = "refresh"; + nodeAPI->setAttribute(refresh, NODE_ID, &idItem); + + ArkUI_NodeHandle list; + CreateList(nodeAPI, list); + ArkUI_NodeHandle radio; + CreateRadio(nodeAPI, radio); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + nodeAPI->registerNodeEvent(refresh, NODE_REFRESH_ON_REFRESH, ON_REFRESH_EVENT_ID, radio); + + // parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(parentColumn, refresh); + nodeAPI->addChild(refresh, list); + nodeAPI->addChild(parentColumn, radio); + + // 挂载组件 + std::string id(xComponentID); + OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn); + + napi_value exports; + napi_create_object(env, &exports); + + return exports; +} +napi_value RefreshTest::CreateNativeNodeNestedScroll(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "refreshTest", "CreateNativeNodeNestedScroll"); + // 获取id + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto refresh = std::make_shared(ARKUI_NODE_REFRESH); + + ArkUI_NodeHandle refreshingComponent; + CreateRefreshingComponent(nodeAPI, refreshingComponent); + ArkUI_AttributeItem refreshingComponent_item { .object = refreshingComponent }; + nodeAPI->setAttribute(refresh->GetComponent(), NODE_REFRESH_CONTENT, &refreshingComponent_item); + + auto nestedScroll = CreateWaterFlowByNestedScroll(ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST, + ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST); + refresh->AddChild(nestedScroll); + parentColumn->AddChild(refresh); + + // 挂载组件 + std::string id(xComponentID); + OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()); + + napi_value exports; + napi_create_object(env, &exports); + + return exports; +} + +napi_value RefreshTest::CreateNativeNodeForResetAttribute(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "refreshTest", "CreateNativeNodeForResetAttribute"); + // 获取id + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "refreshTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto parentColumn = new ColumnComponent(); + auto refresh = std::make_shared(); + refresh->SetPullToRefresh(0); // 默认值:1 + refresh->SetPullDownRatio(0.5); // 默认值:0.0f + refresh->SetRefreshOffset(20); // 默认值:0.0f + + ArkUI_NodeHandle list; + CreateList(nodeAPI, list); + + auto text = new TextComponent(); + text->SetWidth(300); + text->SetHeight(200); + text->SetBackgroundColor(COLOR_PINK); + + auto button = new ButtonComponent(); + button->SetWidth(200); + button->SetHeight(100); + button->SetId("ResetRefresh"); + button->SetLable("ResetRefresh"); + button->SetMargin(10); + button->RegisterOnClick([refresh, text]() { + refresh->resetAttribute(NODE_REFRESH_PULL_TO_REFRESH); + refresh->resetAttribute(NODE_REFRESH_PULL_DOWN_RATIO); + refresh->resetAttribute(NODE_REFRESH_OFFSET); + + auto pullToRefreshItem = refresh->getAttribute(NODE_REFRESH_PULL_TO_REFRESH); + auto pullDownRatio = refresh->getAttribute(NODE_REFRESH_PULL_TO_REFRESH); + auto refreshOffset = refresh->getAttribute(NODE_REFRESH_PULL_TO_REFRESH); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "refreshTest", + "pullToRefreshItem=%{public}d,pullDownRatio=%{public}f,refreshOffset=%{public}f", + pullToRefreshItem->value[0].i32, pullDownRatio->value[0].f32, refreshOffset->value[0].f32); + + std::string str = "pullToRefresh:" + std::to_string(pullToRefreshItem->value[0].i32) + "\n" + + "pullDownRatio:" + std::to_string(pullDownRatio->value[0].f32) + "\n" + + "refreshOffset:" + std::to_string(refreshOffset->value[0].f32) + "\n"; + + text->SetFontSize(20); + text->SetTextContent(str); + }); + + parentColumn->AddChild(std::shared_ptr(refresh)); + parentColumn->AddChild(std::shared_ptr(button)); + nodeAPI->addChild(refresh->GetComponent(), list); + parentColumn->AddChild(std::shared_ptr(text)); + // 挂载组件 + std::string id(xComponentID); + OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn->GetComponent()); + + napi_value exports; + napi_create_object(env, &exports); + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/refresh/refresh_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/refresh/refresh_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e3cda837b4fc8b6693cc9bb05918ba48a1cf84e8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/refresh/refresh_test.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_REFRESH_TEST_H +#define ARKUI_CAPI_DEMO_REFRESH_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RefreshTest { +public: + ~RefreshTest(); + // RefreshTest:testRefresh001,testRefresh002,testRefresh003,testRefresh004 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // RefreshTest:testRefresh005,testRefresh006 + static napi_value CreateNativeNodeForRefreshContentAndRatio(napi_env env, napi_callback_info info); + // RefreshTest:testRefresh007 + static napi_value CreateNativeNodeForRefreshing(napi_env env, napi_callback_info info); + // RefreshTest:testRefresh008 + static napi_value CreateNativeNodeNestedScroll(napi_env env, napi_callback_info info); + // RefreshTest:testRefresh009 + static napi_value CreateNativeNodeForResetAttribute(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_REFRESH_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_barrier_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_barrier_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dfbb27bf50d36a2db2d75f24cea8ad91fd039915 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_barrier_test.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "relativecontainer_barrier_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "arkui/native_node.h" +#include "component/column_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +std::shared_ptr CreateTestColumn( + std::shared_ptr barrier, std::vector> rows) +{ + auto column = std::make_shared(); + column->SetMargin(5); + auto relativeContainer = std::make_shared(); + relativeContainer->SetWidth(200); + relativeContainer->SetHeight(200); + relativeContainer->SetBorderWidth(2); + relativeContainer->SetBorderColor(COLOR_BLUE, COLOR_BLUE, COLOR_BLUE, COLOR_BLUE); + relativeContainer->SetRelativeContainerBarrier(barrier); + for (auto row : rows) { + relativeContainer->AddChild(row); + } + column->AddChild(relativeContainer); + return column; +} + +std::shared_ptr CreateTestRows( + std::string id, uint32_t color = COLOR_RED, std::shared_ptr ruleOption = nullptr) +{ + auto row = std::make_shared(); + row->SetWidth(50.0); + row->SetHeight(50.0); + row->SetId(id); + if (ruleOption) { + row->SetAlignRules(ruleOption->GetOption()); + } + row->SetBackgroundColor(color); + return row; +} + +napi_value RelativeContainerBarrierTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create ruleOption + auto rule1 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule1 { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "__container__" }; + VerticalAlignRule verticalAlignRule1 { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "__container__" }; + AlignmentRuleOption ruleOption1 { .left = horizontalAlignRule1, .top = verticalAlignRule1 }; + rule1->SetAlignOption(ruleOption1); + + auto rule2 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule2 { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "__container__" }; + VerticalAlignRule verticalAlignRule2 { .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM, .anchor = "__container__" }; + AlignmentRuleOption ruleOption2 { .left = horizontalAlignRule2, .bottom = verticalAlignRule2 }; + rule2->SetAlignOption(ruleOption2); + + auto rule3 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule3 { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "__container__" }; + VerticalAlignRule verticalAlignRule3 { .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM, .anchor = "__container__" }; + AlignmentRuleOption ruleOption3 { .right = horizontalAlignRule3, .bottom = verticalAlignRule3 }; + rule3->SetAlignOption(ruleOption3); + + auto rule4 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule4 { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "__container__" }; + VerticalAlignRule verticalAlignRule4 { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "__container__" }; + AlignmentRuleOption ruleOption4 { .right = horizontalAlignRule4, .top = verticalAlignRule4 }; + rule4->SetAlignOption(ruleOption4); + + auto rule5 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule5 { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "barrier1" }; + VerticalAlignRule verticalAlignRule5 { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "barrier2" }; + HorizontalAlignRule horizontalAlignRule6 { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "barrier3" }; + VerticalAlignRule verticalAlignRule6 { .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM, .anchor = "barrier4" }; + AlignmentRuleOption ruleOption5 { .left = horizontalAlignRule5, + .right = horizontalAlignRule6, + .bottom = verticalAlignRule5, + .top = verticalAlignRule6 }; + rule5->SetAlignOption(ruleOption5); + + auto rule6 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule7 { .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER, .anchor = "__container__" }; + VerticalAlignRule verticalAlignRule7 { .align = ARKUI_VERTICAL_ALIGNMENT_CENTER, .anchor = "__container__" }; + AlignmentRuleOption ruleOption7 { .middle = horizontalAlignRule7, .center = verticalAlignRule7 }; + rule6->SetAlignOption(ruleOption7); + + auto rule7 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule8 { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "barrier5" }; + AlignmentRuleOption ruleOption8 { .right = horizontalAlignRule8 }; + rule7->SetAlignOption(ruleOption8); + + auto rule8 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule9 { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "barrier6" }; + AlignmentRuleOption ruleOption9 { .right = horizontalAlignRule9 }; + rule8->SetAlignOption(ruleOption9); + + auto rule9 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule10 { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "barrier7" }; + rule9->SetAlignOption(AlignmentRuleOption { .left = horizontalAlignRule10 }); + + auto rule10 = std::make_shared(); + VerticalAlignRule verticalAlignRule10 { .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM, .anchor = " " }; + rule10->SetAlignOption(AlignmentRuleOption { .top = verticalAlignRule10 }); + + // create row + auto row1 = CreateTestRows("row1", COLOR_RED, rule1); + auto row2 = CreateTestRows("row2", COLOR_BLUE, rule2); + auto row3 = CreateTestRows("row3", COLOR_YELLOW, rule3); + auto row4 = CreateTestRows("row4", COLOR_LIGHT_BLUE, rule4); + auto row5 = CreateTestRows("row5", COLOR_PURPLE, rule5); + auto row6 = CreateTestRows("row6", COLOR_RED, rule6); + auto row7 = CreateTestRows("row7", COLOR_YELLOW, rule7); + auto row8 = CreateTestRows("row8", COLOR_BLUE, rule8); + auto row9 = CreateTestRows("row9", COLOR_GREEN); + auto row10 = CreateTestRows("row10", COLOR_RED, rule9); + auto row11 = CreateTestRows("row11", COLOR_RED); + auto row12 = CreateTestRows("row12", COLOR_YELLOW, rule10); + + // create barrier + auto barrier1 = std::make_shared(4); + BarrierStyle style1 { + .id = "barrier1", .direction = ARKUI_BARRIER_DIRECTION_END, .referencedId = { "row1", "row2" } + }; + BarrierStyle style2 { + .id = "barrier2", .direction = ARKUI_BARRIER_DIRECTION_TOP, .referencedId = { "row2", "row3" } + }; + BarrierStyle style3 { + .id = "barrier3", .direction = ARKUI_BARRIER_DIRECTION_START, .referencedId = { "row3", "row4" } + }; + BarrierStyle style4 { + .id = "barrier4", .direction = ARKUI_BARRIER_DIRECTION_BOTTOM, .referencedId = { "row1", "row4" } + }; + barrier1->SetBarrierStyle(style1, 0); + barrier1->SetBarrierStyle(style2, 1); + barrier1->SetBarrierStyle(style3, 2); + barrier1->SetBarrierStyle(style4, 3); + + auto barrier2 = std::make_shared(2); + BarrierStyle style5 { + .id = "barrier5", .direction = static_cast(4), .referencedId = { "row6" } + }; + BarrierStyle style6 { + .id = "barrier6", .direction = static_cast(-1), .referencedId = { "row7" } + }; + barrier2->SetBarrierStyle(style5, 0); + barrier2->SetBarrierStyle(style6, 1); + + auto barrier3 = std::make_shared(0); + BarrierStyle style7 { .id = "barrier7", .direction = ARKUI_BARRIER_DIRECTION_END, .referencedId = { "row9" } }; + barrier3->SetBarrierStyle(style7, 0); + + auto barrier4 = std::make_shared(1); + BarrierStyle style8 { .id = " ", .direction = ARKUI_BARRIER_DIRECTION_BOTTOM, .referencedId = { "row11" } }; + barrier4->SetBarrierStyle(style8, 0); + + auto column1 = CreateTestColumn(barrier1, { row1, row2, row3, row4, row5 }); + auto column2 = CreateTestColumn(barrier3, { row9, row10 }); + auto column3 = CreateTestColumn(barrier2, { row6, row7, row8 }); + auto column4 = CreateTestColumn(barrier4, { row11, row12 }); + + auto style = barrier1->GetBarrierStyle(0); + auto referenceId = barrier1->GetReferencedId(0, 0); + auto size = barrier1->GetReferencedIdSize(0); + if (style.id == "barrier1" && style.direction == ARKUI_BARRIER_DIRECTION_END && referenceId == "row1" && + size == 2) { + column1->SetBackgroundColor(COLOR_GREEN); + } + + auto rowContainer1 = std::make_shared(); + rowContainer1->SetPadding(10, 0, 0, 0); + rowContainer1->AddChild(column1); + rowContainer1->AddChild(column2); + + auto rowContainer2 = std::make_shared(); + rowContainer2->AddChild(column3); + + auto rowContainer3 = std::make_shared(); + rowContainer3->AddChild(column4); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, rowContainer1->GetComponent()); + nodeAPI->addChild(column, rowContainer2->GetComponent()); + nodeAPI->addChild(column, rowContainer3->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_barrier_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_barrier_test.h new file mode 100644 index 0000000000000000000000000000000000000000..698376a8130dad9c4bf5f5e5becc7f33ff0709d4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_barrier_test.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_RELATIVECONTAINER_BARRIER_TEST_H +#define ARKUI_CAPI_DEMO_RELATIVECONTAINER_BARRIER_TEST_H +#include "../component/relativecontainer_component.h" +#include "../common/common.h" +namespace ArkUICApiDemo { +class RelativeContainerBarrierTest { +public: + ~RelativeContainerBarrierTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} +#endif //ARKUI_CAPI_DEMO_RELATIVECONTAINER_BARRIER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_guideLine_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_guideLine_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..046519a2c6bc7631e19665faa730b63f85d40494 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_guideLine_test.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "relativecontainer_guideLine_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "arkui/native_node.h" +#include "column_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; +static std::shared_ptr CreateTestColumn( + shared_ptr guideLine, vector> rows) +{ + auto column = std::make_shared(); + column->SetMargin(5); + auto relativeContainer = std::make_shared(); + relativeContainer->SetWidth(200); + relativeContainer->SetHeight(200); + relativeContainer->SetBorderWidth(2); + relativeContainer->SetBorderColor(COLOR_BLUE, COLOR_BLUE, COLOR_BLUE, COLOR_BLUE); + + relativeContainer->SetRelativeContainerGuideLine(guideLine); + for (auto row : rows) { + relativeContainer->AddChild(row); + } + column->AddChild(relativeContainer); + return column; +} + +static shared_ptr CreateTestRows(string id, shared_ptr ruleOption, uint32_t color) +{ + auto row = std::make_shared(); + row->SetWidth(50.0); + row->SetHeight(50.0); + row->SetId(id); + row->SetAlignRules(ruleOption->GetOption()); + row->SetBackgroundColor(color); + return row; +} + +napi_value RelativeContainerGuideLineTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create guideLine + auto guideLine1 = std::make_shared(2); + GuidelineStyle style1 { .id = "line1", .direction = ARKUI_AXIS_VERTICAL, .start = 50 }; + GuidelineStyle style2 { .id = "line2", .direction = ARKUI_AXIS_HORIZONTAL, .start = 50, .end = 50 }; + guideLine1->SetGuideLineStyle(style1, 0); + guideLine1->SetGuideLineStyle(style2, 1); + + auto guideLine2 = std::make_shared(0); + guideLine2->SetGuideLineStyle({ .id = "line3", .direction = ARKUI_AXIS_VERTICAL, .start = 50 }, 0); + guideLine2->SetGuideLineStyle({ .id = "line4", .direction = ARKUI_AXIS_HORIZONTAL, .start = 50 }, 1); + + auto guideLine3 = std::make_shared(2); + guideLine3->SetGuideLineStyle({ .id = " ", .direction = ARKUI_AXIS_VERTICAL, .start = 50 }, 0); + guideLine3->SetGuideLineStyle({ .id = "line5", .direction = ARKUI_AXIS_HORIZONTAL, .start = -1 }, 1); + + auto guideLine4 = std::make_shared(2); + guideLine4->SetGuideLineStyle({ .id = "line6", .direction = static_cast(-1), .end = 50 }, 0); + guideLine4->SetGuideLineStyle({ .id = "line7", .direction = ARKUI_AXIS_HORIZONTAL, .end = 50 }, 1); + + // create ruleOption + auto ruleOption1 = std::make_shared(); + HorizontalAlignRule horizontalAlignRule { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "line1" }; + VerticalAlignRule verticalAlignRule { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "line2" }; + ruleOption1->SetAlignOption({ .left = horizontalAlignRule, .top = verticalAlignRule }); + + auto ruleOption2 = std::make_shared(); + ruleOption2->SetAlignOption({ .left = { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "line3" }, + .top = { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "line4" } }); + auto ruleOption3 = std::make_shared(); + ruleOption3->SetAlignOption({ .left = { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = " " }, + .top = { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "line5" } }); + auto ruleOption4 = std::make_shared(); + ruleOption4->SetAlignOption({ .left = { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "line6" }, + .top = { .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM, .anchor = "line7" } }); + + auto column1 = CreateTestColumn(guideLine1, { CreateTestRows("row1", ruleOption1, COLOR_RED) }); + auto column2 = CreateTestColumn(guideLine2, { CreateTestRows("row2", ruleOption2, COLOR_RED) }); + auto column3 = CreateTestColumn(guideLine3, { CreateTestRows("row3", ruleOption3, COLOR_RED) }); + auto column4 = CreateTestColumn(guideLine4, { CreateTestRows("row4", ruleOption4, COLOR_RED) }); + auto row1 = std::make_shared(); + row1->SetPadding(10, 0, 0, 0); + row1->AddChild(column1); + row1->AddChild(column2); + + auto row2 = std::make_shared(); + row2->AddChild(column3); + row2->AddChild(column4); + + auto row3 = std::make_shared(); + row3->SetHeight(50); + row3->SetWidth(50); + row3->SetBackgroundColor(COLOR_RED); + auto lineStyle = guideLine1->GetGuideLineStyle(1); + if (lineStyle.direction == ARKUI_AXIS_HORIZONTAL && lineStyle.start == 50 && lineStyle.end == 50 && + lineStyle.id == "line2") { + column1->SetBackgroundColor(COLOR_GREEN); + } + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, row1->GetComponent()); + nodeAPI->addChild(column, row2->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_guideLine_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_guideLine_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f7784f0701583584930e0f6ad7ca73d2954add3b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/relativecontainer_guideLine_test.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_RELATIVECONTAINER_GUIDELINE_TEST_H +#define ARKUI_CAPI_DEMO_RELATIVECONTAINER_GUIDELINE_TEST_H +#include "../common/common.h" +#include "../component/relativecontainer_component.h" + +namespace ArkUICApiDemo { +class RelativeContainerGuideLineTest { +public: + ~RelativeContainerGuideLineTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RELATIVECONTAINER_GUIDELINE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/ruleOption.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/ruleOption.cpp new file mode 100644 index 0000000000000000000000000000000000000000..abb9c6cd1dc697d0832618d6e4e3c8c1bed6c492 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/ruleOption.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ruleOption.h" + +namespace ArkUICApiDemo { +using namespace std; + +void BarrierOption::SetBarrierStyle(const BarrierStyle& style, int32_t index) +{ + OH_ArkUI_BarrierOption_SetId(barrierOption_, style.id.c_str(), index); + OH_ArkUI_BarrierOption_SetDirection(barrierOption_, style.direction, index); + for (const auto& id : style.referencedId) { + OH_ArkUI_BarrierOption_SetReferencedId(barrierOption_, id.c_str(), index); + } +} + +BarrierStyle BarrierOption::GetBarrierStyle(int32_t index) const +{ + BarrierStyle style; + style.id = OH_ArkUI_BarrierOption_GetId(barrierOption_, index); + style.direction = OH_ArkUI_BarrierOption_GetDirection(barrierOption_, index); + return style; +} + +std::string BarrierOption::GetReferencedId(int32_t index, int32_t referencedIndex) const +{ + return OH_ArkUI_BarrierOption_GetReferencedId(barrierOption_, index, referencedIndex); +} + +int32_t BarrierOption::GetReferencedIdSize(int32_t index) const +{ + return OH_ArkUI_BarrierOption_GetReferencedIdSize(barrierOption_, index); +} + +void GuideLineOption::SetGuideLineStyle(const GuidelineStyle& style, int32_t index) +{ + OH_ArkUI_GuidelineOption_SetId(guideLineOption_, style.id.c_str(), index); + OH_ArkUI_GuidelineOption_SetDirection(guideLineOption_, style.direction, index); + if (style.start.has_value()) { + OH_ArkUI_GuidelineOption_SetPositionStart(guideLineOption_, style.start.value(), index); + } + if (style.end.has_value()) { + OH_ArkUI_GuidelineOption_SetPositionEnd(guideLineOption_, style.end.value(), index); + } +} + +GuidelineStyle GuideLineOption::GetGuideLineStyle(int32_t index) +{ + GuidelineStyle style; + style.id = OH_ArkUI_GuidelineOption_GetId(guideLineOption_, index); + style.direction = OH_ArkUI_GuidelineOption_GetDirection(guideLineOption_, index); + style.start = OH_ArkUI_GuidelineOption_GetPositionStart(guideLineOption_, index); + style.end = OH_ArkUI_GuidelineOption_GetPositionEnd(guideLineOption_, index); + return style; +} + +void RuleOption::SetAlignOption(const AlignmentRuleOption& ruleOption) +{ + OH_ArkUI_AlignmentRuleOption_SetStart(ruleOption_, ruleOption.left.anchor.c_str(), ruleOption.left.align); + OH_ArkUI_AlignmentRuleOption_SetEnd(ruleOption_, ruleOption.right.anchor.c_str(), ruleOption.right.align); + OH_ArkUI_AlignmentRuleOption_SetTop(ruleOption_, ruleOption.top.anchor.c_str(), ruleOption.top.align); + OH_ArkUI_AlignmentRuleOption_SetBottom(ruleOption_, ruleOption.bottom.anchor.c_str(), ruleOption.bottom.align); + OH_ArkUI_AlignmentRuleOption_SetCenterHorizontal( + ruleOption_, ruleOption.middle.anchor.c_str(), ruleOption.middle.align); + OH_ArkUI_AlignmentRuleOption_SetCenterVertical( + ruleOption_, ruleOption.center.anchor.c_str(), ruleOption.center.align); + if (ruleOption.biasHorizontal.has_value()) { + OH_ArkUI_AlignmentRuleOption_SetBiasHorizontal(ruleOption_, ruleOption.biasHorizontal.value()); + } + if (ruleOption.biasVertical.has_value()) { + OH_ArkUI_AlignmentRuleOption_SetBiasVertical(ruleOption_, ruleOption.biasVertical.value()); + } +} +AlignmentRuleOption RuleOption::GetAlignOption() +{ + AlignmentRuleOption ruleOption; + ruleOption.left.align = OH_ArkUI_AlignmentRuleOption_GetStartAlignment(ruleOption_); + ruleOption.right.align = OH_ArkUI_AlignmentRuleOption_GetEndAlignment(ruleOption_); + ruleOption.top.align = OH_ArkUI_AlignmentRuleOption_GetTopAlignment(ruleOption_); + ruleOption.bottom.align = OH_ArkUI_AlignmentRuleOption_GetBottomAlignment(ruleOption_); + ruleOption.middle.align = OH_ArkUI_AlignmentRuleOption_GetCenterAlignmentHorizontal(ruleOption_); + ruleOption.center.align = OH_ArkUI_AlignmentRuleOption_GetCenterAlignmentVertical(ruleOption_); + ruleOption.biasHorizontal = OH_ArkUI_AlignmentRuleOption_GetBiasHorizontal(ruleOption_); + ruleOption.biasVertical = OH_ArkUI_AlignmentRuleOption_GetBiasVertical(ruleOption_); + return ruleOption; +} + +RuleOptionId RuleOption::GetRuleOptionId() +{ + RuleOptionId ruleOptionId; + ruleOptionId.startId = OH_ArkUI_AlignmentRuleOption_GetStartId(ruleOption_); + ruleOptionId.endId = OH_ArkUI_AlignmentRuleOption_GetEndId(ruleOption_); + ruleOptionId.topId = OH_ArkUI_AlignmentRuleOption_GetTopId(ruleOption_); + ruleOptionId.bottomId = OH_ArkUI_AlignmentRuleOption_GetBottomId(ruleOption_); + ruleOptionId.centerIdHorizontal = OH_ArkUI_AlignmentRuleOption_GetCenterIdHorizontal(ruleOption_); + ruleOptionId.centerIdVertical = OH_ArkUI_AlignmentRuleOption_GetCenterIdVertical(ruleOption_); + return ruleOptionId; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/ruleOption.h b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/ruleOption.h new file mode 100644 index 0000000000000000000000000000000000000000..d514c60df3b5f135e3c9b68675151cec22840687 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/ruleOption.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RULEOPTION_H +#define ARKUI_CAPI_DEMO_RULEOPTION_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { +struct BarrierStyle { + std::string id; + ArkUI_BarrierDirection direction; + std::vector referencedId; +}; + +class BarrierOption { +public: + explicit BarrierOption(int32_t size) : barrierOption_(OH_ArkUI_BarrierOption_Create(size)) {} + virtual ~BarrierOption() + { + OH_ArkUI_BarrierOption_Dispose(barrierOption_); + } + + void SetBarrierStyle(const BarrierStyle& style, int32_t index); + + BarrierStyle GetBarrierStyle(int32_t index) const; + std::string GetReferencedId(int32_t index, int32_t referencedIndex) const; + int32_t GetReferencedIdSize(int32_t index) const; + + ArkUI_BarrierOption* GetOption() + { + return barrierOption_; + } + +private: + ArkUI_BarrierOption* barrierOption_; +}; + +struct GuidelineStyle { + std::string id; + ArkUI_Axis direction; + std::optional start; + bool hasStart; + std::optional end; + bool hasEnd; +}; + +class GuideLineOption { +public: + explicit GuideLineOption(int32_t size) : guideLineOption_(OH_ArkUI_GuidelineOption_Create(size)) {} + virtual ~GuideLineOption() + { + OH_ArkUI_GuidelineOption_Dispose(guideLineOption_); + } + + void SetGuideLineStyle(const GuidelineStyle& style, int32_t index); + GuidelineStyle GetGuideLineStyle(int32_t index); + ArkUI_GuidelineOption* GetOption() + { + return guideLineOption_; + } + +private: + ArkUI_GuidelineOption* guideLineOption_ = nullptr; +}; + +struct HorizontalAlignRule { + bool hasValue; + std::string anchor; + ArkUI_HorizontalAlignment align; +}; + +struct VerticalAlignRule { + bool hasValue; + std::string anchor; + ArkUI_VerticalAlignment align; +}; + +struct AlignmentRuleOption { + HorizontalAlignRule left; + HorizontalAlignRule middle; + HorizontalAlignRule right; + VerticalAlignRule top; + VerticalAlignRule center; + VerticalAlignRule bottom; + std::optional biasHorizontal; + std::optional biasVertical; +}; + +struct RuleOptionId { + std::string startId; + std::string endId; + std::string topId; + std::string bottomId; + std::string centerIdHorizontal; + std::string centerIdVertical; +}; + +class RuleOption { +public: + RuleOption() : ruleOption_(OH_ArkUI_AlignmentRuleOption_Create()) {} + virtual ~RuleOption() + { + OH_ArkUI_AlignmentRuleOption_Dispose(ruleOption_); + } + void SetAlignOption(const AlignmentRuleOption& ruleOption); + AlignmentRuleOption GetAlignOption(); + RuleOptionId GetRuleOptionId(); + ArkUI_AlignmentRuleOption* GetOption() + { + return ruleOption_; + } + +private: + ArkUI_AlignmentRuleOption* ruleOption_; +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_RULEOPTION_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/rule_option_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/rule_option_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7632985ddb9c3fb9f22fb7693638a1c676d80daf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/rule_option_test.cpp @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rule_option_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "arkui/native_node.h" +#include "column_component.h" +#include "component/row_component.h" + +namespace ArkUICApiDemo { +using namespace std; +std::shared_ptr CreateTestRow( + std::string id, uint32_t color = COLOR_RED, std::shared_ptr ruleOption = nullptr) +{ + auto row = std::make_shared(); + row->SetWidth(50.0); + row->SetHeight(50.0); + row->SetId(id); + if (ruleOption) { + row->SetAlignRules(ruleOption->GetOption()); + } + row->SetBackgroundColor(color); + return row; +} + +std::shared_ptr CreateTestColumn(std::vector> rows) +{ + auto column = std::make_shared(); + column->SetMargin(5); + auto relativeContainer = std::make_shared(); + relativeContainer->SetWidth(200); + relativeContainer->SetHeight(200); + relativeContainer->SetBorderWidth(2); + relativeContainer->SetBorderColor(COLOR_BLUE, COLOR_BLUE, COLOR_BLUE, COLOR_BLUE); + for (auto row : rows) { + relativeContainer->AddChild(row); + } + column->AddChild(relativeContainer); + return column; +} + +static shared_ptr CreateTestRows(string id, shared_ptr ruleOption, uint32_t color) +{ + auto row = std::make_shared(); + row->SetWidth(50.0); + row->SetHeight(50.0); + row->SetId(id); + row->SetAlignRules(ruleOption->GetOption()); + row->SetBackgroundColor(color); + return row; +} +napi_value RuleOptionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ButtonBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create ruleOption + HorizontalAlignRule start { .align = ARKUI_HORIZONTAL_ALIGNMENT_START, .anchor = "__container__" }; + HorizontalAlignRule end { .align = ARKUI_HORIZONTAL_ALIGNMENT_END, .anchor = "__container__" }; + VerticalAlignRule top { .align = ARKUI_VERTICAL_ALIGNMENT_TOP, .anchor = "__container__" }; + VerticalAlignRule bottom { .align = ARKUI_VERTICAL_ALIGNMENT_BOTTOM, .anchor = "__container__" }; + HorizontalAlignRule middle { .align = ARKUI_HORIZONTAL_ALIGNMENT_CENTER, .anchor = "__container__" }; + VerticalAlignRule center { .align = ARKUI_VERTICAL_ALIGNMENT_CENTER, .anchor = "__container__" }; + + auto horizontalAlignment1 = static_cast(-1); + auto horizontalAlignment2 = static_cast(3); + auto verticalAlignment1 = static_cast(-1); + auto verticalAlignment2 = static_cast(3); + + HorizontalAlignRule start2 { .align = horizontalAlignment1, .anchor = "__container__" }; + HorizontalAlignRule end2 { .align = horizontalAlignment1, .anchor = "__container__" }; + VerticalAlignRule top2 { .align = verticalAlignment1, .anchor = "__container__" }; + VerticalAlignRule bottom2 { .align = verticalAlignment1, .anchor = "__container__" }; + HorizontalAlignRule middle2 { .align = horizontalAlignment1, .anchor = "__container__" }; + VerticalAlignRule center2 { .align = verticalAlignment1, .anchor = "__container__" }; + + HorizontalAlignRule start3 { .align = horizontalAlignment2, .anchor = "__container__" }; + HorizontalAlignRule end3 { .align = horizontalAlignment2, .anchor = "__container__" }; + VerticalAlignRule top3 { .align = verticalAlignment2, .anchor = "__container__" }; + VerticalAlignRule bottom3 { .align = verticalAlignment2, .anchor = "__container__" }; + HorizontalAlignRule middle3 { .align = horizontalAlignment2, .anchor = "__container__" }; + VerticalAlignRule center3 { .align = verticalAlignment2, .anchor = "__container__" }; + + auto rule1 = std::make_shared(); + AlignmentRuleOption ruleOption1 { .left = start, .right = end, .top = top, .bottom = bottom }; + rule1->SetAlignOption(ruleOption1); + + auto rule2 = std::make_shared(); + AlignmentRuleOption ruleOption2 { .left = start, .bottom = bottom }; + rule2->SetAlignOption(ruleOption2); + + auto rule3 = std::make_shared(); + AlignmentRuleOption ruleOption3 { .right = end, .bottom = bottom }; + rule3->SetAlignOption(ruleOption3); + + auto rule4 = std::make_shared(); + AlignmentRuleOption ruleOption4 { .right = end, .top = top }; + rule4->SetAlignOption(ruleOption4); + + auto rule5 = std::make_shared(); + AlignmentRuleOption ruleOption5 { .middle = middle, .center = center }; + rule5->SetAlignOption(ruleOption5); + + auto rule6 = std::make_shared(); + AlignmentRuleOption ruleOption6 { + .biasVertical = 1, .biasHorizontal = 1, .left = start, .right = end, .top = top, .bottom = bottom + }; + rule6->SetAlignOption(ruleOption6); + + auto rule7 = std::make_shared(); + AlignmentRuleOption ruleOption7 { + .biasVertical = 0, .biasHorizontal = 0, .left = start, .right = end, .top = top, .bottom = bottom + }; + rule7->SetAlignOption(ruleOption7); + + auto rule8 = std::make_shared(); + AlignmentRuleOption ruleOption8 { + .biasVertical = -0.3, .biasHorizontal = -0.3, .left = start, .right = end, .top = top, .bottom = bottom + }; + rule8->SetAlignOption(ruleOption8); + + auto rule9 = std::make_shared(); + AlignmentRuleOption ruleOption9 { + .middle = middle2, .center = center2, .left = start2, .right = end2, .top = top2, .bottom = bottom2 + }; + rule9->SetAlignOption(ruleOption9); + + auto rule10 = std::make_shared(); + AlignmentRuleOption ruleOption10 { + .middle = middle3, .center = center3, .left = start3, .right = end3, .top = top3, .bottom = bottom3 + }; + rule10->SetAlignOption(ruleOption10); + + // create row + auto row1 = CreateTestRow("row1", COLOR_RED, rule1); + auto row2 = CreateTestRow("row2", COLOR_BLUE, rule2); + auto row3 = CreateTestRow("row3", COLOR_YELLOW, rule3); + auto row4 = CreateTestRow("row4", COLOR_LIGHT_BLUE, rule4); + auto row5 = CreateTestRow("row5", COLOR_GRAY, rule5); + auto row6 = CreateTestRow("row6", COLOR_RED, rule6); + auto row7 = CreateTestRow("row7", COLOR_YELLOW, rule7); + auto row8 = CreateTestRow("row8", COLOR_GREEN, rule8); + auto row9 = CreateTestRow("row9", COLOR_GREEN, rule9); + auto row10 = CreateTestRow("row10", COLOR_RED, rule10); + auto row11 = CreateTestRow("row11", COLOR_WHITE); + + auto column1 = CreateTestColumn({ row1, row2, row3, row4, row5 }); + auto column2 = CreateTestColumn({ row6, row7, row8 }); + row11->AddChild(row9); + row11->AddChild(row10); + auto column3 = CreateTestColumn({ row11 }); + + auto ruleOptionId1 = rule6->GetRuleOptionId(); + auto ruleOptionId2 = rule5->GetRuleOptionId(); + auto alignOption1 = rule6->GetAlignOption(); + auto alignOption2 = rule5->GetAlignOption(); + if (alignOption1.left.align == start.align && alignOption1.right.align == end.align && + alignOption1.top.align == top.align && alignOption1.bottom.align == bottom.align && + alignOption2.center.align == center.align && center.align && alignOption2.middle.align == middle.align && + ruleOptionId1.startId == "__container__" && ruleOptionId1.endId == "__container__" && + ruleOptionId1.topId == "__container__" && ruleOptionId1.bottomId == "__container__" && + ruleOptionId2.centerIdHorizontal == "__container__" && ruleOptionId2.centerIdVertical == "__container__") { + column1->SetBackgroundColor(COLOR_GREEN); + } + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, column1->GetComponent()); + nodeAPI->addChild(column, column2->GetComponent()); + nodeAPI->addChild(column, column3->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RelativeContainerGuideLineTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/rule_option_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/rule_option_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a947e131e87dba9c5c79a85f85dccdbdc26d11c0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/relativeContainer/rule_option_test.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_RULE_OPTION_TEST_H +#define ARKUI_CAPI_DEMO_RULE_OPTION_TEST_H +#include "../common/common.h" +#include "../component/relativecontainer_component.h" + +namespace ArkUICApiDemo { +class RuleOptionTest { +public: + ~RuleOptionTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RULE_OPTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pangesture_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pangesture_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b013159035d1d2c97167d151139b6f32d54991a4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pangesture_test.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "requirement_pangesture_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "swiper_component.h" + +namespace ArkUICApiDemo { + +ArkUI_NativeNodeAPI_1* RequirementPanGestureTest::nodeAPI = nullptr; + +static void OnEventFirstGesture(ArkUI_GestureEvent* event, void* extraParams) +{ + auto swipe = OH_ArkUI_GestureEvent_GetNode(event); + ArkUI_NumberValue ColorValue[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem ColorItem = { ColorValue, sizeof(ColorValue) / sizeof(ArkUI_NumberValue) }; + RequirementPanGestureTest::nodeAPI->setAttribute(swipe, NODE_BACKGROUND_COLOR, &ColorItem); +} + +static void OnEventSecondGesture(ArkUI_GestureEvent* event, void* extraParams) +{ + auto swipe = OH_ArkUI_GestureEvent_GetNode(event); + ArkUI_NumberValue OutlineWidthValue[] = { { .f32 = SIZE_5 }, { .f32 = SIZE_5 }, { .f32 = SIZE_5 }, + { .f32 = SIZE_5 } }; + ArkUI_AttributeItem OutlineWidthItem = { OutlineWidthValue, sizeof(OutlineWidthValue) / sizeof(ArkUI_NumberValue) }; + RequirementPanGestureTest::nodeAPI->setAttribute(swipe, NODE_OUTLINE_WIDTH, &OutlineWidthItem); + ArkUI_NumberValue OutlineColorValue[] = { { .u32 = COLOR_BLACK }, { .u32 = COLOR_BLACK }, { .u32 = COLOR_BLACK }, + { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem OutlineColorItem = { OutlineColorValue, sizeof(OutlineColorValue) / sizeof(ArkUI_NumberValue) }; + RequirementPanGestureTest::nodeAPI->setAttribute(swipe, NODE_OUTLINE_COLOR, &OutlineColorItem); +} + +static std::shared_ptr CreateTextNodeToRequirement(uint32_t color) +{ + auto text = std::make_shared(); + text->SetWidth(SIZE_100); + text->SetHeight(SIZE_150); + text->SetBackgroundColor(color); + text->SetTextAlign(ARKUI_TEXT_ALIGNMENT_CENTER); + return text; +} + +static auto CreateSwiperNodeToFirstRequirement(ArkUI_NativeGestureAPI_1* gestureAPI, const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetHeight(SIZE_100); + swiper->SetWidth(SIZE_150); + swiper->SetBorderWidth(PARAM_1); + swiper->SetId(id); + swiper->SetMargin(DEFAULT_MARGIN); + auto panGesture = gestureAPI->createPanGesture(1, GESTURE_DIRECTION_ALL, 5); + gestureAPI->setGestureEventTarget(panGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventFirstGesture); + gestureAPI->addGestureToNode(swiper->GetComponent(), panGesture, NORMAL, NORMAL_GESTURE_MASK); + return swiper; +} + +static auto CreateSwiperNodeToSecondRequirement(ArkUI_NativeGestureAPI_1* gestureAPI, const std::string& id) +{ + auto swiper = std::make_shared(); + auto text1 = CreateTextNodeToRequirement(COLOR_GREEN); + auto text2 = CreateTextNodeToRequirement(COLOR_BLUE); + auto text3 = CreateTextNodeToRequirement(COLOR_RED); + std::vector> texts = { text1, text2, text3 }; + swiper->SetHeight(SIZE_100); + swiper->SetWidth(SIZE_150); + swiper->SetBorderWidth(PARAM_1); + swiper->SetId(id); + swiper->SetMargin(DEFAULT_MARGIN); + for (auto text : texts) { + swiper->AddChild(text); + } + auto panGesture = gestureAPI->createPanGesture(1, GESTURE_DIRECTION_ALL, 5); + gestureAPI->setGestureEventTarget(panGesture, GESTURE_EVENT_ACTION_ACCEPT, nullptr, &OnEventSecondGesture); + gestureAPI->addGestureToNode(swiper->GetComponent(), panGesture, NORMAL, NORMAL_GESTURE_MASK); + return swiper; +} + +napi_value RequirementPanGestureTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementPanGestureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementPanGestureTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, RequirementPanGestureTest::nodeAPI); + ArkUI_NativeGestureAPI_1* gestureAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_GESTURE, ArkUI_NativeGestureAPI_1, gestureAPI); + + auto columnP1 = RequirementPanGestureTest::nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto columnP2 = RequirementPanGestureTest::nodeAPI->createNode(ARKUI_NODE_COLUMN); + RequirementPanGestureTest::nodeAPI->addChild( + columnP1, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper1")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP1, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper2")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP1, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper3")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP1, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper4")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP1, CreateSwiperNodeToSecondRequirement(gestureAPI, "swiper5")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP2, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper6")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP2, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper7")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP2, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper8")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP2, CreateSwiperNodeToFirstRequirement(gestureAPI, "swiper9")->GetComponent()); + RequirementPanGestureTest::nodeAPI->addChild( + columnP2, CreateSwiperNodeToSecondRequirement(gestureAPI, "swiper10")->GetComponent()); + auto row = RequirementPanGestureTest::nodeAPI->createNode(ARKUI_NODE_ROW); + RequirementPanGestureTest::nodeAPI->addChild(row, columnP1); + RequirementPanGestureTest::nodeAPI->addChild(row, columnP2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), row) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementPanGestureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pangesture_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pangesture_test.h new file mode 100644 index 0000000000000000000000000000000000000000..f6708a6b105c75f3371981c40457eb31ca2fa6b9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pangesture_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_REQUIREMENT_PAN_GESTURE_TEST_H +#define ARKUI_CAPI_DEMO_REQUIREMENT_PAN_GESTURE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "row_component.h" +#include "scroll_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +class RequirementPanGestureTest { +public: + ~RequirementPanGestureTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static ArkUI_NativeNodeAPI_1* nodeAPI; +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_REQUIREMENT_PAN_GESTURE_TEST_H \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pinchandpangesture_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pinchandpangesture_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5563f14d2ca3b36d60d442f5aad1457515163fea --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pinchandpangesture_test.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "requirement_pinchandpangesture_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" +#include "image_component.h" + +namespace ArkUICApiDemo { + +ArkUI_NativeNodeAPI_1* RequirementPinchAndPanGestureTest::nodeAPI = nullptr; + +static void onEventPanGestureUpdate(ArkUI_GestureEvent* event, void* extraParams) +{ + auto image = OH_ArkUI_GestureEvent_GetNode(event); + auto eventOffsetX = OH_ArkUI_PanGesture_GetOffsetX(event); + auto eventOffsetY = OH_ArkUI_PanGesture_GetOffsetY(event); + ArkUI_NumberValue translate_value[] = { { .f32 = eventOffsetX }, { .f32 = eventOffsetY }, { .f32 = 0 } }; + ArkUI_AttributeItem translate_item = { translate_value, sizeof(translate_value) / sizeof(ArkUI_NumberValue) }; + RequirementPinchAndPanGestureTest::nodeAPI->setAttribute(image, NODE_TRANSLATE, &translate_item); +} + +static void onEventPinchGestureUpdate(ArkUI_GestureEvent* event, void* extraParams) +{ + auto image = OH_ArkUI_GestureEvent_GetNode(event); + auto eventScale = OH_ArkUI_PinchGesture_GetScale(event); + ArkUI_NumberValue scale_value[] = { { .f32 = eventScale }, { .f32 = eventScale } }; + ArkUI_AttributeItem scale_item = { scale_value, sizeof(scale_value) / sizeof(ArkUI_NumberValue) }; + RequirementPinchAndPanGestureTest::nodeAPI->setAttribute(image, NODE_SCALE, &scale_item); +} + +static std::shared_ptr createImageWithRequirement(ArkUI_NativeGestureAPI_1* gestureAPI) +{ + auto image = std::make_shared(); + image->SetWidth(SIZE_200); + image->SetHeight(SIZE_200); + image->SetBorderWidth(PARAM_1); + image->SetBackgroundColor(COLOR_RED); + image->SetId("image"); + auto panGesture = gestureAPI->createPanGesture(2, GESTURE_DIRECTION_ALL, 5); + auto pinchGesture = gestureAPI->createPinchGesture(2, 5); + gestureAPI->setGestureEventTarget(panGesture, GESTURE_EVENT_ACTION_UPDATE, nullptr, &onEventPanGestureUpdate); + gestureAPI->setGestureEventTarget(pinchGesture, GESTURE_EVENT_ACTION_UPDATE, nullptr, &onEventPinchGestureUpdate); + gestureAPI->addGestureToNode(image->GetComponent(), panGesture, PARALLEL, NORMAL_GESTURE_MASK); + gestureAPI->addGestureToNode(image->GetComponent(), pinchGesture, PARALLEL, NORMAL_GESTURE_MASK); + return image; +} + +napi_value RequirementPinchAndPanGestureTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementPinchAndPanGestureTest", "CreateNativeNode"); + + size_t argc = 2; + napi_value args[2] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementPinchAndPanGestureTest", + "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, RequirementPinchAndPanGestureTest::nodeAPI); + ArkUI_NativeGestureAPI_1* gestureAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_GESTURE, ArkUI_NativeGestureAPI_1, gestureAPI); + + auto image = createImageWithRequirement(gestureAPI); + ArkUI_DrawableDescriptor* descriptor = nullptr; + OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue(env, args[1], &descriptor); + ArkUI_NumberValue imageSrc_value[] = {}; + ArkUI_AttributeItem imageSrc_item = { imageSrc_value, sizeof(imageSrc_value) / sizeof(ArkUI_NumberValue) }; + imageSrc_item.object = descriptor; + RequirementPinchAndPanGestureTest::nodeAPI->setAttribute( + image->GetComponent(), NODE_IMAGE_SPAN_SRC, &imageSrc_item); + auto column = RequirementPinchAndPanGestureTest::nodeAPI->createNode(ARKUI_NODE_COLUMN); + RequirementPinchAndPanGestureTest::nodeAPI->addChild(column, image->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementPinchAndPanGestureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pinchandpangesture_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pinchandpangesture_test.h new file mode 100644 index 0000000000000000000000000000000000000000..1b58b67914334fe55acd57782f4925d8d9d26a82 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_pinchandpangesture_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_REQUIREMENT_PINCH_AND_PAN_GESTURE_TEST_H +#define ARKUI_CAPI_DEMO_REQUIREMENT_PINCH_AND_PAN_GESTURE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "multimedia/image_framework/image/pixelmap_native.h" + +namespace ArkUICApiDemo { + +class RequirementPinchAndPanGestureTest { +public: + ~RequirementPinchAndPanGestureTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static ArkUI_NativeNodeAPI_1* nodeAPI; +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_REQUIREMENT_PINCH_AND_PAN_GESTURE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_routerpagestate_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_routerpagestate_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0e2b5613efdf9b801d11093b6a558926f3c46485 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_routerpagestate_test.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "requirement_routerpagestate_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" + +static ArkUI_RouterPageState state; + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateColumnForRouter() +{ + auto column = std::make_shared(); + column->SetWidth(SIZE_150); + column->SetHeight(SIZE_100); + column->SetBorderWidth(PARAM_1); + column->SetMargin(DEFAULT_MARGIN); + return column; +} + +napi_value RequirementRouterPageStateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementRouterPageStateTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementRouterPageStateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto Column1 = CreateColumnForRouter(); + auto Column2 = CreateColumnForRouter(); + auto Column3 = CreateColumnForRouter(); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto column1 = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto image = nodeAPI->createNode(ARKUI_NODE_IMAGE); + nodeAPI->addChild(column1, image); + nodeAPI->addChild(column, column1); + + ArkUI_ErrorCode errorCode1 = OH_ArkUI_GetRouterPageState(image, &state); + ArkUI_ErrorCode errorCode2 = OH_ArkUI_GetRouterPageState(column1, &state); + ArkUI_ErrorCode errorCode3 = OH_ArkUI_GetRouterPageState(column, &state); + auto Column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(Column, Column1->GetComponent()); + nodeAPI->addChild(Column, Column2->GetComponent()); + nodeAPI->addChild(Column, Column3->GetComponent()); + if (errorCode1 == 0) { + Column1->SetBackgroundColor(COLOR_GREEN); + } else if (errorCode1 == 106201) { + Column1->SetBackgroundColor(COLOR_RED); + } else { + Column1->SetBackgroundColor(COLOR_GRAY); + } + + if (errorCode2 == 0) { + Column2->SetBackgroundColor(COLOR_GREEN); + } else if (errorCode2 == 106201) { + Column2->SetBackgroundColor(COLOR_RED); + } else { + Column2->SetBackgroundColor(COLOR_GRAY); + } + + if (errorCode3 == 0) { + Column3->SetBackgroundColor(COLOR_GREEN); + } else if (errorCode3 == 106201) { + Column3->SetBackgroundColor(COLOR_RED); + } else { + Column3->SetBackgroundColor(COLOR_GRAY); + } + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), Column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RequirementRouterPageStateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_routerpagestate_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_routerpagestate_test.h new file mode 100644 index 0000000000000000000000000000000000000000..5f03bf8f9818ff495dfffb05582e2df0152ef532 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/requirement/requirement_routerpagestate_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_REQUIREMENT_ROUTER_PAGE_STATE_TEST_H +#define ARKUI_CAPI_DEMO_REQUIREMENT_ROUTER_PAGE_STATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +class RequirementRouterPageStateTest { +public: + ~RequirementRouterPageStateTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_REQUIREMENT_ROUTER_PAGE_STATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/resourcenapivalue/resourcenapivalue_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/resourcenapivalue/resourcenapivalue_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e5e61c8cbe157204220bd323a5e8edccd1bd3b25 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/resourcenapivalue/resourcenapivalue_test.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "resourcenapivalue_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +napi_value ResourceNapiValueTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ResourceNapiValueTest", "CreateNativeNode"); + + size_t argc = 2; + napi_value args[2] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ResourceNapiValueTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + ArkUI_DrawableDescriptor* descriptor = nullptr; + OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue(env, args[1], &descriptor); + + if (descriptor == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ResourceNapiValueTest", "descriptor is null"); + return nullptr; + } + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto image = nodeAPI->createNode(ARKUI_NODE_IMAGE); + + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_NumberValue height_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(image, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(image, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = PARAM_2 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(image, NODE_BORDER_WIDTH, &borderWidth_value_item); + + ArkUI_NumberValue imageValue[] = {}; + ArkUI_AttributeItem imageItem = { imageValue, sizeof(imageValue) / sizeof(ArkUI_NumberValue) }; + imageItem.object = descriptor; + nodeAPI->setAttribute(image, NODE_IMAGE_SRC, &imageItem); + + nodeAPI->addChild(column, image); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ResourceNapiValueTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/resourcenapivalue/resourcenapivalue_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/resourcenapivalue/resourcenapivalue_test.h new file mode 100644 index 0000000000000000000000000000000000000000..5f97ae9ebae6e8b678b29653c2d9f1dc0f04d538 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/resourcenapivalue/resourcenapivalue_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_RESOURCE_NAPI_VALUE_TEST_H +#define ARKUI_CAPI_DEMO_RESOURCE_NAPI_VALUE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +class ResourceNapiValueTest { +public: + ~ResourceNapiValueTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_RESOURCE_NAPI_VALUE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/row/row_align_items_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_align_items_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d5bf12198e96acd5ac4fe568a1d31f06b836674a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_align_items_test.cpp @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "row_align_items_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createRowNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t verticalAlign) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_ROW); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + // set AlignItems + ArkUI_NumberValue alignItems_value[] = { { .i32 = verticalAlign } }; + ArkUI_AttributeItem alignItems_item = { alignItems_value, sizeof(alignItems_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ROW_ALIGN_ITEMS, &alignItems_item); + return nodeHandle; +} + +static auto createRowNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t verticalAlign, int32_t flexAlign) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_ROW); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + // set AlignItems + ArkUI_NumberValue alignItems_value[] = { { .i32 = verticalAlign } }; + ArkUI_AttributeItem alignItems_item = { alignItems_value, sizeof(alignItems_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ROW_ALIGN_ITEMS, &alignItems_item); + // set justifyContent + ArkUI_NumberValue justifyContent_value[] = { { .i32 = flexAlign } }; + ArkUI_AttributeItem justifyContent_item = { justifyContent_value, + sizeof(justifyContent_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ROW_JUSTIFY_CONTENT, &justifyContent_item); + return nodeHandle; +} + +napi_value RowAlignItemsTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowAlignItemsTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowAlignItemsTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto rowTop = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_TOP); + auto rowCenter = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_CENTER); + auto rowBottom = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_BOTTOM); + auto rowSpaceError = createRowNode(nodeAPI, -1); + nodeAPI->addChild(parentColumn, rowTop); + nodeAPI->addChild(parentColumn, rowCenter); + nodeAPI->addChild(parentColumn, rowBottom); + nodeAPI->addChild(parentColumn, rowSpaceError); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowAlignItemsTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value RowAlignItemsTest::CreateMoreAttributeNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowAlignItemsTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowAlignItemsTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_TOP, ARKUI_FLEX_ALIGNMENT_END); + auto row2 = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_CENTER, ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN); + auto row3 = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_BOTTOM, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY); + auto row4 = createRowNode(nodeAPI, ARKUI_VERTICAL_ALIGNMENT_CENTER, ARKUI_FLEX_ALIGNMENT_SPACE_AROUND); + nodeAPI->addChild(parentColumn, row1); + nodeAPI->addChild(parentColumn, row2); + nodeAPI->addChild(parentColumn, row3); + nodeAPI->addChild(parentColumn, row4); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowAlignItemsTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/row/row_align_items_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_align_items_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2174369ed0e3cecdf9d967b8ab8776fa46db3d28 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_align_items_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ROW_ALIGN_ITEMS_TEST_H +#define ARKUI_CAPI_DEMO_ROW_ALIGN_ITEMS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RowAlignItemsTest { +public: + ~RowAlignItemsTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateMoreAttributeNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ROW_ALIGN_ITEMS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/row/row_justify_content_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_justify_content_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2df25fa4ff9e0e33b46e422e434e749413b88cb9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_justify_content_test.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "row_justify_content_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t backgroundColor) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_BUTTON); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + + // set background color + ArkUI_NumberValue button1_background_color_value[] = { { .u32 = backgroundColor } }; + ArkUI_AttributeItem button1_background_color_item = { button1_background_color_value, + sizeof(button1_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &button1_background_color_item); + return nodeHandle; +} + +static auto createRowNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t flexAlign) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_ROW); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_RED)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_GREEN)); + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, COLOR_YELLOW)); + // set justifyContent + ArkUI_NumberValue justifyContent_value[] = { { .i32 = flexAlign } }; + ArkUI_AttributeItem justifyContent_item = { justifyContent_value, + sizeof(justifyContent_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ROW_JUSTIFY_CONTENT, &justifyContent_item); + return nodeHandle; +} + +napi_value RowJustifyContentTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowJustifyContentTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowJustifyContentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto rowStart = createRowNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_START); + auto rowCenter = createRowNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_CENTER); + auto rowEnd = createRowNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_END); + auto rowSpaceBetween = createRowNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN); + auto rowSpaceAround = createRowNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_SPACE_AROUND); + auto rowSpaceEvenly = createRowNode(nodeAPI, ARKUI_FLEX_ALIGNMENT_SPACE_EVENLY); + auto rowSpaceError = createRowNode(nodeAPI, -1); + nodeAPI->addChild(parentColumn, rowStart); + nodeAPI->addChild(parentColumn, rowCenter); + nodeAPI->addChild(parentColumn, rowEnd); + nodeAPI->addChild(parentColumn, rowSpaceBetween); + nodeAPI->addChild(parentColumn, rowSpaceAround); + nodeAPI->addChild(parentColumn, rowSpaceEvenly); + nodeAPI->addChild(parentColumn, rowSpaceError); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "RowJustifyContentTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/row/row_justify_content_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_justify_content_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ce1d8972544cb1c532256993c8a2a4e75eb96d34 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/row/row_justify_content_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_ROW_JUSTIFY_CONTENT_TEST_H +#define ARKUI_CAPI_DEMO_ROW_JUSTIFY_CONTENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class RowJustifyContentTest { +public: + ~RowJustifyContentTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_ROW_JUSTIFY_CONTENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_enablepaging_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_enablepaging_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f9a213b038fbf76b22710ed255a0f4442f33f150 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_enablepaging_test.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_enablepaging_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateScrollWithEnablePaging(int32_t number, int32_t enablePaging) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollEnablePagingTest", "CreateScrollWithEnablePaging"); + auto scroll = std::make_shared(); + scroll->SetScrollScrollBar(ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + scroll->SetWidth(SIZE_300); + scroll->SetHeight(70); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_HORIZONTAL); + scroll->AddChildWithNumber(number, ARKUI_NODE_ROW); + scroll->SetScrollEnablePaging(enablePaging); + + return scroll; +} + +static void AddEnablePagingChild(ColumnComponent* column) +{ + auto scroll1 = CreateScrollWithEnablePaging(10, -1); + auto scroll2 = CreateScrollWithEnablePaging(10, true); + auto scroll3 = CreateScrollWithEnablePaging(10, false); + auto scroll4 = CreateScrollWithEnablePaging(2, true); + auto scroll5 = CreateScrollWithEnablePaging(2, false); + auto scroll6 = CreateScrollWithEnablePaging(1000, true); + auto scroll7 = CreateScrollWithEnablePaging(1000, false); + auto scroll8 = CreateScrollWithEnablePaging(10, true); + scroll8->resetAttribute(NODE_SCROLL_ENABLE_PAGING); + + column->AddChild(scroll1); + column->AddChild(scroll2); + column->AddChild(scroll3); + column->AddChild(scroll4); + column->AddChild(scroll5); + column->AddChild(scroll6); + column->AddChild(scroll7); + column->AddChild(scroll8); + + scroll1->SetScrollTo(200, 0, {}); + scroll2->SetScrollTo(200, 0, {}); + scroll3->SetScrollTo(200, 0, {}); + scroll4->SetScrollTo(200, 0, {}); + scroll5->SetScrollTo(200, 0, {}); + scroll6->SetScrollTo(200, 0, {}); + scroll7->SetScrollTo(200, 0, {}); + scroll8->SetScrollTo(200, 0, {}); +} + +napi_value ScrollEnablePagingTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollEnablePagingTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollEnablePagingTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + AddEnablePagingChild(column); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollEnablePagingTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_enablepaging_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_enablepaging_test.h new file mode 100644 index 0000000000000000000000000000000000000000..bb15356171f260d3823daefeeb1c78d925483258 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_enablepaging_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SCROLL_ENABLE_PAGING_TEST_H +#define ARKUI_CAPI_DEMO_SCROLL_ENABLE_PAGING_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "scroll_component.h" + +namespace ArkUICApiDemo { + +class ScrollEnablePagingTest { +public: + ~ScrollEnablePagingTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SCROLL_ENABLE_PAGING_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollbarwidth_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollbarwidth_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3135b24f95e8a29391ab900ad635569a6acea77f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollbarwidth_test.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_scrollbarwidth_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateScrollWithBarWidth(float barWidth) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollBarWidthTest", "CreateScrollWithBarWidth"); + auto scroll = std::make_shared(); + scroll->SetScrollScrollBar(ARKUI_SCROLL_BAR_DISPLAY_MODE_ON); + scroll->SetWidth(SIZE_300); + scroll->SetHeight(SIZE_100); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_HORIZONTAL); + scroll->AddChildWithNumber(10, ARKUI_NODE_ROW); + if (barWidth != PARAM_NEGATIVE_100) { + scroll->SetScrollScrollBarWidth(barWidth); + } + + return scroll; +} + +napi_value ScrollScrollBarWidthTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollBarWidthTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollBarWidthTest", "GetContext env or info is null"); + return nullptr; + } + + auto scroll1 = CreateScrollWithBarWidth(-20); + auto scroll2 = CreateScrollWithBarWidth(0); + auto scroll3 = CreateScrollWithBarWidth(10); + auto scroll4 = CreateScrollWithBarWidth(1000); + auto scroll5 = CreateScrollWithBarWidth(-100); + auto scroll6 = CreateScrollWithBarWidth(10); + scroll6->resetAttribute(NODE_SCROLL_BAR_WIDTH); + + auto column = new ColumnComponent(); + column->AddChild(scroll1); + column->AddChild(scroll2); + column->AddChild(scroll3); + column->AddChild(scroll4); + column->AddChild(scroll5); + column->AddChild(scroll6); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollBarWidthTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollbarwidth_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollbarwidth_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d620135916044160b7bf7848b5fb3387c4f23f5f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollbarwidth_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SCROLL_SCROLLBARWIDTH_TEST_H +#define ARKUI_CAPI_DEMO_SCROLL_SCROLLBARWIDTH_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "scroll_component.h" + +namespace ArkUICApiDemo { + +class ScrollScrollBarWidthTest { +public: + ~ScrollScrollBarWidthTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SCROLL_SCROLLBARWIDTH_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollby_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollby_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..efc957358fbf28c3238d92f133a597b1da72614a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollby_test.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_scrollby_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateScrollWithScrollBy(ArkUI_NodeType type, float hDistance, float vDistance) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollByTest", "CreateScrollWithScrollBy"); + auto scroll = std::make_shared(); + scroll->SetScrollScrollBar(ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + scroll->AddChildWithNumber(10, type); + if (type == ARKUI_NODE_ROW) { + scroll->SetWidth(340); + scroll->SetHeight(SIZE_100); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_HORIZONTAL); + } else if (type == ARKUI_NODE_COLUMN) { + scroll->SetWidth(SIZE_100); + scroll->SetHeight(340); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_VERTICAL); + } + scroll->SetScrollBy(hDistance, vDistance); + + return scroll; +} + +napi_value ScrollScrollByTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollByTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollByTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + column->AddChild(CreateScrollWithScrollBy(ARKUI_NODE_ROW, -200, -200)); + column->AddChild(CreateScrollWithScrollBy(ARKUI_NODE_ROW, 1000, 0)); + column->AddChild(CreateScrollWithScrollBy(ARKUI_NODE_ROW, 200, 200)); + auto row = std::make_shared(ARKUI_NODE_ROW); + row->AddChild(CreateScrollWithScrollBy(ARKUI_NODE_COLUMN, -200, -200)); + row->AddChild(CreateScrollWithScrollBy(ARKUI_NODE_COLUMN, 0, 1000)); + row->AddChild(CreateScrollWithScrollBy(ARKUI_NODE_COLUMN, 200, 200)); + column->AddChild(row); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollByTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollby_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollby_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e575d0fde4e08acee50ebdf8274281e5a0985822 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollby_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SCROLL_SCROLLBY_TEST_H +#define ARKUI_CAPI_DEMO_SCROLL_SCROLLBY_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "scroll_component.h" + +namespace ArkUICApiDemo { + +class ScrollScrollByTest { +public: + ~ScrollScrollByTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SCROLL_SCROLLBY_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolledge_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolledge_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..56028fd5b66ae1ce62f479d1ab86911149645a78 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolledge_test.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_scrolledge_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateScrolledScroll(ArkUI_NodeType type) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", "CreateScrolledScroll"); + auto scroll = std::make_shared(); + scroll->SetScrollScrollBar(ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + scroll->AddChildWithNumber(20, type); + if (type == ARKUI_NODE_ROW) { + scroll->SetWidth(340); + scroll->SetHeight(80); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_HORIZONTAL); + } else if (type == ARKUI_NODE_COLUMN) { + scroll->SetWidth(SIZE_100); + scroll->SetHeight(250); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_VERTICAL); + } + scroll->SetScrollBy(500, 500); + + return scroll; +} + +napi_value ScrollScrollEdgeTest::CreateNativeNodeHorizontal(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", "CreateNativeNodeHorizontal"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetId("Button"); + button->SetBackgroundColor(COLOR_TRANSPARENT); + column->AddChild(button); + std::vector> scrolls = { + CreateScrolledScroll(ARKUI_NODE_ROW), CreateScrolledScroll(ARKUI_NODE_ROW), + CreateScrolledScroll(ARKUI_NODE_ROW), CreateScrolledScroll(ARKUI_NODE_ROW), + CreateScrolledScroll(ARKUI_NODE_ROW), CreateScrolledScroll(ARKUI_NODE_ROW)}; + column->AddChild(scrolls[0]); + column->AddChild(scrolls[1]); + column->AddChild(scrolls[2]); + column->AddChild(scrolls[3]); + column->AddChild(scrolls[4]); + column->AddChild(scrolls[5]); + + button->RegisterOnClick([scrolls]() { + scrolls[0]->SetScrollEdge(ARKUI_SCROLL_EDGE_TOP); + scrolls[1]->SetScrollEdge(ARKUI_SCROLL_EDGE_BOTTOM); + scrolls[2]->SetScrollEdge(ARKUI_SCROLL_EDGE_START); + scrolls[3]->SetScrollEdge(ARKUI_SCROLL_EDGE_END); + scrolls[4]->SetScrollEdge(-1); + scrolls[5]->SetScrollEdge(4); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ScrollScrollEdgeTest::CreateNativeNodeVertical(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", "CreateNativeNodeVertical"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", "GetContext env or info is null"); + return nullptr; + } + + auto column = new ColumnComponent(); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetId("Button"); + button->SetBackgroundColor(COLOR_TRANSPARENT); + column->AddChild(button); + auto row1 = std::make_shared(ARKUI_NODE_ROW); + auto row2 = std::make_shared(ARKUI_NODE_ROW); + column->AddChild(row1); + column->AddChild(row2); + std::vector> scrolls = { + CreateScrolledScroll(ARKUI_NODE_COLUMN), CreateScrolledScroll(ARKUI_NODE_COLUMN), + CreateScrolledScroll(ARKUI_NODE_COLUMN), CreateScrolledScroll(ARKUI_NODE_COLUMN), + CreateScrolledScroll(ARKUI_NODE_COLUMN), CreateScrolledScroll(ARKUI_NODE_COLUMN)}; + row1->AddChild(scrolls[0]); + row1->AddChild(scrolls[1]); + row1->AddChild(scrolls[2]); + row2->AddChild(scrolls[3]); + row2->AddChild(scrolls[4]); + row2->AddChild(scrolls[5]); + + button->RegisterOnClick([scrolls]() { + scrolls[0]->SetScrollEdge(ARKUI_SCROLL_EDGE_TOP); + scrolls[1]->SetScrollEdge(ARKUI_SCROLL_EDGE_BOTTOM); + scrolls[2]->SetScrollEdge(ARKUI_SCROLL_EDGE_START); + scrolls[3]->SetScrollEdge(ARKUI_SCROLL_EDGE_END); + scrolls[4]->SetScrollEdge(-1); + scrolls[5]->SetScrollEdge(4); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollEdgeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolledge_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolledge_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2e67aef08714647294c5f5abd2c4799b4b6bf135 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolledge_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SCROLL_SCROLLEDGE_TEST_H +#define ARKUI_CAPI_DEMO_SCROLL_SCROLLEDGE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "scroll_component.h" + +namespace ArkUICApiDemo { + +class ScrollScrollEdgeTest { +public: + ~ScrollScrollEdgeTest(); + static napi_value CreateNativeNodeHorizontal(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeVertical(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SCROLL_SCROLLEDGE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolloffset_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolloffset_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..027780d72e372b7545ac6d44a50fab1a1b76acb1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolloffset_test.cpp @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_scrolloffset_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateScrollWithScrollOffset(ArkUI_NodeType type) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "CreateScrollWithScrollOffset"); + auto scroll = std::make_shared(); + scroll->SetScrollScrollBar(ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + scroll->SetScrollEdgeEffect(ARKUI_EDGE_EFFECT_SPRING, 1); + scroll->AddChildWithNumber(20, type); + if (type == ARKUI_NODE_ROW) { + scroll->SetWidth(320); + scroll->SetHeight(60); + scroll->SetMargin(5); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_HORIZONTAL); + } else if (type == ARKUI_NODE_COLUMN) { + scroll->SetWidth(90); + scroll->SetHeight(300); + scroll->SetMargin(10); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_VERTICAL); + } + return scroll; +} + +napi_value ScrollScrollOffsetTest::CreateNativeNodeOffset(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "CreateNativeNodeOffset"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetId("Button"); + button->SetBackgroundColor(COLOR_TRANSPARENT); + column->AddChild(button); + auto row = std::make_shared(ARKUI_NODE_ROW); + column->AddChild(row); + + auto scroll1 = CreateScrollWithScrollOffset(ARKUI_NODE_COLUMN); + auto scroll2 = CreateScrollWithScrollOffset(ARKUI_NODE_COLUMN); + auto scroll3 = CreateScrollWithScrollOffset(ARKUI_NODE_COLUMN); + auto scroll4 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll5 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll6 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll7 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + row->AddChild(scroll1); + row->AddChild(scroll2); + row->AddChild(scroll3); + column->AddChild(scroll4); + column->AddChild(scroll5); + column->AddChild(scroll6); + column->AddChild(scroll7); + + button->RegisterOnClick([scroll1, scroll2, scroll3, scroll4, scroll5, scroll6, scroll7]() { + // offset test + scroll1->SetScrollTo(-200, -200, {}); + scroll2->SetScrollTo(0, 1000, {}); + scroll3->SetScrollTo(200, 200, {}); + scroll4->SetScrollTo(-200, -200, {}); + scroll5->SetScrollTo(1000, 0, {}); + scroll6->SetScrollTo(200, 200, {}); + scroll7->SetScrollTo(1000, 0, {}); + scroll7->resetAttribute(NODE_SCROLL_OFFSET); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ScrollScrollOffsetTest::CreateNativeNodeCurve(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "CreateNativeNodeCurve"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + auto scroll1 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll2 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll3 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll4 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll5 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll6 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll7 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll8 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll9 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + column->AddChild(scroll1); + column->AddChild(scroll2); + column->AddChild(scroll3); + column->AddChild(scroll4); + column->AddChild(scroll5); + column->AddChild(scroll6); + column->AddChild(scroll7); + column->AddChild(scroll8); + column->AddChild(scroll9); + + button->RegisterOnClick([scroll1, scroll2, scroll3, scroll4, scroll5, scroll6, scroll7, scroll8, scroll9]() { + // duration test + scroll1->SetScrollTo(200, 0, { -1000 }); + scroll2->SetScrollTo(200, 0, { 0 }); + scroll3->SetScrollTo(200, 0, { 2000 }); + // curve test + scroll4->SetScrollTo(200, 0, { 1000, ARKUI_CURVE_LINEAR }); + scroll5->SetScrollTo(200, 0, { 1000, ARKUI_CURVE_EASE }); + scroll6->SetScrollTo(200, 0, { 1000, ARKUI_CURVE_FRICTION }); + scroll7->SetScrollTo(200, 0, { 1000, -1 }); + scroll8->SetScrollTo(200, 0, { 1000, 13 }); + scroll9->SetScrollTo(200, 0, { 2000, ARKUI_CURVE_LINEAR }); + scroll9->resetAttribute(NODE_SCROLL_OFFSET); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value ScrollScrollOffsetTest::CreateNativeNodeOther(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "CreateNativeNodeOther"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto scroll1 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll2 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll3 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll4 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll5 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll6 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + auto scroll7 = CreateScrollWithScrollOffset(ARKUI_NODE_ROW); + column->AddChild(scroll1); + column->AddChild(scroll2); + column->AddChild(scroll3); + column->AddChild(scroll4); + column->AddChild(scroll5); + column->AddChild(scroll6); + column->AddChild(scroll7); + + button->RegisterOnClick([scroll1, scroll2, scroll3, scroll4, scroll5, scroll6, scroll7]() { + // enable the default spring animation test + scroll1->SetScrollTo(1000, 0, { 1000, ARKUI_CURVE_EASE, -1 }); + scroll2->SetScrollTo(1000, 0, { 1000, ARKUI_CURVE_EASE, 1 }); + scroll3->SetScrollTo(1000, 0, { 1000, ARKUI_CURVE_EASE, 0 }); + // canOverScroll test + scroll4->SetScrollTo(1500, 0, { 1000, ARKUI_CURVE_EASE, 0, -1 }); + scroll5->SetScrollTo(1500, 0, { 1000, ARKUI_CURVE_EASE, 0, 1 }); + scroll6->SetScrollTo(1500, 0, { 1000, ARKUI_CURVE_EASE, 0, 0 }); + scroll7->SetScrollTo(1500, 0, { 1000, ARKUI_CURVE_EASE, 0, 1 }); + scroll7->resetAttribute(NODE_SCROLL_OFFSET); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolloffset_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolloffset_test.h new file mode 100644 index 0000000000000000000000000000000000000000..58e2e83a243e730365f1b2fbda30e57d94ae22ba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrolloffset_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SCROLL_SCROLL_OFFSET_TEST_H +#define ARKUI_CAPI_DEMO_SCROLL_SCROLL_OFFSET_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "scroll_component.h" + +namespace ArkUICApiDemo { + +class ScrollScrollOffsetTest { +public: + ~ScrollScrollOffsetTest(); + static napi_value CreateNativeNodeOffset(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeCurve(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOther(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SCROLL_SCROLL_OFFSET_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollpage_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollpage_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c95e6c49575d1abbdef0d8fcb6208d5ec6c2e1aa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollpage_test.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scroll_scrollpage_test.h" + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +std::shared_ptr CreateScrollPage(int32_t number) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollPageTest", "CreateScrollPage"); + auto scroll = std::make_shared(); + scroll->SetWidth(SIZE_300); + scroll->SetHeight(70); + scroll->SetMargin(DEFAULT_MARGIN); + scroll->SetScrollScrollBar(ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + scroll->SetScrollScrollDirection(ARKUI_SCROLL_DIRECTION_HORIZONTAL); + scroll->SetScrollEnablePaging(1); + scroll->AddChildWithNumber(number, ARKUI_NODE_ROW); + scroll->SetScrollBy(500, 0); + + return scroll; +} + +napi_value ScrollScrollPageTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ScrollScrollPageTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollPageTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = new ColumnComponent(); + auto button = std::make_shared(ARKUI_NODE_BUTTON); + button->SetWidth(50); + button->SetHeight(50); + button->SetMargin(10); + button->SetBackgroundColor(COLOR_TRANSPARENT); + button->SetId("Button"); + column->AddChild(button); + + auto scroll1 = CreateScrollPage(20); + auto scroll2 = CreateScrollPage(20); + auto scroll3 = CreateScrollPage(20); + auto scroll4 = CreateScrollPage(20); + auto scroll5 = CreateScrollPage(20); + auto scroll6 = CreateScrollPage(20); + auto scroll7 = CreateScrollPage(3000); + + column->AddChild(scroll1); + column->AddChild(scroll2); + column->AddChild(scroll3); + column->AddChild(scroll4); + column->AddChild(scroll5); + column->AddChild(scroll6); + column->AddChild(scroll7); + + button->RegisterOnClick([scroll1, scroll2, scroll3, scroll4, scroll5, scroll6, scroll7]() { + scroll1->SetScrollPage(-1); + scroll2->SetScrollPage(1); + scroll3->SetScrollPage(0); + scroll4->SetScrollPage(0, -1); + scroll5->SetScrollPage(0, 1); + scroll6->SetScrollPage(0, 0); + scroll7->SetScrollPage(0, 0); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ScrollScrollPageTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollpage_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollpage_test.h new file mode 100644 index 0000000000000000000000000000000000000000..51a9e17a3c56f8d43e80c7c7e3205bc9c435aaf0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/scroll/scroll_scrollpage_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SCROLL_SCROLL_PAGE_TEST_H +#define ARKUI_CAPI_DEMO_SCROLL_SCROLL_PAGE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "scroll_component.h" + +namespace ArkUICApiDemo { + +class ScrollScrollPageTest { +public: + ~ScrollScrollPageTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SCROLL_SCROLL_PAGE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/slider/slider_track_thickness_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/slider/slider_track_thickness_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..371169b0b0d728795062411efcebf9414002878c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/slider/slider_track_thickness_test.cpp @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "slider_track_thickness_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem item = {}; + item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &item); + return nodeHandle; +} + +static auto SetSliderStyle(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t style) +{ + ArkUI_NumberValue value[] = { { .i32 = style } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_SLIDER_STYLE, &item); + return nodeHandle; +} + +static auto SetSlideThickness(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float thickness) +{ + ArkUI_NumberValue value[] = { { .f32 = thickness } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_SLIDER_TRACK_THICKNESS, &item); + return nodeHandle; +} + +static auto SetSlider(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height, int32_t style) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = SetHeight(nodeAPI, nodeHandle, height); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetSliderStyle(nodeAPI, nodeHandle, style); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + return nodeHandle; +} + +napi_value SliderTrackThicknessTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SliderTrackThicknessTest", "CreateNativeNodePage1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SliderTrackThicknessTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // default style + auto slider1 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + + // sliderStyle set to in + auto slider2 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider2 = SetSlider(nodeAPI, slider2, SIZE_20, ARKUI_SLIDER_STYLE_IN_SET); + + // sliderStyle set to in, and the slider track's thickness is less than 0 + auto slider3 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider3 = SetSlider(nodeAPI, slider3, SIZE_20, ARKUI_SLIDER_STYLE_IN_SET); + slider3 = SetSlideThickness(nodeAPI, slider3, PARAM_NEGATIVE_100); + + // sliderStyle set to in, and the slider track's thickness is 0 + auto slider4 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider4 = SetSlider(nodeAPI, slider4, SIZE_20, ARKUI_SLIDER_STYLE_IN_SET); + slider4 = SetSlideThickness(nodeAPI, slider4, PARAM_0); + + // sliderStyle set to in, and the slider track's thickness is greater than 0, and less than slider's height + auto slider5 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider5 = SetSlider(nodeAPI, slider5, SIZE_100, ARKUI_SLIDER_STYLE_IN_SET); + slider5 = SetSlideThickness(nodeAPI, slider5, SIZE_80); + + // sliderStyle set to in, and the slider track's thickness is greater than 0, and greater than slider's height + auto slider6 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider6 = SetSlider(nodeAPI, slider6, SIZE_100, ARKUI_SLIDER_STYLE_IN_SET); + slider6 = SetSlideThickness(nodeAPI, slider6, SIZE_200); + + // sliderStyle set to out + auto slider7 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider7 = SetSlider(nodeAPI, slider7, SIZE_20, ARKUI_SLIDER_STYLE_OUT_SET); + + // sliderStyle set to out, and the slider track's thickness is less than 0 + auto slider8 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider8 = SetSlider(nodeAPI, slider8, SIZE_20, ARKUI_SLIDER_STYLE_OUT_SET); + slider8 = SetSlideThickness(nodeAPI, slider8, PARAM_NEGATIVE_100); + + // sliderStyle set to out, and the slider track's thickness is 0 + auto slider9 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider9 = SetSlider(nodeAPI, slider9, SIZE_20, ARKUI_SLIDER_STYLE_OUT_SET); + slider9 = SetSlideThickness(nodeAPI, slider9, PARAM_0); + + // sliderStyle set to out, and the slider track's thickness is greater than 0, and less than slider's height + auto slider10 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider10 = SetSlider(nodeAPI, slider10, SIZE_100, ARKUI_SLIDER_STYLE_OUT_SET); + slider10 = SetSlideThickness(nodeAPI, slider10, SIZE_16); + + // sliderStyle set to out, and the slider track's thickness is greater than 0, and greater than slider's height + auto slider11 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider11 = SetSlider(nodeAPI, slider11, SIZE_100, ARKUI_SLIDER_STYLE_OUT_SET); + slider11 = SetSlideThickness(nodeAPI, slider11, SIZE_200); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, slider1); + nodeAPI->addChild(column, slider2); + nodeAPI->addChild(column, slider3); + nodeAPI->addChild(column, slider4); + nodeAPI->addChild(column, slider5); + nodeAPI->addChild(column, slider6); + nodeAPI->addChild(column, slider7); + nodeAPI->addChild(column, slider8); + nodeAPI->addChild(column, slider9); + nodeAPI->addChild(column, slider10); + nodeAPI->addChild(column, slider11); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SliderTrackThicknessTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SliderTrackThicknessTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SliderTrackThicknessTest", "CreateNativeNodePage2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SliderTrackThicknessTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // sliderStyle set to none + auto slider12 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider12 = SetSlider(nodeAPI, slider12, SIZE_20, ARKUI_SLIDER_STYLE_NONE); + + // sliderStyle set to none, and the slider track's thickness is less than 0 + auto slider13 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider13 = SetSlider(nodeAPI, slider13, SIZE_20, ARKUI_SLIDER_STYLE_NONE); + slider13 = SetSlideThickness(nodeAPI, slider13, PARAM_NEGATIVE_100); + + // sliderStyle set to none, and the slider track's thickness is 0 + auto slider14 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider14 = SetSlider(nodeAPI, slider14, SIZE_20, ARKUI_SLIDER_STYLE_NONE); + slider14 = SetSlideThickness(nodeAPI, slider14, PARAM_0); + + // sliderStyle set to none, and the slider track's thickness is greater than 0, and less than slider's height + auto slider15 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider15 = SetSlider(nodeAPI, slider15, SIZE_100, ARKUI_SLIDER_STYLE_NONE); + slider15 = SetSlideThickness(nodeAPI, slider15, SIZE_16); + + // sliderStyle set to none, and the slider track's thickness is greater than 0, and greater than slider's height + auto slider16 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider16 = SetSlider(nodeAPI, slider16, SIZE_100, ARKUI_SLIDER_STYLE_NONE); + slider16 = SetSlideThickness(nodeAPI, slider16, SIZE_200); + + // resetAttribute + auto slider17 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider17 = SetSlider(nodeAPI, slider17, SIZE_100, ARKUI_SLIDER_STYLE_NONE); + slider17 = SetSlideThickness(nodeAPI, slider17, SIZE_16); + nodeAPI->resetAttribute(slider17, NODE_SLIDER_TRACK_THICKNESS); + + // sliderStyle set to none, and the slider track's thickness is greater than 0, and less than slider's height + auto slider18 = nodeAPI->createNode(ARKUI_NODE_SLIDER); + slider18 = SetSlider(nodeAPI, slider18, SIZE_100, ARKUI_SLIDER_STYLE_NONE); + slider18 = SetSlideThickness(nodeAPI, slider18, SIZE_16); + slider18 = SetId(nodeAPI, slider18, "slider18"); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, slider12); + nodeAPI->addChild(column, slider13); + nodeAPI->addChild(column, slider14); + nodeAPI->addChild(column, slider15); + nodeAPI->addChild(column, slider16); + nodeAPI->addChild(column, slider17); + nodeAPI->addChild(column, slider18); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SliderTrackThicknessTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/slider/slider_track_thickness_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/slider/slider_track_thickness_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3f1636099eaf907cb3601ec06bf4667021b5c978 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/slider/slider_track_thickness_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SLIDER_TRACK_THICKNESS_TEST_H +#define ARKUI_CAPI_DEMO_SLIDER_TRACK_THICKNESS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_16 16 +#define SIZE_20 20 +#define SIZE_80 80 + +class SliderTrackThicknessTest { +public: + ~SliderTrackThicknessTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SLIDER_TRACK_THICKNESS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_baselineoffset_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_baselineoffset_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f0fd5ad38b04c5757768313027dc00cc3324836 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_baselineoffset_test.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "span_baselineoffset_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +#define IDONE 1 +#define IDTWO 2 +#define IDTHREE 3 +#define IDFOURTH 4 +#define IDFIFTH 5 +#define IDSIX 6 +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, float_t value, std::string content) +{ + auto span = nodeAPI->createNode(ARKUI_NODE_SPAN); + + ArkUI_NumberValue baseLineOffset_value[] = { { .f32 = value } }; + ArkUI_AttributeItem baseLineOffset_item = { baseLineOffset_value, + sizeof(baseLineOffset_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_SPAN_BASELINE_OFFSET, &baseLineOffset_item); + + ArkUI_AttributeItem content_item = { .string = content.c_str() }; + nodeAPI->setAttribute(span, NODE_SPAN_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem fontColor_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_FONT_SIZE, &fontColor_item); + + return span; +} + +napi_value SpanBaseLineOffsetTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanBaseLineOffsetTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanBaseLineOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto span = createChildNode(nodeAPI, 40, "123"); + auto span1 = createChildNode(nodeAPI, 0, "456"); + auto span2 = createChildNode(nodeAPI, -40, "789"); + auto span3 = createChildNode(nodeAPI, -40, "789"); + + nodeAPI->resetAttribute(span3, NODE_SPAN_BASELINE_OFFSET); + + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + nodeAPI->addChild(text, span); + nodeAPI->addChild(text, span1); + nodeAPI->addChild(text, span2); + nodeAPI->addChild(text, span3); + nodeAPI->addChild(column, text); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanBaseLineOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_baselineoffset_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_baselineoffset_test.h new file mode 100644 index 0000000000000000000000000000000000000000..560cd6788a5164adc462f1dd4e26d2b973c1daf9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_baselineoffset_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SPAN_BASELINEOFFSET_TEST_H +#define ARKUI_CAPI_DEMO_SPAN_BASELINEOFFSET_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SpanBaseLineOffsetTest { +public: + ~SpanBaseLineOffsetTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SPAN_BASELINEOFFSET_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_fontfamily_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_fontfamily_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6deb355ad19dbb6d35e3aea9d8124a3381373faf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_fontfamily_test.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "span_fontfamily_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +napi_value SpanFontFamilyTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanFontFamilyTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanFontFamilyTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建column节点组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // 设置column组件宽度和高度 + ArkUI_NumberValue column_width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem column_width_item = { column_width_value, + sizeof(column_width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue column_height_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem column_height_item = { column_height_value, + sizeof(column_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &column_width_item); + nodeAPI->setAttribute(column, NODE_HEIGHT, &column_height_item); + + auto text1 = nodeAPI->createNode(ARKUI_NODE_TEXT); + auto text2 = nodeAPI->createNode(ARKUI_NODE_TEXT); + auto span1 = nodeAPI->createNode(ARKUI_NODE_SPAN); + auto span2 = nodeAPI->createNode(ARKUI_NODE_SPAN); + + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + ArkUI_NumberValue col_height_value[] = { { .f32 = 500 } }; + ArkUI_NumberValue col_width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem col_height_item = { col_height_value, sizeof(col_height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem col_width_item = { col_width_value, sizeof(col_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &col_height_item); + nodeAPI->setAttribute(column, NODE_WIDTH, &col_width_item); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TEXT"; + nodeAPI->setAttribute(span1, NODE_SPAN_CONTENT, &content_item); + nodeAPI->setAttribute(span2, NODE_SPAN_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 65 } }; + ArkUI_AttributeItem fontColor_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span1, NODE_FONT_SIZE, &fontColor_item); + nodeAPI->setAttribute(span2, NODE_FONT_SIZE, &fontColor_item); + + ArkUI_AttributeItem valueItem = {}; + valueItem.string = "HomeVideoBold"; + nodeAPI->setAttribute(span1, NODE_FONT_FAMILY, &valueItem); + // text组件放置父容器column中 + + nodeAPI->addChild(text1, span1); + nodeAPI->addChild(text2, span2); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanFontFamilyTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_fontfamily_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_fontfamily_test.h new file mode 100644 index 0000000000000000000000000000000000000000..8918d8760d6ec5249a516dcc09920d739e00edb9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_fontfamily_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SPAN_FONTFAMILY_TEST_H +#define ARKUI_CAPI_DEMO_SPAN_FONTFAMILY_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SpanFontFamilyTest { +public: + ~SpanFontFamilyTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SPAN_FONTFAMILY_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textbackgroundstyle_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textbackgroundstyle_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..16a5122888aecd25fd50ae52f5e9b2e05e63a369 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textbackgroundstyle_test.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "span_textbackgroundstyle_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define IDONE 1 +#define IDTWO 2 +#define IDTHREE 3 +#define IDFOURTH 4 +#define IDFIFTH 5 +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateSubNode( + ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t color, float_t radius, std::string content, int32_t id) +{ + // 创建span组件 + auto span = nodeAPI->createNode(ARKUI_NODE_SPAN); + + ArkUI_NumberValue textBackgroundStyle_value[] = { { .u32 = color }, { .f32 = radius } }; + ArkUI_AttributeItem textBackgroundStyle_item = { textBackgroundStyle_value, + sizeof(textBackgroundStyle_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_SPAN_TEXT_BACKGROUND_STYLE, &textBackgroundStyle_item); + + if (id == IDFIFTH) { + nodeAPI->resetAttribute(span, NODE_SPAN_TEXT_BACKGROUND_STYLE); + } + + // 设置span内容 + ArkUI_AttributeItem content_item = { .string = content.c_str() }; + nodeAPI->setAttribute(span, NODE_SPAN_CONTENT, &content_item); + + // 创建父节点text,加入span子组件 + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem fontColor_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_FONT_SIZE, &fontColor_item); + nodeAPI->setAttribute(span, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(span, NODE_HEIGHT, &height_item); + nodeAPI->addChild(text, span); + + return text; +} +ArkUI_NodeHandle CreateNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t color, float_t radius1, float_t radius2, + float_t radius3, float_t radius4, std::string content) +{ + // 创建span组件 + auto span = nodeAPI->createNode(ARKUI_NODE_SPAN); + + ArkUI_NumberValue textBackgroundStyle_value[] = { { .u32 = color }, { .f32 = radius1 }, { .f32 = radius2 }, + { .f32 = radius3 }, { .f32 = radius4 } }; + ArkUI_AttributeItem textBackgroundStyle_item = { textBackgroundStyle_value, + sizeof(textBackgroundStyle_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_SPAN_TEXT_BACKGROUND_STYLE, &textBackgroundStyle_item); + + // 设置span内容 + ArkUI_AttributeItem content_item = { .string = content.c_str() }; + nodeAPI->setAttribute(span, NODE_SPAN_CONTENT, &content_item); + + // 创建父节点text,加入span子组件 + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem fontColor_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_FONT_SIZE, &fontColor_item); + nodeAPI->setAttribute(span, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(span, NODE_HEIGHT, &height_item); + nodeAPI->addChild(text, span); + + return text; +} +napi_value SpanTextBackgroundStyleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanTextBackgroundStyleTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanTextBackgroundStyleTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + std::string content = "textBackgroundStyle"; + + uint32_t color = COLOR_RED; + float_t radius = 30; + auto span_first = CreateSubNode(nodeAPI, color, radius, content, IDONE); + + color = COLOR_GREEN; + radius = 20; + auto span_second = CreateSubNode(nodeAPI, -1, radius, content, IDTWO); + auto span_third = CreateSubNode(nodeAPI, color, 0, content, IDTHREE); + auto span_fourth = CreateSubNode(nodeAPI, 0, 0, content, IDFOURTH); + auto span_fifth = CreateSubNode(nodeAPI, color, radius, content, IDFIFTH); + + auto span_six = CreateNode(nodeAPI, color, 40, 0, 10, 20, content); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, span_first); + nodeAPI->addChild(column, span_second); + nodeAPI->addChild(column, span_third); + nodeAPI->addChild(column, span_fourth); + nodeAPI->addChild(column, span_fifth); + nodeAPI->addChild(column, span_six); + + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + + ArkUI_NumberValue col_height_value[] = { { .f32 = 300 } }; + ArkUI_NumberValue col_width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem col_height_item = { col_height_value, sizeof(col_height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem col_width_item = { col_width_value, sizeof(col_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &col_height_item); + nodeAPI->setAttribute(column, NODE_WIDTH, &col_width_item); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanTextBackgroundStyleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textbackgroundstyle_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textbackgroundstyle_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3fbd53d05093cfcc962f51e8b5ac2f2290e97aba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textbackgroundstyle_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SPAN_TEXTBACKGROUNDSTYLE_H +#define ARKUI_CAPI_DEMO_SPAN_TEXTBACKGROUNDSTYLE_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SpanTextBackgroundStyleTest { +public: + ~SpanTextBackgroundStyleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SPAN_TEXTBACKGROUNDSTYLE_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textshadow_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textshadow_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d2986b691d62f449f094838191af0f6713234429 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textshadow_test.cpp @@ -0,0 +1,146 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "span_textshadow_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define IDONE 1 +#define IDTWO 2 +#define IDTHREE 3 +#define IDFOURTH 4 +#define IDFIFTH 5 +#define IDSIX 6 +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateSubNode(ArkUI_NativeNodeAPI_1* nodeAPI, float_t blurRadius, int32_t shadowType, + uint32_t shadowColor, float_t offSetx, float_t offSetY, std::string content, int32_t id) +{ + // 创建span组件 + auto span = nodeAPI->createNode(ARKUI_NODE_SPAN); + + ArkUI_NumberValue textShadow_value[] = { { .f32 = blurRadius }, { .i32 = shadowType }, { .u32 = shadowColor }, + { .f32 = offSetx }, { .f32 = offSetY } }; + ArkUI_AttributeItem textShadow_item = { textShadow_value, sizeof(textShadow_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_TEXT_TEXT_SHADOW, &textShadow_item); + + // 设置reset + if (id == IDSIX) { + nodeAPI->resetAttribute(span, NODE_TEXT_TEXT_SHADOW); + } + + // 设置span内容 + ArkUI_AttributeItem content_item = { .string = content.c_str() }; + nodeAPI->setAttribute(span, NODE_SPAN_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem fontColor_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_FONT_SIZE, &fontColor_item); + + // 创建父节点text,加入span子组件 + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + nodeAPI->addChild(text, span); + return text; +} + +napi_value SpanTextShadowTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanTextShadowTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanTextShadowTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // span first:文本保持原有大小写 + std::string content = "SPAN SPAN SPAN"; + float_t blurRadius = 30; + int32_t shadowType = 1234; + uint32_t shadowColor = COLOR_BLUE; + float_t offSetx = 0; + float_t offSety = 0; + auto span_first = CreateSubNode(nodeAPI, blurRadius, shadowType, shadowColor, offSetx, offSety, content, IDONE); + + shadowType = ARKUI_SHADOW_TYPE_BLUR; + shadowColor = COLOR_RED; + auto span_second = CreateSubNode(nodeAPI, blurRadius, shadowType, shadowColor, offSetx, offSety, content, IDTWO); + + blurRadius = 40; + shadowType = ARKUI_SHADOW_TYPE_COLOR; + shadowColor = COLOR_BLUE; + auto span_third = CreateSubNode(nodeAPI, blurRadius, shadowType, shadowColor, offSetx, offSety, content, IDTHREE); + + blurRadius = -10; + offSetx = 10; + offSety = 10; + auto span_fourth = CreateSubNode(nodeAPI, blurRadius, shadowType, shadowColor, offSetx, offSety, content, IDFOURTH); + + blurRadius = 20; + offSetx = 40; + offSety = 40; + auto span_fifth = CreateSubNode(nodeAPI, blurRadius, shadowType, shadowColor, offSetx, offSety, content, IDFIFTH); + + auto span_reset = CreateSubNode(nodeAPI, blurRadius, shadowType, shadowColor, offSetx, offSety, content, IDSIX); + + // 子组件加入到父容器 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, span_first); + nodeAPI->addChild(column, span_second); + nodeAPI->addChild(column, span_third); + nodeAPI->addChild(column, span_fourth); + nodeAPI->addChild(column, span_fifth); + nodeAPI->addChild(column, span_reset); + + // 设置column子组件在竖直方向上的对齐格式为均匀分配,宽度为300vp,高度为500vp + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + + ArkUI_NumberValue col_height_value[] = { { .f32 = 500 } }; + ArkUI_NumberValue col_width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem col_height_item = { col_height_value, sizeof(col_height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem col_width_item = { col_width_value, sizeof(col_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &col_height_item); + nodeAPI->setAttribute(column, NODE_WIDTH, &col_width_item); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanTextShadowTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textshadow_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textshadow_test.h new file mode 100644 index 0000000000000000000000000000000000000000..09b347e3bd6f3f75eca9dc1f7409382809b076f3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_textshadow_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SPAN_TEXTSHADOW_TEST_H +#define ARKUI_CAPI_DEMO_SPAN_TEXTSHADOW_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SpanTextShadowTest { +public: + ~SpanTextShadowTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SPAN_TEXTSHADOW_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_value_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_value_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..26a1b106f878bab3aafd980cb89efa81f8bf9312 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_value_test.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "span_value_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle SpanValueTest::CreateSubNode(ArkUI_NativeNodeAPI_1* nodeAPI, std::string content) +{ + // 创建span组件 + auto span = nodeAPI->createNode(ARKUI_NODE_SPAN); + + // 设置span内容 + ArkUI_AttributeItem content_item = { .string = content.c_str() }; + nodeAPI->setAttribute(span, NODE_SPAN_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 45 } }; + ArkUI_AttributeItem fontColor_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(span, NODE_FONT_SIZE, &fontColor_item); + // 创建父节点text,加入span子组件 + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + + nodeAPI->addChild(text, span); + + return text; +} + +napi_value SpanValueTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanValueTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanValueTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + std::string content = "test span 01"; + auto span_first = CreateSubNode(nodeAPI, content); + + content = "test span 02"; + auto span_second = CreateSubNode(nodeAPI, content); + + content = "test span 03"; + auto span_third = CreateSubNode(nodeAPI, content); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, span_first); + nodeAPI->addChild(column, span_second); + nodeAPI->addChild(column, span_third); + + // 设置column子组件在竖直方向上的对齐格式为均匀分配,宽度为300vp,高度为500vp + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + ArkUI_NumberValue col_height_value[] = { { .f32 = 500 } }; + ArkUI_NumberValue col_width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem col_height_item = { col_height_value, sizeof(col_height_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_AttributeItem col_width_item = { col_width_value, sizeof(col_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &col_height_item); + nodeAPI->setAttribute(column, NODE_WIDTH, &col_width_item); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SpanValueTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/span/span_value_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_value_test.h new file mode 100644 index 0000000000000000000000000000000000000000..60582ce4574a18582d3c4b47e93a34ec3538eaa1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/span/span_value_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SPAN_VALUE_TEST_H +#define ARKUI_CAPI_DEMO_SPAN_VALUE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SpanValueTest { +public: + ~SpanValueTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static ArkUI_NodeHandle CreateSubNode(ArkUI_NativeNodeAPI_1* nodeAPI, std::string content); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SPAN_VALUE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/stack/stack_align_content_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/stack/stack_align_content_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b712279f42ccbab7b115b76efa64bf33e24e1f5a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/stack/stack_align_content_test.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stack_align_content_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetAlignContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, int32_t align) +{ + ArkUI_NumberValue value[] = { { .i32 = align } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_STACK_ALIGN_CONTENT, &item); + return nodeHandle; +} + +static auto SetAlignment(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, int32_t align) +{ + ArkUI_NumberValue value[] = { { .i32 = align } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_ALIGNMENT, &item); + return nodeHandle; +} + +static auto SetStack(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t align) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_90); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_90); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_RED); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetAlignContent(nodeAPI, nodeHandle, align); + return nodeHandle; +} + +static auto SetButton(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + return nodeHandle; +} + +napi_value StackAlignContentTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "StackAlignContentTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "StackAlignContentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row4 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row5 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto stack1 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack2 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack3 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack4 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack5 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack6 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack7 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack8 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack9 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack10 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack11 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack12 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack13 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto stack14 = nodeAPI->createNode(ARKUI_NODE_STACK); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button2 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button3 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button4 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button5 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button6 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button7 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button8 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button9 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button10 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button11 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button12 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button13 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button14 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(column, row1); + nodeAPI->addChild(column, row2); + nodeAPI->addChild(column, row3); + nodeAPI->addChild(column, row4); + nodeAPI->addChild(column, row5); + nodeAPI->addChild(row1, stack1); + nodeAPI->addChild(row1, stack2); + nodeAPI->addChild(row1, stack3); + nodeAPI->addChild(row2, stack4); + nodeAPI->addChild(row2, stack5); + nodeAPI->addChild(row2, stack6); + nodeAPI->addChild(row3, stack7); + nodeAPI->addChild(row3, stack8); + nodeAPI->addChild(row3, stack9); + nodeAPI->addChild(row4, stack10); + nodeAPI->addChild(row4, stack11); + nodeAPI->addChild(row4, stack12); + nodeAPI->addChild(row5, stack13); + nodeAPI->addChild(row5, stack14); + nodeAPI->addChild(stack1, button1); + nodeAPI->addChild(stack2, button2); + nodeAPI->addChild(stack3, button3); + nodeAPI->addChild(stack4, button4); + nodeAPI->addChild(stack5, button5); + nodeAPI->addChild(stack6, button6); + nodeAPI->addChild(stack7, button7); + nodeAPI->addChild(stack8, button8); + nodeAPI->addChild(stack9, button9); + nodeAPI->addChild(stack10, button10); + nodeAPI->addChild(stack11, button11); + nodeAPI->addChild(stack12, button12); + nodeAPI->addChild(stack13, button13); + nodeAPI->addChild(stack14, button14); + + stack1 = SetStack(nodeAPI, stack1, ARKUI_ALIGNMENT_TOP_START); + stack2 = SetStack(nodeAPI, stack2, ARKUI_ALIGNMENT_TOP); + stack3 = SetStack(nodeAPI, stack3, ARKUI_ALIGNMENT_TOP_END); + stack4 = SetStack(nodeAPI, stack4, ARKUI_ALIGNMENT_START); + stack5 = SetStack(nodeAPI, stack5, ARKUI_ALIGNMENT_CENTER); + stack6 = SetStack(nodeAPI, stack6, ARKUI_ALIGNMENT_END); + stack7 = SetStack(nodeAPI, stack7, ARKUI_ALIGNMENT_BOTTOM_START); + stack8 = SetStack(nodeAPI, stack8, ARKUI_ALIGNMENT_BOTTOM); + stack9 = SetStack(nodeAPI, stack9, ARKUI_ALIGNMENT_BOTTOM_END); + stack10 = SetStack(nodeAPI, stack10, PARAM_NEGATIVE_1); + stack11 = SetStack(nodeAPI, stack11, PARAM_9); + stack12 = SetStack(nodeAPI, stack12, ARKUI_ALIGNMENT_TOP); + stack12 = SetAlignment(nodeAPI, stack12, ARKUI_ALIGNMENT_BOTTOM); + stack13 = SetAlignment(nodeAPI, stack13, ARKUI_ALIGNMENT_BOTTOM); + stack13 = SetStack(nodeAPI, stack13, ARKUI_ALIGNMENT_TOP); + stack14 = SetStack(nodeAPI, stack14, ARKUI_ALIGNMENT_TOP); + nodeAPI->resetAttribute(stack14, NODE_STACK_ALIGN_CONTENT); + + button1 = SetButton(nodeAPI, button1); + button2 = SetButton(nodeAPI, button2); + button3 = SetButton(nodeAPI, button3); + button4 = SetButton(nodeAPI, button4); + button5 = SetButton(nodeAPI, button5); + button6 = SetButton(nodeAPI, button6); + button7 = SetButton(nodeAPI, button7); + button8 = SetButton(nodeAPI, button8); + button9 = SetButton(nodeAPI, button9); + button10 = SetButton(nodeAPI, button10); + button11 = SetButton(nodeAPI, button11); + button12 = SetButton(nodeAPI, button12); + button13 = SetButton(nodeAPI, button13); + button14 = SetButton(nodeAPI, button14); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "StackAlignTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/stack/stack_align_content_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/stack/stack_align_content_test.h new file mode 100644 index 0000000000000000000000000000000000000000..93ac576fb033e541ee44ea8a0a076e41387038c4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/stack/stack_align_content_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_STACK_ALIGN_CONTENT_TEST_H +#define ARKUI_CAPI_DEMO_STACK_ALIGN_CONTENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_90 90 + +class StackAlignContentTest { +public: + ~StackAlignContentTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_STACK_ALIGN_CONTENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_adapter_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_adapter_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..92e2fdecc4587121fa8f7575292faff0a3bae47c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_adapter_test.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_adapter_test.h" +#include +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +ArkUI_NativeNodeAPI_1* nodeAPI_ = nullptr; + +static void OnAdapterEventReceive(ArkUI_NodeAdapterEvent* event) +{ + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperAdapterTest", "OnAdapterEventReceive event is null"); + return; + } + int type = OH_ArkUI_NodeAdapterEvent_GetType(event); + if (NODE_ADAPTER_EVENT_ON_ADD_NODE_TO_ADAPTER == type) { + auto text = std::make_shared(); + text->SetBackgroundColor(COLOR_RED); + OH_ArkUI_NodeAdapterEvent_SetItem(event, text->GetComponent()); + } +} + +static void SetAdapter(ArkUI_NodeHandle handle, int32_t nodeCount) +{ + auto adapter = OH_ArkUI_NodeAdapter_Create(); + OH_ArkUI_NodeAdapter_RegisterEventReceiver(adapter, nullptr, &OnAdapterEventReceive); + OH_ArkUI_NodeAdapter_SetTotalNodeCount(adapter, nodeCount); + ArkUI_AttributeItem adapterItem { .object = adapter }; + nodeAPI_->setAttribute(handle, NODE_SWIPER_NODE_ADAPTER, &adapterItem); +} + +static std::shared_ptr CreateSwiperComponent(const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetId(id); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_10); + return swiper; +} + +napi_value SwiperAdapterTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperAdapterTest", "GetContext env or info is null"); + return nullptr; + } + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI_); + auto swiper = CreateSwiperComponent("swiper"); + SetAdapter(swiper->GetComponent(), PARAM_5); + auto swiper_second = CreateSwiperComponent("swiper_second"); + SetAdapter(swiper_second->GetComponent(), 0); + auto swiper_third = CreateSwiperComponent("swiper_third"); + SetAdapter(swiper_third->GetComponent(), 1); + auto column = nodeAPI_->createNode(ARKUI_NODE_COLUMN); + nodeAPI_->addChild(column, swiper->GetComponent()); + nodeAPI_->addChild(column, swiper_second->GetComponent()); + nodeAPI_->addChild(column, swiper_third->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperAdapterTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_adapter_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_adapter_test.h new file mode 100644 index 0000000000000000000000000000000000000000..25c442b16b321b4c23dea431bf0f6dffaf792f66 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_adapter_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_ADAPTER_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_ADAPTER_TEST_H + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperAdapterTest { +public: + ~SwiperAdapterTest(); + // SwiperAdapterTest:testSwiperAdapter001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // SwiperAdapterTest:testSwiperAdapter002 + static napi_value CreateNativeNodeAbnormal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_ADAPTER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_change_index_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_change_index_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c8398d1c52c6a5c772e741559440ef1fd762ca65 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_change_index_test.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_change_index_test.h" +#include +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateSwiper(const std::string &id, int32_t index) +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(false); + swiper->SetId(id); + std::vector colors = {0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF}; + for (const auto &color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + swiper->AddChild(text); + } + swiper->RegisterOnChange([swiper, index](ArkUI_NodeEvent *event) { swiper->SetSwiperToIndex(index, true); }); + return swiper; +} + +napi_value SwiperChangeIndexTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperChangeIndexTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiper("SwiperChangeIndex", PARAM_2); + auto swiper_second = CreateSwiper("SwiperChangeIndexSecond", PARAM_4); + auto swiper_third = CreateSwiper("SwiperChangeIndexThird", PARAM_NEGATIVE_1); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + nodeAPI->addChild(column, swiper_third->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperChangeIndexTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_change_index_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_change_index_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7466a9ae7e6d497709036ce77909259545767a90 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_change_index_test.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_CHANGE_INDEX_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_CHANGE_INDEX_TEST_H + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperChangeIndexTest { +public: + ~SwiperChangeIndexTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_CHANGE_INDEX_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_common.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_common.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e74f188bd5a13102517823008de84b0b9b27f82 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_common.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_common.h" +#include +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle SwiperCommon::CreateSwiper(SwiperPropertiesInit flags) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperCommon", "CreateSwiper"); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = nodeAPI->createNode(ARKUI_NODE_SWIPER); + + // width + if (flags.initWidthFlag) { + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(swiper, NODE_WIDTH, &width_item); + } + + // height + if (flags.initHeightFlag) { + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(swiper, NODE_HEIGHT, &height_item); + } + + // margin + ArkUI_NumberValue margin_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(swiper, NODE_MARGIN, &margin_item); + + // background + if (flags.initBackgroundColorFlag) { + ArkUI_NumberValue background_color_value[] = { { .u32 = 0xFFFFFFFF } }; + ArkUI_AttributeItem background_color_value_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(swiper, NODE_BACKGROUND_COLOR, &background_color_value_item); + } + + // child node + if (flags.initChildNodeFlag) { + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + // 浅蓝 + ArkUI_NumberValue text_background_value[] = { { .u32 = 0xFFAFEEEE } }; + ArkUI_AttributeItem text_background_item = { text_background_value, + sizeof(text_background_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text, NODE_BACKGROUND_COLOR, &text_background_item); + + auto text_second = nodeAPI->createNode(ARKUI_NODE_TEXT); + // 绿 + ArkUI_NumberValue text_second_background_value[] = { { .u32 = 0xFF00FF00 } }; + ArkUI_AttributeItem text_second_background_item = { text_second_background_value, + sizeof(text_second_background_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text_second, NODE_BACKGROUND_COLOR, &text_second_background_item); + + auto text_third = nodeAPI->createNode(ARKUI_NODE_TEXT); + // 红 + ArkUI_NumberValue text_third_background_value[] = { { .u32 = 0xFFFF0000 } }; + ArkUI_AttributeItem text_third_background_item = { text_third_background_value, + sizeof(text_third_background_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text_third, NODE_BACKGROUND_COLOR, &text_third_background_item); + + auto text_fourth = nodeAPI->createNode(ARKUI_NODE_TEXT); + // 蓝 + ArkUI_NumberValue text_fourth_background_value[] = { { .u32 = 0xFF0000FF } }; + ArkUI_AttributeItem text_fourth_background_item = { text_fourth_background_value, + sizeof(text_fourth_background_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text_fourth, NODE_BACKGROUND_COLOR, &text_fourth_background_item); + + nodeAPI->addChild(swiper, text); + nodeAPI->addChild(swiper, text_second); + nodeAPI->addChild(swiper, text_third); + nodeAPI->addChild(swiper, text_fourth); + } + + return swiper; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_common.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_common.h new file mode 100644 index 0000000000000000000000000000000000000000..09d99001fef2e7cb51f7f97894dc3587b3adfe6a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_common.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_COMMON_H +#define ARKUI_CAPI_DEMO_SWIPER_COMMON_H + +#include +#include +#include +#include "../common/common.h" + +namespace ArkUICApiDemo { +#define ON_ANIMATION_START_EVENT_ID 6015 +#define ON_ANIMATION_END_EVENT_ID 6016 +#define ON_GESTURE_SWIPE_EVENT_ID 6017 +#define ON_DID_SCROLL_EVENT_ID 6018 +#define DID_SCROLL_EVENT_ID 6019 +#define PARAM_NEGATIVE_1 (-1) +#define PARAM_NEGATIVE_10 (-10) +#define PARAM_NEGATIVE_30 (-30) +#define PARAM_20 20 +#define ABNORMAL_PARAM 1000 +#define PARAM_800 800 + +class SwiperCommon { +public: + ~SwiperCommon(); + struct SwiperPropertiesInit { + bool initWidthFlag; + bool initHeightFlag; + bool initBackgroundColorFlag; + bool initChildNodeFlag; + }; + + static ArkUI_NodeHandle CreateSwiper(SwiperPropertiesInit flags); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_COMMON_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_dot_indicator_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_dot_indicator_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a7bdf63c20dc47faaa2d5a27ea3b0b50f44a8c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_dot_indicator_test.cpp @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_dot_indicator_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static void SetBasicIndicator(ArkUI_SwiperIndicator* indicator) +{ + if (indicator == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperDotIndicatorTest", "indicator is null"); + return; + } + OH_ArkUI_SwiperIndicator_SetItemWidth(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetItemHeight(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetSelectedItemWidth(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetSelectedItemHeight(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetMask(indicator, true); + OH_ArkUI_SwiperIndicator_SetColor(indicator, COLOR_YELLOW); + OH_ArkUI_SwiperIndicator_SetSelectedColor(indicator, COLOR_RED); +} + +static SwiperIndicator GetBasicIndicator(ArkUI_SwiperIndicator* indicator) +{ + return { OH_ArkUI_SwiperIndicator_GetTopPosition(indicator), OH_ArkUI_SwiperIndicator_GetBottomPosition(indicator), + OH_ArkUI_SwiperIndicator_GetStartPosition(indicator), OH_ArkUI_SwiperIndicator_GetEndPosition(indicator), + OH_ArkUI_SwiperIndicator_GetItemWidth(indicator), OH_ArkUI_SwiperIndicator_GetItemHeight(indicator), + OH_ArkUI_SwiperIndicator_GetSelectedItemWidth(indicator), + OH_ArkUI_SwiperIndicator_GetSelectedItemHeight(indicator), OH_ArkUI_SwiperIndicator_GetMask(indicator), + OH_ArkUI_SwiperIndicator_GetColor(indicator), OH_ArkUI_SwiperIndicator_GetSelectedColor(indicator) }; +} + +static std::shared_ptr CreateSwiperNode(const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(false); + swiper->SetId(id); + std::vector colors = { 0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF }; + for (const auto& color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + swiper->AddChild(text); + } + return swiper; +} + +static std::shared_ptr SetupSwiper(ArkUI_NativeNodeAPI_1* nodeAPI, const std::string& id, + ArkUI_SwiperIndicator* indicator, int32_t position, bool isRTL) +{ + auto swiper = CreateSwiperNode(id); + swiper->SetSwiperDirection(isRTL ? ARKUI_DIRECTION_RTL : ARKUI_DIRECTION_LTR); + if (isRTL) { + OH_ArkUI_SwiperIndicator_SetEndPosition(indicator, position); + OH_ArkUI_SwiperIndicator_SetTopPosition(indicator, position); + } else { + OH_ArkUI_SwiperIndicator_SetStartPosition(indicator, position); + OH_ArkUI_SwiperIndicator_SetBottomPosition(indicator, position); + } + SetBasicIndicator(indicator); + swiper->SetSwiperIndicator(indicator); + auto temp = GetBasicIndicator(indicator); + if ((isRTL && (temp.topPosition != position || temp.endPosition != position)) || + (!isRTL && (temp.startPosition != position || temp.bottomPosition != position))) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperDotIndicatorTest", + isRTL ? "RTL position error" : "LTR position error"); + auto child = nodeAPI->getChildAt(swiper->GetComponent(), 1); + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_YELLOW } }; + ArkUI_AttributeItem background_color_value_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(child, NODE_BACKGROUND_COLOR, &background_color_value_item); + } + return swiper; +} + +napi_value SwiperDotIndicatorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperDotIndicatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto indicator = OH_ArkUI_SwiperIndicator_Create(ARKUI_SWIPER_INDICATOR_TYPE_DOT); + auto swiper = SetupSwiper(nodeAPI, "SwiperDotIndicator", indicator, PARAM_12, true); + auto indicator_second = OH_ArkUI_SwiperIndicator_Create(ARKUI_SWIPER_INDICATOR_TYPE_DOT); + auto swiper_second = SetupSwiper(nodeAPI, "SwiperSecondDotIndicator", indicator_second, PARAM_12, false); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + OH_ArkUI_SwiperIndicator_Dispose(indicator); + OH_ArkUI_SwiperIndicator_Dispose(indicator_second); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperDotIndicatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SwiperDotIndicatorTest::CreateNativeNodeAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperDotIndicatorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto indicator = OH_ArkUI_SwiperIndicator_Create(ARKUI_SWIPER_INDICATOR_TYPE_DOT); + auto swiper = CreateSwiperNode("SwiperDotIndicator"); + OH_ArkUI_SwiperIndicator_SetTopPosition(indicator, PARAM_NEGATIVE_10); + OH_ArkUI_SwiperIndicator_SetBottomPosition(indicator, PARAM_NEGATIVE_10); + OH_ArkUI_SwiperIndicator_SetItemWidth(indicator, PARAM_NEGATIVE_10); + OH_ArkUI_SwiperIndicator_SetItemHeight(indicator, PARAM_NEGATIVE_10); + OH_ArkUI_SwiperIndicator_SetMask(indicator, true); + swiper->SetSwiperIndicator(indicator); + + auto indicator_second = OH_ArkUI_SwiperIndicator_Create(ARKUI_SWIPER_INDICATOR_TYPE_DOT); + auto swiper_second = CreateSwiperNode("SwiperSecondDotIndicator"); + OH_ArkUI_SwiperIndicator_SetTopPosition(indicator_second, ABNORMAL_PARAM); + OH_ArkUI_SwiperIndicator_SetBottomPosition(indicator_second, ABNORMAL_PARAM); + OH_ArkUI_SwiperIndicator_SetItemWidth(indicator_second, ABNORMAL_PARAM); + OH_ArkUI_SwiperIndicator_SetItemHeight(indicator_second, ABNORMAL_PARAM); + OH_ArkUI_SwiperIndicator_SetMask(indicator_second, true); + swiper_second->SetSwiperIndicator(indicator_second); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + OH_ArkUI_SwiperIndicator_Dispose(indicator); + OH_ArkUI_SwiperIndicator_Dispose(indicator_second); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperDotIndicatorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_dot_indicator_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_dot_indicator_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7355030e51ccb9b3bd211f853ba27560af8fa85b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_dot_indicator_test.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_DOT_INDICATOR_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_DOT_INDICATOR_TEST_H + +#include +#include +#include "../common/common.h" +#include "swiper_common.h" + +namespace ArkUICApiDemo { +struct SwiperIndicator { + float topPosition; + float bottomPosition; + float startPosition; + float endPosition; + float itemWidth; + float itemHeight; + float selectedItemWidth; + float selectedItemHeight; + int32_t mask = 0; + uint32_t color = COLOR_GRAY; + uint32_t selectedColor = COLOR_RED; +}; + +class SwiperDotIndicatorTest { +public: + ~SwiperDotIndicatorTest(); + + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeAbnormal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_DOT_INDICATOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_effectmode_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_effectmode_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..37a29c5791790ea13c48429047553fb472b48e2d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_effectmode_test.cpp @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_effectmode_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "refresh_component.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateSwiper(const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(true); + swiper->SetSwiperInterval(PARAM_800); + swiper->SetId(id); + std::vector colors = { 0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF }; + for (const auto& color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + swiper->AddChild(text); + } + return swiper; +} + +static void CreateRefreshingComponent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& refreshingComponent) +{ + ArkUI_NumberValue clip_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem clip_item = { clip_value, sizeof(clip_value) / sizeof(ArkUI_NumberValue) }; + refreshingComponent = nodeAPI->createNode(ARKUI_NODE_STACK); + nodeAPI->setAttribute(refreshingComponent, NODE_CLIP, &clip_item); + + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + // process height + ArkUI_NumberValue height_value[] = { { .f32 = PARAM_32 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + + // margin + ArkUI_NumberValue margin_value[] = { { .f32 = PARAM_5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + auto loadingProgress = nodeAPI->createNode(ARKUI_NODE_LOADING_PROGRESS); + nodeAPI->setAttribute(loadingProgress, NODE_HEIGHT, &height_item); + + auto text = nodeAPI->createNode(ARKUI_NODE_TEXT); + ArkUI_AttributeItem LABEL_Item = { .string = "refreshing..." }; + ArkUI_NumberValue fontSize[] = { PARAM_16 }; + ArkUI_AttributeItem Font_Item = { fontSize, 1 }; + nodeAPI->setAttribute(text, NODE_TEXT_CONTENT, &LABEL_Item); + nodeAPI->setAttribute(text, NODE_TEXT_FONT, &Font_Item); + nodeAPI->setAttribute(text, NODE_MARGIN, &margin_item); + + nodeAPI->addChild(refreshingComponent, row); + nodeAPI->addChild(row, text); +} + +static void CreateList(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& list) +{ + list = nodeAPI->createNode(ARKUI_NODE_LIST); + ArkUI_NumberValue value[] = { { .f32 = 0.8 } }; + ArkUI_AttributeItem item = { value, 1 }; + nodeAPI->setAttribute(list, NODE_WIDTH_PERCENT, &item); + nodeAPI->setAttribute(list, NODE_HEIGHT_PERCENT, &item); + + ArkUI_NumberValue border_value[] = { { .f32 = PARAM_2 } }; + ArkUI_AttributeItem border_item = { border_value, sizeof(border_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue margin_value[] = { { .f32 = PARAM_5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + + ArkUI_NumberValue item_value[] = { { .f32 = 0.1 } }; + ArkUI_AttributeItem item_height_item = { item_value, 1 }; + for (int i = 0; i < SIZE_10; i++) { + auto listItem = nodeAPI->createNode(ARKUI_NODE_LIST_ITEM); + nodeAPI->setAttribute(listItem, NODE_WIDTH_PERCENT, &item); + nodeAPI->setAttribute(listItem, NODE_HEIGHT_PERCENT, &item_height_item); + nodeAPI->setAttribute(listItem, NODE_BORDER_WIDTH, &border_item); + nodeAPI->setAttribute(listItem, NODE_MARGIN, &margin_item); + nodeAPI->addChild(list, listItem); + } + nodeAPI->setAttribute(list, NODE_BORDER_WIDTH, &border_item); + nodeAPI->setAttribute(list, NODE_MARGIN, &margin_item); +} + +static std::shared_ptr CreateRefreshComponent(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + ArkUI_NodeHandle refreshingComponent; + CreateRefreshingComponent(nodeAPI, refreshingComponent); + auto refresh = std::make_shared(); + refresh->SetId("RefreshContent"); + refresh->SetPullToRefresh(true); + refresh->SetPullDownRatio(1); + refresh->SetPercentWidth(0.8); + refresh->SetPercentHeight(0.8); + refresh->SetMargin(SIZE_30); + refresh->SetRefreshContent(refreshingComponent); + return refresh; +} + +napi_value SwiperEffectModeTest::CreateNativeModeSpring(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiper("SwiperEffectModeSpring"); + swiper->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_SPRING); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SwiperEffectModeTest::CreateNativeModeFade(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiper("SwiperEffectModeFade"); + swiper->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_FADE); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SwiperEffectModeTest::CreateNativeModeNone(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiper("SwiperEffectModeNone"); + swiper->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_NONE); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SwiperEffectModeTest::CreateNativeModeAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiper("SwiperEffectModeAbnormal"); + swiper->SetSwiperEffectMode(PARAM_NEGATIVE_1); + auto swiper_second = CreateSwiper("SwiperEffectModeAbnormalSecond"); + swiper->SetSwiperEffectMode(PARAM_3); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SwiperEffectModeTest::CreateNativeModeInterrupt(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto refresh = CreateRefreshComponent(nodeAPI); + auto swiper = CreateSwiper("SwiperEffectMode"); + auto indicator = OH_ArkUI_SwiperIndicator_Create(ARKUI_SWIPER_INDICATOR_TYPE_DOT); + OH_ArkUI_SwiperIndicator_SetItemWidth(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetItemHeight(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetSelectedItemWidth(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetSelectedItemHeight(indicator, PARAM_20); + OH_ArkUI_SwiperIndicator_SetMask(indicator, true); + OH_ArkUI_SwiperIndicator_SetColor(indicator, COLOR_YELLOW); + OH_ArkUI_SwiperIndicator_SetSelectedColor(indicator, COLOR_RED); + swiper->SetSwiperIndicator(indicator); + swiper->SetSwiperEffectMode(PARAM_NEGATIVE_1); + swiper->SetMargin(SIZE_30); + swiper->SetWidth(SIZE_100); + swiper->SetHeight(SIZE_50); + swiper->SetSwiperDuration(SIZE_800); + swiper->SetSwiperInterval(SIZE_3000); + swiper->SetSwiperLoop(true); + swiper->SetSwiperAutoPlay(true); + ArkUI_NodeHandle list; + CreateList(nodeAPI, list); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, refresh->GetComponent()); + nodeAPI->addChild(refresh->GetComponent(), swiper->GetComponent()); + nodeAPI->addChild(refresh->GetComponent(), list); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEffectModeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_effectmode_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_effectmode_test.h new file mode 100644 index 0000000000000000000000000000000000000000..4df589f168fed289699d53ecef9b206622a72f38 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_effectmode_test.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_EFFECTMODE_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_EFFECTMODE_TEST_H + +#include +#include +#include +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperEffectModeTest { +public: + ~SwiperEffectModeTest(); + // SwiperMarginTest: testSwiperEffectMode001 and testSwiperEffectMode002 + static napi_value CreateNativeModeSpring(napi_env env, napi_callback_info info); + // SwiperMarginTest: testSwiperEffectMode003 + static napi_value CreateNativeModeFade(napi_env env, napi_callback_info info); + // SwiperMarginTest: testSwiperEffectMode004 + static napi_value CreateNativeModeNone(napi_env env, napi_callback_info info); + // SwiperMarginTest: testSwiperEffectMode005 + static napi_value CreateNativeModeAbnormal(napi_env env, napi_callback_info info); + // SwiperMarginTest: testSwiperEffectMode006 + static napi_value CreateNativeModeInterrupt(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_EFFECTMODE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_event_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_event_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..70f30eaa43c8514300687ec64349b01c493fdeb1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_event_test.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_event_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateTextNode(uint32_t color) +{ + auto text = std::make_shared(); + text->SetBackgroundColor(color); + return text; +} + +static std::shared_ptr CreateSwiperNode(const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetId(id); + std::vector colors = { 0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF }; + for (const auto& color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + swiper->AddChild(text); + } + return swiper; +} + +napi_value SwiperEventTest::CreateNativeNodeGesture(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode("OnGestureSwipe"); + swiper->RegisterOnGesture([swiper](ArkUI_NodeEvent* event) { + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + ArkUI_NodeHandle child = nodeAPI->getChildAt(nodeHandler, 1); + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_YELLOW } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(child, NODE_BACKGROUND_COLOR, &background_color_item); + }); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEventTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value SwiperEventTest::CreateNativeNodeDidScroll(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode("OnContentDidScroll"); + swiper->RegisterOnDidScrollContext([swiper](ArkUI_NodeEvent* event) { + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + ArkUI_NodeHandle child = nodeAPI->getChildAt(nodeHandler, 1); + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_YELLOW } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(child, NODE_BACKGROUND_COLOR, &background_color_item); + }); + + auto swiper_second = CreateSwiperNode("OnContentDidScrollSecond"); + swiper_second->SetSwiperIndex(1); + swiper_second->SetSwiperLoop(true); + swiper_second->SetSwiperPrevMigration(PARAM_10); + swiper_second->SetSwiperNextMigration(PARAM_10); + swiper_second->RegisterOnDidScrollContext([swiper_second](ArkUI_NodeEvent* event) { + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + ArkUI_NodeHandle child = nodeAPI->getChildAt(nodeHandler, 1); + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_YELLOW } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(child, NODE_BACKGROUND_COLOR, &background_color_item); + }); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperEventTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_event_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_event_test.h new file mode 100644 index 0000000000000000000000000000000000000000..33440965ba6f4647ebd9169c991b8464095f973a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_event_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_EVENT_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_EVENT_TEST_H + +#include +#include +#include +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperEventTest { +public: + ~SwiperEventTest(); + // SwiperEventTest:testSwiperEvent001 + static napi_value CreateNativeNodeGesture(napi_env env, napi_callback_info info); + // SwiperEventTest:testSwiperEvent002 + static napi_value CreateNativeNodeDidScroll(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_EVENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_margin_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_margin_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3a52a281bb1d860fabf9f71545bc6d42910204ba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_margin_test.cpp @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_margin_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateSwiperNode() +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(false); + swiper->SetSwiperDisplayCount(1); + std::vector colors = {0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF}; + for (const auto &color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + swiper->AddChild(text); + } + return swiper; +} + +napi_value SwiperMarginTest::CreateNativePrevMargin(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode(); + swiper->SetSwiperPrevMigration(PARAM_10); + swiper->SetSwiperVertical(false); + + auto swiper_second = CreateSwiperNode(); + swiper_second->SetSwiperPrevMigration(PARAM_10, true); + swiper_second->SetSwiperIndex(PARAM_2); + swiper_second->SetId("SwiperPrevMargin"); + swiper_second->SetSwiperVertical(true); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value SwiperMarginTest::CreateNativePrevMarginAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode(); + swiper->SetSwiperPrevMigration(SIZE_300); + swiper->SetSwiperNextMigration(PARAM_10); + swiper->SetSwiperVertical(false); + + auto swiper_second = CreateSwiperNode(); + swiper_second->SetSwiperPrevMigration(SIZE_300, true); + swiper_second->SetSwiperNextMigration(PARAM_10, true); + swiper_second->SetSwiperVertical(true); + swiper_second->SetSwiperIndex(PARAM_3); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value SwiperMarginTest::CreateNativeNextMargin(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto swiper = CreateSwiperNode(); + swiper->SetSwiperNextMigration(PARAM_10); + swiper->SetSwiperIndex(0); + swiper->SetSwiperVertical(false); + auto swiper_second = CreateSwiperNode(); + swiper_second->SetSwiperNextMigration(PARAM_10, true); + swiper_second->SetSwiperIndex(PARAM_3); + swiper_second->SetId("SwiperNextMargin"); + swiper_second->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_NONE); + swiper_second->SetSwiperVertical(true); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value SwiperMarginTest::CreateNativeNextMarginAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode(); + swiper->SetSwiperPrevMigration(PARAM_10); + swiper->SetSwiperNextMigration(SIZE_300, true); + swiper->SetSwiperVertical(false); + + auto swiper_second = CreateSwiperNode(); + swiper_second->SetSwiperPrevMigration(PARAM_10); + swiper_second->SetSwiperNextMigration(SIZE_300); + swiper_second->SetSwiperIndex(PARAM_3); + swiper_second->SetSwiperVertical(true); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value SwiperMarginTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode(); + swiper->SetSwiperPrevMigration(PARAM_10, true); + swiper->SetSwiperNextMigration(PARAM_10, true); + swiper->SetSwiperIndex(PARAM_3); + swiper->SetSwiperVertical(false); + + auto swiper_second = CreateSwiperNode(); + swiper_second->SetSwiperPrevMigration(PARAM_NEGATIVE_1); + swiper_second->SetSwiperNextMigration(PARAM_NEGATIVE_1); + swiper_second->SetSwiperIndex(PARAM_3); + swiper_second->SetSwiperVertical(true); + + auto swiper_third = CreateSwiperNode(); + swiper_third->SetSwiperLoop(true); + swiper_third->SetSwiperAutoPlay(true); + swiper_third->SetSwiperPrevMigration(PARAM_10, true); + swiper_third->SetSwiperNextMigration(PARAM_10, true); + swiper_third->SetSwiperIndex(PARAM_3); + swiper_third->SetSwiperVertical(true); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + nodeAPI->addChild(column, swiper_third->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperMarginTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_margin_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_margin_test.h new file mode 100644 index 0000000000000000000000000000000000000000..478c66888a9156fcd339dce1d3b0a105a6cc008a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_margin_test.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_MARGIN_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_MARGIN_TEST_H + +#include +#include +#include +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperMarginTest { +public: + ~SwiperMarginTest(); + // SwiperMarginTest:testSwiperMargin001 + static napi_value CreateNativePrevMargin(napi_env env, napi_callback_info info); + // SwiperMarginTest:testSwiperMargin002 + static napi_value CreateNativePrevMarginAbnormal(napi_env env, napi_callback_info info); + // SwiperMarginTest:testSwiperMargin003 + static napi_value CreateNativeNextMargin(napi_env env, napi_callback_info info); + // SwiperMarginTest:testSwiperMargin004 + static napi_value CreateNativeNextMarginAbnormal(napi_env env, napi_callback_info info); + // SwiperMarginTest:testSwiperMargin005 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_MARGIN_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_nestedscroll_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_nestedscroll_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..44c9baf34ca62811ff6eadbad160d6587c12ee67 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_nestedscroll_test.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_nestedscroll_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateText(uint32_t color) +{ + auto text = std::make_shared(); + text->SetBackgroundColor(color); + text->SetMargin(PARAM_10); + return text; +} + +static std::shared_ptr CreateParentSwiper() +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_400); + swiper->SetHeight(SIZE_200); + swiper->SetSwiperAutoPlay(false); + swiper->SetSwiperLoop(false); + swiper->SetMargin(PARAM_10); + return swiper; +} + +static std::shared_ptr CreateSwiper(const std::string& id) +{ + auto swiper = std::make_shared(); + auto indicator = OH_ArkUI_SwiperIndicator_Create(ARKUI_SWIPER_INDICATOR_TYPE_DOT); + OH_ArkUI_SwiperIndicator_SetItemWidth(indicator, PARAM_10); + OH_ArkUI_SwiperIndicator_SetItemHeight(indicator, PARAM_10); + OH_ArkUI_SwiperIndicator_SetSelectedItemWidth(indicator, PARAM_10); + OH_ArkUI_SwiperIndicator_SetSelectedItemHeight(indicator, PARAM_10); + OH_ArkUI_SwiperIndicator_SetColor(indicator, COLOR_YELLOW); + OH_ArkUI_SwiperIndicator_SetSelectedColor(indicator, COLOR_RED); + swiper->SetSwiperIndicator(indicator); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_10); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(true); + swiper->SetSwiperInterval(SIZE_2000); + swiper->SetId(id); + auto text = CreateText(COLOR_PINK); + swiper->AddChild(text); + return swiper; +} + +napi_value SwiperNestedScrollTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto text_first = CreateText(0xFFAFEEEE); + auto parentSwiper = CreateParentSwiper(); + auto swiper = CreateSwiper("SwiperNestedScroll"); + swiper->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY); + auto childSwiper = CreateSwiper("ChildSwiperNestedScroll"); + childSwiper->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY); + childSwiper->SetWidth(SIZE_100); + childSwiper->SetHeight(SIZE_50); + swiper->AddChild(childSwiper); + parentSwiper->SetSwiperIndex(1); + parentSwiper->AddChild(text_first); + parentSwiper->AddChild(swiper); + + auto parentSwiperSecond = CreateParentSwiper(); + parentSwiperSecond->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST); + auto swiper_second = CreateSwiper("SwiperNestedScrollSecond"); + swiper_second->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST); + swiper_second->SetSwiperIndex(1); + swiper_second->SetSwiperAutoPlay(false); + auto childSwiperSecond = CreateSwiper("ChildSwiperNestedScrollSecond"); + childSwiperSecond->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST); + childSwiperSecond->SetWidth(SIZE_100); + childSwiperSecond->SetHeight(SIZE_50); + swiper_second->AddChild(childSwiperSecond); + parentSwiperSecond->SetSwiperIndex(1); + parentSwiperSecond->AddChild(text_first); + parentSwiperSecond->AddChild(swiper_second); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, parentSwiper->GetComponent()); + nodeAPI->addChild(column, parentSwiperSecond->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value SwiperNestedScrollTest::CreateNativeNodeChild(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + std::vector colors = { 0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF }; + auto parentSwiper = CreateParentSwiper(); + auto swiper = CreateSwiper("SwiperNestedScroll"); + swiper->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY); + swiper->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_FADE); + swiper->SetSwiperAutoPlay(false); + auto parentSwiperSecond = CreateParentSwiper(); + auto swiper_second = CreateSwiper("SwiperNestedScrollSecond"); + swiper_second->SetSwiperNestedScroll(ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST); + swiper_second->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_FADE); + swiper_second->SetSwiperAutoPlay(false); + parentSwiper->AddChild(swiper); + parentSwiperSecond->AddChild(swiper_second); + for (const auto& color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + parentSwiper->AddChild(text); + parentSwiperSecond->AddChild(text); + } + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, parentSwiper->GetComponent()); + nodeAPI->addChild(column, parentSwiperSecond->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +napi_value SwiperNestedScrollTest::CreateNativeNodeAbnormal(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + std::vector colors = { 0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF }; + auto parentSwiper = CreateParentSwiper(); + auto swiper = CreateSwiper("SwiperNestedScroll"); + swiper->SetSwiperNestedScroll(PARAM_NEGATIVE_1); + parentSwiper->SetSwiperIndex(PARAM_4); + auto parentSwiperSecond = CreateParentSwiper(); + auto swiper_second = CreateSwiper("SwiperNestedScrollSecond"); + swiper_second->SetSwiperNestedScroll(PARAM_2); + parentSwiperSecond->SetSwiperIndex(PARAM_4); + for (const auto& color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + parentSwiper->AddChild(text); + parentSwiperSecond->AddChild(text); + } + parentSwiper->AddChild(swiper); + parentSwiperSecond->AddChild(swiper_second); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, parentSwiper->GetComponent()); + nodeAPI->addChild(column, parentSwiperSecond->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_nestedscroll_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_nestedscroll_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3949fd992f53b0a2efbdc32e3988436ec0e53a4a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_nestedscroll_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_NESTEDSCROLL_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_NESTEDSCROLL_TEST_H + +#include +#include +#include +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperNestedScrollTest { +public: + ~SwiperNestedScrollTest(); + // SwiperNestedScrollTest:testSwiperNestedScroll001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // SwiperNestedScrollTest:testSwiperNestedScroll002 + static napi_value CreateNativeNodeChild(napi_env env, napi_callback_info info); + // SwiperNestedScrollTest:testSwiperNestedScroll003 + static napi_value CreateNativeNodeAbnormal(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_NESTEDSCROLL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onanimation_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onanimation_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4d3f7aef9956918defc56582f86ea2606668b9f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onanimation_test.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "swiper_onanimation_test.h" +#include +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateSwiperNode(const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(true); + swiper->SetId(id); + std::vector colors = {0xFFAFEEEE, 0xFF00FF00, 0xFFFF0000, 0xFF0000FF}; + for (const auto &color : colors) { + auto text = std::make_shared(); + text->SetBackgroundColor(color); + swiper->AddChild(text); + } + return swiper; +} + +napi_value SwiperOnAnimationTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = {0}; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperOnAnimationTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1 *nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto text_start = std::make_shared(); + text_start->SetTextContent("test"); + auto swiper = CreateSwiperNode("SwiperOnAnimationStart"); + swiper->RegisterOnAnimationStart([swiper, text_start](ArkUI_NodeEvent *event) { + ArkUI_NodeComponentEvent *result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + std::string str = "Start: \nIndex is: " + std::to_string(result->data[0].i32) + "\n" + + "targetIndex is: " + std::to_string(result->data[1].i32) + "\n" + + "currentOffset is: " + std::to_string(result->data[2].f32) + "\n" + + "targetOffset is: " + std::to_string(result->data[3].f32) + "\n" + + "velocity is: " + std::to_string(result->data[4].f32) + "\n"; + text_start->SetTextContent(str); + swiper->SetBackgroundColor(COLOR_GREEN); + }); + + auto text_end = std::make_shared(); + text_end->SetTextContent("test end"); + auto swiper_second = CreateSwiperNode("SwiperOnAnimationEnd"); + swiper_second->RegisterOnAnimationEnd([swiper_second, text_end](ArkUI_NodeEvent *event) { + ArkUI_NodeComponentEvent *result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + std::string str = "End: \n Index is: " + std::to_string(result->data[0].i32) + "\n" + + "currentOffset is: " + std::to_string(result->data[1].f32); + text_end->SetTextContent(str); + swiper_second->SetBackgroundColor(COLOR_GREEN); + }); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, swiper_second->GetComponent()); + nodeAPI->addChild(column, text_start->GetComponent()); + nodeAPI->addChild(column, text_end->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperOnAnimationTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onanimation_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onanimation_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7459848c440008c333ce2a801dca23d43039f75a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onanimation_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_SWIPER_ONANIMATION_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_ONANIMATION_TEST_H +#include +#include +#include +#include "swiper_common.h" + +namespace ArkUICApiDemo { + +class SwiperOnAnimationTest { +public: + ~SwiperOnAnimationTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_SWIPER_ONANIMATION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onchange_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onchange_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7b03f288752b4b367ec1e6b2afa13ee7fc334a4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onchange_test.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_onchange_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "swiper_common.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +static std::shared_ptr CreateTextNode(uint32_t color) +{ + auto text = std::make_shared(); + text->SetBackgroundColor(color); + return text; +} + +static std::shared_ptr CreateSwiperNode(const std::string& id) +{ + auto swiper = std::make_shared(); + swiper->SetBackgroundColor(0xFFFFFFF); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_20); + swiper->SetSwiperLoop(false); + swiper->SetSwiperAutoPlay(true); + swiper->SetId(id); + auto text = CreateTextNode(0xFFAFEEEE); + auto text_second = CreateTextNode(0xFF00FF00); + swiper->AddChild(text); + swiper->AddChild(text_second); + return swiper; +} + +napi_value SwiperOnChangeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperOnChangeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto swiper = CreateSwiperNode("OnChangeTestSwiper"); + auto text = std::make_shared(); + swiper->RegisterOnChange([swiper, text](ArkUI_NodeEvent* event) { + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + ArkUI_NodeComponentEvent* result = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event); + std::string str = "Page: " + std::to_string(result->data[0].i32); + text->SetTextContent(str); + auto node = nodeAPI->getChildAt(nodeHandler, result->data[0].i32); + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_value_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(node, NODE_BACKGROUND_COLOR, &background_color_value_item); + }); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, swiper->GetComponent()); + nodeAPI->addChild(column, text->GetComponent()); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperOnChangeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onchange_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onchange_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7f4c62894f0dcb68da59a77e1255abd4c5ed1feb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_onchange_test.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_ONCHANGE_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_ONCHANGE_TEST_H +#include "../common/common.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +class SwiperOnChangeTest { +public: + ~SwiperOnChangeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_ONCHANGE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_reset_attribute_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_reset_attribute_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..794f4bcb78de14e5d5a2e3a21aeb8eb59eb75106 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_reset_attribute_test.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "swiper_reset_attribute_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "swiper_component.h" +#include "text_component.h" + +namespace ArkUICApiDemo { + +napi_value SwiperResetAttributeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperResetAttributeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto parentColumn = new ColumnComponent(); + auto swiper = std::make_shared(); + swiper->SetWidth(SIZE_200); + swiper->SetHeight(SIZE_100); + swiper->SetMargin(PARAM_10); + swiper->SetSwiperEffectMode(ARKUI_EDGE_EFFECT_FADE); + swiper->SetSwiperPrevMigration(PARAM_10); + swiper->SetSwiperNextMigration(PARAM_10); + + auto text = std::make_shared(); + text->SetBackgroundColor(0xFFAFEEEE); + auto text_second = std::make_shared(); + text->SetBackgroundColor(0xFF00FF00); + auto text_third = std::make_shared(); + text->SetBackgroundColor(0xFFFF0000); + auto text_fourth = std::make_shared(); + text->SetBackgroundColor(0xFF0000FF); + swiper->AddChild(text); + swiper->AddChild(text_second); + swiper->AddChild(text_third); + swiper->AddChild(text_fourth); + + auto note = std::make_shared(); + note->SetWidth(SIZE_200); + note->SetHeight(SIZE_100); + note->SetBackgroundColor(COLOR_PINK); + + auto button = std::make_shared(); + button->SetId("ResetSwiper"); + button->SetWidth(PARAM_32); + button->SetHeight(PARAM_32); + button->SetMargin(PARAM_10); + button->RegisterOnClick([swiper, note]() { + swiper->resetAttribute(NODE_SWIPER_EDGE_EFFECT_MODE); + swiper->resetAttribute(NODE_SWIPER_PREV_MARGIN); + swiper->resetAttribute(NODE_SWIPER_NEXT_MARGIN); + swiper->resetAttribute(NODE_SWIPER_NESTED_SCROLL); + auto effectModeItem = swiper->getAttribute(NODE_SWIPER_EDGE_EFFECT_MODE); + auto prevMarginItem = swiper->getAttribute(NODE_SWIPER_PREV_MARGIN); + auto nextMarginItem = swiper->getAttribute(NODE_SWIPER_NEXT_MARGIN); + auto nextedScrollItem = swiper->getAttribute(NODE_SWIPER_NESTED_SCROLL); + std::string str = "effectModeItem:" + std::to_string(effectModeItem->value[0].i32) + "\n" + + "prevMarginItem:" + std::to_string(prevMarginItem->value[0].f32) + "\n" + + "nextMarginItem:" + std::to_string(nextMarginItem->value[0].f32) + "\n" + + "nextedScrollItem:" + std::to_string(nextedScrollItem->value[0].i32) + "\n"; + note->SetTextContent(str); + }); + parentColumn->AddChild(swiper); + parentColumn->AddChild(button); + parentColumn->AddChild(note); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + parentColumn->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "SwiperResetAttributeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_reset_attribute_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_reset_attribute_test.h new file mode 100644 index 0000000000000000000000000000000000000000..c99dd55b2f1e891c9f527091ff37560685db9a54 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/swiper/swiper_reset_attribute_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_SWIPER_RESETATTRIBUTE_TEST_H +#define ARKUI_CAPI_DEMO_SWIPER_RESETATTRIBUTE_TEST_H +#include +#include +#include +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class SwiperResetAttributeTest { +public: + ~SwiperResetAttributeTest(); + // SwiperResetAttributeTest:testSwiperResetAttribute001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_SWIPER_RESETATTRIBUTE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_content_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_content_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51893fbe7a4092a6f5849e65fd0962c9168c78dd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_content_test.cpp @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_content_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateSubNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 45 } }; + ArkUI_AttributeItem fontSize_value_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontSize_value_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 2 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_value_item); + + return nodeHandle; +} + +napi_value TextContentTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextContentTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextContentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // Create column node component + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // Set the width and height of the column component + ArkUI_NumberValue column_width_value[] = { { .f32 = 500 } }; + ArkUI_AttributeItem column_width_item = { column_width_value, + sizeof(column_width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue column_height_value[] = { { .f32 = 500 } }; + ArkUI_AttributeItem column_height_item = { column_height_value, + sizeof(column_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &column_width_item); + nodeAPI->setAttribute(column, NODE_HEIGHT, &column_height_item); + + // Create three text node components + auto text1 = CreateSubNode(nodeAPI); + auto text2 = CreateSubNode(nodeAPI); + + // text Place the parent container column中 + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + + // set text content + ArkUI_AttributeItem content_item = {}; + content_item.string = "😄😌😎😭👨‍👩‍👦‍👦📡👁️👁️‍🗨️"; + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &content_item); + + content_item.string = "this is text content"; + nodeAPI->setAttribute(text2, NODE_TEXT_CONTENT, &content_item); + + // set text frame + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_BORDER_WIDTH, &borderWidth_value_item); + nodeAPI->setAttribute(text2, NODE_BORDER_WIDTH, &borderWidth_value_item); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextContentTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_content_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_content_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d126b8a7dbf75152132898957ba2a9ee4df2ea00 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_content_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_CONTENT_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_CONTENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextContentTest { +public: + ~TextContentTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_CONTENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_datadetectorconfig_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_datadetectorconfig_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..74e6e5b917759a068de3b9cff27e9048abe0157e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_datadetectorconfig_test.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_datadetectorconfig_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_AttributeItem text_value = {}; + text_value.string = "18202412345\n www.qwertyy.com\n ***@example.com\n 辽宁省沈阳市大大区小小镇"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &text_value); + + ArkUI_NumberValue copyOption_value[] = { { .i32 = true } }; + ArkUI_AttributeItem copyOption_item = { copyOption_value, sizeof(copyOption_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_COPY_OPTION, ©Option_item); + + ArkUI_NumberValue config_value[] = { { .i32 = value } }; + ArkUI_AttributeItem config_item = { config_value, sizeof(config_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_ENABLE_DATA_DETECTOR_CONFIG, &config_item); + + ArkUI_NumberValue detector_value[] = { { .i32 = true } }; + ArkUI_AttributeItem detector_item = { detector_value, sizeof(detector_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_ENABLE_DATA_DETECTOR, &detector_item); + + return nodeHandle; +} + +napi_value TextDataDetectorConfigTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextDataDetectorConfigTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto text = CreateSubTextNode(nodeAPI, ARKUI_TEXT_DATA_DETECTOR_TYPE_PHONE_NUMBER); + auto text2 = CreateSubTextNode(nodeAPI, ARKUI_TEXT_DATA_DETECTOR_TYPE_URL); + auto text3 = CreateSubTextNode(nodeAPI, ARKUI_TEXT_DATA_DETECTOR_TYPE_EMAIL); + auto text4 = CreateSubTextNode(nodeAPI, ARKUI_TEXT_DATA_DETECTOR_TYPE_ADDRESS); + auto text5 = CreateSubTextNode(nodeAPI, -1); + auto text6 = CreateSubTextNode(nodeAPI, NULL); + auto text7 = CreateSubTextNode(nodeAPI, ARKUI_TEXT_DATA_DETECTOR_TYPE_PHONE_NUMBER); + nodeAPI->resetAttribute(text7, NODE_TEXT_ENABLE_DATA_DETECTOR_CONFIG); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, text); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + nodeAPI->addChild(column, text7); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextDataDetectorConfigTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_datadetectorconfig_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_datadetectorconfig_test.h new file mode 100644 index 0000000000000000000000000000000000000000..40d9453fc631ff382662412a22f1790b84f3eecb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_datadetectorconfig_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_DATADETECTORCONFIG_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_DATADETECTORCONFIG_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextDataDetectorConfigTest { +public: + ~TextDataDetectorConfigTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_DATADETECTORCONFIG_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_decorationstyle_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_decorationstyle_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d9313461658305cd9ff7a602a33d8a873f06b54d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_decorationstyle_test.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_decorationstyle_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode( + ArkUI_NativeNodeAPI_1* nodeAPI, int32_t decorationStyle, float size, int32_t style, int32_t weight) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // 设置组件高度 + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "This is the text "; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = size } }; + ArkUI_AttributeItem fontSize_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontSize_item); + + ArkUI_NumberValue decorationStyle_value[] = { { .i32 = ARKUI_TEXT_DECORATION_TYPE_UNDERLINE }, { .u32 = COLOR_RED }, + { .i32 = decorationStyle } }; + ArkUI_AttributeItem decorationStyle_value_item = { decorationStyle_value, + sizeof(decorationStyle_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_DECORATION, &decorationStyle_value_item); + + ArkUI_NumberValue style_value[] = { { .i32 = style } }; + ArkUI_AttributeItem style_value_item = { style_value, sizeof(style_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_STYLE, &style_value_item); + + ArkUI_NumberValue weight_value[] = { { .i32 = weight } }; + ArkUI_AttributeItem weight_value_item = { weight_value, sizeof(weight_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_WEIGHT, &weight_value_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + return nodeHandle; +} + +napi_value TextDecorationStyleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextDecorationStyleTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextDecorationStyleTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建column节点组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto text1 = createChildNode( + nodeAPI, ARKUI_TEXT_DECORATION_STYLE_SOLID, 35, ARKUI_FONT_STYLE_NORMAL, ARKUI_FONT_WEIGHT_W300); + auto text2 = createChildNode( + nodeAPI, ARKUI_TEXT_DECORATION_STYLE_DOUBLE, 35, ARKUI_FONT_STYLE_ITALIC, ARKUI_FONT_WEIGHT_W300); + auto text3 = createChildNode( + nodeAPI, ARKUI_TEXT_DECORATION_STYLE_DOTTED, 20, ARKUI_FONT_STYLE_NORMAL, ARKUI_FONT_WEIGHT_W400); + auto text4 = createChildNode( + nodeAPI, ARKUI_TEXT_DECORATION_STYLE_DASHED, 20, ARKUI_FONT_STYLE_ITALIC, ARKUI_FONT_WEIGHT_W500); + auto text5 = + createChildNode(nodeAPI, ARKUI_TEXT_DECORATION_STYLE_WAVY, 28, ARKUI_FONT_STYLE_NORMAL, ARKUI_FONT_WEIGHT_W500); + auto text6 = createChildNode(nodeAPI, 5, 28, ARKUI_FONT_STYLE_NORMAL, ARKUI_FONT_WEIGHT_W500); + auto text7 = createChildNode(nodeAPI, -1, 28, ARKUI_FONT_STYLE_NORMAL, ARKUI_FONT_WEIGHT_W500); + auto text8 = createChildNode( + nodeAPI, ARKUI_TEXT_DECORATION_STYLE_SOLID, 28, ARKUI_FONT_STYLE_NORMAL, ARKUI_FONT_WEIGHT_W500); + + nodeAPI->resetAttribute(text8, NODE_TEXT_DECORATION); + // text组件放置父容器column中 + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + nodeAPI->addChild(column, text7); + nodeAPI->addChild(column, text8); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextDecorationStyleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_decorationstyle_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_decorationstyle_test.h new file mode 100644 index 0000000000000000000000000000000000000000..739b247dc1249845e0cdf85c2aff63d48e7ede53 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_decorationstyle_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_DECORATIONSTYLE_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_DECORATIONSTYLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextDecorationStyleTest { +public: + ~TextDecorationStyleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_DECORATIONSTYLE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_ellipsismode_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_ellipsismode_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7ff8481f7cf875b3448ba957127d1493423609c6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_ellipsismode_test.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_ellipsismode_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t ellipsisMode) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + // 设置组件宽度 + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // 设置组件高度 + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // 设置组件边距 + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "The text component is used to display a piece of textual information.Support universal "; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem fontSize_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontSize_item); + + ArkUI_NumberValue lineHeight_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem lineHeight_item = { lineHeight_value, sizeof(lineHeight_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_LINE_HEIGHT, &lineHeight_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 2 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_value_item); + + ArkUI_NumberValue ellipsisMode_value[] = { { .i32 = ellipsisMode } }; + ArkUI_AttributeItem none_value_item = { ellipsisMode_value, + sizeof(ellipsisMode_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_ELLIPSIS_MODE, &none_value_item); + + return nodeHandle; +} + +napi_value TextEllipsisModeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextEllipsisModeTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextEllipsisModeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建column节点组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto text1 = createChildNode(nodeAPI, ARKUI_ELLIPSIS_MODE_START); + auto text2 = createChildNode(nodeAPI, ARKUI_ELLIPSIS_MODE_CENTER); + auto text3 = createChildNode(nodeAPI, ARKUI_ELLIPSIS_MODE_END); + auto text4 = createChildNode(nodeAPI, PARAM_NEGATIVE_1); + auto text5 = createChildNode(nodeAPI, ARKUI_ELLIPSIS_MODE_START); + auto text6 = createChildNode(nodeAPI, ARKUI_ELLIPSIS_MODE_START); + auto text7 = createChildNode(nodeAPI, ARKUI_ELLIPSIS_MODE_START); + + nodeAPI->resetAttribute(text7, NODE_TEXT_ELLIPSIS_MODE); + + ArkUI_NumberValue maxLines_value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem maxLines_item = { maxLines_value, sizeof(maxLines_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_TEXT_MAX_LINES, &maxLines_item); + nodeAPI->setAttribute(text2, NODE_TEXT_MAX_LINES, &maxLines_item); + nodeAPI->setAttribute(text3, NODE_TEXT_MAX_LINES, &maxLines_item); + nodeAPI->setAttribute(text4, NODE_TEXT_MAX_LINES, &maxLines_item); + nodeAPI->setAttribute(text6, NODE_TEXT_MAX_LINES, &maxLines_item); + nodeAPI->setAttribute(text7, NODE_TEXT_MAX_LINES, &maxLines_item); + + ArkUI_NumberValue ellipsis_value[] = { { .i32 = ARKUI_TEXT_OVERFLOW_ELLIPSIS } }; + ArkUI_AttributeItem ellipsis_item = { ellipsis_value, sizeof(ellipsis_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_TEXT_OVERFLOW, &ellipsis_item); + nodeAPI->setAttribute(text2, NODE_TEXT_OVERFLOW, &ellipsis_item); + nodeAPI->setAttribute(text3, NODE_TEXT_OVERFLOW, &ellipsis_item); + nodeAPI->setAttribute(text4, NODE_TEXT_OVERFLOW, &ellipsis_item); + nodeAPI->setAttribute(text5, NODE_TEXT_OVERFLOW, &ellipsis_item); + nodeAPI->setAttribute(text7, NODE_TEXT_OVERFLOW, &ellipsis_item); + + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + nodeAPI->addChild(column, text7); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager ::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextEllipsisModeTest", + "OH_NativeXComponent_AttachNativeRootNode column failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_ellipsismode_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_ellipsismode_test.h new file mode 100644 index 0000000000000000000000000000000000000000..40694758d1f62579df3c804a8875256d5c3cc84a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_ellipsismode_test.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_TEXT_ELLIPSISMODE_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_ELLIPSISMODE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextEllipsisModeTest { +public: + ~TextEllipsisModeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_ELLIPSISMODE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_enabledatadetector_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_enabledatadetector_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..393f920b42e3539ab55d0476b71871bda65659ca --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_enabledatadetector_test.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "text_enabledatadetector_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value, int32_t overflow, int32_t copy) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_AttributeItem text_value = {}; + text_value.string = "18202412345\n www.qwertyy.com\n ***@example.com\n 辽宁省沈阳市大大区小小镇"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &text_value); + + ArkUI_NumberValue copyOption_value[] = { { .i32 = copy } }; + ArkUI_AttributeItem copyOption_item = { copyOption_value, sizeof(copyOption_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_COPY_OPTION, ©Option_item); + + ArkUI_NumberValue invalid_none_value[] = { { .i32 = overflow } }; + ArkUI_AttributeItem invalid_none_value_item = { invalid_none_value, + sizeof(invalid_none_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_OVERFLOW, &invalid_none_value_item); + + ArkUI_NumberValue detector_value[] = { { .i32 = value } }; + ArkUI_AttributeItem detector_item = { detector_value, sizeof(detector_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_ENABLE_DATA_DETECTOR, &detector_item); + + return nodeHandle; +} + +napi_value TextEnableDataDetectorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextEnableDataDetectorTest", "GetContext env or info is null"); + return nullptr; + } + // 创建nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto text = CreateSubTextNode(nodeAPI, 1, ARKUI_TEXT_OVERFLOW_NONE, ARKUI_COPY_OPTIONS_IN_APP); + auto text1 = CreateSubTextNode(nodeAPI, 1, ARKUI_TEXT_OVERFLOW_NONE, ARKUI_COPY_OPTIONS_NONE); + auto text2 = CreateSubTextNode(nodeAPI, 0, ARKUI_TEXT_OVERFLOW_NONE, ARKUI_COPY_OPTIONS_IN_APP); + auto text3 = CreateSubTextNode(nodeAPI, 1, ARKUI_COPY_OPTIONS_NONE, ARKUI_COPY_OPTIONS_IN_APP); + auto text4 = CreateSubTextNode(nodeAPI, 1, ARKUI_TEXT_OVERFLOW_MARQUEE, ARKUI_COPY_OPTIONS_IN_APP); + auto text5 = CreateSubTextNode(nodeAPI, -1, ARKUI_COPY_OPTIONS_NONE, ARKUI_COPY_OPTIONS_IN_APP); + + nodeAPI->resetAttribute(text3, NODE_TEXT_ENABLE_DATA_DETECTOR); + ArkUI_AttributeItem id_item = {}; + id_item.string = "text"; + nodeAPI->setAttribute(text, NODE_ID, &id_item); + + id_item.string = "text1"; + nodeAPI->setAttribute(text1, NODE_ID, &id_item); + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_BETWEEN } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + nodeAPI->addChild(column, text); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextEnableDataDetectorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_enabledatadetector_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_enabledatadetector_test.h new file mode 100644 index 0000000000000000000000000000000000000000..009707c8f168f4388226cea7e611ad1926b3084e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_enabledatadetector_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_ENABLEDATADETECTOR_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_ENABLEDATADETECTOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextEnableDataDetectorTest { +public: + ~TextEnableDataDetectorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_TEXTDATADETECTORTYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_fontfeature_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_fontfeature_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6875931184bf9a6a9e8954bcb08753abf4c5b10 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_fontfeature_test.cpp @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_fontfeature_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text; +static ArkUI_NodeHandle column; +static ArkUI_NativeNodeAPI_1* nodeAPI; + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* value, char* text) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + // set id + ArkUI_AttributeItem value_item = {}; + value_item.string = value; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_FEATURE, &value_item); + + ArkUI_AttributeItem text_item = {}; + text_item.string = text; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &text_item); + + // width + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // height + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // margin + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + return nodeHandle; +} + +napi_value TextFontFeatureTest::CreateNativeNodeFirst(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextFontfeatureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto text1 = createChildNode(nodeAPI, "\"ss01\" on", "0123456789,;//\\-‱%℃℉"); + auto text2 = createChildNode(nodeAPI, "\"ss01\" off", "0123456789,;//\\-‱%℃℉"); + auto text3 = createChildNode(nodeAPI, "\"ss02\" on", "0123456789,;//\\-‱%℃℉"); + auto text4 = createChildNode(nodeAPI, "\"ss02\" off", "0123456789,;//\\-‱%℃℉"); + auto text5 = createChildNode(nodeAPI, "\"ss03\" on", ":+-×÷=≠><≥≤±≈~﹁"); + auto text6 = createChildNode(nodeAPI, "\"ss03\" off", ":+-×÷=≠><≥≤±≈~﹁"); + auto text7 = createChildNode(nodeAPI, "\"ss04\" on", "llllllllll"); + auto text8 = createChildNode(nodeAPI, "\"ss04\" off", "llllllllll"); + auto text9 = + createChildNode(nodeAPI, "\"ss05\" on", "€¢|¦№¤$₫₣₤₱£₦₨₩₪₱₮₡¥₥₭₰+-×÷=≠<>≤≥±≈~∟^∞∧∨∩∪∫Ω△∏∑√‰μδ|"); + auto text10 = + createChildNode(nodeAPI, "\"ss05\" off", "€¢|¦№¤$₫₣₤₱£₦₨₩₪₱₮₡¥₥₭₰+-×÷=≠<>≤≥±≈~∟^∞∧∨∩∪∫Ω△∏∑√‰μδ|"); + auto text11 = createChildNode(nodeAPI, "\"ss08\" on", "{〈《「『【(〔、。!,:;?}〉》」』】〕〗)〕"); + auto text12 = createChildNode(nodeAPI, "\"ss08\" off", "{〈《「『【(〔、。!,:;?}〉》」』】〕〗)〕"); + auto text13 = createChildNode(nodeAPI, "\"ss09\" on", "0123456789"); + auto text14 = createChildNode(nodeAPI, "\"ss09\" off", "0123456789"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + nodeAPI->addChild(column, text7); + nodeAPI->addChild(column, text8); + nodeAPI->addChild(column, text9); + nodeAPI->addChild(column, text10); + nodeAPI->addChild(column, text11); + nodeAPI->addChild(column, text12); + nodeAPI->addChild(column, text13); + nodeAPI->addChild(column, text14); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextFontfeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextFontFeatureTest::CreateNativeNodeSecond(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextFontfeatureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto text15 = createChildNode(nodeAPI, "\"ss10\" on", "0123456789"); + auto text16 = createChildNode(nodeAPI, "\"ss10\" off", "0123456789"); + auto text17 = createChildNode(nodeAPI, "\"frac\" on", "1/2 1/4"); + auto text18 = createChildNode(nodeAPI, "\"frac\" off", "1/2 1/4"); + auto text19 = createChildNode(nodeAPI, "\"sups\" on", "0123456789"); + auto text20 = createChildNode(nodeAPI, "\"sups\" off", "0123456789"); + auto text21 = createChildNode(nodeAPI, "\"subs\" on", "0123456789"); + auto text22 = createChildNode(nodeAPI, "\"subs\" off", "0123456789"); + auto text23 = createChildNode(nodeAPI, "\"numr\" on", "0123456789"); + auto text24 = createChildNode(nodeAPI, "\"numr\" off", "0123456789"); + auto text25 = createChildNode(nodeAPI, "\"dnom\" on", "0123456789"); + auto text26 = createChildNode(nodeAPI, "\"dnom\" off", "0123456789"); + auto text27 = createChildNode(nodeAPI, "\"case\" on", "!¡?¿"); + auto text28 = createChildNode(nodeAPI, "\"case\" off", "!¡?¿"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, text15); + nodeAPI->addChild(column, text16); + nodeAPI->addChild(column, text17); + nodeAPI->addChild(column, text18); + nodeAPI->addChild(column, text19); + nodeAPI->addChild(column, text20); + nodeAPI->addChild(column, text21); + nodeAPI->addChild(column, text22); + nodeAPI->addChild(column, text23); + nodeAPI->addChild(column, text24); + nodeAPI->addChild(column, text25); + nodeAPI->addChild(column, text26); + nodeAPI->addChild(column, text27); + nodeAPI->addChild(column, text28); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextFontfeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextFontFeatureTest::CreateNativeNodeThird(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextFontfeatureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto text29 = createChildNode(nodeAPI, "\"tnum\" on", "0123456789"); + auto text30 = createChildNode(nodeAPI, "\"tnum\" off", "0123456789"); + auto text31 = createChildNode(nodeAPI, "\"pnum\" on", "0123456789"); + auto text32 = createChildNode(nodeAPI, "\"pnum\" off", "0123456789"); + auto text33 = createChildNode(nodeAPI, "\"vert\" on", "【】()"); + auto text34 = createChildNode(nodeAPI, "\"vert\" off", "【】()"); + auto text35 = createChildNode(nodeAPI, "\"vrt2\" on", "【】()"); + auto text36 = createChildNode(nodeAPI, "\"vrt2\" off", "【】()"); + auto text37 = createChildNode(nodeAPI, "\"liga\" on", "ff fl fi ffi ffl"); + auto text38 = createChildNode(nodeAPI, "\"liga\" off", "ff fl fi ffi ffl"); + auto text39 = createChildNode(nodeAPI, "\"ordn\" on", "No.1 1a 1o"); + auto text40 = createChildNode(nodeAPI, "\"ordn\" off", "No.1 1a 1o"); + auto text41 = createChildNode(nodeAPI, "\"sinf\" on", "0123456789"); + auto text42 = createChildNode(nodeAPI, "\"sinf\" off", "0123456789"); + + nodeAPI->addChild(column, text29); + nodeAPI->addChild(column, text30); + nodeAPI->addChild(column, text31); + nodeAPI->addChild(column, text32); + nodeAPI->addChild(column, text33); + nodeAPI->addChild(column, text34); + nodeAPI->addChild(column, text35); + nodeAPI->addChild(column, text36); + nodeAPI->addChild(column, text37); + nodeAPI->addChild(column, text38); + nodeAPI->addChild(column, text39); + nodeAPI->addChild(column, text40); + nodeAPI->addChild(column, text41); + nodeAPI->addChild(column, text42); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextFontfeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_fontfeature_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_fontfeature_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0119ae9a8fb60db70925aad244edd27d4c6d3477 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_fontfeature_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_FONTFEATURE_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_FONTFEATURE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextFontFeatureTest { +public: + ~TextFontFeatureTest(); + static napi_value CreateNativeNodeFirst(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeSecond(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeThird(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_FONTFEATURE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_linespacing_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_linespacing_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6b3757a6244f80504879f31e6d8fce6e5f1995b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_linespacing_test.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_linespacing_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, float_t number, char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + // set component margins + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "This is set linespacing This is set linespacing This is set linespacing."; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 22 } }; + ArkUI_AttributeItem fontSize_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontSize_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 2 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_value_item); + + ArkUI_NumberValue lineSpacing_value[] = { { .f32 = number } }; + ArkUI_AttributeItem none_value_item = { lineSpacing_value, sizeof(lineSpacing_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_LINE_SPACING, &none_value_item); + + ArkUI_NumberValue copyOption_value[] = { { .i32 = ARKUI_COPY_OPTIONS_IN_APP } }; + ArkUI_AttributeItem copyOption_item = { copyOption_value, sizeof(copyOption_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_COPY_OPTION, ©Option_item); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + return nodeHandle; +} +napi_value TextLineSpacingTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextLineSpacingTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextLineSpacingTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // Create column node component + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto text1 = createChildNode(nodeAPI, 20, "text1"); + auto text2 = createChildNode(nodeAPI, 40, "text2"); + auto text3 = createChildNode(nodeAPI, 0, "text3"); + auto text4 = createChildNode(nodeAPI, -1, "text4"); + auto text5 = createChildNode(nodeAPI, -1, "text5"); + auto text6 = createChildNode(nodeAPI, 40, "text6"); + + nodeAPI->resetAttribute(text6, NODE_TEXT_LINE_SPACING); + + ArkUI_NumberValue lineHeight_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem lineHeight_item = { lineHeight_value, sizeof(lineHeight_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text5, NODE_TEXT_LINE_HEIGHT, &lineHeight_item); + + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + // All components mounted to XCompoonent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager ::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextLineSpacingTest", + "OH_NativeXComponent_AttachNativeRootNode column failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_linespacing_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_linespacing_test.h new file mode 100644 index 0000000000000000000000000000000000000000..8326527e196ede17744a2c8074a07cd1e7e7deeb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_linespacing_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_LINESPACING_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_LINESPACING_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextLineSpacingTest { +public: + ~TextLineSpacingTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_LINESPACING_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_paragraph.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_paragraph.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bcc8f7ead5934e8cc6f8faf810d3039b0e0b75f0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_paragraph.cpp @@ -0,0 +1,86 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_paragraph.h" + +#include +#include +#include +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +napi_value TextParagraphTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextParagraphTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextParagraphTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle(); + ArkUI_StyledString* styledString = OH_ArkUI_StyledString_Create(typoStyle, OH_Drawing_CreateFontCollection()); + + OH_Drawing_TextStyle* txtStyle1 = OH_Drawing_CreateTextStyle(); + OH_Drawing_SetTextStyleFontSize(txtStyle1, 150); + OH_Drawing_SetTextStyleColor(txtStyle1, 0xFF00FF00); + OH_ArkUI_StyledString_PushTextStyle(styledString, txtStyle1); + OH_ArkUI_StyledString_AddText(styledString, "段落布局 段落布局 段落布局"); + OH_ArkUI_StyledString_PopTextStyle(styledString); + + ArkUI_NodeHandle text = nodeAPI->createNode(ARKUI_NODE_TEXT); + OH_Drawing_Typography* typography = OH_ArkUI_StyledString_CreateTypography(styledString); + OH_Drawing_TypographyLayout(typography, 200 * 3.25); + ArkUI_AttributeItem item = { .object = styledString }; + nodeAPI->setAttribute(text, NODE_TEXT_CONTENT_WITH_STYLED_STRING, &item); + OH_Drawing_DestroyTextStyle(txtStyle1); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, text); + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextParagraphTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_paragraph.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_paragraph.h new file mode 100644 index 0000000000000000000000000000000000000000..64e6212717a5dfb39b091f46e51f27d512b92510 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_paragraph.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_PARAGRAPH_H +#define ARKUI_CAPI_DEMO_TEXT_PARAGRAPH_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextParagraphTest { +public: + ~TextParagraphTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_PARAGRAPH_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_selectedbackgroundcolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_selectedbackgroundcolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..76099ae840095d9bc89c30e9496bbcad937af050 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_selectedbackgroundcolor_test.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_selectedbackgroundcolor_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t color, char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_AttributeItem text_value = {}; + text_value.string = "123456789"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &text_value); + + ArkUI_NumberValue copyOption_value[] = { { .i32 = ARKUI_COPY_OPTIONS_IN_APP } }; + ArkUI_AttributeItem copyOption_item = { copyOption_value, sizeof(copyOption_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_COPY_OPTION, ©Option_item); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + // set color + ArkUI_NumberValue color_value[] = { { .i32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_SELECTED_BACKGROUND_COLOR, &color_item); + + ArkUI_NumberValue value[] = { { .f32 = 45 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + return nodeHandle; +} + +napi_value TextSelectedBackgroundColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextSelectedBackgroundColorTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto text = CreateSubTextNode(nodeAPI, COLOR_GREEN, "green"); + auto text2 = CreateSubTextNode(nodeAPI, -1, "abnormal"); + auto text3 = CreateSubTextNode(nodeAPI, COLOR_GREEN, "reset"); + + nodeAPI->resetAttribute(text3, NODE_TEXT_SELECTED_BACKGROUND_COLOR); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, text); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextSelectedBackgroundColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_selectedbackgroundcolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_selectedbackgroundcolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..79966dc92b83783c8be35907590fd49a716cbf57 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_selectedbackgroundcolor_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_SELECTEDBACKGROUNDCOLOR_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_SELECTEDBACKGROUNDCOLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextSelectedBackgroundColorTest { +public: + ~TextSelectedBackgroundColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_SELECTEDBACKGROUNDCOLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_wordbreak_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_wordbreak_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..90da652995d4a70828d143eb1d93190b87abfcc6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_wordbreak_test.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text_wordbreak_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto CreateSubTextNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t type) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 82 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set wordBreakType + ArkUI_NumberValue textinputValue[] = { { .i32 = type } }; + ArkUI_AttributeItem textinputItem = { textinputValue, sizeof(textinputValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_WORD_BREAK, &textinputItem); + + ArkUI_NumberValue lines_value[] = { { .i32 = 3 } }; + ArkUI_AttributeItem lines_value_value_item = { lines_value, sizeof(lines_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_MAX_LINES, &lines_value_value_item); + + ArkUI_NumberValue borderWidth_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem borderWidth_value_item = { borderWidth_value, + sizeof(borderWidth_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &borderWidth_value_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue fontSize_value[] = { { .f32 = 20 } }; + ArkUI_AttributeItem fontSize_item = { fontSize_value, sizeof(fontSize_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontSize_item); + + return nodeHandle; +} +napi_value TextWordBreakTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextWordBreakTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextWordBreakTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // Create column node component + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto text0 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_NORMAL); + auto text1 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_NORMAL); + auto text2 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_ALL); + auto text3 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_ALL); + auto text4 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_WORD); + auto text5 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_WORD); + auto text6 = CreateSubTextNode(nodeAPI, -1); + auto text7 = CreateSubTextNode(nodeAPI, 3); + auto text8 = CreateSubTextNode(nodeAPI, ARKUI_WORD_BREAK_NORMAL); + + // set text + ArkUI_AttributeItem text1_item = {}; + text1_item.string = "This is set wordBreak to WordBreak text Taumatawhakatangihangakoauauotamateat"; + ArkUI_AttributeItem text2_item = {}; + text2_item.string = "多行文本输入框组件,当输入的文本内容超过组件宽度时会自动换行显示。\n高度未设置时,组件无默认高" + "度,自适应内容高度。宽度未设置时,默认撑满最大宽度"; + + nodeAPI->setAttribute(text0, NODE_TEXT_CONTENT, &text1_item); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &text2_item); + nodeAPI->setAttribute(text2, NODE_TEXT_CONTENT, &text1_item); + nodeAPI->setAttribute(text3, NODE_TEXT_CONTENT, &text2_item); + nodeAPI->setAttribute(text4, NODE_TEXT_CONTENT, &text1_item); + nodeAPI->setAttribute(text5, NODE_TEXT_CONTENT, &text2_item); + nodeAPI->setAttribute(text6, NODE_TEXT_CONTENT, &text1_item); + nodeAPI->setAttribute(text7, NODE_TEXT_CONTENT, &text1_item); + nodeAPI->setAttribute(text8, NODE_TEXT_CONTENT, &text1_item); + + nodeAPI->resetAttribute(text8, NODE_TEXT_WORD_BREAK); + + nodeAPI->addChild(column, text0); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + nodeAPI->addChild(column, text7); + nodeAPI->addChild(column, text8); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextWordBreakTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/text/text_wordbreak_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_wordbreak_test.h new file mode 100644 index 0000000000000000000000000000000000000000..50114b7611660e55ab1e791ac60b2ad21511f3e1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/text/text_wordbreak_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_WORDBREAK_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_WORDBREAK_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextWordBreakTest { +public: + ~TextWordBreakTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_WORDBREAK_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_bluronsubmit_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_bluronsubmit_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6efca11798dd50a9801ac99fb1d857c867f7adef --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_bluronsubmit_test.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "textarea_bluronsubmit_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +#define ON_BLUR_ID 2 +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &width_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue blur_value[] = { { .i32 = value } }; + ArkUI_AttributeItem blur_item = { blur_value, sizeof(blur_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_BLUR_ON_SUBMIT, &blur_item); + + return nodeHandle; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaBlurOnSubmitTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaBlurOnSubmitTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaBlurOnSubmitTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CHANGE_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } else if (eventId == ON_BLUR_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } +} + +napi_value TextAreaBlurOnSubmitTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaBlurOnSubmitTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaBlurOnSubmitTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textArea1 = createChildNode(nodeAPI, 0); + auto textArea2 = createChildNode(nodeAPI, 1); + auto textArea3 = createChildNode(nodeAPI, -1); + + nodeAPI->registerNodeEvent(textArea1, NODE_ON_FOCUS, ON_CHANGE_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textArea1, NODE_ON_BLUR, ON_BLUR_ID, nullptr); + + nodeAPI->registerNodeEvent(textArea2, NODE_ON_FOCUS, ON_CHANGE_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textArea2, NODE_ON_BLUR, ON_BLUR_ID, nullptr); + + nodeAPI->registerNodeEvent(textArea3, NODE_ON_FOCUS, ON_CHANGE_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textArea3, NODE_ON_BLUR, ON_BLUR_ID, nullptr); + + ArkUI_AttributeItem id1_item = {}; + id1_item.string = "BlurOnSubmitFalse"; + nodeAPI->setAttribute(textArea1, NODE_ID, &id1_item); + + ArkUI_AttributeItem id2_item = {}; + id2_item.string = "BlurOnSubmitTrue"; + nodeAPI->setAttribute(textArea2, NODE_ID, &id2_item); + + id2_item.string = "BlurOnSubmitAbnormal"; + nodeAPI->setAttribute(textArea3, NODE_ID, &id2_item); + + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaBlurOnSubmitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_bluronsubmit_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_bluronsubmit_test.h new file mode 100644 index 0000000000000000000000000000000000000000..5a2ad8b5100c6668b64b101b95e6d2660863942d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_bluronsubmit_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_BLURONSUBMIT_COLOR_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_BLURONSUBMIT_COLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaBlurOnSubmitTest { +public: + ~TextAreaBlurOnSubmitTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_BLURONSUBMIT_COLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_caretposition_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_caretposition_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8be896edc854558ec95bc3a4bec86fa022199bc3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_caretposition_test.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_caretposition_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define ON_CLICK_1 6001 +#define ON_CLICK_2 6002 +#define ON_CLICK_3 6003 + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text1; + +static ArkUI_NodeHandle textArea1; + +ArkUI_NodeHandle CreateSubTextAreaCaretPositionNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 300; + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TextArea"; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &content_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_NumberValue fontsize[] = { { .f32 = 45 } }; + ArkUI_AttributeItem fontsize_item = { fontsize, sizeof(fontsize) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_FONT_SIZE, &fontsize_item); + + return textArea; +} + +static auto CreatButton(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandler = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &height_item); + + return nodeHandler; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", "OnEventReceive eventId: %{public}d", + eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + switch (eventId) { + case ON_CLICK_1: { + ArkUI_NumberValue setCaretPosition_value[] = { { .i32 = 3 } }; + ArkUI_AttributeItem setCaretPosition_item = { setCaretPosition_value, + sizeof(setCaretPosition_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET, &setCaretPosition_item); + auto result = nodeAPI->getAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET); + if (result == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", + "Failed to get caret offset attribute"); + return; + } + if (text1 != nullptr) { + std::string str = "index:" + std::to_string(result->value[0].i32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } else { + std::string str = "error"; + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } + return; + } + case ON_CLICK_2: { + ArkUI_NumberValue setCaretPosition_value[] = { { .i32 = -1 } }; + ArkUI_AttributeItem setCaretPosition_item = { setCaretPosition_value, + sizeof(setCaretPosition_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET, &setCaretPosition_item); + auto result = nodeAPI->getAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET); + if (result == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", + "Failed to get caret offset attribute"); + return; + } + if (text1 != nullptr) { + std::string str = "index:" + std::to_string(result->value[0].i32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } else { + std::string str = "error"; + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } + return; + } + case ON_CLICK_3: { + ArkUI_NumberValue setCaretPosition_value[] = { { .i32 = 100 } }; + ArkUI_AttributeItem setCaretPosition_item = { setCaretPosition_value, + sizeof(setCaretPosition_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET, &setCaretPosition_item); + auto result = nodeAPI->getAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET); + if (result == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", + "Failed to get caret offset attribute"); + return; + } + if (text1 != nullptr) { + std::string str = "index:" + std::to_string(result->value[0].i32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } else { + std::string str = "error"; + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } + return; + } + default: { + return; + } + } +} + +napi_value TextAreaCaretPositionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + text1 = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue value[] = { { .f32 = 35 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_FONT_SIZE, &value_item); + + textArea1 = CreateSubTextAreaCaretPositionNode(nodeAPI); + + auto button1 = CreatButton(nodeAPI); + auto button2 = CreatButton(nodeAPI); + auto button3 = CreatButton(nodeAPI); + + ArkUI_AttributeItem id_item1 = {}; + id_item1.string = "TextAreaCaretPosition_id1"; + nodeAPI->setAttribute(button1, NODE_ID, &id_item1); + + ArkUI_AttributeItem id_item2 = {}; + id_item2.string = "TextAreaCaretPosition_id2"; + nodeAPI->setAttribute(button2, NODE_ID, &id_item2); + + ArkUI_AttributeItem id_item3 = {}; + id_item3.string = "TextAreaCaretPosition_id3"; + nodeAPI->setAttribute(button3, NODE_ID, &id_item3); + + ArkUI_AttributeItem id_item4 = {}; + id_item4.string = "textArea1"; + nodeAPI->setAttribute(textArea1, NODE_ID, &id_item4); + + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_1, nodeAPI); + nodeAPI->registerNodeEvent(button2, NODE_ON_CLICK, ON_CLICK_2, nodeAPI); + nodeAPI->registerNodeEvent(button3, NODE_ON_CLICK, ON_CLICK_3, nodeAPI); + + ArkUI_AttributeItem button_item1 = {}; + button_item1.string = "设置光标位置3"; + nodeAPI->setAttribute(button1, NODE_BUTTON_LABEL, &button_item1); + + ArkUI_AttributeItem button_item2 = {}; + button_item2.string = "设置光标位置-1"; + nodeAPI->setAttribute(button2, NODE_BUTTON_LABEL, &button_item2); + + ArkUI_AttributeItem button_item3 = {}; + button_item3.string = "设置光标位置100"; + nodeAPI->setAttribute(button3, NODE_BUTTON_LABEL, &button_item3); + + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, button1); + nodeAPI->addChild(column, button2); + nodeAPI->addChild(column, button3); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaCaretPositionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_caretposition_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_caretposition_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7f3cc90b2ef0cc0836ee65ce9b6583fc5a76afb3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_caretposition_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_CARETPOSITION_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_CARETPOSITION_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaCaretPositionTest { +public: + ~TextAreaCaretPositionTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_CARETPOSITION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_contenttype_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_contenttype_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d15780a824707f7601db25fe940fe8603d3a7cd5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_contenttype_test.cpp @@ -0,0 +1,145 @@ +// +// Created on 2024/11/11. +// +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, +// please include "napi/native_api.h". + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_contenttype_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateSubNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t contentType, const char* id) +{ + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = 350 } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = 45 } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_NumberValue fontsize[] = { { .f32 = 45 } }; + ArkUI_AttributeItem fontsize_item = { fontsize, sizeof(fontsize) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_FONT_SIZE, &fontsize_item); + + ArkUI_NumberValue value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_ENABLE_AUTO_FILL, &item); + + ArkUI_NumberValue value1[] = { { .i32 = contentType } }; + ArkUI_AttributeItem item1 = { value1, sizeof(value1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_CONTENT_TYPE, &item1); + + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeApi->setAttribute(textArea, NODE_ID, &id_item); + + return textArea; +} + +ArkUI_NodeHandle CreateTextSubNode(ArkUI_NativeNodeAPI_1* nodeApi, std::string content, const char* id) +{ + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = 350 } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = 45 } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_MARGIN, &margin_item); + + ArkUI_AttributeItem content_item = { .string = content.c_str() }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &content_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeApi->setAttribute(textArea, NODE_ID, &id_item); + + return textArea; +} + +napi_value TextAreaContentTypeTest::CreateNativeNodePageOne(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaContentTypeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaContentTypeTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textArea1 = CreateTextSubNode(nodeAPI, "18202412345", "textArea1"); + auto textArea_1 = CreateSubNode(nodeAPI, ARKUI_TEXTINPUT_CONTENT_TYPE_PHONE_NUMBER, "textArea_1"); + + nodeAPI->addChild(column, textArea_1); + nodeAPI->addChild(column, textArea1); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaContentTypeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_contenttype_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_contenttype_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0a9fd914c04d6212adc5f4a6a3765ddad6886542 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_contenttype_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_CONTENTTYPE_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_CONTENTTYPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_21 21 + +class TextAreaContentTypeTest { +public: + ~TextAreaContentTypeTest(); + static napi_value CreateNativeNodePageOne(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_CONTENTTYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_controller_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_controller_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c3ca5baa62c44ab73b9efd6963f6e147115b2a3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_controller_test.cpp @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "textarea_controller_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define CONTROLLER_GET_INFORMATION 6017 +#define CONTROLLER_CHANGE_INFORMATION 1 +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text; +static ArkUI_NodeHandle textArea; +static ArkUI_NodeHandle text1; +static ArkUI_NodeHandle text2; +static ArkUI_NodeHandle text3; + +ArkUI_NodeHandle CreateTextOne(ArkUI_NativeNodeAPI_1* nodeApi) +{ + auto text = nodeApi->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue widthValue[] = { { .f32 = 300 } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = 200 } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_FONT_SIZE, &value_item); + + return text; +} + +ArkUI_NodeHandle CreateSubTextAreaNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 100; + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue caretColor_value[] = { { .u32 = COLOR_TRANSPARENT } }; + ArkUI_AttributeItem caretColor_item = { caretColor_value, sizeof(caretColor_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_INPUT_CARET_COLOR, &caretColor_item); + + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + + ArkUI_NumberValue keyboard1_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard1_item = { keyboard1_value, sizeof(keyboard1_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard1_item); + + ArkUI_NumberValue value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_FONT_SIZE, &value_item); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "textArea"; + nodeApi->setAttribute(textArea, NODE_TEXT_INPUT_TEXT, &content_item); + + return textArea; +} + +static auto CreatButton(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandler = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &height_item); + + return nodeHandler; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaControllerTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaControllerTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaControllerTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + switch (eventId) { + case CONTROLLER_GET_INFORMATION: { + auto result2 = nodeAPI->getAttribute(textArea, NODE_TEXT_INPUT_CONTENT_RECT); + if (result2 == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaControllerTest", + "Failed to get caret offset attribute"); + return; + } + std::string str = "horizontal:" + std::to_string(result2->value[0].f32) + " vertiacal" + + std::to_string(result2->value[1].f32) + " width" + std::to_string(result2->value[2].f32) + + " height" + std::to_string(result2->value[3].f32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + auto result3 = nodeAPI->getAttribute(textArea, NODE_TEXT_INPUT_CONTENT_LINE_COUNT); + if (result3 == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaControllerTest", + "Failed to get caret offset attribute"); + return; + } + if (result3 != nullptr) { + str = "line:" + std::to_string(result3->value[0].i32); + ArkUI_AttributeItem line_item = {}; + line_item.string = str.c_str(); + nodeAPI->setAttribute(text2, NODE_TEXT_CONTENT, &line_item); + } + return; + } + case CONTROLLER_CHANGE_INFORMATION: { + ArkUI_AttributeItem line_item = {}; + line_item.string = "Textarea Textarea Textarea Textarea"; + nodeAPI->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &line_item); + return; + } + default:{ + return; + } + } +} + +napi_value TextAreaControllerTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto Area = CreateSubTextAreaNode(nodeAPI); + textArea = Area; + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_AttributeItem textArea_id_item = {}; + textArea_id_item.string = "TextAreaControllerTest_textInput_id"; + nodeAPI->setAttribute(textArea, NODE_ID, &textArea_id_item); + + auto button_1 = CreatButton(nodeAPI); + auto button_2 = CreatButton(nodeAPI); + + ArkUI_AttributeItem button_1_content_item = {}; + button_1_content_item.string = "获取输入框信息,获取输入框行数"; + nodeAPI->setAttribute(button_1, NODE_BUTTON_LABEL, &button_1_content_item); + + button_1_content_item.string = "多行后变化"; + nodeAPI->setAttribute(button_2, NODE_BUTTON_LABEL, &button_1_content_item); + + nodeAPI->registerNodeEvent(button_1, NODE_ON_CLICK, CONTROLLER_GET_INFORMATION, nodeAPI); + nodeAPI->registerNodeEvent(button_2, NODE_ON_CLICK, CONTROLLER_CHANGE_INFORMATION, nodeAPI); + + ArkUI_AttributeItem id_item_1 = {}; + id_item_1.string = "TextAreaControllerTest_button_id"; + nodeAPI->setAttribute(button_1, NODE_ID, &id_item_1); + + id_item_1.string = "TextAreaControllerTest_button_id_2"; + nodeAPI->setAttribute(button_2, NODE_ID, &id_item_1); + + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + + text1 = CreateTextOne(nodeAPI); + text2 = CreateTextOne(nodeAPI); + text3 = CreateTextOne(nodeAPI); + + nodeAPI->addChild(column, button_1); + nodeAPI->addChild(column, button_2); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, textArea); + nodeAPI->addChild(column, row); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaControllerTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_controller_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_controller_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d5a196d86d781c943a9c75c3297c8b10c8dbe895 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_controller_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_CONTROLLER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_CONTROLLER_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaControllerTest { +public: + ~TextAreaControllerTest(); + + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_CONTROLLER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enableautofill_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enableautofill_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cf922ec298268db91317f70a728774a22731dc16 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enableautofill_test.cpp @@ -0,0 +1,126 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_enableautofill_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateFillNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t AutoFill, const char* id) +{ + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = 350 } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = 45 } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_NumberValue value[] = { { .i32 = AutoFill } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_ENABLE_AUTO_FILL, &item); + + ArkUI_NumberValue value1[] = { { .i32 = ARKUI_TEXTINPUT_CONTENT_TYPE_PHONE_NUMBER } }; + ArkUI_AttributeItem item1 = { value1, sizeof(value1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_CONTENT_TYPE, &item1); + + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeApi->setAttribute(textArea, NODE_ID, &id_item); + + return textArea; +} + +napi_value TextAreaEnableAutoFillTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableAutoFillTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableAutoFillTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textArea = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto textArea1 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto textArea2 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto textArea3 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto textArea4 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + auto textArea5 = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // 设置属性 + textArea = CreateFillNode(nodeAPI, PARAM_1, "textArea"); + textArea1 = CreateFillNode(nodeAPI, PARAM_1, "textArea1"); + textArea2 = CreateFillNode(nodeAPI, PARAM_0, "textArea2"); + textArea3 = CreateFillNode(nodeAPI, PARAM_2, "textArea3"); + textArea4 = CreateFillNode(nodeAPI, PARAM_NEGATIVE_1, "textArea4"); + textArea5 = CreateFillNode(nodeAPI, PARAM_1, "textArea5"); + nodeAPI->resetAttribute(textArea5, NODE_TEXT_AREA_ENABLE_AUTO_FILL); + + ArkUI_AttributeItem content_item = { .string = "18212312312" }; + nodeAPI->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &content_item); + + nodeAPI->addChild(column, textArea); + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + nodeAPI->addChild(column, textArea4); + nodeAPI->addChild(column, textArea5); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableAutoFillTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enableautofill_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enableautofill_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ed3a926e1d4151d5d439ae66f405353814d6a82e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enableautofill_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_ENABLEAUTOFILL_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_ENABLEAUTOFILL_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaEnableAutoFillTest { +public: + ~TextAreaEnableAutoFillTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_ENABLEAUTOFILL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enablekeyboardonfocus_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enablekeyboardonfocus_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b7978f8891a95e6d45fff6f5da2e69bd9a7d4b70 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enablekeyboardonfocus_test.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_enablekeyboardonfocus_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t enableKeyboardOnFocus, const char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + // width + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // height + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // margin + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + // enableKeyboardOnFocus + ArkUI_NumberValue enableKeyboardOnFocus_value[] = { { .i32 = enableKeyboardOnFocus } }; + ArkUI_AttributeItem enableKeyboardOnFocus_item = { enableKeyboardOnFocus_value, + sizeof(enableKeyboardOnFocus_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_ENABLE_KEYBOARD_ON_FOCUS, &enableKeyboardOnFocus_item); + + return nodeHandle; +} + +napi_value TextAreaEnableKeyboardOnFocusTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textArea = createChildNode(nodeAPI, PARAM_1, "enable"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, textArea); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextAreaEnableKeyboardOnFocusTest::CreateNativeNodeDisableKeyBoard(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textArea2 = createChildNode(nodeAPI, PARAM_0, "disable"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, textArea2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +napi_value TextAreaEnableKeyboardOnFocusTest::CreateNativeNodeAbnormal(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textArea3 = createChildNode(nodeAPI, PARAM_NEGATIVE_1, "abnormal"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, textArea3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextAreaEnableKeyboardOnFocusTest::CreateNativeNodeReset(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textArea4 = createChildNode(nodeAPI, 0, "reset"); + + nodeAPI->resetAttribute(textArea4, NODE_TEXT_AREA_ENABLE_KEYBOARD_ON_FOCUS); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, textArea4); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnableKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enablekeyboardonfocus_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enablekeyboardonfocus_test.h new file mode 100644 index 0000000000000000000000000000000000000000..638412ef4d9195e5f2112be728a76fce506bfe02 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enablekeyboardonfocus_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_ENABLEKEYBOARDONFOCUS_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_ENABLEKEYBOARDONFOCUS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaEnableKeyboardOnFocusTest { +public: + ~TextAreaEnableKeyboardOnFocusTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeDisableKeyBoard(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeAbnormal(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeReset(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_ENABLEKEYBOARDONFOCUS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enterkeytype_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enterkeytype_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d7e323f69bead5d4138a66ad4697196b504a3825 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enterkeytype_test.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_enterkeytype_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t enterKeyType, char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + ArkUI_NumberValue enterKeyType_value[] = { { .i32 = enterKeyType } }; + ArkUI_AttributeItem enterKeyType_item = { enterKeyType_value, + sizeof(enterKeyType_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_ENTER_KEY_TYPE, &enterKeyType_item); + + return nodeHandle; +} + +napi_value TextAreaEnterKeyTypeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnterKeyTypeTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnterKeyTypeTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textAreaFirst = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_GO, "OnClickTypeGo"); + auto textAreaFirstEnd = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_SEARCH, "OnClickTypeSearch"); + auto textAreaSecond = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_SEND, "OnClickTypeSend"); + auto textAreaSecondEnd = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_NEXT, "OnClickTypeNext"); + auto textAreaThird = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_DONE, "OnClickTypeDone"); + auto textAreaThirdEnd = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_PREVIOUS, "OnClickTypePrevious"); + auto textAreaFourth = createChildNode(nodeAPI, ARKUI_ENTER_KEY_TYPE_NEW_LINE, "OnClickTypeNewLine"); + auto textAreaFourthEnd = createChildNode(nodeAPI, PARAM_NEGATIVE_1, "OnClickAbnormal"); + + auto rowFirst = nodeAPI->createNode(ARKUI_NODE_ROW); + auto rowSecond = nodeAPI->createNode(ARKUI_NODE_ROW); + auto rowThird = nodeAPI->createNode(ARKUI_NODE_ROW); + auto rowFourth = nodeAPI->createNode(ARKUI_NODE_ROW); + nodeAPI->addChild(rowFirst, textAreaFirst); + nodeAPI->addChild(rowFirst, textAreaFirstEnd); + nodeAPI->addChild(rowSecond, textAreaSecond); + nodeAPI->addChild(rowSecond, textAreaSecondEnd); + nodeAPI->addChild(rowThird, textAreaThird); + nodeAPI->addChild(rowThird, textAreaThirdEnd); + nodeAPI->addChild(rowFourth, textAreaFourth); + nodeAPI->addChild(rowFourth, textAreaFourthEnd); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + ArkUI_NumberValue col_height_value[] = { { .f32 = 800 } }; + ArkUI_AttributeItem col_height_item = { col_height_value, sizeof(col_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_HEIGHT, &col_height_item); + // set alignment + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_END } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + nodeAPI->addChild(column, rowFirst); + nodeAPI->addChild(column, rowSecond); + nodeAPI->addChild(column, rowThird); + nodeAPI->addChild(column, rowFourth); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaEnterKeyTypeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enterkeytype_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enterkeytype_test.h new file mode 100644 index 0000000000000000000000000000000000000000..4b7954d29798c7576a8610c0ddd4bf8f2bccdf02 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_enterkeytype_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_ENTERKEYTYPE_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_ENTERKEYTYPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaEnterKeyTypeTest { +public: + ~TextAreaEnterKeyTypeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_ENTERKEYTYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_fontfeature_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_fontfeature_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..88bd804f23e9f3b06088cf62462d12923dbf7680 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_fontfeature_test.cpp @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_fontfeature_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static ArkUI_NodeHandle textArea; +static ArkUI_NodeHandle column; +static ArkUI_NativeNodeAPI_1* nodeAPI; + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* value, char* text) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set id + ArkUI_AttributeItem value_item = {}; + value_item.string = value; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_FEATURE, &value_item); + + ArkUI_AttributeItem text_item = {}; + text_item.string = text; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT, &text_item); + + // width + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // height + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // margin + ArkUI_NumberValue margin_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + return nodeHandle; +} + +napi_value TextAreaFontFeatureTest::CreateNativeNodeFirst(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaFontfeatureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textArea1 = createChildNode(nodeAPI, "\"ss01\" on", "0123456789,;//\\-‱%℃℉"); + auto textArea2 = createChildNode(nodeAPI, "\"ss01\" off", "0123456789,;//\\-‱%℃℉"); + auto textArea3 = createChildNode(nodeAPI, "\"ss02\" on", "0123456789,;//\\-‱%℃℉"); + auto textArea4 = createChildNode(nodeAPI, "\"ss02\" off", "0123456789,;//\\-‱%℃℉"); + auto textArea5 = createChildNode(nodeAPI, "\"ss03\" on", ":+-×÷=≠><≥≤±≈~﹁"); + auto textArea6 = createChildNode(nodeAPI, "\"ss03\" off", ":+-×÷=≠><≥≤±≈~﹁"); + auto textArea7 = createChildNode(nodeAPI, "\"ss04\" on", "llllllllll"); + auto textArea8 = createChildNode(nodeAPI, "\"ss04\" off", "llllllllll"); + auto textArea9 = + createChildNode(nodeAPI, "\"ss05\" on", "€¢|¦№¤$₫₣₤₱£₦₨₩₪₱₮₡¥₥₭₰+-×÷=≠<>≤≥±≈~∟^∞∧∨∩∪∫Ω△∏∑√‰μδ|"); + auto textArea10 = + createChildNode(nodeAPI, "\"ss05\" off", "€¢|¦№¤$₫₣₤₱£₦₨₩₪₱₮₡¥₥₭₰+-×÷=≠<>≤≥±≈~∟^∞∧∨∩∪∫Ω△∏∑√‰μδ|"); + auto textArea11 = createChildNode(nodeAPI, "\"ss08\" on", "{〈《「『【(〔、。!,:;?}〉》」』】〕〗)〕"); + auto textArea12 = createChildNode(nodeAPI, "\"ss08\" off", "{〈《「『【(〔、。!,:;?}〉》」』】〕〗)〕"); + auto textArea13 = createChildNode(nodeAPI, "\"ss09\" on", "0123456789"); + auto textArea14 = createChildNode(nodeAPI, "\"ss09\" off", "0123456789"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + nodeAPI->addChild(column, textArea4); + nodeAPI->addChild(column, textArea5); + nodeAPI->addChild(column, textArea6); + nodeAPI->addChild(column, textArea7); + nodeAPI->addChild(column, textArea8); + nodeAPI->addChild(column, textArea9); + nodeAPI->addChild(column, textArea10); + nodeAPI->addChild(column, textArea11); + nodeAPI->addChild(column, textArea12); + nodeAPI->addChild(column, textArea13); + nodeAPI->addChild(column, textArea14); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaFontfeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextAreaFontFeatureTest::CreateNativeNodeSecond(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaFontfeatureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textArea15 = createChildNode(nodeAPI, "\"ss10\" on", "0123456789"); + auto textArea16 = createChildNode(nodeAPI, "\"ss10\" off", "0123456789"); + auto textArea17 = createChildNode(nodeAPI, "\"frac\" on", "1/2 1/4"); + auto textArea18 = createChildNode(nodeAPI, "\"frac\" off", "1/2 1/4"); + auto textArea19 = createChildNode(nodeAPI, "\"sups\" on", "0123456789"); + auto textArea20 = createChildNode(nodeAPI, "\"sups\" off", "0123456789"); + auto textArea21 = createChildNode(nodeAPI, "\"subs\" on", "0123456789"); + auto textArea22 = createChildNode(nodeAPI, "\"subs\" off", "0123456789"); + auto textArea23 = createChildNode(nodeAPI, "\"numr\" on", "0123456789"); + auto textArea24 = createChildNode(nodeAPI, "\"numr\" off", "0123456789"); + auto textArea25 = createChildNode(nodeAPI, "\"dnom\" on", "0123456789"); + auto textArea26 = createChildNode(nodeAPI, "\"dnom\" off", "0123456789"); + auto textArea27 = createChildNode(nodeAPI, "\"case\" on", "!¡?¿"); + auto textArea28 = createChildNode(nodeAPI, "\"case\" off", "!¡?¿"); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + nodeAPI->addChild(column, textArea15); + nodeAPI->addChild(column, textArea16); + nodeAPI->addChild(column, textArea17); + nodeAPI->addChild(column, textArea18); + nodeAPI->addChild(column, textArea19); + nodeAPI->addChild(column, textArea20); + nodeAPI->addChild(column, textArea21); + nodeAPI->addChild(column, textArea22); + nodeAPI->addChild(column, textArea23); + nodeAPI->addChild(column, textArea24); + nodeAPI->addChild(column, textArea25); + nodeAPI->addChild(column, textArea26); + nodeAPI->addChild(column, textArea27); + nodeAPI->addChild(column, textArea28); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaFontfeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextAreaFontFeatureTest::CreateNativeNodeThird(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaFontfeatureTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto textArea29 = createChildNode(nodeAPI, "\"tnum\" on", "0123456789"); + auto textArea30 = createChildNode(nodeAPI, "\"tnum\" off", "0123456789"); + auto textArea31 = createChildNode(nodeAPI, "\"pnum\" on", "0123456789"); + auto textArea32 = createChildNode(nodeAPI, "\"pnum\" off", "0123456789"); + auto textArea33 = createChildNode(nodeAPI, "\"vert\" on", "【】()"); + auto textArea34 = createChildNode(nodeAPI, "\"vert\" off", "【】()"); + auto textArea35 = createChildNode(nodeAPI, "\"vrt2\" on", "【】()"); + auto textArea36 = createChildNode(nodeAPI, "\"vrt2\" off", "【】()"); + auto textArea37 = createChildNode(nodeAPI, "\"liga\" on", "ff fl fi ffi ffl"); + auto textArea38 = createChildNode(nodeAPI, "\"liga\" off", "ff fl fi ffi ffl"); + auto textArea39 = createChildNode(nodeAPI, "\"ordn\" on", "No.1 1a 1o"); + auto textArea40 = createChildNode(nodeAPI, "\"ordn\" off", "No.1 1a 1o"); + auto textArea41 = createChildNode(nodeAPI, "\"sinf\" on", "0123456789"); + auto textArea42 = createChildNode(nodeAPI, "\"sinf\" off", "0123456789"); + + nodeAPI->addChild(column, textArea29); + nodeAPI->addChild(column, textArea30); + nodeAPI->addChild(column, textArea31); + nodeAPI->addChild(column, textArea32); + nodeAPI->addChild(column, textArea33); + nodeAPI->addChild(column, textArea34); + nodeAPI->addChild(column, textArea35); + nodeAPI->addChild(column, textArea36); + nodeAPI->addChild(column, textArea37); + nodeAPI->addChild(column, textArea38); + nodeAPI->addChild(column, textArea39); + nodeAPI->addChild(column, textArea40); + nodeAPI->addChild(column, textArea41); + nodeAPI->addChild(column, textArea42); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaFontfeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_fontfeature_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_fontfeature_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7e3895b0d6e2a804146c0de72ac302422dc8c731 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_fontfeature_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_FONTFEATURE_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_FONTFEATURE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaFontFeatureTest { +public: + ~TextAreaFontFeatureTest(); + static napi_value CreateNativeNodeFirst(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeSecond(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeThird(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_FONTFEATURE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_getcaretoffset_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_getcaretoffset_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ebf46618e0c8443aea2a4b9c1dbe8c46ebd75499 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_getcaretoffset_test.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_getcaretoffset_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text1; + +static ArkUI_NodeHandle textArea1; + +ArkUI_NodeHandle TextAreaGetCaretOffsetTest::CreateSubTextAreaNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 200; + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "Text"; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &content_item); + + ArkUI_NumberValue value[] = { { .f32 = 45 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_FONT_SIZE, &value_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + return textArea; +} +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaGetCareOffsetTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaGetCareOffsetTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaGetCareOffsetTest", "OnEventReceive eventId: %{public}d", + eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + if (eventId == ON_CHANGE_EVENT_ID) { + auto result1 = nodeAPI->getAttribute(textArea1, NODE_TEXT_AREA_CARET_OFFSET); + if (result1 == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", + "Failed to get caret offset attribute"); + return; + } + std::string str1 = "index:" + std::to_string(result1->value[0].i32); + + ArkUI_AttributeItem getTextContentLineCount_item = {}; + getTextContentLineCount_item.string = str1.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &getTextContentLineCount_item); + + return; + } +} + +napi_value TextAreaGetCaretOffsetTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaGetCareOffsetTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaGetCareOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + text1 = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TextAreaGetCareOffsetTest"; + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &content_item); + + ArkUI_NumberValue value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_FONT_SIZE, &value_item); + + textArea1 = CreateSubTextAreaNode(nodeAPI); + + ArkUI_AttributeItem id_item1 = {}; + id_item1.string = "TextAreaGetCaretOffsetTest_textArea_id1"; + nodeAPI->setAttribute(textArea1, NODE_ID, &id_item1); + + nodeAPI->registerNodeEvent(textArea1, NODE_TEXT_AREA_ON_CHANGE, ON_CHANGE_EVENT_ID, nodeAPI); + + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, text1); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaGetCareOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_getcaretoffset_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_getcaretoffset_test.h new file mode 100644 index 0000000000000000000000000000000000000000..28e8a4b49757750f66c5397a21e0212fdee48c3c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_getcaretoffset_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_GETCARETOFFSET_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_GETCARETOFFSET_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaGetCaretOffsetTest { +public: + ~TextAreaGetCaretOffsetTest(); + static ArkUI_NodeHandle CreateSubTextAreaNode(ArkUI_NativeNodeAPI_1* nodeApi); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_TEXTAREA_GETCARETOFFSET_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_inputfilter_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_inputfilter_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd99b8cb1de32ec3bf98d97e57cfc169b7d532f4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_inputfilter_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE 2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_inputfilter_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* str) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + // set str + ArkUI_AttributeItem textAreaItem = {}; + textAreaItem.string = str; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_INPUT_FILTER, &textAreaItem); + + ArkUI_NumberValue value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + nodeAPI->registerNodeEvent(nodeHandle, NODE_TEXT_AREA_ON_INPUT_FILTER_ERROR, ON_CHANGE_EVENT_ID, nullptr); + + return nodeHandle; +} + +static void EventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonEventOnClickTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonEventOnClickTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonEventOnClickTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CHANGE_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + return; + } +} + +napi_value TextAreaInputFilterTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaInputFilterTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaInputFilterTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + const char* srcLocal1 = "[\u4e00-\u9fa5a-yA-Z1-9{}()(^&*;;“”\'\"+_——]|(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-" + "9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))"; + auto textArea = CreateSubTextInputNode(nodeAPI, srcLocal1); + auto textArea2 = CreateSubTextInputNode(nodeAPI, nullptr); + auto textArea3 = CreateSubTextInputNode(nodeAPI, srcLocal1); + + nodeAPI->resetAttribute(textArea3, NODE_TEXT_AREA_INPUT_FILTER); + + ArkUI_AttributeItem item = {}; + item.string = "@#$%^&*';\'()123456789zZABCDEFGHIJKLMN-1-9-80,-4.9,4.9"; + nodeAPI->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &item); + nodeAPI->setAttribute(textArea2, NODE_TEXT_AREA_TEXT, &item); + nodeAPI->setAttribute(textArea3, NODE_TEXT_AREA_TEXT, &item); + + nodeAPI->addChild(column, textArea); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + + nodeAPI->registerNodeEventReceiver(&EventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaInputFilterTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_inputfilter_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_inputfilter_test.h new file mode 100644 index 0000000000000000000000000000000000000000..3fefd592d1295ff456826f3b8ac6e713ba01e7c6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_inputfilter_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_INPUTFILTER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_INPUTFILTER_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaInputFilterTest { +public: + ~TextAreaInputFilterTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_INPUTFILTER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_maxlines_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_maxlines_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b4621a2a5073692080ee1ecbad9ab3079a98ae99 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_maxlines_test.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_maxlines_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextAreaNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 80 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set maxlines + ArkUI_NumberValue lines_value[] = { { .i32 = value } }; + ArkUI_AttributeItem lines_item = { lines_value, sizeof(lines_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_MAX_LINES, &lines_item); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &Border_Item_1); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &marginItem); + + return nodeHandle; +} + +napi_value TextAreaMaxLinesTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaMaxLinesTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaMaxLinesTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // create textarea + auto textarea1 = CreateSubTextAreaNode(nodeAPI, 1); + auto textarea2 = CreateSubTextAreaNode(nodeAPI, -1); + auto textarea3 = CreateSubTextAreaNode(nodeAPI, 1); + auto textarea4 = CreateSubTextAreaNode(nodeAPI, 100); + auto textarea5 = CreateSubTextAreaNode(nodeAPI, -1); + auto textarea6 = CreateSubTextAreaNode(nodeAPI, 1); + auto textarea7 = CreateSubTextAreaNode(nodeAPI, 1); + auto textarea8 = CreateSubTextAreaNode(nodeAPI, 1); + auto textarea9 = CreateSubTextAreaNode(nodeAPI, 1); + nodeAPI->resetAttribute(textarea9, NODE_TEXT_MAX_LINES); + + // set textoverflow + ArkUI_NumberValue over_value[] = { { .i32 = ARKUI_TEXT_OVERFLOW_ELLIPSIS } }; + ArkUI_AttributeItem over_item = { over_value, sizeof(over_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textarea1, NODE_TEXT_OVERFLOW, &over_item); + nodeAPI->setAttribute(textarea2, NODE_TEXT_OVERFLOW, &over_item); + nodeAPI->setAttribute(textarea4, NODE_TEXT_OVERFLOW, &over_item); + nodeAPI->setAttribute(textarea5, NODE_TEXT_OVERFLOW, &over_item); + nodeAPI->setAttribute(textarea8, NODE_TEXT_OVERFLOW, &over_item); + + // set 7、8 inline style + ArkUI_NumberValue style_value[] = { { .i32 = ARKUI_TEXTINPUT_STYLE_INLINE } }; + ArkUI_AttributeItem style_item = { style_value, sizeof(style_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textarea6, NODE_TEXT_INPUT_STYLE, &style_item); + nodeAPI->setAttribute(textarea7, NODE_TEXT_INPUT_STYLE, &style_item); + nodeAPI->setAttribute(textarea8, NODE_TEXT_INPUT_STYLE, &style_item); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = "textArea7"; + nodeAPI->setAttribute(textarea7, NODE_ID, &id_item); + + // text into column + nodeAPI->addChild(column, textarea1); + nodeAPI->addChild(column, textarea2); + nodeAPI->addChild(column, textarea3); + nodeAPI->addChild(column, textarea4); + nodeAPI->addChild(column, textarea5); + nodeAPI->addChild(column, textarea6); + nodeAPI->addChild(column, textarea7); + nodeAPI->addChild(column, textarea8); + nodeAPI->addChild(column, textarea9); + + // set text + ArkUI_AttributeItem text_item = {}; + text_item.string = "Test the maximum number of lines in text attribute of the C API"; + nodeAPI->setAttribute(textarea1, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea2, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea3, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea4, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea5, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea6, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea7, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea8, NODE_TEXT_AREA_TEXT, &text_item); + nodeAPI->setAttribute(textarea9, NODE_TEXT_AREA_TEXT, &text_item); + + // XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaMaxLinesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_maxlines_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_maxlines_test.h new file mode 100644 index 0000000000000000000000000000000000000000..e399c8b92ad2fa54474fee275d4d2495a2f491a5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_maxlines_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_AREA_MAXLINES_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_AREA_MAXLINES_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaMaxLinesTest { +public: + ~TextAreaMaxLinesTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_AREA_MAXLINES_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_numberoflines_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_numberoflines_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cc795481f0b336d553e9861496911ce10532effd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_numberoflines_test.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_numberoflines_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateSubTextAreaNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t value) +{ + float width = 200; + float height = 100; + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_MARGIN, &marginItem); + + ArkUI_NumberValue Line_Value_1[] = { { .i32 = value } }; + ArkUI_AttributeItem Line_Item_1 = { Line_Value_1, sizeof(Line_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_NUMBER_OF_LINES, &Line_Item_1); + + ArkUI_AttributeItem textInput_id_item = {}; + textInput_id_item.string = "line1\nline2\nline3\nline4"; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &textInput_id_item); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_BORDER_WIDTH, &Border_Item_1); + + return textArea; +} + +ArkUI_NodeHandle CreateSubTextAreaPlaceholderNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t value) +{ + float width = 200; + float height = 100; + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_MARGIN, &marginItem); + + ArkUI_AttributeItem textInput_id_item = {}; + textInput_id_item.string = "line1\nline2\nline3\nline4"; + nodeApi->setAttribute(textArea, NODE_TEXT_INPUT_PLACEHOLDER, &textInput_id_item); + + ArkUI_NumberValue Line_Value_1[] = { { .i32 = value } }; + ArkUI_AttributeItem Line_Item_1 = { Line_Value_1, sizeof(Line_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_NUMBER_OF_LINES, &Line_Item_1); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_BORDER_WIDTH, &Border_Item_1); + ; + + return textArea; +} + +napi_value TextAreaNumberOfLinesTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaNumberOfLinesTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaNumberOfLinesTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto textArea_1 = CreateSubTextAreaNode(nodeAPI, 0); + auto textArea_2 = CreateSubTextAreaNode(nodeAPI, 3); + auto textArea_3 = CreateSubTextAreaNode(nodeAPI, 3); + auto textArea_4 = CreateSubTextAreaPlaceholderNode(nodeAPI, 0); + auto textArea_5 = CreateSubTextAreaNode(nodeAPI, 3); + auto textInput_reset = CreateSubTextAreaNode(nodeAPI, 100); + auto textArea_6 = CreateSubTextAreaNode(nodeAPI, 100); + + ArkUI_NumberValue font_Value_4[] = { { .f32 = 25 } }; + ArkUI_AttributeItem font_Item_4 = { font_Value_4, sizeof(font_Value_4) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea_4, NODE_TEXT_AREA_PLACEHOLDER_FONT, &font_Item_4); + + ArkUI_NumberValue lineHeight_Value_3[] = { { .f32 = 12 } }; + ArkUI_AttributeItem lineHeight_Item_3 = { lineHeight_Value_3, + sizeof(lineHeight_Value_3) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea_3, NODE_TEXT_LINE_HEIGHT, &lineHeight_Item_3); + + ArkUI_NumberValue line_Value[] = { { .i32 = 1 } }; + ArkUI_AttributeItem line_Item = { line_Value, sizeof(line_Value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea_5, NODE_TEXT_MAX_LINES, &line_Item); + + nodeAPI->resetAttribute(textInput_reset, NODE_TEXT_AREA_NUMBER_OF_LINES); + + nodeAPI->addChild(column, textArea_1); + nodeAPI->addChild(column, textArea_2); + nodeAPI->addChild(column, textArea_3); + nodeAPI->addChild(column, textArea_4); + nodeAPI->addChild(column, textInput_reset); + nodeAPI->addChild(column, textArea_5); + nodeAPI->addChild(column, textArea_6); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaNumberOfLinesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_numberoflines_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_numberoflines_test.h new file mode 100644 index 0000000000000000000000000000000000000000..98bb4217ca1faa8ccf1838c0e9faa6953e636e53 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_numberoflines_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_NUMBEROFLINES_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_NUMBEROFLINES_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaNumberOfLinesTest { +public: + ~TextAreaNumberOfLinesTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_TEXTAREA_NUMBEROFLINES_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectedbackgroundcolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectedbackgroundcolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a5313aa6eeff0f161e1f9a68a96d16a6a40fc2dd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectedbackgroundcolor_test.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_selectedbackgroundcolor_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define COLOR_TRANSPARENT_RED 0x77FF0000 + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t color, char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue marginValue[] = { { .f32 = 10 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &marginItem); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_AttributeItem text_value = {}; + text_value.string = "123456789"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT, &text_value); + + // select all + ArkUI_NumberValue textInput_select_all_value[] = { { .i32 = -1 } }; + ArkUI_AttributeItem textInput_select_all_item = { textInput_select_all_value, + sizeof(textInput_select_all_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT_SELECTION, &textInput_select_all_item); + + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + + ArkUI_NumberValue keyboard1_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard1_item = { keyboard1_value, sizeof(keyboard1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard1_item); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + // set color + ArkUI_NumberValue color_value[] = { { .i32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SELECTED_BACKGROUND_COLOR, &color_item); + + ArkUI_NumberValue value[] = { { .f32 = 45 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + return nodeHandle; +} + +napi_value TextAreaSelectedBackgroundColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSelectedBackgroundColorTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSelectedBackgroundColorTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto textInput = CreateSubTextInputNode(nodeAPI, COLOR_GREEN, "green"); + auto textInput2 = CreateSubTextInputNode(nodeAPI, -1, "textAreaAbnormal"); + auto textInput3 = CreateSubTextInputNode(nodeAPI, COLOR_GREEN, "textAreaReset"); + + nodeAPI->resetAttribute(textInput3, NODE_TEXT_AREA_SELECTED_BACKGROUND_COLOR); + + // parent node + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + nodeAPI->addChild(column, textInput); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSelectedBackgroundColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectedbackgroundcolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectedbackgroundcolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0e3737c82448a8c97230bcefcef4a6da6d40631d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectedbackgroundcolor_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_SELECTEDBACKGROUNDCOLOR_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_SELECTEDBACKGROUNDCOLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaSelectedBackgroundColorTest { +public: + ~TextAreaSelectedBackgroundColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_SELECTEDBACKGROUNDCOLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectionmenuhidden_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectionmenuhidden_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..640fd9ec86028423389d2fb56b4b8a0cb5f6dc77 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectionmenuhidden_test.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_selectionmenuhidden_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set text + ArkUI_AttributeItem text_item = {}; + text_item.string = "test"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT, &text_item); + + // set selectall + ArkUI_NumberValue select_value[] = { { .i32 = 0 }, { .i32 = sizeof(text_item) / sizeof(ArkUI_AttributeItem) } }; + ArkUI_AttributeItem select_item = { select_value, sizeof(select_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT_SELECTION, &select_item); + + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + + ArkUI_NumberValue keyboard1_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard1_item = { keyboard_value, sizeof(keyboard1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard1_item); + + ArkUI_NumberValue show_value[] = { { .i32 = value } }; + ArkUI_AttributeItem show_item = { show_value, sizeof(show_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SELECTION_MENU_HIDDEN, &show_item); + + ArkUI_NumberValue fontsize[] = { { .f32 = 40 } }; + ArkUI_AttributeItem fontsize_item = { fontsize, sizeof(fontsize) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &fontsize_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + return nodeHandle; +} + +napi_value TextAreaSelectionMenuHiddenTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSelectionMenuHiddenTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSelectionMenuHiddenTest", "GetContext env or info is null"); + return nullptr; + } + // create nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // textArea + auto textArea = CreateSubTextInputNode(nodeAPI, 1); + auto textArea2 = CreateSubTextInputNode(nodeAPI, 0); + auto textArea3 = CreateSubTextInputNode(nodeAPI, -1); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = "textArea1"; + nodeAPI->setAttribute(textArea, NODE_ID, &id_item); + + ArkUI_AttributeItem id2_item = {}; + id2_item.string = "textArea2"; + nodeAPI->setAttribute(textArea2, NODE_ID, &id2_item); + + ArkUI_AttributeItem id3_item = {}; + id2_item.string = "textArea3"; + nodeAPI->setAttribute(textArea3, NODE_ID, &id2_item); + + // insert into the column + + nodeAPI->addChild(column, textArea); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSelectionMenuHiddenTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectionmenuhidden_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectionmenuhidden_test.h new file mode 100644 index 0000000000000000000000000000000000000000..8f264b297922b0dd395041ffaa16abcaf7bda19d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_selectionmenuhidden_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_SELECTIONMENUHIDDEN_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_SELECTIONMENUHIDDEN_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaSelectionMenuHiddenTest { +public: + ~TextAreaSelectionMenuHiddenTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_SELECTIONMENUHIDDEN_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_settextselection_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_settextselection_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..94ec1218afb9a458e4488318d99297b882b694f7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_settextselection_test.cpp @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "textarea_settextselection_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define ON_CLICK_1 6001 +#define ON_CLICK_2 6002 +#define ON_CLICK_3 6003 +#define ON_CLICK_4 6004 + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text1; + +static ArkUI_NodeHandle textArea1; + +ArkUI_NodeHandle CreateTextAreaNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 280; + auto textArea = nodeApi->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_HEIGHT, &heightItem); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TextArea"; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_TEXT, &content_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_NumberValue value[] = { { .f32 = 55 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textArea, NODE_FONT_SIZE, &value_item); + + return textArea; +} + +static auto CreatButton(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandler = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &height_item); + + return nodeHandler; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaSetTextSelectionTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSetTextSelectionTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaSetTextSelectionTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + switch (eventId) { + case ON_CLICK_1: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = 0 }, { .i32 = 4 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + case ON_CLICK_2: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = -1 }, { .i32 = -1 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + case ON_CLICK_3: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = 0 }, { .i32 = 100 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + case ON_CLICK_4: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = 7 }, { .i32 = 2 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + default: { + return; + } + } +} + +napi_value TextAreaSetTextSelectionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSetTextSelectionTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSetTextSelectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + textArea1 = CreateTextAreaNode(nodeAPI); + + ArkUI_AttributeItem id_item = {}; + id_item.string = "TextAreaSetTextSelectionTest_textArea_id1"; + nodeAPI->setAttribute(textArea1, NODE_ID, &id_item); + + auto button1 = CreatButton(nodeAPI); + auto button2 = CreatButton(nodeAPI); + auto button3 = CreatButton(nodeAPI); + auto button4 = CreatButton(nodeAPI); + + ArkUI_AttributeItem id_item1 = {}; + id_item1.string = "TextAreaSetTextSelectionTest_id1"; + nodeAPI->setAttribute(button1, NODE_ID, &id_item1); + + ArkUI_AttributeItem id_item2 = {}; + id_item2.string = "TextAreaSetTextSelectionTest_id2"; + nodeAPI->setAttribute(button2, NODE_ID, &id_item2); + + ArkUI_AttributeItem id_item3 = {}; + id_item3.string = "TextAreaSetTextSelectionTest_id3"; + nodeAPI->setAttribute(button3, NODE_ID, &id_item3); + + ArkUI_AttributeItem id_item4 = {}; + id_item4.string = "TextAreaSetTextSelectionTest_id4"; + nodeAPI->setAttribute(button4, NODE_ID, &id_item4); + + ArkUI_AttributeItem button_item1 = {}; + button_item1.string = "选中0-4"; + nodeAPI->setAttribute(button1, NODE_BUTTON_LABEL, &button_item1); + + button_item1.string = "选中-1 - -1"; + nodeAPI->setAttribute(button2, NODE_BUTTON_LABEL, &button_item1); + + button_item1.string = "选中0-100"; + nodeAPI->setAttribute(button3, NODE_BUTTON_LABEL, &button_item1); + + button_item1.string = "选中7-2"; + nodeAPI->setAttribute(button4, NODE_BUTTON_LABEL, &button_item1); + + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_1, nodeAPI); + nodeAPI->registerNodeEvent(button2, NODE_ON_CLICK, ON_CLICK_2, nodeAPI); + nodeAPI->registerNodeEvent(button3, NODE_ON_CLICK, ON_CLICK_3, nodeAPI); + nodeAPI->registerNodeEvent(button4, NODE_ON_CLICK, ON_CLICK_4, nodeAPI); + + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, button1); + nodeAPI->addChild(column, button2); + nodeAPI->addChild(column, button3); + nodeAPI->addChild(column, button4); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaSetTextSelectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_settextselection_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_settextselection_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2d91254c7cdfe29d8b7eac7b7fe270520676f700 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_settextselection_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_SETTEXTSELECTION_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_SETTEXTSELECTION_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaSetTextSelectionTest { +public: + ~TextAreaSetTextSelectionTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_SETTEXTSELECTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showcounter_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showcounter_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4ec4683da532680a9286299856e1920955f1199 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showcounter_test.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_showcounter_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode( + ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value, float_t value2, int32_t value3, char* id, const char* content) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue length_value[] = { { .i32 = 3 } }; + ArkUI_AttributeItem length_item = { length_value, sizeof(length_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_MAX_LENGTH, &length_item); + + ArkUI_AttributeItem text_item = {}; + text_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT, &text_item); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + ArkUI_NumberValue show_value[] = { { .i32 = value }, { .f32 = value2 }, { .i32 = value3 } }; + ArkUI_AttributeItem show_item = { show_value, sizeof(show_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SHOW_COUNTER, &show_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + return nodeHandle; +} + +napi_value TextAreaShowCounterTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowCounterTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowCounterTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // textArea + auto textArea = CreateSubTextInputNode(nodeAPI, true, 100, true, "normal", "te1s"); + auto textArea2 = CreateSubTextInputNode(nodeAPI, true, 100, false, "showNumber", "te2s"); + auto textArea3 = CreateSubTextInputNode(nodeAPI, true, -1, true, "blankFirst", "te3s"); + auto textArea4 = CreateSubTextInputNode(nodeAPI, true, -1, false, "blankSecond", "te4s"); + auto textArea5 = CreateSubTextInputNode(nodeAPI, false, 100, true, "abNormal", "te5s"); + auto textArea6 = CreateSubTextInputNode(nodeAPI, true, 100, true, "reset", "te6s"); + + nodeAPI->resetAttribute(textArea6, NODE_TEXT_AREA_SHOW_COUNTER); + // insert into the column + nodeAPI->addChild(column, textArea); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + nodeAPI->addChild(column, textArea4); + nodeAPI->addChild(column, textArea5); + nodeAPI->addChild(column, textArea6); + + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowCounterTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showcounter_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showcounter_test.h new file mode 100644 index 0000000000000000000000000000000000000000..38636dd9f33f4e9112758390673f524930041318 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showcounter_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_SHOWCOUNTER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_SHOWCOUNTER_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaShowCounterTest { +public: + ~TextAreaShowCounterTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_SHOWCOUNTER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showkeyboardonfocus_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showkeyboardonfocus_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..344bab7bab31886dd58dba277a6be4647ac76295 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showkeyboardonfocus_test.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_showkeyboardonfocus_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue blur_value[] = { { .i32 = value } }; + ArkUI_AttributeItem blur_item = { blur_value, sizeof(blur_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, &blur_item); + + ArkUI_NumberValue enterKeyType_value[] = { { .i32 = ARKUI_ENTER_KEY_TYPE_GO } }; + ArkUI_AttributeItem enterKeyType_item = { enterKeyType_value, + sizeof(enterKeyType_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_ENTER_KEY_TYPE, &enterKeyType_item); + + return nodeHandle; +} + +napi_value TextAreaShowKeyboardOnFocusTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaShowKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowKeyboardOnFocusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + auto textArea = createChildNode(nodeAPI, 1); + auto textArea2 = createChildNode(nodeAPI, 0); + + ArkUI_AttributeItem id_item = {}; + id_item.string = "normal"; + nodeAPI->setAttribute(textArea, NODE_ID, &id_item); + + ArkUI_AttributeItem id2_item = {}; + id2_item.string = "abnormal"; + nodeAPI->setAttribute(textArea2, NODE_ID, &id2_item); + + nodeAPI->addChild(row, textArea); + nodeAPI->addChild(row, textArea2); + nodeAPI->addChild(column, row); + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextAreaShowKeyboardOnFocusTest::CreateAbnormalNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextAreaShowKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowKeyboardOnFocusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto textArea3 = createChildNode(nodeAPI, -1); + auto textArea4 = createChildNode(nodeAPI, 0); + + nodeAPI->resetAttribute(textArea4, NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS); + ArkUI_AttributeItem id3_item = {}; + id3_item.string = "disable"; + nodeAPI->setAttribute(textArea3, NODE_ID, &id3_item); + + ArkUI_AttributeItem id4_item = {}; + id4_item.string = "reset"; + nodeAPI->setAttribute(textArea4, NODE_ID, &id4_item); + nodeAPI->addChild(row1, textArea3); + nodeAPI->addChild(row1, textArea4); + nodeAPI->addChild(column, row1); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaShowKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showkeyboardonfocus_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showkeyboardonfocus_test.h new file mode 100644 index 0000000000000000000000000000000000000000..29cd3a5e1d78e12f44b7d681acaf35653a497e71 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_showkeyboardonfocus_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_SHOWKEYBOARDONFOCUS_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_SHOWKEYBOARDONFOCUS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaShowKeyboardOnFocusTest { +public: + ~TextAreaShowKeyboardOnFocusTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateAbnormalNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_SHOWKEYBOARDONFOCUSTEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_textplaceholder_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_textplaceholder_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1215a4b92f71ce5b83b4b294fd3daeb6b39202e8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_textplaceholder_test.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_textplaceholder_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextAreaNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + return nodeHandle; +} + +napi_value TextAreaTextPlaceholderTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaTextFontfeaturePlaceholderTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaTextFontfeaturePlaceholderTest", + "GetContext env or info is null"); + return nullptr; + } + // create nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // textArea + auto textArea1 = CreateSubTextAreaNode(nodeAPI); + auto textArea2 = CreateSubTextAreaNode(nodeAPI); + + // set text + ArkUI_AttributeItem text_item = {}; + text_item.string = "texttest"; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_TEXT, &text_item); + + // set placeholder + ArkUI_AttributeItem placeholder_item = {}; + placeholder_item.string = "placeholder test"; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_PLACEHOLDER, &placeholder_item); + nodeAPI->setAttribute(textArea2, NODE_TEXT_AREA_PLACEHOLDER, &placeholder_item); + + ArkUI_NumberValue value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textArea1, NODE_TEXT_AREA_PLACEHOLDER_FONT, &value_item); + nodeAPI->setAttribute(textArea2, NODE_TEXT_AREA_PLACEHOLDER_FONT, &value_item); + + // insert into the column + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, textArea2); + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaTextFontfeaturePlaceholderTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_textplaceholder_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_textplaceholder_test.h new file mode 100644 index 0000000000000000000000000000000000000000..13e7dac5b65e2f0d5e774dec2afac4fffbf0f5b5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_textplaceholder_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTAREA_TEXTPLACEHOLDER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTAREA_TEXTPLACEHOLDER_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextAreaTextPlaceholderTest { +public: + ~TextAreaTextPlaceholderTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTAREA_TEXTPLACEHOLDER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_type_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_type_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28c1f297ef2c182b696da7c12597963b1059710a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_type_test.cpp @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textarea_type_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t type) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_AREA); + + // set type + ArkUI_NumberValue type_value[] = { { .i32 = type } }; + ArkUI_AttributeItem type_item = { type_value, sizeof(type_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TYPE, &type_item); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 250 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set keyboard + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &marginItem); + + // set text + ArkUI_AttributeItem text_item = {}; + text_item.string = "+1.2a@@3"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_TEXT, &text_item); + + ArkUI_NumberValue value[] = { { .f32 = 35 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + return nodeHandle; +} + +napi_value TextAreaTypeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaTypeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaTypeTest", "GetContext env or info is null"); + return nullptr; + } + + // parent column + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // set alignment + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_AROUND } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + + auto textArea1 = createChildNode(nodeAPI, ARKUI_TEXTAREA_TYPE_NORMAL); + auto textArea2 = createChildNode(nodeAPI, ARKUI_TEXTAREA_TYPE_NUMBER); + auto textArea3 = createChildNode(nodeAPI, ARKUI_TEXTAREA_TYPE_PHONE_NUMBER); + auto textArea4 = createChildNode(nodeAPI, ARKUI_TEXTAREA_TYPE_EMAIL); + auto textArea5 = createChildNode(nodeAPI, -1); + auto textArea6 = createChildNode(nodeAPI, 6); + auto textArea7 = createChildNode(nodeAPI, ARKUI_TEXTAREA_TYPE_NUMBER); + + nodeAPI->resetAttribute(textArea7, NODE_TEXT_AREA_TYPE); + + nodeAPI->addChild(column, textArea1); + nodeAPI->addChild(column, textArea2); + nodeAPI->addChild(column, textArea3); + nodeAPI->addChild(column, textArea4); + nodeAPI->addChild(column, textArea5); + nodeAPI->addChild(column, textArea6); + nodeAPI->addChild(column, textArea7); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextAreaTypeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_type_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_type_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0113ff0456be717b976b2e5cd0a1640bb7f8182a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textarea/textarea_type_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_XTS_CB_TEXTAREA_TYPE_TEST_H +#define ARKUI_CAPI_XTS_CB_TEXTAREA_TYPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define TEXTINPUT_WIDTH_150 150 + +class TextAreaTypeTest { +public: + ~TextAreaTypeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_XTS_CB_TEXTAREA_TYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_bluronsubmit_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_bluronsubmit_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9cdb3068016852e5d8ee906198400389b70985bb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_bluronsubmit_test.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "textinput_bluronsubmit_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +#define ON_BLUR_ID 2 +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &width_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue blur_value[] = { { .i32 = value } }; + ArkUI_AttributeItem blur_item = { blur_value, sizeof(blur_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_BLUR_ON_SUBMIT, &blur_item); + + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + + ArkUI_NumberValue keyboard1_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard1_item = { keyboard1_value, sizeof(keyboard1_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard1_item); + + return nodeHandle; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputBlurOnSubmitTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputBlurOnSubmitTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputBlurOnSubmitTest", "OnEventReceive eventId: %{public}d", + eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CHANGE_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } else if (eventId == ON_BLUR_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } +} + +napi_value TextInputBlurOnSubmitTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputBlurOnSubmitTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputBlurOnSubmitTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInputOne = createChildNode(nodeAPI, 1); + auto textInputTwo = createChildNode(nodeAPI, 0); + auto textInputThree = createChildNode(nodeAPI, -1); + + ArkUI_AttributeItem id_item = {}; + id_item.string = "OnSubmitTestTextInput"; + nodeAPI->setAttribute(textInputOne, NODE_ID, &id_item); + id_item.string = "OnSubmitTestTextInputCompare"; + nodeAPI->setAttribute(textInputTwo, NODE_ID, &id_item); + id_item.string = "OnSubmitTestTextInputAbnormal"; + nodeAPI->setAttribute(textInputThree, NODE_ID, &id_item); + + nodeAPI->addChild(column, textInputOne); + nodeAPI->addChild(column, textInputTwo); + nodeAPI->addChild(column, textInputThree); + + nodeAPI->registerNodeEvent(textInputOne, NODE_ON_FOCUS, ON_CHANGE_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInputOne, NODE_ON_BLUR, ON_BLUR_ID, nullptr); + + nodeAPI->registerNodeEvent(textInputTwo, NODE_ON_FOCUS, ON_CHANGE_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInputTwo, NODE_ON_BLUR, ON_BLUR_ID, nullptr); + + nodeAPI->registerNodeEvent(textInputThree, NODE_ON_FOCUS, ON_CHANGE_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInputThree, NODE_ON_BLUR, ON_BLUR_ID, nullptr); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputBlurOnSubmitTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_bluronsubmit_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_bluronsubmit_test.h new file mode 100644 index 0000000000000000000000000000000000000000..746972415dc1412b6065da0adda08144a3d56ce9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_bluronsubmit_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_BLURONSUBMIT_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_BLURONSUBMIT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputBlurOnSubmitTest { +public: + ~TextInputBlurOnSubmitTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_BLURONSUBMIT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_cancelbutton_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_cancelbutton_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e54f1037bfa43b3b32eb4a2fbe276ad64d660175 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_cancelbutton_test.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_cancelbutton_test.h" + +#include + +#include "../manager/plugin_manager.h" + +static ArkUI_NodeHandle text; + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t type, float_t size, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + // set type + ArkUI_NumberValue type_value[] = { { .i32 = type }, { .f32 = size }, { .u32 = color } }; + ArkUI_AttributeItem type_item = { type_value, sizeof(type_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_CANCEL_BUTTON, &type_item); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + return nodeHandle; +} + +napi_value TextInputCancelButtonTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCancelButtonTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCancelButtonTest", "GetContext env or info is null"); + return nullptr; + } + + // parent column + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // set alignment + ArkUI_NumberValue justify_content_value[] = { { .i32 = ARKUI_FLEX_ALIGNMENT_SPACE_AROUND } }; + ArkUI_AttributeItem justify_content_item = { justify_content_value, + sizeof(justify_content_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_COLUMN_JUSTIFY_CONTENT, &justify_content_item); + + // textinput + auto textInput1 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_CONSTANT, 10, COLOR_RED); + auto textInput2 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_CONSTANT, 15, COLOR_GREEN); + auto textInput3 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_INVISIBLE, 10, COLOR_RED); + auto textInput4 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_INVISIBLE, 15, COLOR_GREEN); + auto textInput5 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_INPUT, 10, COLOR_RED); + auto textInput6 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_INPUT, 15, COLOR_GREEN); + auto textInput7 = createChildNode(nodeAPI, -1, 10, COLOR_RED); + auto textInput8 = createChildNode(nodeAPI, -1, 15, COLOR_GREEN); + auto textInput9 = createChildNode(nodeAPI, 3, 10, COLOR_RED); + auto textInput10 = createChildNode(nodeAPI, 3, 15, COLOR_GREEN); + auto textInput11 = createChildNode(nodeAPI, ARKUI_CANCELBUTTON_STYLE_INVISIBLE, 10, COLOR_RED); + // text + ArkUI_AttributeItem text_item = {}; + text_item.string = ""; + ArkUI_AttributeItem text1_item = {}; + text1_item.string = + "dqr3feasdfhwieuhr2iuehfi3h2riuh3riu24hrfui24hfi2u4hfiu24fiu2bfi2ubf4i2ubfi4ubi2u4bi2ubi24ufb2i4ufbif"; + + nodeAPI->resetAttribute(textInput11, NODE_TEXT_INPUT_CANCEL_BUTTON); + + // set text + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput4, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textInput5, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput6, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textInput7, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput8, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textInput9, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput10, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textInput11, NODE_TEXT_INPUT_TEXT, &text_item); + + ArkUI_AttributeItem id_item = {}; + id_item.string = "textInput1"; + nodeAPI->setAttribute(textInput1, NODE_ID, &id_item); + + nodeAPI->addChild(column, text); + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + nodeAPI->addChild(column, textInput9); + nodeAPI->addChild(column, textInput10); + nodeAPI->addChild(column, textInput11); + + // xComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCancelButtonTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_cancelbutton_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_cancelbutton_test.h new file mode 100644 index 0000000000000000000000000000000000000000..797dc7c35b08ad291d040d5211ce3c4d6bba85bd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_cancelbutton_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_CANCELBUTTON_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_CANCELBUTTON_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +using namespace std; + +class TextInputCancelButtonTest { +public: + ~TextInputCancelButtonTest(); + static ArkUI_NodeHandle CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t value, const char* src); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_CANCELBUTTON_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_caretposition_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_caretposition_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7dd26a45698f1290e10d2cc1dd5ae43e05e8601 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_caretposition_test.cpp @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "textinput_caretposition_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define ON_CLICK_1 6001 +#define ON_CLICK_2 6002 +#define ON_CLICK_3 6003 + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text1; + +static ArkUI_NodeHandle textInput1; + +ArkUI_NodeHandle TextInputCaretPositionTest::CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 300; + auto textInput = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_HEIGHT, &heightItem); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TextInput"; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_TEXT, &content_item); + + ArkUI_NumberValue fontSizeValue[] = { { .f32 = 30 } }; + ArkUI_AttributeItem fontSizeItem = { fontSizeValue, sizeof(fontSizeValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_FONT_SIZE, &fontSizeItem); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_NumberValue keyboard1_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard1_item = { keyboard1_value, sizeof(keyboard1_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard1_item); + + return textInput; +} + +static auto CreatButton(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandler = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &height_item); + + return nodeHandler; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + switch (eventId) { + case ON_CLICK_1: { + ArkUI_NumberValue setCaretPosition_value[] = { { .i32 = 3 } }; + ArkUI_AttributeItem setCaretPosition_item = { setCaretPosition_value, + sizeof(setCaretPosition_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET, &setCaretPosition_item); + auto result = nodeAPI->getAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET); + if (result == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", + "Failed to get caret offset attribute"); + return; + } + if (text1 != nullptr) { + std::string str = "index:" + std::to_string(result->value[0].i32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } else { + std::string str = "error"; + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } + return; + } + case ON_CLICK_2: { + ArkUI_NumberValue setCaretPosition_value[] = { { .i32 = -1 } }; + ArkUI_AttributeItem setCaretPosition_item = { setCaretPosition_value, + sizeof(setCaretPosition_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET, &setCaretPosition_item); + auto result = nodeAPI->getAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET); + if (result == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", + "Failed to get caret offset attribute"); + return; + } + if (text1 != nullptr) { + std::string str = "index:" + std::to_string(result->value[0].i32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } else { + std::string str = "error"; + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } + return; + } + case ON_CLICK_3: { + ArkUI_NumberValue setCaretPosition_value[] = { { .i32 = 100 } }; + ArkUI_AttributeItem setCaretPosition_item = { setCaretPosition_value, + sizeof(setCaretPosition_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET, &setCaretPosition_item); + auto result = nodeAPI->getAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET); + if (result == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", + "Failed to get caret offset attribute"); + return; + } + if (text1 != nullptr) { + std::string str = "index:" + std::to_string(result->value[0].i32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } else { + std::string str = "error"; + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + } + return; + } + default: { + return; + } + } +} + +napi_value TextInputCaretPositionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + text1 = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue value[] = { { .f32 = 35 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_FONT_SIZE, &value_item); + + textInput1 = CreateSubTextInputNode(nodeAPI); + + auto button1 = CreatButton(nodeAPI); + auto button2 = CreatButton(nodeAPI); + auto button3 = CreatButton(nodeAPI); + + ArkUI_AttributeItem id_item1 = {}; + id_item1.string = "TextInputCaretPositionTest_buttonId1"; + nodeAPI->setAttribute(button1, NODE_ID, &id_item1); + + ArkUI_AttributeItem id_item2 = {}; + id_item2.string = "TextInputCaretPositionTest_buttonId2"; + nodeAPI->setAttribute(button2, NODE_ID, &id_item2); + + ArkUI_AttributeItem id_item3 = {}; + id_item3.string = "TextInputCaretPositionTest_buttonId3"; + nodeAPI->setAttribute(button3, NODE_ID, &id_item3); + + ArkUI_AttributeItem id_item4 = {}; + id_item4.string = "textInput1"; + nodeAPI->setAttribute(textInput1, NODE_ID, &id_item4); + + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_1, nodeAPI); + nodeAPI->registerNodeEvent(button2, NODE_ON_CLICK, ON_CLICK_2, nodeAPI); + nodeAPI->registerNodeEvent(button3, NODE_ON_CLICK, ON_CLICK_3, nodeAPI); + + ArkUI_AttributeItem button_item1 = {}; + button_item1.string = "设置光标位置3"; + nodeAPI->setAttribute(button1, NODE_BUTTON_LABEL, &button_item1); + + ArkUI_AttributeItem button_item2 = {}; + button_item2.string = "设置光标位置-1"; + nodeAPI->setAttribute(button2, NODE_BUTTON_LABEL, &button_item2); + + ArkUI_AttributeItem button_item3 = {}; + button_item3.string = "设置光标位置100"; + nodeAPI->setAttribute(button3, NODE_BUTTON_LABEL, &button_item3); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, button1); + nodeAPI->addChild(column, button2); + nodeAPI->addChild(column, button3); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCaretPositionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_caretposition_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_caretposition_test.h new file mode 100644 index 0000000000000000000000000000000000000000..cdfcf737750f59049b824112ea7dc8cba4272922 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_caretposition_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_CARETPOSITION_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_CARETPOSITION_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputCaretPositionTest { +public: + ~TextInputCaretPositionTest(); + static ArkUI_NodeHandle CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_CARETPOSITION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_content_type_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_content_type_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8db912fc6a61ce527829247748658634196d1985 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_content_type_test.cpp @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_content_type_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetOffSet(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float offSetX, float offSetY) +{ + ArkUI_NumberValue value[] = { { .f32 = offSetX }, { .f32 = offSetY } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_OFFSET, &item); + return nodeHandle; +} + +static auto setId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto setContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_TEXT, &content_item); + return nodeHandle; +} + +static auto setMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto setFontsize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float fontsize) +{ + ArkUI_NumberValue font_size_value[] = { { .f32 = fontsize } }; + ArkUI_AttributeItem font_size_item = { font_size_value, sizeof(font_size_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &font_size_item); + return nodeHandle; +} + +static auto setEnableAutoFill(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t enable) +{ + ArkUI_NumberValue value[] = { { .i32 = enable } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_ENABLE_AUTO_FILL, &item); + return nodeHandle; +} + +static auto setContentType(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t contentType) +{ + ArkUI_NumberValue value[] = { { .i32 = contentType } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_CONTENT_TYPE, &item); + return nodeHandle; +} + +static auto setTextInput( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t contentType, const char* id) +{ + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_400); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setId(nodeAPI, nodeHandle, id); + nodeHandle = setMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setFontsize(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = setEnableAutoFill(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setContentType(nodeAPI, nodeHandle, contentType); + return nodeHandle; +} + +static auto setTextInput( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* content, const char* id) +{ + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_400); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setId(nodeAPI, nodeHandle, id); + nodeHandle = setMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setFontsize(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = setEnableAutoFill(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setContent(nodeAPI, nodeHandle, content); + return nodeHandle; +} + +napi_value TextInputContentTypeTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputContentTypeTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputContentTypeTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput1); + + // 设置属性 + textInput1 = setTextInput(nodeAPI, textInput1, "18202412345", "textInput1"); + textInput2 = setTextInput(nodeAPI, textInput2, ARKUI_TEXTINPUT_CONTENT_TYPE_PHONE_NUMBER, "textInput2"); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputContentTypeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_content_type_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_content_type_test.h new file mode 100644 index 0000000000000000000000000000000000000000..1f5adfddb331d81a954f6c7c90c922706fc79c98 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_content_type_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_CONTENT_TYPE_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_CONTENT_TYPE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_21 21 + +class TextInputContentTypeTest { +public: + ~TextInputContentTypeTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_CONTENT_TYPE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_controller_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_controller_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b98bc0f31cf5154d18c9be84dd0ce3fce202c11 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_controller_test.cpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// NODE_TEXT_INPUT_CONTENT_RECT NODE_TEXT_INPUT_CONTENT_LINE_COUNT + +#include "textinput_controller_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define CONTROLLER_GET_INFORMATION 6017 +#define CONTROLLER_CHANGE_INFORMATION 1 +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text; +static ArkUI_NodeHandle textInput; +static ArkUI_NodeHandle text1; +static ArkUI_NodeHandle text2; +static ArkUI_NodeHandle text3; + +ArkUI_NodeHandle CreateText(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 200; + auto text = nodeApi->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(text, NODE_FONT_SIZE, &value_item); + return text; +} + +ArkUI_NodeHandle CreateTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 200; + float height = 200; + auto textInput = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue style_value[] = { { .i32 = ARKUI_TEXTINPUT_STYLE_INLINE } }; + ArkUI_AttributeItem style_item = { style_value, sizeof(style_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_STYLE, &style_item); + + // set maxlines + ArkUI_NumberValue lines_value[] = { { .i32 = 2 } }; + ArkUI_AttributeItem lines_item = { lines_value, sizeof(lines_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_MAX_LINES, &lines_item); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TextInput TextInput "; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_TEXT, &content_item); + + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + + ArkUI_NumberValue keyboard1_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard1_item = { keyboard1_value, sizeof(keyboard1_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard1_item); + + ArkUI_NumberValue value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_FONT_SIZE, &value_item); + + return textInput; +} + +static auto CreatButton(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandler = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &height_item); + + return nodeHandler; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputControllerTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputControllerTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + switch (eventId) { + case CONTROLLER_GET_INFORMATION: { + auto result2 = nodeAPI->getAttribute(textInput, NODE_TEXT_INPUT_CONTENT_RECT); + if (result2 == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", + "Failed to get caret offset attribute"); + return; + } + std::string str = "horizontal:" + std::to_string(result2->value[0].f32) + " vertiacal" + + std::to_string(result2->value[1].f32) + " width" + std::to_string(result2->value[2].f32) + + " height" + std::to_string(result2->value[3].f32); + ArkUI_AttributeItem setCaretPosition_content_item = {}; + setCaretPosition_content_item.string = str.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &setCaretPosition_content_item); + + auto result3 = nodeAPI->getAttribute(textInput, NODE_TEXT_INPUT_CONTENT_LINE_COUNT); + if (result3 == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", + "Failed to get caret offset attribute"); + return; + } + if (result3 != nullptr) { + str = "line:" + std::to_string(result3->value[0].i32); + ArkUI_AttributeItem line_item = {}; + line_item.string = str.c_str(); + nodeAPI->setAttribute(text2, NODE_TEXT_CONTENT, &line_item); + } + return; + } + case CONTROLLER_CHANGE_INFORMATION: { + ArkUI_AttributeItem line_item = {}; + line_item.string = "TextInput TextInput TextInput TextInput"; + nodeAPI->setAttribute(textInput, NODE_TEXT_INPUT_TEXT, &line_item); + return; + } + default: { + return; + } + } +} + +napi_value TextInputControllerTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto Input = CreateTextInputNode(nodeAPI); + textInput = Input; + + ArkUI_AttributeItem textInput_id_item = {}; + textInput_id_item.string = "TextInputControllerTest_textInput_id"; + nodeAPI->setAttribute(textInput, NODE_ID, &textInput_id_item); + + auto button_1 = CreatButton(nodeAPI); + auto button_2 = CreatButton(nodeAPI); + + ArkUI_AttributeItem button_1_content_item = {}; + button_1_content_item.string = "获取输入框信息,获取输入框行数"; + nodeAPI->setAttribute(button_1, NODE_BUTTON_LABEL, &button_1_content_item); + + button_1_content_item.string = "多行后变化"; + nodeAPI->setAttribute(button_2, NODE_BUTTON_LABEL, &button_1_content_item); + + nodeAPI->registerNodeEvent(button_1, NODE_ON_CLICK, CONTROLLER_GET_INFORMATION, nodeAPI); + nodeAPI->registerNodeEvent(button_2, NODE_ON_CLICK, CONTROLLER_CHANGE_INFORMATION, nodeAPI); + + ArkUI_AttributeItem id_item_1 = {}; + id_item_1.string = "TextInputControllerTest_button_id"; + nodeAPI->setAttribute(button_1, NODE_ID, &id_item_1); + + id_item_1.string = "TextInputControllerTest_button_id2"; + nodeAPI->setAttribute(button_2, NODE_ID, &id_item_1); + + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + + text1 = CreateText(nodeAPI); + text2 = CreateText(nodeAPI); + + nodeAPI->addChild(column, button_1); + nodeAPI->addChild(column, button_2); + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, textInput); + + nodeAPI->addChild(column, row); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_controller_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_controller_test.h new file mode 100644 index 0000000000000000000000000000000000000000..16a2111ec41b9ab5a65ee91b2ec3ef14c2f8ef6c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_controller_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_COMTROLLER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_COMTROLLER_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputControllerTest { +public: + ~TextInputControllerTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_COMTROLLER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_custom_keyboard_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_custom_keyboard_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0dafdec213ebae30c32b3e5e4fecfaffb5c09b2a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_custom_keyboard_test.cpp @@ -0,0 +1,662 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput/textinput_custom_keyboard_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle textInputGlobal; + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto setId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto setBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto setCustomKeyboard( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, ArkUI_NodeHandle keyboard, int options) +{ + ArkUI_NumberValue keyboard_value[] = { { .i32 = options } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + keyboard_item.object = keyboard; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_CUSTOM_KEYBOARD, &keyboard_item); + return nodeHandle; +} + +static auto setOther(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width, float height, char* id) +{ + nodeHandle = setWidth(nodeAPI, nodeHandle, width); + nodeHandle = setHeight(nodeAPI, nodeHandle, height); + nodeHandle = setMargin(nodeAPI, nodeHandle, PARAM_3); + nodeHandle = setId(nodeAPI, nodeHandle, id); + return nodeHandle; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CLICK_EVENT_ID_ONE) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_RED } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + if (eventId == ON_CLICK_EVENT_ID_TWO) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + } + + // 点击推出编辑 + if (eventId == ON_CLICK_EVENT_ID_THREE) { + ArkUI_NumberValue editing_value[] = { { .u32 = PARAM_0 } }; + ArkUI_AttributeItem editing_item = { editing_value, sizeof(editing_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInputGlobal, NODE_TEXT_INPUT_EDITING, &editing_item); + } + + // 点击清除焦点 + if (eventId == ON_CLICK_EVENT_ID_FOUR) { + ArkUI_NumberValue editing_value[] = { { .u32 = PARAM_0 } }; + ArkUI_AttributeItem editing_item = { editing_value, sizeof(editing_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInputGlobal, NODE_FOCUS_STATUS, &editing_item); + } +} + +napi_value TextInputCustomKeyboardTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "CreateNativeNodePage1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput1); + + auto customKeyboard = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row4 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button2 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button3 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button4 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button5 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button6 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button7 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button8 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button9 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button10 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button11 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + nodeAPI->addChild(customKeyboard, row1); + nodeAPI->addChild(customKeyboard, row2); + nodeAPI->addChild(customKeyboard, row3); + nodeAPI->addChild(customKeyboard, row4); + nodeAPI->addChild(row1, button1); + nodeAPI->addChild(row1, button2); + nodeAPI->addChild(row1, button3); + nodeAPI->addChild(row2, button4); + nodeAPI->addChild(row2, button5); + nodeAPI->addChild(row2, button6); + nodeAPI->addChild(row3, button7); + nodeAPI->addChild(row3, button8); + nodeAPI->addChild(row3, button9); + nodeAPI->addChild(row4, button10); + nodeAPI->addChild(row4, button11); + + // 设置键盘属性 + button1 = setOther(nodeAPI, button1, SIZE_100, SIZE_100, "button1"); + button2 = setOther(nodeAPI, button2, SIZE_100, SIZE_100, "button2"); + button3 = setOther(nodeAPI, button3, SIZE_100, SIZE_100, "button3"); + button4 = setOther(nodeAPI, button4, SIZE_100, SIZE_100, "button4"); + button5 = setOther(nodeAPI, button5, SIZE_100, SIZE_100, "button5"); + button6 = setOther(nodeAPI, button6, SIZE_100, SIZE_100, "button6"); + button7 = setOther(nodeAPI, button7, SIZE_100, SIZE_100, "button7"); + button8 = setOther(nodeAPI, button8, SIZE_100, SIZE_100, "button8"); + button9 = setOther(nodeAPI, button9, SIZE_100, SIZE_100, "button9"); + button10 = setOther(nodeAPI, button10, SIZE_100, SIZE_100, "button10"); + button11 = setOther(nodeAPI, button11, SIZE_100, SIZE_100, "button11"); + + // 设置textInput和button属性 + button = setOther(nodeAPI, button, SIZE_300, SIZE_600, "button"); + button = setBackgroundColor(nodeAPI, button, COLOR_BLUE); + textInput1 = setOther(nodeAPI, textInput1, SIZE_300, SIZE_50, "textInput1"); + textInput1 = setCustomKeyboard(nodeAPI, textInput1, customKeyboard, PARAM_0); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputCustomKeyboardTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "CreateNativeNodePage2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput2); + + // 自定义键盘 + auto customKeyboard = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row4 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button2 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button3 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button4 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button5 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button6 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button7 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button8 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button9 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button10 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button11 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + nodeAPI->addChild(customKeyboard, row1); + nodeAPI->addChild(customKeyboard, row2); + nodeAPI->addChild(customKeyboard, row3); + nodeAPI->addChild(customKeyboard, row4); + nodeAPI->addChild(row1, button1); + nodeAPI->addChild(row1, button2); + nodeAPI->addChild(row1, button3); + nodeAPI->addChild(row2, button4); + nodeAPI->addChild(row2, button5); + nodeAPI->addChild(row2, button6); + nodeAPI->addChild(row3, button7); + nodeAPI->addChild(row3, button8); + nodeAPI->addChild(row3, button9); + nodeAPI->addChild(row4, button10); + nodeAPI->addChild(row4, button11); + + // 设置键盘属性 + button1 = setOther(nodeAPI, button1, SIZE_100, SIZE_100, "button1"); + button2 = setOther(nodeAPI, button2, SIZE_100, SIZE_100, "button2"); + button3 = setOther(nodeAPI, button3, SIZE_100, SIZE_100, "button3"); + button4 = setOther(nodeAPI, button4, SIZE_100, SIZE_100, "button4"); + button5 = setOther(nodeAPI, button5, SIZE_100, SIZE_100, "button5"); + button6 = setOther(nodeAPI, button6, SIZE_100, SIZE_100, "button6"); + button7 = setOther(nodeAPI, button7, SIZE_100, SIZE_100, "button7"); + button8 = setOther(nodeAPI, button8, SIZE_100, SIZE_100, "button8"); + button9 = setOther(nodeAPI, button9, SIZE_100, SIZE_100, "button9"); + button10 = setOther(nodeAPI, button10, SIZE_100, SIZE_100, "button10"); + button11 = setOther(nodeAPI, button11, SIZE_100, SIZE_100, "button11"); + + // 设置textInput和button属性 + button = setOther(nodeAPI, button, SIZE_300, SIZE_600, "button"); + button = setBackgroundColor(nodeAPI, button, COLOR_BLUE); + textInput2 = setOther(nodeAPI, textInput2, SIZE_300, SIZE_50, "textInput2"); + textInput2 = setCustomKeyboard(nodeAPI, textInput2, customKeyboard, PARAM_1); + + // 注册获取点击事件 + nodeAPI->registerNodeEvent(textInput2, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputCustomKeyboardTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "CreateNativeNodePage3"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput3); + + // 自定义键盘 + auto customKeyboard = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(customKeyboard, button1); + + // 设置键盘属性 + button1 = setOther(nodeAPI, button1, SIZE_300, SIZE_400, "button1"); + + // 设置textInput和button属性 + button = setOther(nodeAPI, button, SIZE_300, SIZE_600, "button"); + button = setBackgroundColor(nodeAPI, button, COLOR_BLUE); + textInput3 = setOther(nodeAPI, textInput3, SIZE_300, SIZE_50, "textInput3"); + textInput3 = setCustomKeyboard(nodeAPI, textInput3, customKeyboard, PARAM_0); + + // 注册获取点击事件 + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_ONE, nullptr); + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_EVENT_ID_TWO, nullptr); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputCustomKeyboardTest::CreateNativeNodePage4(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "CreateNativeNodePage4"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + textInputGlobal = textInput4; + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput4); + + // 自定义键盘 + auto customKeyboard = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row4 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button2 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button3 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button4 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button5 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button6 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button7 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button8 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button9 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button10 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button11 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + nodeAPI->addChild(customKeyboard, row1); + nodeAPI->addChild(customKeyboard, row2); + nodeAPI->addChild(customKeyboard, row3); + nodeAPI->addChild(customKeyboard, row4); + nodeAPI->addChild(row1, button1); + nodeAPI->addChild(row1, button2); + nodeAPI->addChild(row1, button3); + nodeAPI->addChild(row2, button4); + nodeAPI->addChild(row2, button5); + nodeAPI->addChild(row2, button6); + nodeAPI->addChild(row3, button7); + nodeAPI->addChild(row3, button8); + nodeAPI->addChild(row3, button9); + nodeAPI->addChild(row4, button10); + nodeAPI->addChild(row4, button11); + + // 设置键盘属性 + button1 = setOther(nodeAPI, button1, SIZE_100, SIZE_30, "button1"); + button2 = setOther(nodeAPI, button2, SIZE_100, SIZE_30, "button2"); + button3 = setOther(nodeAPI, button3, SIZE_100, SIZE_30, "button3"); + button4 = setOther(nodeAPI, button4, SIZE_100, SIZE_30, "button4"); + button5 = setOther(nodeAPI, button5, SIZE_100, SIZE_30, "button5"); + button6 = setOther(nodeAPI, button6, SIZE_100, SIZE_30, "button6"); + button7 = setOther(nodeAPI, button7, SIZE_100, SIZE_30, "button7"); + button8 = setOther(nodeAPI, button8, SIZE_100, SIZE_30, "button8"); + button9 = setOther(nodeAPI, button9, SIZE_100, SIZE_30, "button9"); + button10 = setOther(nodeAPI, button10, SIZE_100, SIZE_30, "button10"); + button11 = setOther(nodeAPI, button11, SIZE_100, SIZE_30, "button11"); + + // 设置textInput和button属性 + button = setOther(nodeAPI, button, SIZE_300, SIZE_300, "button"); + button = setBackgroundColor(nodeAPI, button, COLOR_BLUE); + textInput4 = setOther(nodeAPI, textInput4, SIZE_300, SIZE_50, "textInput4"); + textInput4 = setCustomKeyboard(nodeAPI, textInput4, customKeyboard, PARAM_0); + + // 设置点击按钮失去焦点 + nodeAPI->registerNodeEvent(button, NODE_ON_CLICK, ON_CLICK_EVENT_ID_FOUR, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputCustomKeyboardTest::CreateNativeNodePage5(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "CreateNativeNodePage5"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + textInputGlobal = textInput5; + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput5); + + // 自定义键盘 + auto customKeyboard = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + nodeAPI->addChild(customKeyboard, button1); + + // 设置键盘属性 + button1 = setOther(nodeAPI, button1, SIZE_300, SIZE_400, "button1"); + + // 设置textInput和button属性 + button = setOther(nodeAPI, button, SIZE_300, SIZE_600, "button"); + button = setBackgroundColor(nodeAPI, button, COLOR_BLUE); + textInput5 = setOther(nodeAPI, textInput5, SIZE_300, SIZE_50, "textInput5"); + textInput5 = setCustomKeyboard(nodeAPI, textInput5, customKeyboard, PARAM_0); + + // 注册获取点击事件 + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_EVENT_ID_THREE, nullptr); + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputCustomKeyboardTest::CreateNativeNodePage6(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "CreateNativeNodePage6"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, button); + nodeAPI->addChild(column, textInput6); + + // 自定义键盘 + auto customKeyboard = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row2 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row3 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto row4 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto button1 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button2 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button3 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button4 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button5 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button6 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button7 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button8 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button9 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button10 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + auto button11 = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + nodeAPI->addChild(customKeyboard, row1); + nodeAPI->addChild(customKeyboard, row2); + nodeAPI->addChild(customKeyboard, row3); + nodeAPI->addChild(customKeyboard, row4); + nodeAPI->addChild(row1, button1); + nodeAPI->addChild(row1, button2); + nodeAPI->addChild(row1, button3); + nodeAPI->addChild(row2, button4); + nodeAPI->addChild(row2, button5); + nodeAPI->addChild(row2, button6); + nodeAPI->addChild(row3, button7); + nodeAPI->addChild(row3, button8); + nodeAPI->addChild(row3, button9); + nodeAPI->addChild(row4, button10); + nodeAPI->addChild(row4, button11); + + // 设置键盘属性 + button1 = setOther(nodeAPI, button1, SIZE_100, SIZE_100, "button1"); + button2 = setOther(nodeAPI, button2, SIZE_100, SIZE_100, "button2"); + button3 = setOther(nodeAPI, button3, SIZE_100, SIZE_100, "button3"); + button4 = setOther(nodeAPI, button4, SIZE_100, SIZE_100, "button4"); + button5 = setOther(nodeAPI, button5, SIZE_100, SIZE_100, "button5"); + button6 = setOther(nodeAPI, button6, SIZE_100, SIZE_100, "button6"); + button7 = setOther(nodeAPI, button7, SIZE_100, SIZE_100, "button7"); + button8 = setOther(nodeAPI, button8, SIZE_100, SIZE_100, "button8"); + button9 = setOther(nodeAPI, button9, SIZE_100, SIZE_100, "button9"); + button10 = setOther(nodeAPI, button10, SIZE_100, SIZE_100, "button10"); + button11 = setOther(nodeAPI, button11, SIZE_100, SIZE_100, "button11"); + + // 设置textInput和button属性 + button = setOther(nodeAPI, button, SIZE_300, SIZE_600, "button"); + button = setBackgroundColor(nodeAPI, button, COLOR_BLUE); + textInput6 = setOther(nodeAPI, textInput6, SIZE_300, SIZE_50, "textInput6"); + textInput6 = setCustomKeyboard(nodeAPI, textInput6, customKeyboard, PARAM_1); + nodeAPI->resetAttribute(textInput6, NODE_TEXT_INPUT_CUSTOM_KEYBOARD); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputCustomKeyboardTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_custom_keyboard_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_custom_keyboard_test.h new file mode 100644 index 0000000000000000000000000000000000000000..2d2b165ca64b25b4a1db6473b74b307f60c33a3d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_custom_keyboard_test.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_CUSTOM_KEYBOARD_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_CUSTOM_KEYBOARD_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define SIZE_700 700 +#define ON_CLICK_EVENT_ID_ONE 6014 +#define ON_CLICK_EVENT_ID_TWO 6015 +#define ON_CLICK_EVENT_ID_THREE 6016 +#define ON_CLICK_EVENT_ID_FOUR 6017 + +class TextInputCustomKeyboardTest { +public: + ~TextInputCustomKeyboardTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage4(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage5(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage6(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_CUSTOM_KEYBOARD_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_enable_auto_fill_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_enable_auto_fill_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75e87c6566064dd767c9b8e184eb70f9a29404b1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_enable_auto_fill_test.cpp @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_enable_auto_fill_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto setContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_TEXT, &content_item); + return nodeHandle; +} + +static auto setMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto setFontsize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float fontsize) +{ + ArkUI_NumberValue font_size_value[] = { { .f32 = fontsize } }; + ArkUI_AttributeItem font_size_item = { font_size_value, sizeof(font_size_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &font_size_item); + return nodeHandle; +} + +static auto setContentType(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t contentType) +{ + ArkUI_NumberValue value[] = { { .i32 = contentType } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_CONTENT_TYPE, &item); + return nodeHandle; +} + +static auto setEnableAutoFill(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t enable) +{ + ArkUI_NumberValue value[] = { { .i32 = enable } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_ENABLE_AUTO_FILL, &item); + return nodeHandle; +} + +static auto setTextInput(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t enable, const char* id) +{ + // 设置聚焦不拉起输入法 + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_400); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setId(nodeAPI, nodeHandle, id); + nodeHandle = setMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setFontsize(nodeAPI, nodeHandle, PARAM_16); + nodeHandle = setEnableAutoFill(nodeAPI, nodeHandle, enable); + nodeHandle = setContentType(nodeAPI, nodeHandle, ARKUI_TEXTINPUT_CONTENT_TYPE_PHONE_NUMBER); + return nodeHandle; +} + +static auto setTextInput(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* str, const char* id) +{ + // 设置聚焦不拉起输入法 + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_400); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setId(nodeAPI, nodeHandle, id); + nodeHandle = setMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setContent(nodeAPI, nodeHandle, str); + nodeHandle = setFontsize(nodeAPI, nodeHandle, PARAM_16); + return nodeHandle; +} + +napi_value TextInputEnableAutoFillTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputEnableAutoFillTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputEnableAutoFillTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + + textInput1 = setTextInput(nodeAPI, textInput1, PARAM_1, "textInput1"); + textInput2 = setTextInput(nodeAPI, textInput2, PARAM_0, "textInput2"); + textInput3 = setTextInput(nodeAPI, textInput3, PARAM_2, "textInput3"); + textInput4 = setTextInput(nodeAPI, textInput4, PARAM_NEGATIVE_1, "textInput4"); + textInput5 = setTextInput(nodeAPI, textInput5, PARAM_1, "textInput5"); + nodeAPI->resetAttribute(textInput5, NODE_TEXT_INPUT_ENABLE_AUTO_FILL); + textInput6 = setTextInput(nodeAPI, textInput6, "18202412345", "textInput6"); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputEnableAutoFillTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_enable_auto_fill_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_enable_auto_fill_test.h new file mode 100644 index 0000000000000000000000000000000000000000..95382c563d5dcd27c2eb66d2b2fec025e72803c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_enable_auto_fill_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_ENABLE_AUTO_FILL_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_ENABLE_AUTO_FILL_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputEnableAutoFillTest { +public: + ~TextInputEnableAutoFillTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_ENABLE_AUTO_FILL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_fontfeature_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_fontfeature_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0105dd9a7abed7e4557733119eec9648533b624e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_fontfeature_test.cpp @@ -0,0 +1,366 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_fontfeature_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_TEXT, &content_item); + return nodeHandle; +} + +static auto setFontsize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float fontsize) +{ + ArkUI_NumberValue font_size_value[] = { { .f32 = fontsize } }; + ArkUI_AttributeItem font_size_item = { font_size_value, sizeof(font_size_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &font_size_item); + return nodeHandle; +} + +static auto setFontFeature(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* fontfeature) +{ + ArkUI_AttributeItem font_feature_item = {}; + font_feature_item.string = fontfeature; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_FEATURE, &font_feature_item); + return nodeHandle; +} + +static auto setNodeHandle( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* content, float fontsize, char* fontfeature) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = PARAM_1 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + nodeHandle = setContent(nodeAPI, nodeHandle, content); + nodeHandle = setFontsize(nodeAPI, nodeHandle, fontsize); + nodeHandle = setFontFeature(nodeAPI, nodeHandle, fontfeature); + return nodeHandle; +} + +napi_value TextInputFontFeatureTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", "CreateNativeNodePage1"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput7 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput8 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput9 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput10 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput11 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput12 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput13 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput14 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput15 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput16 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput17 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput18 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + nodeAPI->addChild(column, textInput9); + nodeAPI->addChild(column, textInput10); + nodeAPI->addChild(column, textInput11); + nodeAPI->addChild(column, textInput12); + nodeAPI->addChild(column, textInput13); + nodeAPI->addChild(column, textInput14); + nodeAPI->addChild(column, textInput15); + nodeAPI->addChild(column, textInput16); + nodeAPI->addChild(column, textInput17); + nodeAPI->addChild(column, textInput18); + + // 设置属性 + textInput1 = setNodeHandle(nodeAPI, textInput1, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss01\" on"); + textInput2 = setNodeHandle(nodeAPI, textInput2, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss01\" 1"); + textInput3 = setNodeHandle(nodeAPI, textInput3, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss01\" "); + textInput4 = setNodeHandle(nodeAPI, textInput4, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss01\" off"); + textInput5 = setNodeHandle(nodeAPI, textInput5, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss01\" 0"); + textInput6 = setNodeHandle(nodeAPI, textInput6, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss02\" on"); + textInput7 = setNodeHandle(nodeAPI, textInput7, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss02\" 1"); + textInput8 = setNodeHandle(nodeAPI, textInput8, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss02\" "); + textInput9 = setNodeHandle(nodeAPI, textInput9, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss02\" off"); + textInput10 = setNodeHandle(nodeAPI, textInput10, "0123456789,;/\\-‱%℃℉", PARAM_16, "\"ss02\" 0"); + textInput11 = setNodeHandle(nodeAPI, textInput11, ":+-×÷=≠><≥≤±≈~﹁", PARAM_16, "\"ss03\" on"); + textInput12 = setNodeHandle(nodeAPI, textInput12, ":+-×÷=≠><≥≤±≈~﹁", PARAM_16, "\"ss03\" off"); + textInput13 = setNodeHandle(nodeAPI, textInput13, "llllllllll", PARAM_16, "\"ss04\" on"); + textInput14 = setNodeHandle(nodeAPI, textInput14, "llllllllll", PARAM_16, "\"ss04\" off"); + textInput15 = setNodeHandle(nodeAPI, textInput15, "€¢|¦№¤$₫₣₤₱£₦₨₩₪₱₮₡¥₥₭₰+-×", PARAM_16, "\"ss05\" on"); + textInput16 = setNodeHandle(nodeAPI, textInput16, "€¢|¦№¤$₫₣₤₱£₦₨₩₪₱₮₡¥₥₭₰+-×", PARAM_16, "\"ss05\" off"); + textInput17 = setNodeHandle(nodeAPI, textInput17, "÷=≠<>≤≥±≈~∟^∞∧∨∩∪∫Ω△∏∑√‰μδ|", PARAM_16, "\"ss05\" on"); + textInput18 = setNodeHandle(nodeAPI, textInput18, "÷=≠<>≤≥±≈~∟^∞∧∨∩∪∫Ω△∏∑√‰μδ|", PARAM_16, "\"ss05\" off"); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputFontFeatureTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", "CreateNativeNodePage2"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput7 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput8 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput9 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput10 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput11 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput12 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput13 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput14 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput15 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput16 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput17 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput18 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + nodeAPI->addChild(column, textInput9); + nodeAPI->addChild(column, textInput10); + nodeAPI->addChild(column, textInput11); + nodeAPI->addChild(column, textInput12); + nodeAPI->addChild(column, textInput13); + nodeAPI->addChild(column, textInput14); + nodeAPI->addChild(column, textInput15); + nodeAPI->addChild(column, textInput16); + nodeAPI->addChild(column, textInput17); + nodeAPI->addChild(column, textInput18); + + // 设置属性 + textInput1 = setNodeHandle( + nodeAPI, textInput1, "{〈《「『【(〔、。!,:;?}〉》」』】〕〗)〕", PARAM_16, "\"ss08\" on"); + textInput2 = setNodeHandle( + nodeAPI, textInput2, "{〈《「『【(〔、。!,:;?}〉》」』】〕〗)〕", PARAM_16, "\"ss08\" off"); + textInput3 = setNodeHandle(nodeAPI, textInput3, "0123456789", PARAM_16, "\"ss09\" on"); + textInput4 = setNodeHandle(nodeAPI, textInput4, "0123456789", PARAM_16, "\"ss09\" off"); + textInput5 = setNodeHandle(nodeAPI, textInput5, "0123456789", PARAM_16, "\"ss010\" on"); + textInput6 = setNodeHandle(nodeAPI, textInput6, "0123456789", PARAM_16, "\"ss010\" off"); + textInput7 = setNodeHandle(nodeAPI, textInput7, "1/2 1/4 2/45", PARAM_16, "\"frac\" on"); + textInput8 = setNodeHandle(nodeAPI, textInput8, "1/2 1/4 2/45", PARAM_16, "\"frac\" off"); + textInput9 = setNodeHandle(nodeAPI, textInput9, "0123456789", PARAM_16, "\"sups\" on"); + textInput10 = setNodeHandle(nodeAPI, textInput10, "0123456789", PARAM_16, "\"sups\" off"); + textInput11 = setNodeHandle(nodeAPI, textInput11, "0123456789", PARAM_16, "\"subs\" on"); + textInput12 = setNodeHandle(nodeAPI, textInput12, "0123456789", PARAM_16, "\"subs\" off"); + textInput13 = setNodeHandle(nodeAPI, textInput13, "0123456789", PARAM_16, "\"numr\" on"); + textInput14 = setNodeHandle(nodeAPI, textInput14, "0123456789", PARAM_16, "\"numr\" off"); + textInput15 = setNodeHandle(nodeAPI, textInput15, "0123456789", PARAM_16, "\"dnom\" on"); + textInput16 = setNodeHandle(nodeAPI, textInput16, "0123456789", PARAM_16, "\"dnom\" off"); + textInput17 = setNodeHandle(nodeAPI, textInput17, "!¡?¿", PARAM_16, "\"case\" on"); + textInput18 = setNodeHandle(nodeAPI, textInput18, "!¡?¿", PARAM_16, "\"case\" off"); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputFontFeatureTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", "CreateNativeNodePage3"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput7 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput8 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput9 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput10 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput11 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput12 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput13 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput14 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput15 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput16 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + nodeAPI->addChild(column, textInput9); + nodeAPI->addChild(column, textInput10); + nodeAPI->addChild(column, textInput11); + nodeAPI->addChild(column, textInput12); + nodeAPI->addChild(column, textInput13); + nodeAPI->addChild(column, textInput14); + nodeAPI->addChild(column, textInput15); + nodeAPI->addChild(column, textInput16); + + // 设置属性 + textInput1 = setNodeHandle(nodeAPI, textInput1, "0123456789", PARAM_16, "\"tnum\" on"); + textInput2 = setNodeHandle(nodeAPI, textInput2, "0123456789", PARAM_16, "\"tnum\" off"); + textInput3 = setNodeHandle(nodeAPI, textInput3, "0123456789", PARAM_16, "\"pnum\" on"); + textInput4 = setNodeHandle(nodeAPI, textInput4, "0123456789", PARAM_16, "\"pnum\" off"); + textInput5 = setNodeHandle(nodeAPI, textInput5, "【】()", PARAM_16, "\"vert\" on"); + textInput6 = setNodeHandle(nodeAPI, textInput6, "【】()", PARAM_16, "\"vert\" off"); + textInput7 = setNodeHandle(nodeAPI, textInput7, "【】()", PARAM_16, "\"vrt2\" on"); + textInput8 = setNodeHandle(nodeAPI, textInput8, "【】()", PARAM_16, "\"vrt2\" off"); + textInput9 = setNodeHandle(nodeAPI, textInput9, "ff fl fi ffi ffl", PARAM_16, "\"liga\" on"); + textInput10 = setNodeHandle(nodeAPI, textInput10, "ff fl fi ffi ffl", PARAM_16, "\"liga\" off"); + textInput11 = setNodeHandle(nodeAPI, textInput11, "No.1 1a 1o", PARAM_16, "\"ordn\" on"); + textInput12 = setNodeHandle(nodeAPI, textInput12, "No.1 1a 1o", PARAM_16, "\"ordn\" off"); + textInput13 = setNodeHandle(nodeAPI, textInput13, "0123456789", PARAM_16, "\"sinf\" on"); + textInput14 = setNodeHandle(nodeAPI, textInput14, "0123456789", PARAM_16, "\"sinf\" off"); + textInput15 = setNodeHandle(nodeAPI, textInput15, "0123456789", PARAM_16, "\"sinf\" on"); + textInput16 = setNodeHandle(nodeAPI, textInput16, "0123456789", PARAM_16, "\"sinf\" on"); + nodeAPI->resetAttribute(textInput16, NODE_FONT_FEATURE); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputFontFeatureTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_fontfeature_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_fontfeature_test.h new file mode 100644 index 0000000000000000000000000000000000000000..5c9895b984ae9e1fbb49a2afcc05d6dd0d1b8e26 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_fontfeature_test.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_FONTFEATURE_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_FONTFEATURE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +#define PARAM_16 16 + +class TextInputFontFeatureTest { +public: + ~TextInputFontFeatureTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_FONTFEATURE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_getcaretoffset_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_getcaretoffset_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..250b42b08040dd9b0da5843ad01818cae27bb5a7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_getcaretoffset_test.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_getcaretoffset_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text1; +static ArkUI_NodeHandle textInput1; + +ArkUI_NodeHandle TextInputGetCaretOffsetTest::CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 200; + auto textInput = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_HEIGHT, &heightItem); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "text"; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_TEXT, &content_item); + + ArkUI_NumberValue value[] = { { .f32 = 45 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_FONT_SIZE, &value_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + return textInput; +} +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputGetCaretOffsetTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputGetCaretOffsetTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputGetCaretOffsetTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + if (eventId == ON_CHANGE_EVENT_ID) { + auto result1 = nodeAPI->getAttribute(textInput1, NODE_TEXT_INPUT_CARET_OFFSET); + if (result1 == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputControllerTest", + "Failed to get caret offset attribute"); + return; + } + std::string str1 = "index:" + std::to_string(result1->value[0].i32); + + ArkUI_AttributeItem getTextContentLineCount_item = {}; + getTextContentLineCount_item.string = str1.c_str(); + nodeAPI->setAttribute(text1, NODE_TEXT_CONTENT, &getTextContentLineCount_item); + + return; + } +} + +napi_value TextInputGetCaretOffsetTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputGetCaretOffsetTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputGetCaretOffsetTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + text1 = nodeAPI->createNode(ARKUI_NODE_TEXT); + + ArkUI_NumberValue value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_FONT_SIZE, &value_item); + + textInput1 = CreateSubTextInputNode(nodeAPI); + + ArkUI_AttributeItem id_item1 = {}; + id_item1.string = "TextInputGetCaretOffsetTest_textInput_id1"; + nodeAPI->setAttribute(textInput1, NODE_ID, &id_item1); + + nodeAPI->registerNodeEvent(textInput1, NODE_TEXT_INPUT_ON_CHANGE, ON_CHANGE_EVENT_ID, nodeAPI); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, text1); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputGetCaretOffsetTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_getcaretoffset_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_getcaretoffset_test.h new file mode 100644 index 0000000000000000000000000000000000000000..90a655c651c65feb58fbba037a9c67233d2629b4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_getcaretoffset_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_GETCARETOFFSET_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_GETCARETOFFSET_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputGetCaretOffsetTest { +public: + ~TextInputGetCaretOffsetTest(); + static ArkUI_NodeHandle CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_GETCARETOFFSET_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_inputfilter_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_inputfilter_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aee4c2cfc660f865f99c4dc28d84cc17db5001bd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_inputfilter_test.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE 2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_inputfilter_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle textInput; +static ArkUI_NodeHandle column; +static ArkUI_NativeNodeAPI_1* nodeAPI; + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, const char* str) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue value[] = { { .f32 = 30 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + // set str + ArkUI_AttributeItem textinputItem = {}; + textinputItem.string = str; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_INPUT_FILTER, &textinputItem); + + nodeAPI->registerNodeEvent(nodeHandle, NODE_TEXT_INPUT_ON_INPUT_FILTER_ERROR, ON_CHANGE_EVENT_ID, nullptr); + + return nodeHandle; +} + +static void EventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonEventOnClickTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "CommonEventOnClickTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + OH_LOG_Print( + LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "CommonEventOnClickTest", "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto nodeHandler = OH_ArkUI_NodeEvent_GetNodeHandle(event); + + if (eventId == ON_CHANGE_EVENT_ID) { + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_BACKGROUND_COLOR, &background_color_item); + return; + } +} + +napi_value TextInputInputFilterTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputInputFilterTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputInputFilterTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建容器组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + const char* srcLocal1 = "[\u4e00-\u9fa5a-yA-Z1-9{}()(^&*;;“”\'\"+_——]|(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-" + "9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))"; + + auto textInput = CreateSubTextInputNode(nodeAPI, srcLocal1); + auto textInput2 = CreateSubTextInputNode(nodeAPI, nullptr); + auto textInput3 = CreateSubTextInputNode(nodeAPI, srcLocal1); + + nodeAPI->resetAttribute(textInput3, NODE_TEXT_INPUT_INPUT_FILTER); + + ArkUI_AttributeItem item = {}; + item.string = "@#$%^&*';\'()123456789zZABCDEFGHIJKLMN-1-9-80,-4.9,4.9"; + nodeAPI->setAttribute(textInput, NODE_TEXT_INPUT_TEXT, &item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_TEXT, &item); + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_TEXT, &item); + + nodeAPI->addChild(column, textInput); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + + nodeAPI->registerNodeEventReceiver(&EventReceive); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputInputFilterTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_inputfilter_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_inputfilter_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9ff2df602956cdf560a76ca96d439e5f4d31a4f9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_inputfilter_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_INPUTFILTER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_INPUTFILTER_TEST_H + +#include +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputInputFilterTest { +public: + ~TextInputInputFilterTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_INPUTFILTER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_maxlines_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_maxlines_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0318ddc1c6983e5e5689bab4155c01df07728377 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_maxlines_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_maxlines_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value, const char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set style + ArkUI_NumberValue style_value[] = { { .i32 = ARKUI_TEXTINPUT_STYLE_INLINE } }; + ArkUI_AttributeItem style_item = { style_value, sizeof(style_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_STYLE, &style_item); + + // set maxlines + ArkUI_NumberValue lines_value[] = { { .i32 = value } }; + ArkUI_AttributeItem lines_item = { lines_value, sizeof(lines_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_MAX_LINES, &lines_item); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &Border_Item_1); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &marginItem); + + // set id + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + return nodeHandle; +} + +napi_value TextInputMaxLinesTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputMaxLinesTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputMaxLinesTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // create textinput + auto textinput1 = CreateSubTextInputNode(nodeAPI, 1, "normal"); + auto textinput2 = CreateSubTextInputNode(nodeAPI, -1, "negative"); + auto textinput3 = CreateSubTextInputNode(nodeAPI, 100, "large"); + auto textinput4 = CreateSubTextInputNode(nodeAPI, 1, "normalTwo"); + auto textinput5 = CreateSubTextInputNode(nodeAPI, -1, "negativeTwo"); + auto textinput6 = CreateSubTextInputNode(nodeAPI, 100, "largeTwo"); + auto textinput7 = CreateSubTextInputNode(nodeAPI, 100, "reset"); + + nodeAPI->resetAttribute(textinput7, NODE_TEXT_MAX_LINES); + + // text into column + nodeAPI->addChild(column, textinput1); + nodeAPI->addChild(column, textinput2); + nodeAPI->addChild(column, textinput3); + nodeAPI->addChild(column, textinput4); + nodeAPI->addChild(column, textinput5); + nodeAPI->addChild(column, textinput6); + nodeAPI->addChild(column, textinput7); + + // set text + ArkUI_AttributeItem text_item = {}; + text_item.string = "This is the text with the maxlines set This is the text with the maxlines set " + "This is the text with the maxlines set This is the text with the max set " + "This is the text with the maxlines set"; + nodeAPI->setAttribute(textinput1, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textinput2, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textinput3, NODE_TEXT_INPUT_TEXT, &text_item); + nodeAPI->setAttribute(textinput4, NODE_TEXT_INPUT_PLACEHOLDER, &text_item); + nodeAPI->setAttribute(textinput5, NODE_TEXT_INPUT_PLACEHOLDER, &text_item); + nodeAPI->setAttribute(textinput6, NODE_TEXT_INPUT_PLACEHOLDER, &text_item); + nodeAPI->setAttribute(textinput7, NODE_TEXT_INPUT_TEXT, &text_item); + + // XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputMaxLinesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_maxlines_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_maxlines_test.h new file mode 100644 index 0000000000000000000000000000000000000000..0e73de161dfbe251f5784cdc304e1ac87706162c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_maxlines_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXT_INPUT_MAXLINES_TEST_H +#define ARKUI_CAPI_DEMO_TEXT_INPUT_MAXLINES_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputMaxLinesTest { +public: + ~TextInputMaxLinesTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXT_INPUT_MAXLINES_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_minfontsizeandmaxfontsize.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_minfontsizeandmaxfontsize.cpp new file mode 100644 index 0000000000000000000000000000000000000000..382e253e59ec9eb1fdd7e8a45c13151ca4c45325 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_minfontsizeandmaxfontsize.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_minfontsizeandmaxfontsize.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +napi_value TextInputMinFontSizeAndMaxFontSizeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputMinFontSizeAndMaxFontSizeTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputMinFontSizeAndMaxFontSizeTest", + "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // 创建column节点组件 + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // 设置column组件宽度和高度 + ArkUI_NumberValue column_width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem column_width_item = { column_width_value, + sizeof(column_width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue column_height_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem column_height_item = { column_height_value, + sizeof(column_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(column, NODE_WIDTH, &column_width_item); + nodeAPI->setAttribute(column, NODE_HEIGHT, &column_height_item); + + // 创建text节点组件 + auto text1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto text2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto text3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto text4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto text5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto text6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + // 设置text组件宽度和高度 + ArkUI_NumberValue width_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(text2, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(text3, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(text4, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(text5, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(text6, NODE_HEIGHT, &height_item); + nodeAPI->setAttribute(text1, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(text2, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(text3, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(text4, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(text5, NODE_WIDTH, &width_item); + nodeAPI->setAttribute(text6, NODE_WIDTH, &width_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(text2, NODE_MARGIN, &margin_item); + // text组件放置父容器column中 + nodeAPI->setAttribute(text3, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(text4, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(text5, NODE_MARGIN, &margin_item); + nodeAPI->setAttribute(text6, NODE_MARGIN, &margin_item); + + // text组件放置父容器column中 + nodeAPI->addChild(column, text1); + nodeAPI->addChild(column, text2); + nodeAPI->addChild(column, text3); + nodeAPI->addChild(column, text4); + nodeAPI->addChild(column, text5); + nodeAPI->addChild(column, text6); + + // 设置text组件文本 + ArkUI_AttributeItem content_item = {}; + content_item.string = "Min"; + nodeAPI->setAttribute(text1, NODE_TEXT_INPUT_TEXT, &content_item); + nodeAPI->setAttribute(text2, NODE_TEXT_INPUT_TEXT, &content_item); + nodeAPI->setAttribute(text3, NODE_TEXT_INPUT_TEXT, &content_item); + + content_item.string = "Max"; + nodeAPI->setAttribute(text4, NODE_TEXT_INPUT_TEXT, &content_item); + nodeAPI->setAttribute(text5, NODE_TEXT_INPUT_TEXT, &content_item); + nodeAPI->setAttribute(text6, NODE_TEXT_INPUT_TEXT, &content_item); + + // 设置字体大小 + ArkUI_NumberValue font_size_valueOne[] = { { .f32 = 10 } }; + ArkUI_AttributeItem font_size_valueOne_item = { font_size_valueOne, + sizeof(font_size_valueOne) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_FONT_SIZE, &font_size_valueOne_item); + nodeAPI->setAttribute(text2, NODE_FONT_SIZE, &font_size_valueOne_item); + nodeAPI->setAttribute(text3, NODE_FONT_SIZE, &font_size_valueOne_item); + + ArkUI_NumberValue font_size_valueTwo[] = { { .f32 = 20 } }; + ArkUI_AttributeItem font_size_valueTwo_item = { font_size_valueTwo, + sizeof(font_size_valueTwo) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text4, NODE_FONT_SIZE, &font_size_valueTwo_item); + nodeAPI->setAttribute(text5, NODE_FONT_SIZE, &font_size_valueTwo_item); + nodeAPI->setAttribute(text6, NODE_FONT_SIZE, &font_size_valueTwo_item); + + // 设置text组件文本最小显示字号 + ArkUI_NumberValue minFontSize_valueOne[] = { { .f32 = 20 } }; + ArkUI_AttributeItem minFontSize_valueOne_item = { minFontSize_valueOne, + sizeof(minFontSize_valueOne) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_TEXT_MIN_FONT_SIZE, &minFontSize_valueOne_item); + nodeAPI->setAttribute(text2, NODE_TEXT_MIN_FONT_SIZE, &minFontSize_valueOne_item); + + ArkUI_NumberValue maxFontSize_valueTwo[] = { { .f32 = 10 } }; + ArkUI_AttributeItem maxFontSize_valueTwo_item = { maxFontSize_valueTwo, + sizeof(maxFontSize_valueTwo) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text4, NODE_TEXT_MAX_FONT_SIZE, &maxFontSize_valueTwo_item); + nodeAPI->setAttribute(text5, NODE_TEXT_MAX_FONT_SIZE, &maxFontSize_valueTwo_item); + + // 设置text组件文本最多行数 + ArkUI_NumberValue lines_valueOne[] = { { .i32 = 1 } }; + ArkUI_AttributeItem lines_value_valueOne_item = { lines_valueOne, + sizeof(lines_valueOne) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_TEXT_MAX_LINES, &lines_value_valueOne_item); + nodeAPI->setAttribute(text3, NODE_TEXT_MAX_LINES, &lines_value_valueOne_item); + + ArkUI_NumberValue lines_valueTwo[] = { { .i32 = 1 } }; + ArkUI_AttributeItem lines_value_valueTwo_item = { lines_valueTwo, + sizeof(lines_valueTwo) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text4, NODE_TEXT_MAX_LINES, &lines_value_valueTwo_item); + nodeAPI->setAttribute(text6, NODE_TEXT_MAX_LINES, &lines_value_valueTwo_item); + + // 设置text组件文本最大显示字号 + ArkUI_NumberValue maxFontSize_valueOne[] = { { .f32 = 40 } }; + ArkUI_AttributeItem maxFontSize_valueOne_item = { maxFontSize_valueOne, + sizeof(maxFontSize_valueOne) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text1, NODE_TEXT_MAX_FONT_SIZE, &maxFontSize_valueOne_item); + nodeAPI->setAttribute(text3, NODE_TEXT_MAX_FONT_SIZE, &maxFontSize_valueOne_item); + + ArkUI_NumberValue minFontSize_valueTwo[] = { { .f32 = 5 } }; + ArkUI_AttributeItem minFontSize_valueTwo_item = { minFontSize_valueTwo, + sizeof(minFontSize_valueTwo) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text4, NODE_TEXT_MIN_FONT_SIZE, &minFontSize_valueTwo_item); + nodeAPI->setAttribute(text6, NODE_TEXT_MIN_FONT_SIZE, &minFontSize_valueTwo_item); + + ArkUI_NumberValue exception_valueOne[] = { { .f32 = 0 } }; + ArkUI_AttributeItem exception_value_valueOne_item = { exception_valueOne, + sizeof(exception_valueOne) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text3, NODE_TEXT_MIN_FONT_SIZE, &exception_value_valueOne_item); + + ArkUI_NumberValue exception_valueTwo[] = { { .f32 = -1 } }; + ArkUI_AttributeItem exception_value_valueTwo_item = { exception_valueTwo, + sizeof(exception_valueTwo) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(text6, NODE_TEXT_MAX_FONT_SIZE, &exception_value_valueTwo_item); + + // 所有组件挂载到XComponent + std::string id(xComponentID); + + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputMinFontSizeAndMaxFontSizeTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_minfontsizeandmaxfontsize.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_minfontsizeandmaxfontsize.h new file mode 100644 index 0000000000000000000000000000000000000000..2c7ed459ba19b979480f11b810f1eb1dc4020e5a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_minfontsizeandmaxfontsize.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_MINFONTSIZEANDMAXFONTSIZE_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_MINFONTSIZEANDMAXFONTSIZE_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputMinFontSizeAndMaxFontSizeTest { +public: + ~TextInputMinFontSizeAndMaxFontSizeTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_MINFONTSIZEANDMAXFONTSIZE_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_numberoflines_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_numberoflines_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..47a7725ec524fc2b3542ba94253e1f0c3a9e9fac --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_numberoflines_test.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_numberoflines_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +ArkUI_NodeHandle CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t value) +{ + float width = 200; + float height = 100; + auto textInput = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_MARGIN, &marginItem); + + ArkUI_NumberValue Line_Value_1[] = { { .i32 = value } }; + ArkUI_AttributeItem Line_Item_1 = { Line_Value_1, sizeof(Line_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_AREA_NUMBER_OF_LINES, &Line_Item_1); + + ArkUI_AttributeItem textInput_id_item = {}; + textInput_id_item.string = "line1\nline2\nline3\nline4"; + nodeApi->setAttribute(textInput, NODE_TEXT_AREA_TEXT, &textInput_id_item); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_BORDER_WIDTH, &Border_Item_1); + + return textInput; +} + +ArkUI_NodeHandle CreateSubTextInputPlaceholderNode(ArkUI_NativeNodeAPI_1* nodeApi, int32_t value) +{ + float width = 200; + float height = 100; + auto textInput = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_HEIGHT, &heightItem); + + ArkUI_NumberValue marginValue[] = { { .f32 = 5 } }; + ArkUI_AttributeItem marginItem = { marginValue, sizeof(marginValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_MARGIN, &marginItem); + + ArkUI_AttributeItem textInput_id_item = {}; + textInput_id_item.string = "line1\nline2\nline3\nline4"; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_PLACEHOLDER, &textInput_id_item); + + ArkUI_NumberValue Line_Value_1[] = { { .i32 = value } }; + ArkUI_AttributeItem Line_Item_1 = { Line_Value_1, sizeof(Line_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_NUMBER_OF_LINES, &Line_Item_1); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_BORDER_WIDTH, &Border_Item_1); + ; + + return textInput; +} + +napi_value TextInputNumberOfLinesTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputNumberOfLinesTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputNumberOfLinesTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto textInput_1 = CreateSubTextInputNode(nodeAPI, 0); + auto textInput_2 = CreateSubTextInputNode(nodeAPI, 3); + auto textInput_3 = CreateSubTextInputNode(nodeAPI, 3); + auto textInput_4 = CreateSubTextInputPlaceholderNode(nodeAPI, 0); + auto textInput_reset = CreateSubTextInputNode(nodeAPI, 5); + auto textInput_5 = CreateSubTextInputNode(nodeAPI, 100); + + nodeAPI->resetAttribute(textInput_reset, NODE_TEXT_INPUT_NUMBER_OF_LINES); + + ArkUI_NumberValue font_Value_4[] = { { .f32 = 12 } }; + ArkUI_AttributeItem font_Item_4 = { font_Value_4, sizeof(font_Value_4) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput_4, NODE_FONT_SIZE, &font_Item_4); + + ArkUI_NumberValue lineHeight_Value_3[] = { { .f32 = 30 } }; + ArkUI_AttributeItem lineHeight_Item_3 = { lineHeight_Value_3, + sizeof(lineHeight_Value_3) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput_3, NODE_TEXT_LINE_HEIGHT, &lineHeight_Item_3); + + nodeAPI->addChild(column, textInput_1); + nodeAPI->addChild(column, textInput_2); + nodeAPI->addChild(column, textInput_3); + nodeAPI->addChild(column, textInput_4); + nodeAPI->addChild(column, textInput_reset); + nodeAPI->addChild(column, textInput_5); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputNumberOfLinesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_numberoflines_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_numberoflines_test.h new file mode 100644 index 0000000000000000000000000000000000000000..b32fea39a8d67e3e23085f8d7232eb6642edeb99 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_numberoflines_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_NUMBEROFLINES_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_NUMBEROFLINES_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputNumberOfLinesTest { +public: + ~TextInputNumberOfLinesTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_NUMBEROFLINES_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_password_rules_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_password_rules_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0cce5af61500ce6e08da91e30145e6c11cd36bbd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_password_rules_test.cpp @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_password_rules_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto setContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_TEXT, &content_item); + return nodeHandle; +} + +static auto setMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto setFontsize(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float fontsize) +{ + ArkUI_NumberValue font_size_value[] = { { .f32 = fontsize } }; + ArkUI_AttributeItem font_size_item = { font_size_value, sizeof(font_size_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &font_size_item); + return nodeHandle; +} + +static auto setEnableAutoFill(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t enable) +{ + ArkUI_NumberValue value[] = { { .i32 = enable } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_ENABLE_AUTO_FILL, &item); + return nodeHandle; +} + +static auto setContentType(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, int32_t contentType) +{ + ArkUI_NumberValue value[] = { { .i32 = contentType } }; + ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_CONTENT_TYPE, &item); + return nodeHandle; +} + +static auto setPasswordRules(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* rules) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = rules; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_PASSWORD_RULES, &content_item); + return nodeHandle; +} + +static auto setTextInput( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id, const char* rules) +{ + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_400); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setId(nodeAPI, nodeHandle, id); + nodeHandle = setMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setFontsize(nodeAPI, nodeHandle, SIZE_30); + nodeHandle = setEnableAutoFill(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = setContentType(nodeAPI, nodeHandle, ARKUI_TEXTINPUT_CONTENT_TYPE_NEW_PASSWORD); + nodeHandle = setPasswordRules(nodeAPI, nodeHandle, rules); + return nodeHandle; +} + +napi_value TextInputPasswordRulesTest::CreateNativeNodePage1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput7 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput8 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput9 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput10 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput11 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput12 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + nodeAPI->addChild(column, textInput9); + nodeAPI->addChild(column, textInput10); + nodeAPI->addChild(column, textInput11); + nodeAPI->addChild(column, textInput12); + + textInput1 = setTextInput(nodeAPI, textInput1, "textInput1", "begin:[upper]"); + textInput2 = setTextInput(nodeAPI, textInput2, "textInput2", "begin:[lower]"); + textInput3 = setTextInput(nodeAPI, textInput3, "textInput3", "begin:[digit]"); + textInput4 = setTextInput(nodeAPI, textInput4, "textInput4", "begin:[]"); + textInput5 = setTextInput(nodeAPI, textInput5, "textInput5", "begin:[llllower]"); + textInput6 = setTextInput(nodeAPI, textInput6, "textInput6", "beeegin:[lower]"); + textInput7 = setTextInput(nodeAPI, textInput7, "textInput7", "special:[yes]"); + textInput8 = setTextInput(nodeAPI, textInput8, "textInput8", "ssssspecial:[yes]"); + textInput9 = setTextInput(nodeAPI, textInput9, "textInput9", "special:[yyyyyyes]"); + textInput10 = setTextInput(nodeAPI, textInput10, "textInput10", ""); + textInput11 = setTextInput(nodeAPI, textInput11, "textInput11", "len:[fixedlen:16]"); + textInput12 = setTextInput(nodeAPI, textInput12, "textInput12", "len:[]"); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputPasswordRulesTest::CreateNativeNodePage2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput7 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput8 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput9 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput10 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput11 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput12 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + nodeAPI->addChild(column, textInput9); + nodeAPI->addChild(column, textInput10); + nodeAPI->addChild(column, textInput11); + nodeAPI->addChild(column, textInput12); + + // 设置属性 + textInput1 = setTextInput(nodeAPI, textInput1, "textInput1", "len:[fixedlen:5]"); + textInput2 = setTextInput(nodeAPI, textInput2, "textInput2", "len:[fixedlen:100]"); + textInput3 = setTextInput(nodeAPI, textInput3, "textInput3", "leeeen:[fixedlen:15]"); + textInput4 = setTextInput(nodeAPI, textInput4, "textInput4", "len:[minlen:16"); + textInput5 = setTextInput(nodeAPI, textInput5, "textInput5", "len:[minlen:5]"); + textInput6 = setTextInput(nodeAPI, textInput6, "textInput6", "len:[minlen:100]"); + textInput7 = setTextInput(nodeAPI, textInput7, "textInput7", "len:[maxlen:28]"); + textInput8 = setTextInput(nodeAPI, textInput8, "textInput8", "len:[maxlen:5]"); + textInput9 = setTextInput(nodeAPI, textInput9, "textInput9", "len:[maxlen:100]"); + textInput10 = setTextInput(nodeAPI, textInput10, "textInput10", "len:[minlen:13,maxlen:18]"); + textInput11 = setTextInput(nodeAPI, textInput11, "textInput11", "len:[maxlen:18,minlen:13]"); + textInput12 = setTextInput(nodeAPI, textInput12, "textInput12", "len:[minlen:18,maxlen:13]"); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputPasswordRulesTest::CreateNativeNodePage3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + + // 设置属性 + textInput1 = + setTextInput(nodeAPI, textInput1, "textInput1", "begin:[upper],special:[yes],len:[maxlen:32,minlen:12]"); + textInput2 = + setTextInput(nodeAPI, textInput2, "textInput2", "special:[yes],begin:[upper],len:[maxlen:32,minlen:12]"); + textInput3 = setTextInput(nodeAPI, textInput3, "textInput3", "special:[yes],begin:[upper]"); + textInput4 = setTextInput(nodeAPI, textInput4, "textInput4", "special:[yes]@begin:[upper]"); + textInput5 = + setTextInput(nodeAPI, textInput5, "textInput5", "begin:[upper],special:[yes],len:[maxlen:32,minlen:12]"); + nodeAPI->resetAttribute(textInput5, NODE_TEXT_INPUT_PASSWORD_RULES); + + // 组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputPasswordRulesTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_password_rules_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_password_rules_test.h new file mode 100644 index 0000000000000000000000000000000000000000..33b8fb621b10dd7a48f4e168f68fc7715c636de2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_password_rules_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_PASSWORD_RULES_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_PASSWORD_RULES_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputPasswordRulesTest { +public: + ~TextInputPasswordRulesTest(); + static napi_value CreateNativeNodePage1(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodePage3(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_PASSWORD_RULES_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selectall_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selectall_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a5b099366e84509b45dda548a6f8dd2735d28943 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selectall_test.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput/textinput_selectall_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_TEXT, &content_item); + return nodeHandle; +} + +static auto setId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto setCaretColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_CARET_COLOR, &color_item); + return nodeHandle; +} + +static auto setSelectAll( + ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* content, char* id, int selectAll) +{ + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setContent(nodeAPI, nodeHandle, content); + nodeHandle = setCaretColor(nodeAPI, nodeHandle, COLOR_TRANSPARENT); + nodeHandle = setId(nodeAPI, nodeHandle, id); + ArkUI_NumberValue select_all_value[] = { { .i32 = selectAll } }; + ArkUI_AttributeItem select_all_item = { select_all_value, sizeof(select_all_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SELECT_ALL, &select_all_item); + return nodeHandle; +} + +napi_value TextInputSelectAllTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSelectAllTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSelectAllTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput5 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput6 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + + // 设置selectAll + textInput1 = setSelectAll(nodeAPI, textInput1, "the textInput content", "textInput1", PARAM_1); + textInput2 = setSelectAll(nodeAPI, textInput2, "the textInput content", "textInput2", PARAM_0); + textInput3 = setSelectAll(nodeAPI, textInput3, "the textInput content", "textInput3", PARAM_NEGATIVE_1); + textInput4 = setSelectAll(nodeAPI, textInput4, + "the textInput content the textInput content the textInput content the textInput content", "textInput4", + PARAM_1); + textInput5 = setSelectAll(nodeAPI, textInput5, "", "textInput5", PARAM_1); + textInput6 = setSelectAll(nodeAPI, textInput6, "the textInput content", "textInput6", PARAM_1); + nodeAPI->resetAttribute(textInput6, NODE_TEXT_INPUT_SELECT_ALL); + + // 设置聚焦不拉起输入法 + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput4, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput5, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput6, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + + // 注册获取焦点事件 + nodeAPI->registerNodeEvent(textInput1, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput2, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput3, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput4, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput5, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput6, NODE_ON_FOCUS, ON_FOCUS_EVENT_ID, nullptr); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSelectAllTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selectall_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selectall_test.h new file mode 100644 index 0000000000000000000000000000000000000000..7034faa60e46178c545baf575d14d69a7b575dd3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selectall_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_SELECTALL_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_SELECTALL_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputSelectAllTest { +public: + ~TextInputSelectAllTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_SELECTALL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selection_menu_hidden_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selection_menu_hidden_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..607a03e4241efd6dace0e9a83112157d0ebab1a1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selection_menu_hidden_test.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput/textinput_selection_menu_hidden_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto setWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto setHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto setContent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* content) +{ + ArkUI_AttributeItem content_item = {}; + content_item.string = content; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_TEXT, &content_item); + return nodeHandle; +} + +static auto setId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* id) +{ + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + return nodeHandle; +} + +static auto setSelectionMenuHidden(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, char* id, int select) +{ + nodeHandle = setWidth(nodeAPI, nodeHandle, SIZE_300); + nodeHandle = setHeight(nodeAPI, nodeHandle, SIZE_50); + nodeHandle = setContent(nodeAPI, nodeHandle, "thetextInputcontentthe"); + nodeHandle = setId(nodeAPI, nodeHandle, id); + ArkUI_NumberValue select_value[] = { { .i32 = select } }; + ArkUI_AttributeItem select_item = { select_value, sizeof(select_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SELECTION_MENU_HIDDEN, &select_item); + return nodeHandle; +} + +napi_value TextInputSelectionMenuHiddenTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSelectionMenuHiddenTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSelectionMenuHiddenTest", "GetContext env or info is null"); + return nullptr; + } + + // 创建节点组件 + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto textInput1 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput2 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput3 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + auto textInput4 = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + + // 设置selectionMenuHidden + textInput1 = setSelectionMenuHidden(nodeAPI, textInput1, "textInput1", PARAM_1); + textInput2 = setSelectionMenuHidden(nodeAPI, textInput2, "textInput2", PARAM_0); + textInput3 = setSelectionMenuHidden(nodeAPI, textInput3, "textInput3", PARAM_NEGATIVE_1); + textInput4 = setSelectionMenuHidden(nodeAPI, textInput4, "textInput4", PARAM_1); + nodeAPI->resetAttribute(textInput4, NODE_TEXT_INPUT_SELECTION_MENU_HIDDEN); + + // 设置聚焦不拉起输入法 + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput4, NODE_TEXT_INPUT_ENABLE_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + nodeAPI->setAttribute(textInput4, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + + // 注册获取点击事件 + nodeAPI->registerNodeEvent(textInput1, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput2, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput3, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + nodeAPI->registerNodeEvent(textInput4, NODE_ON_CLICK, ON_CLICK_EVENT_ID, nullptr); + + // column组件挂载到XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSelectionMenuHiddenTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selection_menu_hidden_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selection_menu_hidden_test.h new file mode 100644 index 0000000000000000000000000000000000000000..aeb38ab0effec54289b8ae490b734118c4116879 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_selection_menu_hidden_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_SELECTION_MENU_HIDDEN_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_SELECTION_MENU_HIDDEN_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputSelectionMenuHiddenTest { +public: + ~TextInputSelectionMenuHiddenTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_SELECTION_MENU_HIDDEN_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_settextselection_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_settextselection_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e5feac222af0ef228a6608132e2bbaf8224e6802 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_settextselection_test.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_settextselection_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define ON_CLICK_1 6001 +#define ON_CLICK_2 6002 +#define ON_CLICK_3 6003 +#define ON_CLICK_4 6004 + +namespace ArkUICApiDemo { + +static ArkUI_NodeHandle text1; + +static ArkUI_NodeHandle textInput1; + +ArkUI_NodeHandle TextInputSetTextSelectionTest::CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi) +{ + float width = 300; + float height = 280; + auto textInput = nodeApi->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue widthValue[] = { { .f32 = width } }; + ArkUI_AttributeItem widthItem = { widthValue, sizeof(widthValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_WIDTH, &widthItem); + + ArkUI_NumberValue heightValue[] = { { .f32 = height } }; + ArkUI_AttributeItem heightItem = { heightValue, sizeof(heightValue) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_HEIGHT, &heightItem); + + ArkUI_AttributeItem content_item = {}; + content_item.string = "TextInput"; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_TEXT, &content_item); + + ArkUI_NumberValue caretColor_value[] = { { .u32 = COLOR_TRANSPARENT } }; + ArkUI_AttributeItem caretColor_item = { caretColor_value, sizeof(caretColor_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_CARET_COLOR, &caretColor_item); + + ArkUI_NumberValue keyboardEnable_value[] = { { .i32 = 0 } }; + ArkUI_AttributeItem keyboardEnable_item = { keyboardEnable_value, + sizeof(keyboardEnable_value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboardEnable_item); + + ArkUI_NumberValue value[] = { { .f32 = 55 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeApi->setAttribute(textInput, NODE_FONT_SIZE, &value_item); + + return textInput; +} + +static auto CreatButton(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandler = nodeAPI->createNode(ARKUI_NODE_BUTTON); + + ArkUI_NumberValue width_value[] = { { .f32 = 300 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandler, NODE_HEIGHT, &height_item); + + return nodeHandler; +} + +static void OnEventReceive(ArkUI_NodeEvent* event) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputSetTextSelectionTest", "OnEventReceive"); + if (event == nullptr) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSetTextSelectionTest", "OnEventReceive: event is null"); + return; + } + + int32_t eventId = OH_ArkUI_NodeEvent_GetTargetId(event); + if (eventId == 0) { + return; + } + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputSetTextSelectionTest", + "OnEventReceive eventId: %{public}d", eventId); + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + switch (eventId) { + case ON_CLICK_1: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = 0 }, { .i32 = 4 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + case ON_CLICK_2: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = -1 }, { .i32 = -1 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + case ON_CLICK_3: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = 0 }, { .i32 = 100 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + case ON_CLICK_4: { + ArkUI_NumberValue setTextSelection_value1[] = { { .i32 = 7 }, { .i32 = 2 } }; + ArkUI_AttributeItem setTextSelection_item1 = { setTextSelection_value1, + sizeof(setTextSelection_value1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT_SELECTION, &setTextSelection_item1); + + return; + } + default: { + return; + } + } +} + +napi_value TextInputSetTextSelectionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSetTextSelectionTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSetTextSelectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + text1 = nodeAPI->createNode(ARKUI_NODE_TEXT); + + textInput1 = CreateSubTextInputNode(nodeAPI); + + ArkUI_AttributeItem id_item = {}; + id_item.string = "TextInputSetTextSelectionTest_textInput_id1"; + nodeAPI->setAttribute(textInput1, NODE_ID, &id_item); + + auto button1 = CreatButton(nodeAPI); + auto button2 = CreatButton(nodeAPI); + auto button3 = CreatButton(nodeAPI); + auto button4 = CreatButton(nodeAPI); + + ArkUI_AttributeItem id_item1 = {}; + id_item1.string = "TextInputSetTextSelectionTest_id1"; + nodeAPI->setAttribute(button1, NODE_ID, &id_item1); + + ArkUI_AttributeItem id_item2 = {}; + id_item2.string = "TextInputSetTextSelectionTest_id2"; + nodeAPI->setAttribute(button2, NODE_ID, &id_item2); + + ArkUI_AttributeItem id_item3 = {}; + id_item3.string = "TextInputSetTextSelectionTest_id3"; + nodeAPI->setAttribute(button3, NODE_ID, &id_item3); + + ArkUI_AttributeItem id_item4 = {}; + id_item4.string = "TextInputSetTextSelectionTest_id4"; + nodeAPI->setAttribute(button4, NODE_ID, &id_item4); + + ArkUI_AttributeItem button_item1 = {}; + button_item1.string = "选中0-4"; + nodeAPI->setAttribute(button1, NODE_BUTTON_LABEL, &button_item1); + + button_item1.string = "选中-1 - -1"; + nodeAPI->setAttribute(button2, NODE_BUTTON_LABEL, &button_item1); + + button_item1.string = "选中0-100"; + nodeAPI->setAttribute(button3, NODE_BUTTON_LABEL, &button_item1); + + button_item1.string = "选中7-2"; + nodeAPI->setAttribute(button4, NODE_BUTTON_LABEL, &button_item1); + + nodeAPI->registerNodeEvent(button1, NODE_ON_CLICK, ON_CLICK_1, nodeAPI); + nodeAPI->registerNodeEvent(button2, NODE_ON_CLICK, ON_CLICK_2, nodeAPI); + nodeAPI->registerNodeEvent(button3, NODE_ON_CLICK, ON_CLICK_3, nodeAPI); + nodeAPI->registerNodeEvent(button4, NODE_ON_CLICK, ON_CLICK_4, nodeAPI); + + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, button1); + nodeAPI->addChild(column, button2); + nodeAPI->addChild(column, button3); + nodeAPI->addChild(column, button4); + + nodeAPI->registerNodeEventReceiver(&OnEventReceive); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputSetTextSelectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_settextselection_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_settextselection_test.h new file mode 100644 index 0000000000000000000000000000000000000000..30011fd376a4a83bf9957d79efda13b1bee7839a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_settextselection_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_SETTEXTSELECTION_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_SETTEXTSELECTION_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputSetTextSelectionTest { +public: + ~TextInputSetTextSelectionTest(); + static ArkUI_NodeHandle CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeApi); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_SETTEXTSELECTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_showkeyboardonfocus_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_showkeyboardonfocus_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c1b3e3caa0a5c9826f74d64b7ecd56382422051e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_showkeyboardonfocus_test.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_showkeyboardonfocus_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + + ArkUI_NumberValue showKey_value[] = { { .i32 = value } }; + ArkUI_AttributeItem showKey_item = { showKey_value, sizeof(showKey_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &showKey_item); + + ArkUI_NumberValue width_value[] = { { .f32 = SIZE_200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_300 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = DEFAULT_MARGIN } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + return nodeHandle; +} + +napi_value TextInputShowKeyboardOnFocusTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputShowKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputShowKeyboardOnFocusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row = nodeAPI->createNode(ARKUI_NODE_ROW); + auto textInput = createChildNode(nodeAPI, 1); + auto textInputCompare = createChildNode(nodeAPI, 0); + + ArkUI_AttributeItem id_item = {}; + id_item.string = "OnFocusTestTextInput"; + nodeAPI->setAttribute(textInput, NODE_ID, &id_item); + id_item.string = "OnFocusTestTextInputCompare"; + nodeAPI->setAttribute(textInputCompare, NODE_ID, &id_item); + + nodeAPI->addChild(row, textInput); + nodeAPI->addChild(row, textInputCompare); + nodeAPI->addChild(column, row); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputShowKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value TextInputShowKeyboardOnFocusTest::CreateAbnormalNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "TextInputShowKeyboardOnFocusTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputShowKeyboardOnFocusTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto row1 = nodeAPI->createNode(ARKUI_NODE_ROW); + auto textInput3 = createChildNode(nodeAPI, -1); + auto textInput4 = createChildNode(nodeAPI, 0); + + ArkUI_AttributeItem id_item = {}; + + id_item.string = "TextInputDisableTest"; + nodeAPI->setAttribute(textInput3, NODE_ID, &id_item); + id_item.string = "OnFocusTestTextInputReset"; + nodeAPI->setAttribute(textInput4, NODE_ID, &id_item); + nodeAPI->resetAttribute(textInput4, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS); + + nodeAPI->addChild(row1, textInput3); + nodeAPI->addChild(row1, textInput4); + nodeAPI->addChild(column, row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputShowKeyboardOnFocusTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, nullptr, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_showkeyboardonfocus_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_showkeyboardonfocus_test.h new file mode 100644 index 0000000000000000000000000000000000000000..88f7c9c845625a5522b5ca3e82b76f55b922114d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_showkeyboardonfocus_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_SHOWKEYBOARDONFOCUS_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_SHOWKEYBOARDONFOCUS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputShowKeyboardOnFocusTest { +public: + ~TextInputShowKeyboardOnFocusTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateAbnormalNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_SHOWKEYBOARDONFOCUS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_style_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_style_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2d2807b25ae55d25d463e42059deb8bbce5fddc4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_style_test.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_style_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t value, const char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set style + ArkUI_NumberValue style_value[] = { { .i32 = value } }; + ArkUI_AttributeItem type_item = { style_value, sizeof(style_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_STYLE, &type_item); + + // set text + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + return nodeHandle; +} + +napi_value TextInputStyleTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputStyleTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputStyleTest", "GetContext env or info is null"); + return nullptr; + } + // create nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // textinput + auto textInput1 = CreateSubTextInputNode(nodeAPI, ARKUI_TEXTINPUT_STYLE_DEFAULT, "default"); + auto textInput2 = CreateSubTextInputNode(nodeAPI, ARKUI_TEXTINPUT_STYLE_INLINE, "inline"); + auto textInput3 = CreateSubTextInputNode(nodeAPI, -1, "negative"); + auto textInput4 = CreateSubTextInputNode(nodeAPI, 2, "large"); + auto textInput5 = CreateSubTextInputNode(nodeAPI, ARKUI_TEXTINPUT_STYLE_INLINE, "reset"); + + nodeAPI->resetAttribute(textInput5, NODE_TEXT_INPUT_STYLE); + + // insert into the column + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputStyleTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_style_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_style_test.h new file mode 100644 index 0000000000000000000000000000000000000000..8f964da7bb469c5e6ad3640ec59efcdb17d95ba3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_style_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_STYLE_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_STYLE_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputStyleTest { +public: + ~TextInputStyleTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_Style_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_textplaceholder_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_textplaceholder_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c336c690031bc85a430e9ec903207e5a3aa98328 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_textplaceholder_test.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_textplaceholder_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 150 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &value_item); + + return nodeHandle; +} + +napi_value TextInputTextPlaceholderTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputTextPlaceholderTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputTextPlaceholderTest", "GetContext env or info is null"); + return nullptr; + } + // create nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // textinput + auto textInput1 = CreateSubTextInputNode(nodeAPI); + auto textInput2 = CreateSubTextInputNode(nodeAPI); + + // set text + ArkUI_AttributeItem text_item = {}; + text_item.string = "texttest"; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT, &text_item); + + // set placeholder + ArkUI_AttributeItem placeholder_item = {}; + placeholder_item.string = "placeholder test"; + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_PLACEHOLDER, &placeholder_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_PLACEHOLDER, &placeholder_item); + + ArkUI_NumberValue value[] = { { .f32 = 40 } }; + ArkUI_AttributeItem value_item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput1, NODE_TEXT_AREA_PLACEHOLDER_FONT, &value_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_AREA_PLACEHOLDER_FONT, &value_item); + + // insert into the column + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputTextPlaceholderTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_textplaceholder_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_textplaceholder_test.h new file mode 100644 index 0000000000000000000000000000000000000000..d1c041d18012ef5b81491bef0b846f60a5ed6b59 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_textplaceholder_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_TEXTPLACEHOLDER_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_TEXTPLACEHOLDER_TEST_H +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputTextPlaceholderTest { +public: + ~TextInputTextPlaceholderTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_TEXTPLACEHOLDER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_underlinecolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_underlinecolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..443072ce2421b71e9fb39ac92de5407cee546d7a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_underlinecolor_test.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_underlinecolor_test.h" + +#include +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto CreateUnderlineColorNode( + ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t color, uint32_t color1, uint32_t color2, uint32_t color3) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 350 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 70 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // showUnderline + ArkUI_NumberValue showUnderlineValue[] = { { .i32 = 1 } }; + ArkUI_AttributeItem showUnderlineItem = { showUnderlineValue, + sizeof(showUnderlineValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_UNDERLINE, &showUnderlineItem); + + ArkUI_NumberValue keyboard_value[] = { { .i32 = PARAM_0 } }; + ArkUI_AttributeItem keyboard_item = { keyboard_value, sizeof(keyboard_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_SHOW_KEYBOARD_ON_FOCUS, &keyboard_item); + + // maxLength + ArkUI_NumberValue lengthValue[] = { { .i32 = 4 } }; + ArkUI_AttributeItem lengthValueItem = { lengthValue, sizeof(lengthValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_MAX_LENGTH, &lengthValueItem); + + ArkUI_NumberValue showValue[] = { { .i32 = 1 }, { .i32 = 100 }, { .i32 = 1 } }; + ArkUI_AttributeItem showValueItem = { showValue, sizeof(showValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_AREA_SHOW_COUNTER, &showValueItem); + + // set typing\normal\error\disable color + ArkUI_NumberValue color_value[] = { { .u32 = color }, { .u32 = color1 }, { .u32 = color2 }, { .u32 = color3 } }; + ArkUI_AttributeItem color_value_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_UNDERLINE_COLOR, &color_value_item); + + return nodeHandle; +} + +napi_value TextInputUnderlineColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputUnderlineColorTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputUnderlineColorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // textinput1 normal + auto textInput1 = CreateUnderlineColorNode(nodeAPI, COLOR_GREEN, COLOR_BLUE, COLOR_RED, COLOR_BLACK); + + // textinput2 typing + auto textInput2 = CreateUnderlineColorNode(nodeAPI, COLOR_GREEN, COLOR_BLUE, COLOR_RED, COLOR_BLACK); + + // textinput3 error + auto textInput3 = CreateUnderlineColorNode(nodeAPI, COLOR_GREEN, COLOR_BLUE, COLOR_RED, COLOR_BLACK); + + // textinput4 disable + auto textInput4 = CreateUnderlineColorNode(nodeAPI, COLOR_GREEN, COLOR_BLUE, COLOR_RED, COLOR_BLACK); + + // textinput2 typing + ArkUI_AttributeItem id_item = {}; + id_item.string = "textInput2"; + nodeAPI->setAttribute(textInput2, NODE_ID, &id_item); + + id_item.string = "textInput3"; + nodeAPI->setAttribute(textInput3, NODE_ID, &id_item); + + // textinput3 error + ArkUI_AttributeItem text_item = {}; + text_item.string = "12345"; + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_TEXT, &text_item); + + // textinput4 disable + ArkUI_NumberValue editValue[] = { { .i32 = false } }; + ArkUI_AttributeItem editItem = { editValue, sizeof(editValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(textInput4, NODE_ENABLED, &editItem); + + // insert into the column + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputUnderlineColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_underlinecolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_underlinecolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..10bcfde8a842aae9c05080b7369bd1a1b930dab1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_underlinecolor_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_UNDERLINECOLOR_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_UNDERLINECOLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputUnderlineColorTest { +public: + ~TextInputUnderlineColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_UNDERLINECOLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_wordbreak_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_wordbreak_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a212dba3ff3e8fc0404ea2aa06a2b73156a2e358 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_wordbreak_test.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "textinput_wordbreak_test.h" + +#include + +#include "../manager/plugin_manager.h" + +#define TEXTINPUT_WIDTH_150 150 + +namespace ArkUICApiDemo { + +static auto CreateSubTextInputNode(ArkUI_NativeNodeAPI_1* nodeAPI, int32_t type, char* id) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT_INPUT); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = TEXTINPUT_WIDTH_150 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + + // set height + ArkUI_NumberValue height_value[] = { { .f32 = SIZE_50 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + + // set inlineStyle + ArkUI_NumberValue style_value[] = { { .i32 = ARKUI_TEXTINPUT_STYLE_INLINE } }; + ArkUI_AttributeItem type_item = { style_value, sizeof(style_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_STYLE, &type_item); + + // set wordBreakType + ArkUI_NumberValue textinputValue[] = { { .i32 = type } }; + ArkUI_AttributeItem textinputItem = { textinputValue, sizeof(textinputValue) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_INPUT_WORD_BREAK, &textinputItem); + + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + + ArkUI_NumberValue Border_Value_1[] = { { .f32 = 1 } }; + ArkUI_AttributeItem Border_Item_1 = { Border_Value_1, sizeof(Border_Value_1) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_WIDTH, &Border_Item_1); + + ArkUI_AttributeItem id_item = {}; + id_item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_ID, &id_item); + + return nodeHandle; +} + +napi_value TextInputWordBreakTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputWordBreakTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputWordBreakTest", "GetContext env or info is null"); + return nullptr; + } + // create nodeAPI + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // create column + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + // create four textinput with diffrent types + auto textInput0 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_NORMAL, "textInput0"); + auto textInput1 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_NORMAL, "textInput1"); + auto textInput2 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_ALL, "textInput2"); + auto textInput3 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_ALL, "textInput3"); + auto textInput4 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_WORD, "textInput4"); + auto textInput5 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_BREAK_WORD, "textInput5"); + auto textInput6 = CreateSubTextInputNode(nodeAPI, -1, "textInput6"); + auto textInput7 = CreateSubTextInputNode(nodeAPI, 3, "textInput7"); + auto textInput8 = CreateSubTextInputNode(nodeAPI, ARKUI_WORD_BREAK_NORMAL, "textInput8"); + + nodeAPI->resetAttribute(textInput8, NODE_TEXT_INPUT_WORD_BREAK); + + // insert into the column + nodeAPI->addChild(column, textInput0); + nodeAPI->addChild(column, textInput1); + nodeAPI->addChild(column, textInput2); + nodeAPI->addChild(column, textInput3); + nodeAPI->addChild(column, textInput4); + nodeAPI->addChild(column, textInput5); + nodeAPI->addChild(column, textInput6); + nodeAPI->addChild(column, textInput7); + nodeAPI->addChild(column, textInput8); + + // set text + ArkUI_AttributeItem text1_item = {}; + text1_item.string = "This is set wordBreak to WordBreak text Taumatawhakatangihangakoauauotamateat"; + ArkUI_AttributeItem text2_item = {}; + text2_item.string = "多行文本输入框组件,当输入的文本内容超过组件宽度时会自动换行显示。\n高度未设置时,组件无默认高" + "度,自适应内容高度。宽度未设置时,默认撑满最大宽度"; + + nodeAPI->setAttribute(textInput0, NODE_TEXT_INPUT_TEXT, &text2_item); + nodeAPI->setAttribute(textInput1, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput2, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput3, NODE_TEXT_INPUT_TEXT, &text2_item); + nodeAPI->setAttribute(textInput4, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput5, NODE_TEXT_INPUT_TEXT, &text2_item); + nodeAPI->setAttribute(textInput6, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput7, NODE_TEXT_INPUT_TEXT, &text1_item); + nodeAPI->setAttribute(textInput8, NODE_TEXT_INPUT_TEXT, &text1_item); + + // XComponent + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TextInputWordBreakTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_wordbreak_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_wordbreak_test.h new file mode 100644 index 0000000000000000000000000000000000000000..eb241bf1adadf5b4009025041687f9f862ebf444 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/textinput/textinput_wordbreak_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TEXTINPUT_WORDBREAK_TEST_H +#define ARKUI_CAPI_DEMO_TEXTINPUT_WORDBREAK_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class TextInputWordBreakTest { +public: + ~TextInputWordBreakTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TEXTINPUT_WORDBREAK_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/toggle/toggle_unselectedcolor_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/toggle/toggle_unselectedcolor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ed6b74c688786f2d0fbca6aa293482cc35a9cbd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/toggle/toggle_unselectedcolor_test.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "toggle_unselectedcolor_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "text_component.h" +#include "toggle_component.h" + +#define ON_CHANGE_TOGGLE_EVENT_ID 6006 +namespace ArkUICApiDemo { + +static std::shared_ptr CreateToggle(uint32_t value) +{ + auto toggle = std::make_shared(); + toggle->SetUnselectedColor(value); + toggle->SetToggleValue(false); + toggle->SetMargin(SIZE_10); + return toggle; +} + +static std::shared_ptr CreateTextComponent() +{ + auto note = std::make_shared(); + note->SetWidth(SIZE_300); + note->SetHeight(SIZE_50); + note->SetBackgroundColor(COLOR_PINK); + note->SetMargin(PARAM_10); + return note; +} + +napi_value ToggleUnSelectedColorTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = 0; + char xComponentID[PARAM_64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ToggleUnSelectedColorTest", "GetContext env or info is null"); + return nullptr; + } + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto toggle_first = CreateToggle(0xFFFF0000); + auto toggle_second = CreateToggle(COLOR_RED); + auto toggle_third = CreateToggle(SIZE_100); + auto toggle_reset = CreateToggle(0xFFFF0000); + auto note = CreateTextComponent(); + auto button = std::make_shared(); + button->SetId("ResetToggle"); + button->SetWidth(PARAM_32); + button->SetHeight(PARAM_32); + button->RegisterOnClick([toggle_reset, note]() { + toggle_reset->resetAttribute(NODE_TOGGLE_UNSELECTED_COLOR); + auto colorItem = toggle_reset->getAttribute(NODE_TOGGLE_UNSELECTED_COLOR); + std::string str = "colorItem:" + std::to_string(colorItem->value[0].u32) + "\n"; + note->SetTextContent(str); + if (colorItem->value[0].u32 != 0x337F7F7F) { + note->SetBackgroundColor(COLOR_RED); + } + }); + auto column = new ColumnComponent(); + column->AddChild(toggle_first); + column->AddChild(toggle_second); + column->AddChild(toggle_third); + column->AddChild(toggle_reset); + column->AddChild(button); + column->AddChild(note); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), + column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ToggleUnSelectedColorTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/toggle/toggle_unselectedcolor_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/toggle/toggle_unselectedcolor_test.h new file mode 100644 index 0000000000000000000000000000000000000000..cfd82d8227b3a6b0089815891b2941f7d5432970 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/toggle/toggle_unselectedcolor_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TOGGLE_UNSELECTEDCOLOR_TEST_H +#define ARKUI_CAPI_DEMO_TOGGLE_UNSELECTEDCOLOR_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ToggleUnSelectedColorTest { +public: + ~ToggleUnSelectedColorTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TOGGLE_UNSELECTEDCOLOR_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/tools/tools_layout_rect_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/tools/tools_layout_rect_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a6f99b8a1cd798068fc6eecce31ec25d588d9aaf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/tools/tools_layout_rect_test.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "tools_layout_rect_test.h" + +#include +#include +#include + +#include "../component/button_component.h" +#include "../component/column_component.h" +#include "../component/component.h" +#include "../component/flex_component.h" +#include "../manager/plugin_manager.h" +#include "button_component.h" + +namespace ArkUICApiDemo { +static auto addFlexNodes(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle parentColumn) +{ + // 屏幕分为上下两部分,上部分是设定的显示效果,下部分是通过获取的数据后设置的显示效果 + // 上部分column1 + auto column1 = std::make_shared(); + nodeAPI->addChild(parentColumn, column1->GetComponent()); + column1->SetPercentWidth(1); + column1->SetPercentHeight(0.5); + column1->SetBackgroundColor(COLOR_WHITE); + auto flex1 = std::make_shared(); + // 设置flex1组件Layout Rect + flex1->SetLayoutRect(50, 20, 275, 190); + flex1->SetBackgroundColor(COLOR_BLUE); + column1->AddChild(flex1); + // 下部分column2 + auto column2 = std::make_shared(); + nodeAPI->addChild(parentColumn, column2->GetComponent()); + column2->SetPercentWidth(1); + column2->SetPercentHeight(0.5); + column2->SetBackgroundColor(COLOR_GRAY); + auto flex2 = std::make_shared(); + // 获取flex1组件Layout Rect + auto resLayoutRect = nodeAPI->getAttribute(flex1->GetComponent(), NODE_LAYOUT_RECT); + flex2->SetBackgroundColor(COLOR_BLUE); + int32_t resX = resLayoutRect->value[0].i32; + int32_t resY = resLayoutRect->value[1].i32; + int32_t resWidth = resLayoutRect->value[2].i32; + int32_t resHeight = resLayoutRect->value[3].i32; + // 设置flex2组件Layout Rect + flex2->SetLayoutRect(resX, resY, resWidth, resHeight); + column2->AddChild(flex2); + // 将获取的组件Layout Rect的4个值与原设定值进行比较,设置4个button的背景颜色 + auto button1 = std::make_shared(); + auto button2 = std::make_shared(); + auto button3 = std::make_shared(); + auto button4 = std::make_shared(); + flex2->AddChild(button1); + flex2->AddChild(button2); + flex2->AddChild(button3); + flex2->AddChild(button4); + button1->SetWidth(100); + button1->SetHeight(30); + button2->SetWidth(100); + button2->SetHeight(30); + button3->SetWidth(100); + button3->SetHeight(30); + button4->SetWidth(100); + button4->SetHeight(30); + button1->SetBackgroundColor(resX == 50 ? COLOR_GREEN : COLOR_RED); + button2->SetBackgroundColor(resY == 20 ? COLOR_GREEN : COLOR_RED); + button3->SetBackgroundColor(resWidth == 275 ? COLOR_GREEN : COLOR_RED); + button4->SetBackgroundColor(resHeight == 190 ? COLOR_GREEN : COLOR_RED); +} +napi_value ToolsLayoutRectTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ToolsLayoutRectTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ToolsLayoutRectTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + addFlexNodes(nodeAPI, parentColumn); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ToolsLayoutRectTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/tools/tools_layout_rect_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/tools/tools_layout_rect_test.h new file mode 100644 index 0000000000000000000000000000000000000000..c0a0fd0d2f1fbfd5e3848a10602b524258bae3e5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/tools/tools_layout_rect_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_TOOLS_LAYOUT_RECT_TEST_H +#define ARKUI_CAPI_DEMO_TOOLS_LAYOUT_RECT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class ToolsLayoutRectTest { +public: + ~ToolsLayoutRectTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_TOOLS_LAYOUT_RECT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/types/libnativerender/index.d.ts b/function/ui_compare/capidemo/entry/src/main/cpp/types/libnativerender/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e5adf6ff77f341b5a097a5337e9798f80a5f9a7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/types/libnativerender/index.d.ts @@ -0,0 +1,739 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const animateAnimateOptionDurationTest: (a: string) => void; + +export const animateAnimateOptionDelayTest: (a: string) => void; + +export const animateAnimateOptionIterationsTest: (a: string) => void; + +export const animateAnimatorOptionDurationTest: (a: string) => void; + +export const animateAnimatorOptionInterpolationTest: (a: string) => void; + +export const animateAnimatorOptionIterationsTest: (a: string) => void; + +export const animateAnimatorOptionStateTest: (a: string) => void; + +export const animateCurveTest: (a: string) => void; + +export const animateGeometryTransitionNormalTest: (a: string) => void; + +export const animateGeometryTransitionMultiTest: (a: string) => void; + +export const animateGeometryTransitionDoubleTest: (a: string) => void; + +export const animateKeyframeAnimateOptionDurationTest: (a: string) => void; + +export const animateKeyframeAnimateOptionDelayTest: (a: string) => void; + +export const animateKeyframeAnimateOptionIterationsTest: (a: string) => void; + +export const listScrollByTest: (a: string) => void; + +export const listScrollEdgeTest: (a: string) => void; + +export const listScrollOffset2Test: (a: string) => void; + +export const listScrollOffset6Test: (a: string) => void; + +export const listScrollPageTest: (a: string) => void; + +export const listSpaceAndAlignmentTest: (a: string) => void; + +export const listScrollToIndexTest: (a: string) => void; + +export const listScrollBarWidthAndColorTest: (a: string) => void; + +export const listChildrenMainSizeTest: (a: string) => void; + +export const listCloseAllTest: (a: string) => void; + +export const listDividerAndInitialIndexTest: (a: string) => void; + +export const listNestedScrollTest: (a: string) => void; + +export const listNestedScrollSmallTest: (a: string) => void; + +export const listItemGroupDividerTest: (a: string) => void; + +export const listItemGroupHeaderAndFooterTest: (a: string) => void; + +export const columnJustifyContentTest: (a: string) => void; + +export const columnAlignItemsTest: (a: string) => void; + +export const columnAlignItemsMoreAttributeTest: (a: string) => void; + +export const rowJustifyContentTest: (a: string) => void; + +export const rowAlignItemsTest: (a: string) => void; + +export const rowAlignItemsMoreAttributeTest: (a: string) => void; + +export const flexOptionsTest: (a: string) => void; + +export const radioCheckedTest: (a: string) => void; + +export const radioStyleTest: (a: string) => void; + +export const radioValueAndGroupTest: (a: string) => void; + +export const radioResetAttributeTest: (a: string) => void; + +export const relativeContainerGuideLineTest: (a: string) => void; + +export const relativeContainerBarrierTest: (a: string) => void; + +export const ruleOptionTest: (a: string) => void; + +export const gridTest: (a: string) => void; + +export const gridCachedCountTest: (a: string) => void; + +export const gridResetAttributeTest: (a: string) => void; + +export const gestureGestureTest: (a: string) => void; + +export const gestureGesture1Test: (a: string) => void; + +export const gestureGesture2Test: (a: string) => void; + +export const gestureGesture3Test: (a: string) => void; + +export const requirementPanGestureTest: (a: string) => void; + +export const requirementPinchAndPanGestureTest: (a: string, b: object) => void; + +export const requirementRouterPageStateTest: (a: string) => void; + +export const resourceNapiValueTest: (a: string, b: object) => void; + +export const lazyForEachGetAllItemTest: (a: string) => void; + +export const lazyForEachUnregisterTest: (a: string) => void; + +export const lazyForEachTotalCountTest: (a: string) => void; + +export const lazyForEachNodeIdTest: (a: string) => void; + +export const lazyForEachDisposeTest: (a: string) => void; + +export const lazyForEachHostNodeTest: (a: string) => void; + +export const lazyForEachReloadAllItemsTest: (a: string) => void; + +export const lazyForEachReloadItemTest: (a: string) => void; + +export const lazyForEachReloadItemBigTest: (a: string) => void; + +export const lazyForEachRemoveItemTest: (a: string) => void; + +export const lazyForEachRemoveItemBigTest: (a: string) => void; + +export const lazyForEachInsertItemTest: (a: string) => void; + +export const lazyForEachInsertItemBigTest: (a: string) => void; + +export const lazyForEachMoveItemTest: (a: string) => void; + +export const lazyForEachMoveItemBigTest: (a: string) => void; + +export const lazyForEachGetRemovedNodeTest: (a: string) => void; + +export const refreshForContentAndRatioTest: (a: string, b: number) => void; + +export const refreshForRefreshingTest: (a: string) => void; + +export const refreshTest: (a: string, b: number, c: number) => void; + +export const refreshNestedScrollTest: (a: string) => void; + +export const refreshResetAttributeTest: (a: string) => void; + +export const toggleUnSelectedColorTest: (a: string) => void; + +export const imageFrameInfoTest: (a: string) => void; + +export const imageFrameInfoAbnormalTest: (a: string) => void; + +export const imageFrameInfoDrawableTest: (a: string) => void; + +export const imageFrameInfoDrawableAbnormalTest: (a: string) => void; + +export const imageAnimatorTest: (a: string) => void; + +export const imageAnimatorDurationTest: (a: string) => void; + +export const imageAnimatorReverseTest: (a: string) => void; + +export const imageAnimatorFixedSizeTest: (a: string) => void; + +export const imageAnimatorFillModeTest: (a: string) => void; + +export const imageAnimatorIterationsTest: (a: string) => void; + +export const imageAnimatorResetAttributeTest: (a: string) => void; + +export const swiperEffectModeSpringTest: (a: string) => void; + +export const swiperEffectModeMultipleTest: (a: string) => void; + +export const swiperEffectModeFadeTest: (a: string) => void; + +export const swiperEffectModeNoneTest: (a: string) => void; + +export const swiperEffectModeAbnormalTest: (a: string) => void; + +export const swiperEffectModeInterruptTest: (a: string) => void; + +export const swiperAdapterTest: (a: string) => void; + +export const swiperPrevMarginTest: (a: string) => void; + +export const swiperPrevMarginAbnormalTest: (a: string) => void; + +export const swiperNextMarginTest: (a: string) => void; + +export const swiperNextMarginAbnormalTest: (a: string) => void; + +export const swiperMarginTest: (a: string) => void; + +export const swiperNestedScrollTest: (a: string) => void; + +export const swiperNestedScrollChildTest: (a: string) => void; + +export const swiperNestedScrollAbnormalTest: (a: string) => void; + +export const swiperChangeIndexTest: (a: string) => void; + +export const swiperDotIndicatorTest: (a: string) => void; + +export const swiperDotIndicatorAbnormalTest: (a: string) => void; + +export const swiperEventOnGestureTest: (a: string) => void; + +export const swiperEventOnDidScrollTest: (a: string) => void; + +export const swiperOnChangeTest: (a: string) => void; + +export const swiperOnAnimationTest: (a: string) => void; + +export const swiperResetAttributeTest: (a: string) => void; + +export const customDialogContentTest: (a: string) => void; + +export const buttonTypeTest: (a: string) => void; + +export const calendarPickerHintRadiusPage1Test: (a: string) => void; + +export const calendarPickerHintRadiusPage2Test: (a: string) => void; + +export const calendarPickerHintRadiusPage3Test: (a: string) => void; + +export const calendarPickerHintRadiusPage4Test: (a: string) => void; + +export const calendarPickerHintRadiusPage5Test: (a: string) => void; + +export const calendarPickerHintRadiusPage6Test: (a: string) => void; + +export const calendarPickerHintRadiusPage7Test: (a: string) => void; + +export const calendarPickerHintRadiusPage8Test: (a: string) => void; + +export const calendarPickerSelectedDatePage1Test: (a: string) => void; + +export const calendarPickerSelectedDatePage2Test: (a: string) => void; + +export const calendarPickerSelectedDatePage3Test: (a: string) => void; + +export const calendarPickerSelectedDatePage4Test: (a: string) => void; + +export const sliderTrackThicknessPage1Test: (a: string) => void; + +export const sliderTrackThicknessPage2Test: (a: string) => void; + +export const stackAlignContentTest: (a: string) => void; + +export const waterFlowCachedCountTest: (a: string) => void; + +export const waterFlowSectionTest1: (a: string) => void; + +export const waterFlowSectionTest2: (a: string) => void; + +export const waterFlowSectionTest3: (a: string) => void; + +export const waterFlowLayoutDirectionTest: (a: string) => void; + +export const waterFlowColumnsRowsTemplateTest: (a: string) => void; + +export const waterFlowColumnsRowsGapTest: (a: string) => void; + +export const waterFlowNestedScrollTest: (a: string) => void; + +export const waterFlowNestedScrollSmallTest: (a: string) => void; + +export const waterFlowNestedScrollResetTest: (a: string) => void; + +export const waterFlowScrollBarDisplayModeTest: (a: string) => void; + +export const waterFlowScrollBarWidthTest: (a: string) => void; + +export const waterFlowScrollBarColorTest: (a: string) => void; + +export const waterFlowScrollFrictionTest: (a: string) => void; + +export const waterFlowScrollEdgeEffectTest: (a: string) => void; + +export const waterFlowScrollOffset2Test: (a: string) => void; + +export const waterFlowScrollOffset6Test: (a: string) => void; + +export const waterFlowScrollOffsetCurveTest: (a: string) => void; + +export const waterFlowScrollEdgeTest: (a: string) => void; + +export const waterFlowScrollPageTest: (a: string) => void; + +export const waterFlowScrollByTest: (a: string) => void; + +export const waterFlowEnableScrollInteractionTest: (a: string) => void; + +export const waterFlowScrollToIndexTest: (a: string) => void; + +export const waterFlowScrollToIndex8Test: (a: string) => void; + +export const waterFlowItemConstraintSizeTest: (a: string) => void; + +export const waterFlowFooterTest: (a: string) => void; + +export const waterFlowOnWillScrollTest: (a: string) => void; + +export const waterFlowOnStartEndStopTest: (a: string) => void; + +export const waterFlowOnDidScrollTest: (a: string) => void; + +export const waterFlowOnScrollFrameBeginTest: (a: string) => void; + +export const waterFlowOnScrollIndexTest: (a: string) => void; + +export const xComponentIdTest: (a: string) => void; + +export const scrollScrollBarWidthTest: (a: string) => void; + +export const scrollScrollByTest: (a: string) => void; + +export const scrollEnablePagingTest: (a: string) => void; + +export const scrollScrollOffsetTest: (a: string) => void; + +export const scrollScrollOffsetCurveTest: (a: string) => void; + +export const scrollScrollOffsetOtherTest: (a: string) => void; + +export const scrollScrollPageTest: (a: string) => void; + +export const scrollScrollEdgeHorizontalTest: (a: string) => void; + +export const scrollScrollEdgeVerticalTest: (a: string) => void; + +export const spanValueTest: (a: string) => void; + +export const spanTextBackgroundStyleTest: (a: string) => void; + +export const spanTextShadowTest: (a: string) => void; + +export const spanBaseLineOffsetTest: (a: string) => void; + +export const spanFontFamilyTest: (a: string) => void; + +export const progressTypeTest: (a: string) => void; + +export const progressValueAndTotalTest: (a: string) => void; + +export const textContentTest: (a: string) => void; + +export const textDecorationStyleTest: (a: string) => void; + +export const textWordBreakTest: (a: string) => void; + +export const textEllipsisModeTest: (a: string) => void; + +export const textLineSpacingTest: (a: string) => void; + +export const textFontFeatureFirstTest: (a: string) => void; + +export const textFontFeatureSecondTest: (a: string) => void; + +export const textFontFeatureThirdTest: (a: string) => void; + +export const textSelectedBackgroundColorTest: (a: string) => void; + +export const textEnableDataDetectorTest: (a: string) => void; + +export const textDataDetectorConfigTest: (a: string) => void; + +export const textParagraphTest: (a: string) => void; + +export const textAreaTextPlaceholderTest: (a: string) => void; + +export const textAreaTypeTest: (a: string) => void; + +export const textAreaShowCounterTest: (a: string) => void; + +export const textAreaFontFeatureFirstTest: (a: string) => void; + +export const textAreaFontFeatureSecondTest: (a: string) => void; + +export const textAreaFontFeatureThirdTest: (a: string) => void; + +export const textAreaMaxLinesTest: (a: string) => void; + +export const textAreaSelectionMenuHiddenTest: (a: string) => void; + +export const textAreaInputFilterTest: (a: string) => void; + +export const textAreaSelectedBackgroundColorTest: (a: string) => void; + +export const textAreaEnterKeyTypeTest: (a: string) => void; + +export const textAreaEnableKeyboardOnFocusTest: (a: string) => void; + +export const textAreaEnableKeyboardOnFocusDisableTest: (a: string) => void; + +export const textAreaEnableKeyboardOnFocusAbnormalTest: (a: string) => void; + +export const textAreaEnableKeyboardOnFocusResetTest: (a: string) => void; + +export const textAreaBlurOnSubmitTest: (a: string) => void; + +export const textAreaShowKeyboardOnFocusTest: (a: string) => void; + +export const textAreaShowKeyboardOnFocusAbnormalTest: (a: string) => void; + +export const textAreaGetCaretOffsetTest: (a: string) => void; + +export const textAreaCaretPositionTest: (a: string) => void; + +export const textAreaControllerTest: (a: string) => void; + +export const textAreaSetTextSelectionTest: (a: string) => void; + +export const textAreaEnableAutoFillTest: (a: string) => void; + +export const textAreaContentTypePageOneTest: (a: string) => void; + +export const textAreaNumberOfLinesTest: (a: string) => void; + +export const textInputFontFeaturePage1Test: (a: string) => void; + +export const textInputFontFeaturePage2Test: (a: string) => void; + +export const textInputFontFeaturePage3Test: (a: string) => void; + +export const textInputEnableAutoFillTest: (a: string) => void; + +export const textInputContentTypePage1Test: (a: string) => void; + +export const textInputSelectionMenuHiddenTest: (a: string) => void; + +export const textInputPasswordRulesPage1Test: (a: string) => void; + +export const textInputPasswordRulesPage2Test: (a: string) => void; + +export const textInputPasswordRulesPage3Test: (a: string) => void; + +export const textInputCustomKeyboardPage1Test: (a: string) => void; + +export const textInputCustomKeyboardPage2Test: (a: string) => void; + +export const textInputCustomKeyboardPage3Test: (a: string) => void; + +export const textInputCustomKeyboardPage4Test: (a: string) => void; + +export const textInputCustomKeyboardPage5Test: (a: string) => void; + +export const textInputCustomKeyboardPage6Test: (a: string) => void; + +export const textInputSelectAllTest: (a: string) => void; + +export const textInputTextPlaceholderTest: (a: string) => void; + +export const textInputCancelButtonTest: (a: string) => void; + +export const textInputSetTextSelectionTest: (a: string) => void; + +export const textInputUnderlineColorTest: (a: string) => void; + +export const textInputWordBreakTest: (a: string) => void; + +export const textInputStyleTest: (a: string) => void; + +export const textInputMinFontSizeAndMaxFontSizeTest: (a: string) => void; + +export const textInputMaxLinesTest: (a: string) => void; + +export const textInputNumberOfLinesTest: (a: string) => void; + +export const textInputInputFilterTest: (a: string) => void; + +export const textInputShowKeyboardOnFocusTest: (a: string) => void; + +export const textInputShowKeyboardOnFocusAbnormalTest: (a: string) => void; + +export const textInputBlurOnSubmitTest: (a: string) => void; + +export const textInputGetCaretOffsetTest: (a: string) => void; + +export const textInputCaretPositionTest: (a: string) => void; + +export const textInputControllerTest: (a: string) => void; + +export const commonAttrsBackgroundBlurStyleTest: (a: string) => void; + +export const commonAttrsBackgroundImageResourceStrTest: (a: string) => void; + +export const commonAttrsBackgroundImagePixelMapTest: (a: string) => void; + +export const commonAttrsBackgroundImageSizeTest: (a: string) => void; + +export const commonAttrsBackgroundImagePositionTest: (a: string) => void; + +export const commonAttrsBrightnessTest: (a: string) => void; + +export const commonAttrsSaturateTest: (a: string) => void; + +export const commonAttrsBlurTest: (a: string) => void; + +export const commonAttrsClipShapeTest: (a: string) => void; + +export const commonAttrsCustomShadowTest: (a: string) => void; + +export const commonAttrsVisibilityTest: (a: string) => void; + +export const commonAttrsDefaultFocusSingleTest: (a: string) => void; + +export const commonAttrsDefaultFocusNoneTest: (a: string) => void; + +export const commonAttrsDefaultFocusMultiTest: (a: string) => void; + +export const commonAttrsDefaultFocusAbnormalTest: (a: string) => void; + +export const commonAttrsFocusStatusTest: (a: string) => void; + +export const commonAttrsAspectRatioTest: (a: string) => void; + +export const commonAttrsForegroundColorTest: (a: string) => void; + +export const commonAttrsMarkAnchorTest: (a: string) => void; + +export const commonAttrsOffsetTest: (a: string) => void; + +export const commonAttrsOverlayTest: (a: string) => void; + +export const commonAttrsResponseRegionTest: (a: string) => void; + +export const commonAttrsScaleTest: (a: string) => void; + +export const commonAttrsZIndexPage1Test: (a: string) => void; + +export const commonAttrsZIndexPage2Test: (a: string) => void; + +export const commonAttrsZIndexPage3Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage1Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage2Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage3Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage4Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage5Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage6Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage7Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage8Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage9Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage10Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage11Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage12Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage13Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage14Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage15Test: (a: string) => void; + +export const commonAttrsExpandSafeAreaPage16Test: (a: string) => void; + +export const commonAttrsOutlineColorTest: (a: string) => void; + +export const commonAttrsSizeTest: (a: string) => void; + +export const commonAttrsAccessibilityRoleTest: (a: string) => void; + +export const commonAttrsAccessibilityStateTest: (a: string) => void; + +export const commonAttrsAccessibilityValueTest: (a: string) => void; + +export const commonAttrsFocusOnTouchTest: (a: string) => void; + +export const commonAttrsAlignmentPage1Test: (a: string) => void; + +export const commonAttrsAlignmentPage2Test: (a: string) => void; + +export const commonAttrsAlignmentPage3Test: (a: string) => void; + +export const commonAttrsPaddingTest: (a: string) => void; + +export const commonAttrsTranslateTest: (a: string) => void; + +export const commonAttrsTouchAbleTest: (a: string) => void; + +export const commonAttrsRotateTest: (a: string) => void; + +export const commonAttrsRenderGroupTest: (a: string) => void; + +export const commonAttrsRenderFit1Test: (a: string) => void; + +export const commonAttrsRenderFit2Test: (a: string) => void; + +export const commonAttrsRenderFit3Test: (a: string) => void; + +export const commonAttrsRenderFit4Test: (a: string) => void; + +export const commonAttrsRenderFit5Test: (a: string) => void; + +export const commonAttrsLayoutWeightTest: (a: string) => void; + +export const commonAttrsDisplayPriorityTest: (a: string) => void; + +export const commonAttrsOutlineWidthTest: (a: string) => void; + +export const commonAttrsChainModeTest: (a: string) => void; + +export const commonAttrsChainMode1Test: (a: string) => void; + +export const commonAttrsChainMode2Test: (a: string) => void; + +export const commonAttrsColorBlendTest: (a: string) => void; + +export const commonAttrsTransformCenterTest: (a: string) => void; + +export const commonAttrsTransitionMoveTest: (a: string) => void; + +export const commonAttrsTransitionOpacityTest: (a: string) => void; + +export const commonAttrsTransitionRotateTest: (a: string) => void; + +export const commonAttrsTransitionScaleTest: (a: string) => void; + +export const commonAttrsTransitionTranslateTest: (a: string) => void; + +export const commonAttrsTransitionAsymmetricTest: (a: string) => void; + +export const commonEventTest: (a: string) => void; + +export const commonHoverEventTest: (a: string) => void; + +export const commonOnVisibleAreaChangeEventTest: (a: string) => void; + +export const commonOnMouseEventTest: (a: string) => void; + +export const commonOnTouchInterceptEventTest: (a: string) => void; + +export const nodeTreeInsertTest: (a: string) => void; + +export const nodeTreeXComponentTest: (a: string, b: string) => void; + +export const nodeTreeRemoveTest: (a: string) => void; + +export const eventCallbackSpecifyNodeTest: (a: string) => void; + +export const eventCallbackGlobalTest: (a: string) => void; + +export const attributeSettingTest: (a: string) => void; + +export const inputEventTest: (a: string) => void; + +export const imageSrcTest: (a: string) => void; + +export const imagePixelMapSrcTest: (a: string) => void; + +export const imageResizableTest: (a: string) => void; + +export const imageDraggableTest: (a: string) => void; + +export const imageRenderModeTest: (a: string) => void; + +export const imageFitOriginalSizeTest: (a: string) => void; + +export const imageFillColorTest: (a: string) => void; + +export const imageOnfinishTest: (a: string) => void; + +export const imageDownProgressTest: (a: string) => void; + +export const imageSpanSrcTest: (a: string) => void; + +export const imageSpanPixelMapSrcTest: (a: string) => void; + +export const imageSpanAltAndOnClickTest: (a: string) => void; + +export const imageObjectFitTest: (a: string) => void; + +export const imageObjectFitResetAndAbnormalTest: (a: string) => void; + +export const unitLengthMetricsTest: (a: string) => void; + +export const unitPercentTest: (a: string) => void; + +export const unitPercentBorderRadiusTest: (a: string) => void; + +export const unitPercentPaddingTest: (a: string) => void; + +export const mixGetNodeHandleTest: (a: string, b: object, c: object) => void; + +export const toolsLayoutRectTest: (a: string) => void; + +export const customComponentMeasuredSizeTest: (a: string) => void; + +export const customComponentLayoutPositionTest: (a: string) => void; + +export const customComponentLayoutConstraintTest: (a: string) => void; + +export const customComponentDrawContextTest: (a: string) => void; + +export const customComponentGetTotalChildCountTest: (a: string) => void; + +export const customComponentGetChildAtTest: (a: string) => void; + +export const customComponentGetFirstChildTest: (a: string) => void; + +export const customComponentGetLastChildTest: (a: string) => void; + +export const customComponentGetPreviousNextSiblingTest: (a: string) => void; + +export const customComponentCustomEventTest: (a: string) => void; + +export const customComponentUnregisterCustomEventTest: (a: string) => void; + +export const customComponentLayoutAgainTest: (a: string) => void; diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/types/libnativerender/oh-package.json5 b/function/ui_compare/capidemo/entry/src/main/cpp/types/libnativerender/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c696c592ecfee7f80e46f55e790cf8353ede0fb9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/types/libnativerender/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libnativerender.so", + "types": "./index.d.ts", + "version": "0.1.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_Percent_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_Percent_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b7dc9b08a5863b4d2182b4d74d1a2079178f6162 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_Percent_test.cpp @@ -0,0 +1,416 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_Percent_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem width_item = { width_value, 1 }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 1 } }; + ArkUI_AttributeItem height_item = { height_value, 1 }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLACK } }; + ArkUI_AttributeItem background_color_item = { background_color_value, 1 }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + return nodeHandle; +} + +static auto createFlexNode(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, float margin, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN_PERCENT, &margin_item); + return nodeHandle; +} + +static auto createFlexNode(ArkUI_NativeNodeAPI_1* nodeAPI, float width, float height, float* margin, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = margin[0] }, { .f32 = margin[1] }, { .f32 = margin[2] }, + { .f32 = margin[3] } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN_PERCENT, &margin_item); + return nodeHandle; +} + +static auto createFlexAndBorderRadiusNode(ArkUI_NativeNodeAPI_1* nodeAPI, float radius, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 0.8 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 0.1 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set border radius + ArkUI_NumberValue radius_value[] = { { .f32 = radius } }; + ArkUI_AttributeItem radius_item = { radius_value, sizeof(radius_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_RADIUS_PERCENT, &radius_item); + return nodeHandle; +} + +static auto createFlexAndBorderRadiusNode(ArkUI_NativeNodeAPI_1* nodeAPI, float* radius, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 0.8 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 0.1 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set border radius + ArkUI_NumberValue radius_value[] = { { .f32 = radius[0] }, { .f32 = radius[1] }, { .f32 = radius[2] }, + { .f32 = radius[3] } }; + ArkUI_AttributeItem radius_item = { radius_value, sizeof(radius_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_RADIUS_PERCENT, &radius_item); + return nodeHandle; +} + +static auto createFlexAndBorderRadiusNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 0.8 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH_PERCENT, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 0.1 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT_PERCENT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set border radius + ArkUI_AttributeItem radius_item; + nodeAPI->setAttribute(nodeHandle, NODE_BORDER_RADIUS_PERCENT, &radius_item); + return nodeHandle; +} + +static auto createFlexAndPaddingNode(ArkUI_NativeNodeAPI_1* nodeAPI, float padding, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set padding percent + ArkUI_NumberValue padding_value[] = { { .f32 = padding } }; + ArkUI_AttributeItem padding_item = { padding_value, sizeof(padding_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_PADDING_PERCENT, &padding_item); + // add child + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI)); + return nodeHandle; +} + +static auto createFlexAndPaddingNode(ArkUI_NativeNodeAPI_1* nodeAPI, float* padding, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set padding percent + ArkUI_NumberValue padding_value[] = { { .f32 = padding[0] }, { .f32 = padding[1] }, { .f32 = padding[2] }, + { .f32 = padding[3] } }; + ArkUI_AttributeItem padding_item = { padding_value, sizeof(padding_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_PADDING_PERCENT, &padding_item); + // add child + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI)); + return nodeHandle; +} + +static auto createFlexAndPaddingNode(ArkUI_NativeNodeAPI_1* nodeAPI, uint32_t color) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_FLEX); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 400 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 100 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 10 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set padding percent nullptr + ArkUI_AttributeItem padding_item; + nodeAPI->setAttribute(nodeHandle, NODE_PADDING_PERCENT, &padding_item); + // add child + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI)); + return nodeHandle; +} + +napi_value UnitPercentTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + float margin[4] = { 0.05, 0.0, 0.08, 0.1 }; + auto flex1 = createFlexNode(nodeAPI, 1, 0.15, 0.25, COLOR_RED); + auto flex2 = createFlexNode(nodeAPI, 0.05, 0.35, margin, COLOR_BLUE); + auto flex3 = createFlexNode(nodeAPI, 0, 0, 0.1, COLOR_GREEN); + auto flex4 = createFlexNode(nodeAPI, 2, 2, 2, COLOR_YELLOW); + auto flex5 = createFlexNode(nodeAPI, -1, -1, -1, COLOR_PURPLE); + nodeAPI->addChild(parentColumn, flex1); + nodeAPI->addChild(parentColumn, flex2); + nodeAPI->addChild(parentColumn, flex3); + nodeAPI->addChild(parentColumn, flex4); + nodeAPI->addChild(parentColumn, flex5); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value UnitPercentTest::CreatePaddingNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + float padding1[4] = { 0.0, 0.0, 0.0, 0.2 }; + float padding2[4] = { 0.1, 0.0, 0.0, 0.0 }; + float padding3[4] = { 0.05, 0.01, 0.1, 0.2 }; + float padding4[4] = { 0.0, 0.0, 0.1, 0.0 }; + float padding5[4] = { -0.01, -0.02, 0.1, 0.1 }; + auto flex1 = createFlexAndPaddingNode(nodeAPI, 0.05, COLOR_RED); + auto flex2 = createFlexAndPaddingNode(nodeAPI, padding1, COLOR_BLUE); + auto flex3 = createFlexAndPaddingNode(nodeAPI, padding2, COLOR_GREEN); + auto flex4 = createFlexAndPaddingNode(nodeAPI, padding3, COLOR_YELLOW); + auto flex5 = createFlexAndPaddingNode(nodeAPI, padding4, COLOR_PURPLE); + auto flex6 = createFlexAndPaddingNode(nodeAPI, padding5, COLOR_LIGHT_BLUE); + auto flex7 = createFlexAndPaddingNode(nodeAPI, COLOR_BLACK); + nodeAPI->addChild(parentColumn, flex1); + nodeAPI->addChild(parentColumn, flex2); + nodeAPI->addChild(parentColumn, flex3); + nodeAPI->addChild(parentColumn, flex4); + nodeAPI->addChild(parentColumn, flex5); + nodeAPI->addChild(parentColumn, flex6); + nodeAPI->addChild(parentColumn, flex7); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value UnitPercentTest::CreateBorderRadiusNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + float radius1[4] = { 0.05, 0.01, 0.1, 0.2 }; + float radius2[4] = { 0.0, 0.0, 0.0, 0.2 }; + float radius3[4] = { 0.0, 0.0, 0.1, 0.0 }; + float radius4[4] = { 0.1, 0.0, 0.0, 0.0 }; + float radius5[4] = { -0.5, -0.2, 0.0, 0.0 }; + auto flex1 = createFlexAndBorderRadiusNode(nodeAPI, 0.15, COLOR_RED); + auto flex2 = createFlexAndBorderRadiusNode(nodeAPI, radius1, COLOR_BLUE); + auto flex3 = createFlexAndBorderRadiusNode(nodeAPI, radius2, COLOR_GREEN); + auto flex4 = createFlexAndBorderRadiusNode(nodeAPI, radius3, COLOR_YELLOW); + auto flex5 = createFlexAndBorderRadiusNode(nodeAPI, radius4, COLOR_PURPLE); + auto flex6 = createFlexAndBorderRadiusNode(nodeAPI, radius5, COLOR_GRAY); + auto flex7 = createFlexAndBorderRadiusNode(nodeAPI, COLOR_BLACK); + nodeAPI->addChild(parentColumn, flex1); + nodeAPI->addChild(parentColumn, flex2); + nodeAPI->addChild(parentColumn, flex3); + nodeAPI->addChild(parentColumn, flex4); + nodeAPI->addChild(parentColumn, flex5); + nodeAPI->addChild(parentColumn, flex6); + nodeAPI->addChild(parentColumn, flex7); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitPercentTest", "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_Percent_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_Percent_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a95907ca31aa87d8a67bd9a43572e48c64583ed1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_Percent_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_UNIT_PERCENT_TEST_H +#define ARKUI_CAPI_DEMO_UNIT_PERCENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class UnitPercentTest { +public: + ~UnitPercentTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + static napi_value CreatePaddingNativeNode(napi_env env, napi_callback_info info); + static napi_value CreateBorderRadiusNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_UNIT_PERCENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_length_metrics_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_length_metrics_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f53c253c7f298525144d50793bd1c666b7e188a2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_length_metrics_test.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_length_metrics_test.h" + +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto createChildNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_LengthMetricUnit unit) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_TEXT); + // set width + ArkUI_NumberValue button_width_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem button_width_item = { button_width_value, + sizeof(button_width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &button_width_item); + // set height + ArkUI_NumberValue button_height_value[] = { { .f32 = 50 } }; + ArkUI_AttributeItem button_height_item = { button_height_value, + sizeof(button_height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &button_height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set background color + ArkUI_NumberValue text_background_color_value[] = { { .u32 = COLOR_GREEN } }; + ArkUI_AttributeItem text_background_color_item = { text_background_color_value, + sizeof(text_background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &text_background_color_item); + // set font size + ArkUI_NumberValue font_size_value[] = { { .f32 = 16 } }; + nodeAPI->setLengthMetricUnit(nodeHandle, unit); + ArkUI_AttributeItem font_size_item = { font_size_value, sizeof(font_size_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_FONT_SIZE, &font_size_item); + // set text content + ArkUI_AttributeItem content_item = {}; + content_item.string = "TEXT"; + nodeAPI->setAttribute(nodeHandle, NODE_TEXT_CONTENT, &content_item); + return nodeHandle; +} + +static auto createColumnNode(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_LengthMetricUnit unit) +{ + auto nodeHandle = nodeAPI->createNode(ARKUI_NODE_COLUMN); + // set background color + ArkUI_NumberValue background_color_value[] = { { .u32 = COLOR_BLUE } }; + ArkUI_AttributeItem background_color_item = { background_color_value, + sizeof(background_color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &background_color_item); + // set width + ArkUI_NumberValue width_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setLengthMetricUnit(nodeHandle, unit); + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + // set height + ArkUI_NumberValue height_value[] = { { .f32 = 200 } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + // set margin + ArkUI_NumberValue margin_value[] = { { .f32 = 5 } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + // set children + nodeAPI->addChild(nodeHandle, createChildNode(nodeAPI, unit)); + return nodeHandle; +} + +napi_value UnitLengthMetricsTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitLengthMetricsTest", "CreateNativeNode"); + + size_t argc = 1; + napi_value args[1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = 64; + size_t strLength = 0; + char xComponentID[64] = { 0 }; + napi_get_value_string_utf8(env, args[0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitLengthMetricsTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + // set parent node + auto parentColumn = nodeAPI->createNode(ARKUI_NODE_COLUMN); + + auto column1 = createColumnNode(nodeAPI, ARKUI_LENGTH_METRIC_UNIT_DEFAULT); + auto column2 = createColumnNode(nodeAPI, ARKUI_LENGTH_METRIC_UNIT_PX); + auto column3 = createColumnNode(nodeAPI, ARKUI_LENGTH_METRIC_UNIT_FP); + auto column4 = createColumnNode(nodeAPI, ARKUI_LENGTH_METRIC_UNIT_VP); + + nodeAPI->addChild(parentColumn, column1); + nodeAPI->addChild(parentColumn, column2); + nodeAPI->addChild(parentColumn, column3); + nodeAPI->addChild(parentColumn, column4); + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), parentColumn) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "UnitLengthMetricsTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_length_metrics_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_length_metrics_test.h new file mode 100644 index 0000000000000000000000000000000000000000..20ef7663589050bf56f4c65491711ae4999b230b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/unit/unit_length_metrics_test.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_UNIT_LENGTH_METRICS_TEST_H +#define ARKUI_CAPI_DEMO_UNIT_LENGTH_METRICS_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class UnitLengthMetricsTest { +public: + ~UnitLengthMetricsTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_UNIT_LENGTH_METRICS_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_cached_count_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_cached_count_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..548e143d9eae2a60a6d06f82b415b8afaa3ef71e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_cached_count_test.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_cached_count_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "column_component.h" +#include "flowitem_component.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +constexpr int32_t FLOW_ITEM_COUNT = 20; + +void changeWaterFlowItem( + std::shared_ptr> adapter, WaterFlowComponent* waterFlow, int32_t index) +{ + adapter->SetAllItem([](std::shared_ptr item, uint32_t index) { + auto children = item->GetChildren(); + if (!children.empty()) { + children.front()->SetBackgroundColor(COLOR_GREEN); + } + }); + waterFlow->SetWaterFlowScrollToIndex(index + 10, 0, 0); + waterFlow->SetWaterFlowScrollToIndex(index, 0, 0); +} + +ColumnComponent* WaterFlowCachedCountTest::CreateWaterFlowCachedCountExample(int32_t cachedCount, bool reset) +{ + auto column = new ColumnComponent(); + auto waterFlow = std::make_shared(); + waterFlow->SetWidth(120); + waterFlow->SetHeight(400); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + + std::vector> input; + auto adapter = std::make_shared>(input); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetWaterFlowCachedCount(cachedCount); + + auto item = waterFlow->getAttribute(NODE_WATER_FLOW_CACHED_COUNT); + if (item->value[0].i32 != cachedCount) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(100); + col->SetHeight(100); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / FLOW_ITEM_COUNT) | 0xFF000000); + col->SetBorderRadius(5, 5, 5, 5); + adapter->InsertItem(i, col); + } + + if (reset) { + waterFlow->resetAttribute(NODE_WATER_FLOW_CACHED_COUNT); + } + + waterFlow->SetWaterFlowScrollToIndex(1, 1, 0); + column->AddChild(waterFlow); + return column; +} + +napi_value WaterFlowCachedCountTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowCachedCountTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowCachedCountTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto col1 = CreateWaterFlowCachedCountExample(-2); + auto col2 = CreateWaterFlowCachedCountExample(0); + auto col3 = CreateWaterFlowCachedCountExample(2); + auto col4 = CreateWaterFlowCachedCountExample(2, true); + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row = std::make_shared(); + row->AddChild(std::shared_ptr(col1)); + row->AddChild(std::shared_ptr(col2)); + row->AddChild(std::shared_ptr(col3)); + row->AddChild(std::shared_ptr(col4)); + column->AddChild(row); + column->AddChild(btn); + + btn->RegisterOnClick([col1, col2, col3, col4]() { + auto waterFlow1 = dynamic_cast(col1->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col2->GetChildren().front().get()); + auto waterFlow3 = dynamic_cast(col3->GetChildren().front().get()); + auto waterFlow4 = dynamic_cast(col4->GetChildren().front().get()); + changeWaterFlowItem(waterFlow1->GetAdapter(), waterFlow1, 4); + changeWaterFlowItem(waterFlow2->GetAdapter(), waterFlow2, 3); + changeWaterFlowItem(waterFlow3->GetAdapter(), waterFlow3, 5); + changeWaterFlowItem(waterFlow4->GetAdapter(), waterFlow4, 4); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowCachedCountTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_cached_count_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_cached_count_test.h new file mode 100644 index 0000000000000000000000000000000000000000..6a216d8bb5651b07af625490d90e4e950fbc9c99 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_cached_count_test.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_WATERFLOW_CACHED_COUNT_TEST_H +#define ARKUI_CAPI_DEMO_WATERFLOW_CACHED_COUNT_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowCachedCountTest { +public: + ~WaterFlowCachedCountTest(); + static ColumnComponent* CreateWaterFlowCachedCountExample(int32_t cachedCount, bool reset = false); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo + +#endif // ARKUI_CAPI_DEMO_WATERFLOW_CACHED_COUNT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_gap.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_gap.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f4fdcbbb732ebd65af17fdc3b5f1ef7b6a0bfe19 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_gap.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_columns_rows_gap.h" + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" +namespace ArkUICApiDemo { +constexpr int32_t FLOW_ITEM_COUNT = 40; +napi_value WaterFlowColumnsRowsGapTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowColumnsRowsTemplateTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowColumnsRowsTemplateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + float colGap1 = -10; + float colGap2 = 10; + float rowGap1 = -10; + float rowGap2 = 10; + + // NODE_WATER_FLOW_COLUMN_GAP + // NODE_WATER_FLOW_ROW_GAP + auto col1 = CreateWaterFlowByGap(colGap1, rowGap1, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col2 = CreateWaterFlowByGap(colGap1, rowGap1, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col3 = CreateWaterFlowByGap(colGap1, rowGap2, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col4 = CreateWaterFlowByGap(colGap1, rowGap2, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col5 = CreateWaterFlowByGap(colGap2, rowGap1, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col6 = CreateWaterFlowByGap(colGap2, rowGap1, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col7 = CreateWaterFlowByGap(colGap2, rowGap2, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col8 = CreateWaterFlowByGap(colGap2, rowGap2, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col9 = CreateWaterFlowByGap(colGap2, rowGap2, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto waterFlow1 = dynamic_cast(col9->GetChildren().front().get()); + waterFlow1->resetAttribute(NODE_WATER_FLOW_ROW_GAP); + waterFlow1->resetAttribute(NODE_WATER_FLOW_COLUMN_GAP); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowColumnsRowsTemplateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +std::shared_ptr WaterFlowColumnsRowsGapTest::CreateWaterFlowByGap( + float columnGap, float rowGap, ArkUI_FlexDirection layoutDirection) +{ + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowColumnsGap(columnGap); + waterFlow->SetWaterFlowRowsGap(rowGap); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetColumnsTemplate("1fr 1fr 1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr 1fr 1fr 1fr 1fr 1fr"); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetLayoutDirection(layoutDirection); + + auto item1 = waterFlow->getAttribute(NODE_WATER_FLOW_COLUMN_GAP); + if (item1->value[0].f32 != columnGap) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + auto item2 = waterFlow->getAttribute(NODE_WATER_FLOW_ROW_GAP); + if (item1->value[0].f32 != rowGap) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(COLOR_WHITE); + col->SetBorderRadius(10, 10, 10, 10); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_gap.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_gap.h new file mode 100644 index 0000000000000000000000000000000000000000..d46f82ecdfbc8d77efa1b5680665c4d378d978c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_gap.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_COLUMNS_ROWS_GAP_H +#define CAPIDEMO_WATERFLOW_COLUMNS_ROWS_GAP_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowColumnsRowsGapTest { +public: + ~WaterFlowColumnsRowsGapTest() = default; + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + +private: + static std::shared_ptr CreateWaterFlowByGap( + float columnGap, float rowGap, ArkUI_FlexDirection layoutDirection); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_COLUMNS_ROWS_GAP_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_template_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_template_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f599b288a070f176b4d359917cb30f2f1b341e25 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_template_test.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_columns_rows_template_test.h" + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" +namespace ArkUICApiDemo { +constexpr int32_t FLOW_ITEM_COUNT = 20; +napi_value WaterFlowColumnsRowsTemplateTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowColumnsRowsTemplateTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, + LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowColumnsRowsTemplateTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + std::string correctStr = "1fr 1fr 2fr"; + std::string incorrectStr = "1 fr abc"; + + // NODE_WATER_FLOW_COLUMN_TEMPLATE + // NODE_WATER_FLOW_ROW_TEMPLATE + auto col1 = CreateWaterFlowByTemplate(correctStr, correctStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col2 = CreateWaterFlowByTemplate(correctStr, correctStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col3 = CreateWaterFlowByTemplate(correctStr, incorrectStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col4 = CreateWaterFlowByTemplate(correctStr, incorrectStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col5 = CreateWaterFlowByTemplate(incorrectStr, correctStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col6 = CreateWaterFlowByTemplate(incorrectStr, correctStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col7 = CreateWaterFlowByTemplate(incorrectStr, incorrectStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col8 = CreateWaterFlowByTemplate(incorrectStr, incorrectStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto col9 = CreateWaterFlowByTemplate(correctStr, correctStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + auto col10 = CreateWaterFlowByTemplate(correctStr, correctStr, ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); + auto waterFlow1 = dynamic_cast(col9->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col10->GetChildren().front().get()); + waterFlow1->SetWidth(75); + waterFlow1->resetAttribute(NODE_WATER_FLOW_ROW_TEMPLATE); + waterFlow2->SetWidth(75); + waterFlow2->resetAttribute(NODE_WATER_FLOW_COLUMN_TEMPLATE); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowColumnsRowsTemplateTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +std::shared_ptr WaterFlowColumnsRowsTemplateTest::CreateWaterFlowByTemplate( + const std::string& columnTemplate, const std::string& rowTemplate, ArkUI_FlexDirection layoutDirection) +{ + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetColumnsTemplate(columnTemplate); + waterFlow->SetRowsTemplate(rowTemplate); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetLayoutDirection(layoutDirection); + + auto item1 = waterFlow->getAttribute(NODE_WATER_FLOW_COLUMN_TEMPLATE); + if (item1->string != columnTemplate) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + + auto item2 = waterFlow->getAttribute(NODE_WATER_FLOW_ROW_TEMPLATE); + if (item2->string != rowTemplate) { + waterFlow->SetBackgroundColor(COLOR_GREEN); + } + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / FLOW_ITEM_COUNT) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_template_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_template_test.h new file mode 100644 index 0000000000000000000000000000000000000000..60ffbe349204a388d68dfc901893fd44154796bf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_columns_rows_template_test.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_COLUMNS_ROWS_TEMPLATE_TEST_H +#define CAPIDEMO_WATERFLOW_COLUMNS_ROWS_TEMPLATE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowColumnsRowsTemplateTest { +public: + ~WaterFlowColumnsRowsTemplateTest() = default; + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + +private: + static std::shared_ptr CreateWaterFlowByTemplate( + const std::string& columnTemplate, const std::string& rowTemplate, ArkUI_FlexDirection layoutDirection); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_COLUMNS_ROWS_TEMPLATE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_event_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_event_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..153818dfa3d49ccb0db2aa3e17638108823a9a89 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_event_test.cpp @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_event_test.h" + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "row_component.h" + +namespace ArkUICApiDemo { + +using OnWillScrollCallBack = std::function, bool)>; +using OnReachStartCallBack = std::function, bool)>; +using OnReachEndCallBack = std::function, bool)>; +using OnScrollStopCallBack = std::function, bool)>; +using OnDidScrollCallBack = std::function, bool)>; +using OnScrollFrameBeginCallBack = std::function, bool)>; +using OnScrollIndexCallBack = std::function, bool)>; + +napi_value WaterFlowEventTest::CreateNativeNodeOnWillScroll(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + OnWillScrollCallBack change1 = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetOnWillScroll([waterFlow](float offset, int32_t direction, int32_t index) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OnWillScroll offset: %{public}f, direction: %{public}d, index: %{public}d", offset, direction, index); + waterFlow->SetBackgroundColor(COLOR_RED); + }); + }; + + // NODE_ON_WILL_SCROLL + auto col1 = CreateWaterFlow(change1, false); + auto col2 = CreateWaterFlow(change1, true); + auto btn = std::make_shared(); + btn->SetHeight(50); + btn->SetWidth(100); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + column->AddChild(row1); + column->AddChild(btn); + + btn->RegisterOnClick([col1, col2]() { + auto waterFlow1 = dynamic_cast(col1->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col2->GetChildren().front().get()); + waterFlow1->SetScrollTo(0, 100, {}); + waterFlow2->SetScrollTo(100, 0, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// NODE_SCROLL_EVENT_ON_REACH_START +// NODE_SCROLL_EVENT_ON_REACH_END +// NODE_SCROLL_EVENT_ON_SCROLL_STOP +napi_value WaterFlowEventTest::CreateNativeNodeStartEndStop(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + OnReachStartCallBack reachStart = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(6, 0, 0); + waterFlow->SetOnReachStart([waterFlow]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "OnReachStart"); + waterFlow->SetBackgroundColor(COLOR_RED); + }); + }; + OnReachEndCallBack reachEnd = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(6, 0, 0); + waterFlow->SetOnReachEnd([waterFlow]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "OnReachEnd"); + waterFlow->SetBackgroundColor(COLOR_RED); + }); + }; + OnScrollStopCallBack scrollStop = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetOnScrollStop([waterFlow]() { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "OnScrollStop"); + waterFlow->SetBackgroundColor(COLOR_RED); + }); + }; + + // NODE_SCROLL_EVENT_ON_REACH_START + auto col1 = CreateWaterFlow(reachStart, false); + auto col2 = CreateWaterFlow(reachStart, true); + // NODE_SCROLL_EVENT_ON_REACH_END + auto col3 = CreateWaterFlow(reachEnd, false); + auto col4 = CreateWaterFlow(reachEnd, true); + // NODE_SCROLL_EVENT_ON_SCROLL_STOP + auto col5 = CreateWaterFlow(scrollStop, false); + auto col6 = CreateWaterFlow(scrollStop, true); + auto btn = std::make_shared(); + btn->SetHeight(50); + btn->SetWidth(100); + btn->SetId("btn"); + + std::vector> columns1 = { col1, col2 }; + std::vector> columns2 = { col3, col4, col5, col6 }; + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(btn); + + btn->RegisterOnClick([columns1, columns2]() { + for (auto node : columns1) { + auto waterFlow = dynamic_cast(node->GetChildren().front().get()); + waterFlow->SetScrollTo(-100000, -100000, {}); + } + for (auto node : columns2) { + auto waterFlow = dynamic_cast(node->GetChildren().front().get()); + waterFlow->SetScrollTo(100000, 100000, {}); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// NODE_WATER_FLOW_ON_DID_SCROLL +napi_value WaterFlowEventTest::CreateNativeNodeOnDidScroll(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + OnDidScrollCallBack didScroll = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetOnDidScroll([waterFlow](float offset, int32_t state) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OnDidScroll offset: %{public}f, state: %{public}d", offset, state); + waterFlow->SetBackgroundColor(COLOR_RED); + }); + }; + + // NODE_WATER_FLOW_ON_DID_SCROLL + auto col1 = CreateWaterFlow(didScroll, false); + auto col2 = CreateWaterFlow(didScroll, true); + auto btn = std::make_shared(); + btn->SetHeight(50); + btn->SetWidth(100); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + column->AddChild(row1); + column->AddChild(btn); + + btn->RegisterOnClick([col1, col2]() { + auto waterFlow1 = dynamic_cast(col1->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col2->GetChildren().front().get()); + waterFlow1->SetScrollTo(0, 100, {}); + waterFlow2->SetScrollTo(100, 0, {}); + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// NODE_SCROLL_EVENT_ON_SCROLL_FRAME_BEGIN +napi_value WaterFlowEventTest::CreateNativeNodeOnScrollFrameBegin(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + OnScrollFrameBeginCallBack scrollFrameBegin = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetOnScrollFrameBegin([waterFlow](float offset, int32_t state) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OnScrollFrameBegin offset: %{public}f, state: %{public}d", offset, state); + waterFlow->SetBackgroundColor(COLOR_RED); + return 10; + }); + }; + + // NODE_WATER_FLOW_ON_DID_SCROLL + auto col1 = CreateWaterFlow(scrollFrameBegin, false); + auto col2 = CreateWaterFlow(scrollFrameBegin, true); + col1->SetId("col1"); + col2->SetId("col2"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// NODE_WATER_FLOW_ON_SCROLL_INDEX +napi_value WaterFlowEventTest::CreateNativeNodeOnScrollIndex(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + OnScrollIndexCallBack scrollIndex = [](std::shared_ptr waterFlow, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetOnScrollIndex([waterFlow](int32_t first, int32_t last) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OnScrollIndex first: %{public}d, last: %{public}d", first, last); + if (first == 6 && last == 13) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }); + }; + + // NODE_WATER_FLOW_ON_SCROLL_INDEX + auto col1 = CreateWaterFlow(scrollIndex, false); + auto col2 = CreateWaterFlow(scrollIndex, true); + col1->SetId("col1"); + col2->SetId("col2"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowEventTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_event_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_event_test.h new file mode 100644 index 0000000000000000000000000000000000000000..6fc9359ac344563de0e1627aa1cebda901607e7c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_event_test.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_EVENT_TEST_H +#define CAPIDEMO_WATERFLOW_EVENT_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "text_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { +constexpr int32_t EVENT_FLOW_ITEM_COUNT = 15; + +class WaterFlowEventTest { +public: + ~WaterFlowEventTest() = default; + static napi_value CreateNativeNodeOnWillScroll(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeStartEndStop(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOnDidScroll(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOnScrollFrameBegin(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOnScrollIndex(napi_env env, napi_callback_info info); + +private: + template + static std::shared_ptr CreateWaterFlow( + std::function, Args...)> change, Args... args) + { + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(110); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetWaterFlowColumnsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetColumnsTemplate("1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr"); + + for (int i = 0; i < size; i++) { + auto col = std::make_shared(); + col->SetWidth(40); + col->SetHeight(40); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / size) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + column->AddChild(waterFlow); + if (change) { + change(waterFlow, args...); + } + return column; + } +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_EVENT_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_footer_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_footer_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..120bcd97607c298cc8153a14769bc1bfa1290d70 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_footer_test.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_footer_test.h" + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" + +namespace ArkUICApiDemo { +constexpr int32_t FLOW_ITEM_COUNT = 10; +std::shared_ptr CreateWaterFlow(ArkUI_NodeHandle footer, bool isRow) +{ + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(205); + waterFlow->SetHeight(300); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetColumnsTemplate("1fr 1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr 1fr"); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowFooter(footer); + waterFlow->SetWaterFlowScrollToIndex(9); + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(50); + col->SetHeight(50); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / FLOW_ITEM_COUNT) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; +} +napi_value WaterFlowFooterTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto footer1 = std::make_shared(); + auto footer2 = std::make_shared(); + footer1->SetWidth(200); + footer1->SetHeight(200); + footer1->SetBackgroundColor(COLOR_BLUE); + footer2->SetWidth(200); + footer2->SetHeight(200); + footer2->SetBackgroundColor(COLOR_RED); + + auto col1 = CreateWaterFlow(footer1->GetComponent(), false); + auto col2 = CreateWaterFlow(footer2->GetComponent(), true); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + column->AddChild(row1); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_footer_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_footer_test.h new file mode 100644 index 0000000000000000000000000000000000000000..bd878f46572efcbe667846f428a7747088c58645 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_footer_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_FOOTER_TEST_H +#define CAPIDEMO_WATERFLOW_FOOTER_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowFooterTest { +public: + ~WaterFlowFooterTest() = default; + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_FOOTER_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_item_constraint_size_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_item_constraint_size_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7bb4b8a95c1564679e22b29f0bf1e22994bb3c96 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_item_constraint_size_test.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_item_constraint_size_test.h" + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" + +namespace ArkUICApiDemo { +constexpr int32_t FLOW_ITEM_COUNT = 20; +std::shared_ptr CreateWaterFlow(float minWidth, float maxWidth, float minHeight, float maxHeight) +{ + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetColumnsTemplate("1fr 1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr 1fr"); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetItemConstraintSize(minWidth, maxWidth, minHeight, maxHeight); + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / FLOW_ITEM_COUNT) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + auto item = waterFlow->getAttribute(NODE_WATER_FLOW_ITEM_CONSTRAINT_SIZE); + if (item->value[0].f32 != minWidth || item->value[1].f32 != maxWidth || item->value[2].f32 != minHeight || + item->value[3].f32 != maxHeight) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + column->AddChild(waterFlow); + return column; +} +napi_value WaterFlowItemConstraintSizeTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + auto col1 = CreateWaterFlow(30, 40, 30, 40); + auto col2 = CreateWaterFlow(30, -20, 30, 40); + auto col3 = CreateWaterFlow(30, 40, 30, -20); + auto col4 = CreateWaterFlow(-20, 40, -30, 40); + auto col5 = CreateWaterFlow(50, 50, -30, 50); + auto col6 = CreateWaterFlow(50, 60, 50, 60); + auto col7 = CreateWaterFlow(50, 40, 50, 40); + auto col8 = CreateWaterFlow(20, 22, 20, 22); + auto col9 = CreateWaterFlow(20, 22, 20, 22); + auto waterFlow = dynamic_cast(col9->GetChildren().front().get()); + waterFlow->resetAttribute(NODE_WATER_FLOW_ITEM_CONSTRAINT_SIZE); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_item_constraint_size_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_item_constraint_size_test.h new file mode 100644 index 0000000000000000000000000000000000000000..666a3ef7f8ce4ad2bfa82c3e0198731106260262 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_item_constraint_size_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_ITEM_CONSTRAINT_SIZE_TEST_H +#define CAPIDEMO_WATERFLOW_ITEM_CONSTRAINT_SIZE_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowItemConstraintSizeTest { +public: + ~WaterFlowItemConstraintSizeTest() = default; + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_ITEM_CONSTRAINT_SIZE_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_layout_direction_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_layout_direction_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a2d1a28aa27fa295be7a7fdb38b08687b965740e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_layout_direction_test.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_layout_direction_test.h" + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" + +namespace ArkUICApiDemo { +constexpr int32_t FLOW_ITEM_COUNT = 20; +napi_value WaterFlowLayoutDirectionTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // NODE_WATER_FLOW_LAYOUT_DIRECTION + auto col1 = CreateWaterFlowByLayoutDirection(-1); // down overflow + auto col2 = CreateWaterFlowByLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); // ROW + auto col3 = CreateWaterFlowByLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN); // COLUMN + auto col4 = CreateWaterFlowByLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW_REVERSE); // ROW_REVERSE + auto col5 = + CreateWaterFlowByLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN_REVERSE); // COLUMN_REVERSE + auto col6 = CreateWaterFlowByLayoutDirection(4); // up overflow + auto col7 = + CreateWaterFlowByLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_COLUMN_REVERSE); // COLUMN_REVERSE + auto col8 = CreateWaterFlowByLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW_REVERSE); // ROW_REVERSE + auto waterFlow1 = dynamic_cast(col7->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col8->GetChildren().front().get()); + waterFlow1->resetAttribute(NODE_WATER_FLOW_LAYOUT_DIRECTION); + waterFlow2->resetAttribute(NODE_WATER_FLOW_LAYOUT_DIRECTION); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowLayoutDirectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +std::shared_ptr WaterFlowLayoutDirectionTest::CreateWaterFlowByLayoutDirection( + int32_t layoutDirection) +{ + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetColumnsTemplate("1fr 1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr 1fr"); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetLayoutDirection(layoutDirection); + + auto item = waterFlow->getAttribute(NODE_WATER_FLOW_LAYOUT_DIRECTION); + if (item->value[0].i32 != layoutDirection) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + + for (int i = 0; i < FLOW_ITEM_COUNT; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / FLOW_ITEM_COUNT) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_layout_direction_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_layout_direction_test.h new file mode 100644 index 0000000000000000000000000000000000000000..51ae19d257f230aa970e41a2cb4f59118e05591a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_layout_direction_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_WATERFLOW_LAYOUT_DIRECTION_TEST_H +#define ARKUI_CAPI_DEMO_WATERFLOW_LAYOUT_DIRECTION_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowLayoutDirectionTest { +public: + ~WaterFlowLayoutDirectionTest() = default; + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + +private: + static std::shared_ptr CreateWaterFlowByLayoutDirection(int32_t layoutDirection); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_WATERFLOW_LAYOUT_DIRECTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_nested_scroll_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_nested_scroll_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..89e972d0657a2e6f8eb0b71639f8824e772a1586 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_nested_scroll_test.cpp @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_nested_scroll_test.h" + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" + +namespace ArkUICApiDemo { +napi_value WaterFlowNestedScrollTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto mode0 = -1; + auto mode1 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_ONLY; + auto mode2 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_FIRST; + auto mode3 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST; + auto mode4 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARALLEL; + auto mode5 = 4; + + // NODE_SCROLL_NESTED_SCROLL + // 测试向下滑动 + auto scroll1 = CreateWaterFlowByNestedScroll(mode2, mode0); + auto scroll2 = CreateWaterFlowByNestedScroll(mode2, mode1); + auto scroll3 = CreateWaterFlowByNestedScroll(mode2, mode2); + auto scroll4 = CreateWaterFlowByNestedScroll(mode2, mode3); + auto scroll5 = CreateWaterFlowByNestedScroll(mode2, mode4); + auto scroll6 = CreateWaterFlowByNestedScroll(mode2, mode5); + // 测试向上滑动 + auto scroll7 = CreateWaterFlowByNestedScroll(mode0, mode2, false); + auto scroll8 = CreateWaterFlowByNestedScroll(mode1, mode2, false); + auto scroll9 = CreateWaterFlowByNestedScroll(mode2, mode2, false); + auto scroll10 = CreateWaterFlowByNestedScroll(mode3, mode2, false); + auto scroll11 = CreateWaterFlowByNestedScroll(mode4, mode2, false); + auto scroll12 = CreateWaterFlowByNestedScroll(mode5, mode2, false); + scroll1->SetId("scroll1"); + scroll2->SetId("scroll2"); + scroll3->SetId("scroll3"); + scroll4->SetId("scroll4"); + scroll5->SetId("scroll5"); + scroll6->SetId("scroll6"); + scroll7->SetId("scroll7"); + scroll8->SetId("scroll8"); + scroll9->SetId("scroll9"); + scroll10->SetId("scroll10"); + scroll11->SetId("scroll11"); + scroll12->SetId("scroll12"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(scroll1); + row1->AddChild(scroll2); + row1->AddChild(scroll3); + row1->AddChild(scroll4); + row2->AddChild(scroll5); + row2->AddChild(scroll6); + row2->AddChild(scroll7); + row2->AddChild(scroll8); + row3->AddChild(scroll9); + row3->AddChild(scroll10); + row3->AddChild(scroll11); + row3->AddChild(scroll12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value WaterFlowNestedScrollTest::CreateNativeNodeSmall(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto mode0 = -1; + auto mode1 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_ONLY; + auto mode2 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_FIRST; + auto mode3 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST; + auto mode4 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARALLEL; + auto mode5 = 4; + + // NODE_SCROLL_NESTED_SCROLL + // 测试向下滑动 + auto scroll1 = CreateWaterFlowByNestedScroll<8>(mode2, mode0); + auto scroll2 = CreateWaterFlowByNestedScroll<8>(mode2, mode1); + auto scroll3 = CreateWaterFlowByNestedScroll<8>(mode2, mode2); + auto scroll4 = CreateWaterFlowByNestedScroll<8>(mode2, mode3); + auto scroll5 = CreateWaterFlowByNestedScroll<8>(mode2, mode4); + auto scroll6 = CreateWaterFlowByNestedScroll<8>(mode2, mode5); + // 测试向上滑动<8> + auto scroll7 = CreateWaterFlowByNestedScroll<8>(mode0, mode2, false); + auto scroll8 = CreateWaterFlowByNestedScroll<8>(mode1, mode2, false); + auto scroll9 = CreateWaterFlowByNestedScroll<8>(mode2, mode2, false); + auto scroll10 = CreateWaterFlowByNestedScroll<8>(mode3, mode2, false); + auto scroll11 = CreateWaterFlowByNestedScroll<8>(mode4, mode2, false); + auto scroll12 = CreateWaterFlowByNestedScroll<8>(mode5, mode2, false); + scroll1->SetId("scroll1"); + scroll2->SetId("scroll2"); + scroll3->SetId("scroll3"); + scroll4->SetId("scroll4"); + scroll5->SetId("scroll5"); + scroll6->SetId("scroll6"); + scroll7->SetId("scroll7"); + scroll8->SetId("scroll8"); + scroll9->SetId("scroll9"); + scroll10->SetId("scroll10"); + scroll11->SetId("scroll11"); + scroll12->SetId("scroll12"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(scroll1); + row1->AddChild(scroll2); + row1->AddChild(scroll3); + row1->AddChild(scroll4); + row2->AddChild(scroll5); + row2->AddChild(scroll6); + row2->AddChild(scroll7); + row2->AddChild(scroll8); + row3->AddChild(scroll9); + row3->AddChild(scroll10); + row3->AddChild(scroll11); + row3->AddChild(scroll12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value WaterFlowNestedScrollTest::CreateNativeNodeReset(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print( + LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto mode0 = -1; + auto mode1 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_ONLY; + auto mode2 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_SELF_FIRST; + auto mode3 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARENT_FIRST; + auto mode4 = ArkUI_ScrollNestedMode::ARKUI_SCROLL_NESTED_MODE_PARALLEL; + auto mode5 = 4; + + // NODE_SCROLL_NESTED_SCROLL + // 测试向下滑动 + auto scroll1 = CreateWaterFlowByNestedScrollReset(mode2, mode0); + auto scroll2 = CreateWaterFlowByNestedScrollReset(mode2, mode1); + auto scroll3 = CreateWaterFlowByNestedScrollReset(mode2, mode2); + auto scroll4 = CreateWaterFlowByNestedScrollReset(mode2, mode3); + auto scroll5 = CreateWaterFlowByNestedScrollReset(mode2, mode4); + auto scroll6 = CreateWaterFlowByNestedScrollReset(mode2, mode5); + // 测试向上滑动 + auto scroll7 = CreateWaterFlowByNestedScrollReset(mode0, mode2, false); + auto scroll8 = CreateWaterFlowByNestedScrollReset(mode1, mode2, false); + auto scroll9 = CreateWaterFlowByNestedScrollReset(mode2, mode2, false); + auto scroll10 = CreateWaterFlowByNestedScrollReset(mode3, mode2, false); + auto scroll11 = CreateWaterFlowByNestedScrollReset(mode4, mode2, false); + auto scroll12 = CreateWaterFlowByNestedScrollReset(mode5, mode2, false); + scroll1->SetId("scroll1"); + scroll2->SetId("scroll2"); + scroll3->SetId("scroll3"); + scroll4->SetId("scroll4"); + scroll5->SetId("scroll5"); + scroll6->SetId("scroll6"); + scroll7->SetId("scroll7"); + scroll8->SetId("scroll8"); + scroll9->SetId("scroll9"); + scroll10->SetId("scroll10"); + scroll11->SetId("scroll11"); + scroll12->SetId("scroll12"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(scroll1); + row1->AddChild(scroll2); + row1->AddChild(scroll3); + row1->AddChild(scroll4); + row2->AddChild(scroll5); + row2->AddChild(scroll6); + row2->AddChild(scroll7); + row2->AddChild(scroll8); + row3->AddChild(scroll9); + row3->AddChild(scroll10); + row3->AddChild(scroll11); + row3->AddChild(scroll12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowNestedScrollTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_nested_scroll_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_nested_scroll_test.h new file mode 100644 index 0000000000000000000000000000000000000000..377e351228913e9822d19b853d6af833689cd6c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_nested_scroll_test.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_NESTED_SCROLL_TEST_H +#define CAPIDEMO_WATERFLOW_NESTED_SCROLL_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "scroll_component.h" +#include "text_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { +class WaterFlowNestedScrollTest { +public: + ~WaterFlowNestedScrollTest() = default; + // testWaterFlowNestedScroll001 + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); + // testWaterFlowNestedScroll002 + static napi_value CreateNativeNodeSmall(napi_env env, napi_callback_info info); + // testWaterFlowNestedScroll003 + static napi_value CreateNativeNodeReset(napi_env env, napi_callback_info info); + +private: + template + static std::shared_ptr CreateWaterFlowByNestedScroll( + int32_t forward, int32_t backward, bool up = true) + { + auto scroll = std::make_shared(); + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + auto reserveTop = std::make_shared(); + auto reserveDown = std::make_shared(); + // 设置上占位框 + reserveTop->SetWidth(110); + reserveTop->SetHeight(60); + reserveTop->SetBackgroundColor(COLOR_GREEN); + reserveTop->SetBorderRadius(10, 10, 10, 10); + // 设置下占位框 + reserveDown->SetWidth(110); + reserveDown->SetHeight(60); + reserveDown->SetBackgroundColor(COLOR_RED); + reserveDown->SetBorderRadius(10, 10, 10, 10); + + waterFlow->SetWidth(110); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetColumnsTemplate("1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr"); + waterFlow->SetWaterFlowNestedScroll(forward, backward); + + auto item = waterFlow->getAttribute(NODE_SCROLL_NESTED_SCROLL); + if (item->value[0].i32 != forward || item->value[1].i32 != backward) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + + for (int i = 0; i < size; i++) { + auto col = std::make_shared(); + col->SetWidth(40); + col->SetHeight(40); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / size) | 0xFF000000); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // col->SetBorderRadius(10, 10, 10, 10); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + column->AddChild(reserveTop); + column->AddChild(waterFlow); + column->AddChild(reserveDown); + // 设置scroll选项 + scroll->SetHeight(200); + scroll->AddChild(column); + scroll->SetScrollScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + scroll->SetBorderWidth(1, 1, 1, 1); + scroll->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + if (up) { + scroll->SetScrollTo(0, 200, {}); + waterFlow->SetWaterFlowScrollToIndex(size - 1, 0, 0); + } + return scroll; + } + + template + static std::shared_ptr CreateWaterFlowByNestedScrollReset( + int32_t forward, int32_t backward, bool up = true) + { + auto scroll = std::make_shared(); + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + auto reserveTop = std::make_shared(); + auto reserveDown = std::make_shared(); + // 设置上占位框 + reserveTop->SetWidth(110); + reserveTop->SetHeight(60); + reserveTop->SetBackgroundColor(COLOR_GREEN); + reserveTop->SetBorderRadius(10, 10, 10, 10); + // 设置下占位框 + reserveDown->SetWidth(110); + reserveDown->SetHeight(60); + reserveDown->SetBackgroundColor(COLOR_RED); + reserveDown->SetBorderRadius(10, 10, 10, 10); + + waterFlow->SetWidth(110); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetColumnsTemplate("1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr"); + waterFlow->SetWaterFlowNestedScroll(forward, backward); + waterFlow->resetAttribute(NODE_SCROLL_NESTED_SCROLL); + + for (int i = 0; i < size; i++) { + auto col = std::make_shared(); + col->SetWidth(40); + col->SetHeight(40); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / size) | 0xFF000000); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // col->SetBorderRadius(10, 10, 10, 10); + // auto text = std::make_shared(); + // ext->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + column->AddChild(reserveTop); + column->AddChild(waterFlow); + column->AddChild(reserveDown); + // 设置scroll选项 + scroll->SetHeight(200); + scroll->AddChild(column); + scroll->SetBorderWidth(1, 1, 1, 1); + scroll->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + scroll->SetScrollScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF); + if (up) { + scroll->SetScrollTo(0, 200, {}); + waterFlow->SetWaterFlowScrollToIndex(size - 1, 0, 0); + } + return scroll; + } +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_NESTED_SCROLL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_scroll_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_scroll_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..251e694c32f8e9d03404cae42b42d05d2d87183d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_scroll_test.cpp @@ -0,0 +1,1425 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_scroll_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "button_component.h" +#include "row_component.h" +#include "scroll_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" +#include "waterflow_section_test.h" + +namespace ArkUICApiDemo { +using DisplayModeCallBack = std::function, int32_t, bool)>; +using WidthCallBack = std::function, float, bool)>; +using ColorCallBack = std::function, uint32_t, bool)>; +using FrictionCallBack = std::function, float, bool)>; +using EdgeEffectCallBack = std::function, int32_t, bool)>; +using ScrollTo2CallBack = std::function, float, float, bool)>; +using ScrollTo6CallBack = + std::function, float, float, const std::vector, bool)>; +using ScrollToBySectionOptionCallBack = std::function, std::vector, float hOffset, float vOffset, bool)>; +using EdgeCallBack = std::function, int32_t, bool)>; +using PageWithoutAnimationCallBack = std::function, bool, bool, int32_t)>; +using PageWithAnimationCallBack = std::function, bool, bool, bool, int32_t)>; +using ByCallBack = std::function, float, float, bool)>; +using EnableScrollInteractionCallBack = std::function, bool, bool)>; +using ScrollToIndex1CallBack = std::function, int32_t)>; +using ScrollToIndex2CallBack = std::function, int32_t, bool)>; +using ScrollToIndex3CallBack = std::function, int32_t, bool, int32_t)>; + +std::shared_ptr CreateReloadColumn() +{ + auto col = std::make_shared(); + col->SetWidth(100); + col->SetHeight(80); + col->SetBackgroundColor(COLOR_YELLOW); + return col; +} + +ScrollToBySectionOptionCallBack AddSectionOption = [](std::shared_ptr waterFlow, + std::vector sections, float hOffset, + float vOffset, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + // set water flow section option + auto options = std::make_shared(); + options->SetSize(sections.size()); + for (int i = 0; i < sections.size(); i++) { + options->SetSection(i, sections[i]); + } + // reloadItem + auto adapter = waterFlow->GetAdapter(); + adapter->ReloadItem(5, CreateReloadColumn()); + // waterFlow + waterFlow->SetWaterFlowSectionOption(0, options); + waterFlow->SetWaterFlowScrollToIndex(11, 0, ARKUI_SCROLL_ALIGNMENT_START); + waterFlow->SetScrollTo(hOffset, vOffset, {}); + // getAttribute + std::thread th( + [](std::shared_ptr waterFlow, float hOffset, float vOffset, bool isRow) { + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + auto item = waterFlow->getAttribute(NODE_SCROLL_OFFSET); + if ((isRow && item->value[0].f32 != hOffset) || (!isRow && item->value[1].f32 != vOffset)) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }, + waterFlow, hOffset, vOffset, isRow); + th.detach(); +}; + +// DISPLAY_MODE +napi_value WaterFlowScrollTest::CreateNativeNodeDisplayMode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + int32_t mode0 = -1; + int32_t mode1 = ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_OFF; + int32_t mode2 = ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_AUTO; + int32_t mode3 = ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_ON; + int32_t mode4 = 3; + DisplayModeCallBack change = [](std::shared_ptr waterFlow, int32_t mode, bool isRow = false) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollBar(mode); + auto item = waterFlow->getAttribute(NODE_SCROLL_BAR_DISPLAY_MODE); + if (item->value[0].i32 != mode) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }; + + // NODE_SCROLL_BAR_DISPLAY_MODE + auto col1 = CreateWaterFlow(change, mode0, false); + auto col2 = CreateWaterFlow(change, mode1, false); + auto col3 = CreateWaterFlow(change, mode2, false); + auto col4 = CreateWaterFlow(change, mode3, false); + auto col5 = CreateWaterFlow(change, mode4, false); + auto col6 = CreateWaterFlow(change, mode0, true); + auto col7 = CreateWaterFlow(change, mode1, true); + auto col8 = CreateWaterFlow(change, mode2, true); + auto col9 = CreateWaterFlow(change, mode3, true); + auto col10 = CreateWaterFlow(change, mode4, true); + auto col11 = CreateWaterFlow<4>(change, mode2, false); + auto col12 = CreateWaterFlow(change, mode1, false); + auto waterFlow = dynamic_cast(col12->GetChildren().front().get()); + waterFlow->resetAttribute(NODE_SCROLL_BAR_DISPLAY_MODE); + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetId("btn"); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + std::vector> columns { col1, col2, col3, col4, col5, col6, col7, col8, col9, col11, + col12 }; + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + row3->AddChild(col11); + row3->AddChild(col12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + + btn->RegisterOnClick([columns]() { + for (auto node : columns) { + auto waterFlow = dynamic_cast(node->GetChildren().front().get()); + waterFlow->SetScrollTo(100, 100, {}); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// WIDTH +napi_value WaterFlowScrollTest::CreateNativeNodeWidth(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + WidthCallBack change = [](std::shared_ptr waterFlow, float width, bool isRow) { + waterFlow->SetWaterFlowScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_ON); + waterFlow->SetWaterFlowScrollBarWidth(width); + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + auto item = waterFlow->getAttribute(NODE_SCROLL_BAR_WIDTH); + if (item->value[0].f32 != width) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }; + + // NODE_SCROLL_BAR_WIDTH + auto col1 = CreateWaterFlow(change, -20.0f, false); + auto col2 = CreateWaterFlow(change, 0.0f, false); + auto col3 = CreateWaterFlow(change, 20.0f, false); + auto col4 = CreateWaterFlow(change, -20.0f, true); + auto col5 = CreateWaterFlow(change, 0.0f, true); + auto col6 = CreateWaterFlow(change, 20.0f, true); + auto col7 = CreateWaterFlow(change, 20.0f, false); + auto col8 = CreateWaterFlow(change, 20.0f, true); + auto waterFlow1 = dynamic_cast(col7->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col8->GetChildren().front().get()); + waterFlow1->resetAttribute(NODE_SCROLL_BAR_WIDTH); + waterFlow2->resetAttribute(NODE_SCROLL_BAR_WIDTH); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// COLOR +napi_value WaterFlowScrollTest::CreateNativeNodeColor(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + ColorCallBack change = [](std::shared_ptr waterFlow, uint32_t color, bool isRow) { + waterFlow->SetWaterFlowScrollBar(ArkUI_ScrollBarDisplayMode::ARKUI_SCROLL_BAR_DISPLAY_MODE_ON); + waterFlow->SetWaterFlowScrollBarColor(color); + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + auto item = waterFlow->getAttribute(NODE_SCROLL_BAR_COLOR); + if (item->value[0].u32 != color) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }; + // NODE_SCROLL_BAR_COLOR + auto col1 = CreateWaterFlow(change, uint32_t(COLOR_RED), false); + auto col2 = CreateWaterFlow(change, uint32_t(COLOR_TRANSPARENT), false); + auto col3 = CreateWaterFlow(change, uint32_t(COLOR_BLUE), false); + auto col4 = CreateWaterFlow(change, uint32_t(COLOR_RED), true); + auto col5 = CreateWaterFlow(change, uint32_t(COLOR_TRANSPARENT), true); + auto col6 = CreateWaterFlow(change, uint32_t(COLOR_BLUE), true); + auto col7 = CreateWaterFlow(change, uint32_t(COLOR_BLUE), true); + auto col8 = CreateWaterFlow(change, uint32_t(COLOR_YELLOW), true); + auto waterFlow1 = dynamic_cast(col7->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col8->GetChildren().front().get()); + waterFlow1->resetAttribute(NODE_SCROLL_BAR_COLOR); + waterFlow2->resetAttribute(NODE_SCROLL_BAR_COLOR); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// FRICTION +napi_value WaterFlowScrollTest::CreateNativeNodeFriction(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + FrictionCallBack change = [](std::shared_ptr waterFlow, float friction, bool isRow) { + waterFlow->SetWaterFlowFriction(friction); + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + auto item = waterFlow->getAttribute(NODE_SCROLL_FRICTION); + if (item->value[0].f32 != friction) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }; + // NODE_SCROLL_FRICTION + auto col1 = CreateWaterFlow<60>(change, -0.8f, false); + auto col2 = CreateWaterFlow<60>(change, 11.2f, false); + auto col3 = CreateWaterFlow<60>(change, 100.2f, false); + auto col4 = CreateWaterFlow<60>(change, -0.8f, true); + auto col5 = CreateWaterFlow<60>(change, 11.2f, true); + auto col6 = CreateWaterFlow<60>(change, 100.2f, true); + col1->SetId("col1"); + col2->SetId("col2"); + col3->SetId("col3"); + col4->SetId("col4"); + col5->SetId("col5"); + col6->SetId("col6"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// EDGE_EFFECT +napi_value WaterFlowScrollTest::CreateNativeNodeEdgeEffect(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + EdgeEffectCallBack change = [](std::shared_ptr waterFlow, int32_t edgeEffect, + bool alwaysEnabled) { + waterFlow->SetPercentWidth(0.23); + waterFlow->SetWaterFlowEdgeEffect(edgeEffect, alwaysEnabled); + auto item = waterFlow->getAttribute(NODE_SCROLL_EDGE_EFFECT); + if (item->value[0].i32 != edgeEffect || item->value[1].i32 != alwaysEnabled) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }; + int32_t effect0 = -1; + int32_t effect1 = ArkUI_EdgeEffect::ARKUI_EDGE_EFFECT_SPRING; + int32_t effect2 = ArkUI_EdgeEffect::ARKUI_EDGE_EFFECT_FADE; + int32_t effect3 = ArkUI_EdgeEffect::ARKUI_EDGE_EFFECT_NONE; + int32_t effect4 = 3; + + // NODE_SCROLL_EDGE_EFFECT + auto col1 = CreateWaterFlow<8>(change, effect0, false); + auto col2 = CreateWaterFlow<8>(change, effect1, false); + auto col3 = CreateWaterFlow<8>(change, effect2, false); + auto col4 = CreateWaterFlow<8>(change, effect3, false); + auto col5 = CreateWaterFlow<8>(change, effect4, false); + auto col6 = CreateWaterFlow<8>(change, effect0, true); + auto col7 = CreateWaterFlow<8>(change, effect1, true); + auto col8 = CreateWaterFlow<8>(change, effect2, true); + auto col9 = CreateWaterFlow<8>(change, effect3, true); + auto col10 = CreateWaterFlow<8>(change, effect4, true); + auto col11 = CreateWaterFlow<8>(change, effect1, true); + auto col12 = CreateWaterFlow<8>(change, effect1, true); + auto waterFlow1 = dynamic_cast(col11->GetChildren().front().get()); + auto waterFlow2 = dynamic_cast(col12->GetChildren().front().get()); + waterFlow1->resetAttribute(NODE_SCROLL_EDGE_EFFECT); + waterFlow2->resetAttribute(NODE_SCROLL_EDGE_EFFECT); + col1->SetId("col1"); + col2->SetId("col2"); + col3->SetId("col3"); + col4->SetId("col4"); + col5->SetId("col5"); + col6->SetId("col6"); + col7->SetId("col7"); + col8->SetId("col8"); + col9->SetId("col9"); + col10->SetId("col10"); + col11->SetId("col11"); + col12->SetId("col12"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + row3->AddChild(col11); + row3->AddChild(col12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// OFFSET 测试前两个参数 +napi_value WaterFlowScrollTest::CreateNativeNodeOffset2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + ScrollTo2CallBack change = [](std::shared_ptr waterFlow, float hOffset, float vOffset, + bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(6, 0, ARKUI_SCROLL_ALIGNMENT_START); + waterFlow->SetScrollTo(hOffset, vOffset, {}); + std::thread th( + [](std::shared_ptr waterFlow, float hOffset, float vOffset, bool isRow) { + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + auto item = waterFlow->getAttribute(NODE_SCROLL_OFFSET); + if ((isRow && item->value[0].f32 != hOffset) || (!isRow && item->value[1].f32 != vOffset)) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }, + waterFlow, hOffset, vOffset, isRow); + th.detach(); + }; + float offset1 = -20; + float offset2 = 0; + float offset3 = 130; + float offset4 = 100000; + // NODE_SCROLL_OFFSET + // row + auto col1 = CreateWaterFlow<60>(change, offset1, offset2, true); + auto col2 = CreateWaterFlow<60>(change, offset2, offset2, true); + auto col3 = CreateWaterFlow<60>(change, offset3, offset2, true); + auto col4 = CreateWaterFlow<60>(change, offset4, offset2, true); + // column + auto col5 = CreateWaterFlow<60>(change, offset2, offset1, false); + auto col6 = CreateWaterFlow<60>(change, offset2, offset2, false); + auto col7 = CreateWaterFlow<60>(change, offset2, offset3, false); + auto col8 = CreateWaterFlow<60>(change, offset2, offset4, false); + // 不同sectionOption + std::vector DEFAULT_INDEX_SECTION { { 4, 2, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, + { 6, 3, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, { 4, 2, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, + { 6, 3, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, { 4, 2, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, + { 6, 3, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr } }; + auto col9 = CreateWaterFlow<30>(AddSectionOption, DEFAULT_INDEX_SECTION, offset2, offset3, false); + auto col10 = CreateWaterFlow<30>(AddSectionOption, DEFAULT_INDEX_SECTION, offset3, offset2, true); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// OFFSET 测试6个参数 +napi_value WaterFlowScrollTest::CreateNativeNodeOffset6(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + // 收集测试滚动参数,待button点击滚动 + typedef std::tuple, float, float, std::vector> ClickParam; + std::vector clickVector; + + ScrollTo6CallBack change = [&clickVector](std::shared_ptr waterFlow, float hOffset, + float vOffset, const std::vector optionalParams, bool isRow) { + waterFlow->SetPercentWidth(0.23); + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + if (optionalParams.size() == SIZE_4) { + waterFlow->SetWaterFlowEdgeEffect(ArkUI_EdgeEffect::ARKUI_EDGE_EFFECT_SPRING, true); + } + clickVector.emplace_back(waterFlow, hOffset, vOffset, optionalParams); + }; + float offset = 200; + std::vector optionalParams1 = { -1000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE }; + std::vector optionalParams2 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE }; + std::vector optionalParams3 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR }; + std::vector optionalParams4 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR, true }; + std::vector optionalParams5 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR, true, true }; + // NODE_SCROLL_OFFSET + // row + auto col1 = CreateWaterFlow(change, 0.0f, offset, optionalParams1, false); + auto col2 = CreateWaterFlow(change, 0.0f, offset, optionalParams2, false); + auto col3 = CreateWaterFlow(change, 0.0f, offset, optionalParams3, false); + auto col4 = CreateWaterFlow(change, 0.0f, offset, optionalParams4, false); + auto col5 = CreateWaterFlow(change, 0.0f, offset, optionalParams5, false); + // column + auto col6 = CreateWaterFlow(change, offset, 0.0f, optionalParams1, true); + auto col7 = CreateWaterFlow(change, offset, 0.0f, optionalParams2, true); + auto col8 = CreateWaterFlow(change, offset, 0.0f, optionalParams3, true); + auto col9 = CreateWaterFlow(change, offset, 0.0f, optionalParams4, true); + auto col10 = CreateWaterFlow(change, offset, 0.0f, optionalParams5, true); + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + + btn->RegisterOnClick([clickVector]() { + for (auto&& item : clickVector) { + auto waterFlow = std::get<0>(item); + auto hOffset = std::get<1>(item); + auto vOffset = std::get<2>(item); + auto optionalParams = std::get<3>(item); + waterFlow->SetScrollTo(hOffset, vOffset, optionalParams); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// OFFSET 测试curve +napi_value WaterFlowScrollTest::CreateNativeNodeOffsetCurve(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + // 收集测试滚动参数,待button点击滚动 + typedef std::tuple, float, float, std::vector> ClickParam; + std::vector clickVector; + + ScrollTo6CallBack change = [&clickVector](std::shared_ptr waterFlow, float hOffset, + float vOffset, const std::vector optionalParams, bool row) { + waterFlow->SetPercentWidth(0.23); + clickVector.emplace_back(waterFlow, hOffset, vOffset, optionalParams); + }; + float offset = 200; + std::vector optionalParams1 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE_IN }; + std::vector optionalParams2 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE_OUT }; + std::vector optionalParams3 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_EASE_IN_OUT }; + std::vector optionalParams4 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_FAST_OUT_SLOW_IN }; + std::vector optionalParams5 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR_OUT_SLOW_IN }; + std::vector optionalParams6 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_FAST_OUT_LINEAR_IN }; + std::vector optionalParams7 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_EXTREME_DECELERATION }; + std::vector optionalParams8 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_SHARP }; + std::vector optionalParams9 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_RHYTHM }; + std::vector optionalParams10 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_SMOOTH }; + std::vector optionalParams11 = { 2000, ArkUI_AnimationCurve::ARKUI_CURVE_FRICTION }; + std::vector optionalParams12 = { 2000, 13 }; + // NODE_SCROLL_OFFSET + auto col1 = CreateWaterFlow(change, 0.0f, offset, optionalParams1, false); + auto col2 = CreateWaterFlow(change, 0.0f, offset, optionalParams2, false); + auto col3 = CreateWaterFlow(change, 0.0f, offset, optionalParams3, false); + auto col4 = CreateWaterFlow(change, 0.0f, offset, optionalParams4, false); + auto col5 = CreateWaterFlow(change, 0.0f, offset, optionalParams5, false); + auto col6 = CreateWaterFlow(change, 0.0f, offset, optionalParams6, false); + auto col7 = CreateWaterFlow(change, 0.0f, offset, optionalParams7, false); + auto col8 = CreateWaterFlow(change, 0.0f, offset, optionalParams8, false); + auto col9 = CreateWaterFlow(change, 0.0f, offset, optionalParams9, false); + auto col10 = CreateWaterFlow(change, 0.0f, offset, optionalParams10, false); + auto col11 = CreateWaterFlow(change, 0.0f, offset, optionalParams11, false); + auto col12 = CreateWaterFlow(change, 0.0f, offset, optionalParams12, false); + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + row3->AddChild(col11); + row3->AddChild(col12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + + btn->RegisterOnClick([clickVector]() { + for (auto&& item : clickVector) { + auto waterFlow = std::get<0>(item); + auto hOffset = std::get<1>(item); + auto vOffset = std::get<2>(item); + auto optionalParams = std::get<3>(item); + waterFlow->SetScrollTo(hOffset, vOffset, optionalParams); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// EDGE +napi_value WaterFlowScrollTest::CreateNativeNodeEdge(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + EdgeCallBack change = [](std::shared_ptr waterFlow, int32_t type, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(6, 0, ARKUI_SCROLL_ALIGNMENT_START); + waterFlow->SetScrollEdge(type); + std::thread th( + [](std::shared_ptr waterFlow, int32_t type) { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + auto item = waterFlow->getAttribute(NODE_SCROLL_EDGE); + if (item->value[0].i32 != type) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }, + waterFlow, type); + th.detach(); + }; + int32_t type1 = -2; + int32_t type2 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_TOP; + int32_t type3 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_BOTTOM; + int32_t type4 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_START; + int32_t type5 = ArkUI_ScrollEdge::ARKUI_SCROLL_EDGE_END; + int32_t type6 = 4; + + // NODE_SCROLL_EDGE + // column + auto col1 = CreateWaterFlow(change, type1, false); + auto col2 = CreateWaterFlow(change, type2, false); + auto col3 = CreateWaterFlow(change, type3, false); + auto col4 = CreateWaterFlow(change, type6, false); + // row + auto col5 = CreateWaterFlow(change, type1, true); + auto col6 = CreateWaterFlow(change, type4, true); + auto col7 = CreateWaterFlow(change, type5, true); + auto col8 = CreateWaterFlow(change, type6, true); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// PAGE +napi_value WaterFlowScrollTest::CreateNativeNodePage(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + // 收集测试滚动参数,待button点击滚动 + typedef std::tuple, bool> ClickWithoutAnimation; + typedef std::tuple, bool, bool> ClickWithAnimation; + std::vector clickWithoutAnimation; + std::vector clickWithAnimation; + PageWithoutAnimationCallBack changeWithoutAnimation = [&clickWithoutAnimation]( + std::shared_ptr waterFlow, bool next, + bool isRow, int32_t targetIndex) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(targetIndex, 0, ARKUI_SCROLL_ALIGNMENT_START); + clickWithoutAnimation.emplace_back(waterFlow, next); + }; + PageWithAnimationCallBack changeWithAnimation = [&clickWithAnimation](std::shared_ptr waterFlow, + bool next, bool animation, bool isRow, int32_t targetIndex) { + waterFlow->SetPercentWidth(0.23); + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(targetIndex, 0, ARKUI_SCROLL_ALIGNMENT_START); + clickWithAnimation.emplace_back(waterFlow, next, animation); + }; + bool pre = true, next = false; + + // NODE_SCROLL_PAGE + // column无动画 + auto col1 = CreateWaterFlow<40>(changeWithoutAnimation, pre, false, 10); // 正常 预置位置为10 + auto col2 = CreateWaterFlow<40>(changeWithoutAnimation, next, false, 10); // 正常 预置位置为10 + auto col3 = CreateWaterFlow<40>(changeWithoutAnimation, pre, false, 0); // 已达边界 预置位置为0 + auto col4 = CreateWaterFlow<40>(changeWithoutAnimation, next, false, 39); // 已达边界 预置位置为39 + // row有动画 + auto col5 = CreateWaterFlow<40>(changeWithAnimation, pre, true, true, 10); // 正常 预置位置为10 + auto col6 = CreateWaterFlow<40>(changeWithAnimation, next, true, true, 10); // 正常 预置位置为10 + auto col7 = CreateWaterFlow<40>(changeWithAnimation, pre, true, true, 0); // 已达边界 预置位置为0 + auto col8 = CreateWaterFlow<40>(changeWithAnimation, next, true, true, 39); // 已达边界 预置位置为39 + // 混合column, row 有动画 + auto col9 = CreateWaterFlow<40>(changeWithAnimation, pre, true, false, 10); // 正常 预置位置为10 + auto col10 = CreateWaterFlow<40>(changeWithAnimation, next, true, false, 10); // 正常 预置位置为10 + // 混合column, row 无动画 + auto col11 = CreateWaterFlow<40>(changeWithoutAnimation, pre, true, 10); // 正常 预置位置为10 + auto col12 = CreateWaterFlow<40>(changeWithoutAnimation, next, true, 10); // 正常 预置位置为10 + auto btn = std::make_shared(); + btn->SetHeight(50); + btn->SetWidth(100); + btn->SetId("btn"); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + row3->AddChild(col11); + row3->AddChild(col12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + + btn->RegisterOnClick([clickWithoutAnimation, clickWithAnimation]() { + for (auto&& item : clickWithoutAnimation) { + auto waterFlow = std::get<0>(item); + auto next = std::get<1>(item); + waterFlow->SetScrollPage(next); + } + for (auto&& item : clickWithAnimation) { + auto waterFlow = std::get<0>(item); + auto next = std::get<1>(item); + auto animation = std::get<2>(item); + waterFlow->SetScrollPage(next, animation); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// BY +napi_value WaterFlowScrollTest::CreateNativeNodeBy(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + ByCallBack change = [](std::shared_ptr waterFlow, float hDistance, float vDistance, + bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(15, 0, ARKUI_SCROLL_ALIGNMENT_START); + std::thread scrollPage([waterFlow, hDistance, vDistance]() { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + waterFlow->SetScrollBy(hDistance, vDistance); + }); + scrollPage.detach(); + }; + float distance1 = -100000; + float distance2 = -100; + float distance3 = 100; + float distance4 = 100000; + float distance5 = 0; + + // NODE_SCROLL_BY + // column + auto col1 = CreateWaterFlow<60>(change, distance5, distance1, false); + auto col2 = CreateWaterFlow<60>(change, distance5, distance2, false); + auto col3 = CreateWaterFlow<60>(change, distance5, distance3, false); + auto col4 = CreateWaterFlow<60>(change, distance5, distance4, false); + // row + auto col5 = CreateWaterFlow<60>(change, distance1, distance5, true); + auto col6 = CreateWaterFlow<60>(change, distance2, distance5, true); + auto col7 = CreateWaterFlow<60>(change, distance3, distance5, true); + auto col8 = CreateWaterFlow<60>(change, distance4, distance5, true); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + column->AddChild(row1); + column->AddChild(row2); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// EnableScrollInteraction +napi_value WaterFlowScrollTest::CreateNativeNodeEnableScrollInteraction(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + EnableScrollInteractionCallBack change = [](std::shared_ptr waterFlow, + bool enableScrollInteraction, bool isRow) { + if (isRow) { + waterFlow->SetLayoutDirection(ArkUI_FlexDirection::ARKUI_FLEX_DIRECTION_ROW); + } + waterFlow->SetWaterFlowScrollToIndex(15, 0, ARKUI_SCROLL_ALIGNMENT_START); + waterFlow->SetWaterFlowEnableScrollInteraction(enableScrollInteraction); + if (!enableScrollInteraction) { + waterFlow->SetScrollTo(100, 100, {}); + } + auto item = waterFlow->getAttribute(NODE_SCROLL_ENABLE_SCROLL_INTERACTION); + if (item->value[0].i32 != enableScrollInteraction) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + }; + auto createOutsideNested = [change](bool enableScrollInteraction, bool isRow, const std::string& id) { + auto scroll = std::make_shared(); + auto column = std::make_shared(); + if (isRow) { + scroll->SetScrollScrollable(ArkUI_ScrollDirection::ARKUI_SCROLL_DIRECTION_HORIZONTAL); + } + auto upColumn = CreateReloadColumn(); + upColumn->SetId(id); + auto col = CreateWaterFlow(change, enableScrollInteraction, isRow); + auto waterFlow = dynamic_cast(col->GetChildren().front().get()); + waterFlow->SetHeight(50); + column->AddChild(upColumn); + column->AddChild(col); + column->AddChild(CreateReloadColumn()); + scroll->AddChild(column); + scroll->SetHeight(150); + return scroll; + }; + auto createInsideNested = [change](bool enableScrollInteraction, bool isRow, const std::string& id) { + auto column = CreateWaterFlow(change, enableScrollInteraction, isRow); + auto waterFlow = dynamic_cast(column->GetChildren().front().get()); + auto adapter = waterFlow->GetAdapter(); + auto subColumn = CreateWaterFlow(change, true, isRow); + auto subWaterFlow = dynamic_cast(subColumn->GetChildren().front().get()); + subWaterFlow->SetHeight(150); + subWaterFlow->SetWidth(100); + subColumn->SetId(id); + waterFlow->SetWaterFlowScrollToIndex(4); + adapter->ReloadItem(4, subColumn); + return column; + }; + + // NODE_SCROLL_ENABLE_SCROLL_INTERACTION + // column + auto col1 = CreateWaterFlow<40>(change, true, false); + auto col2 = CreateWaterFlow<40>(change, false, false); + // row + auto col3 = CreateWaterFlow<40>(change, true, true); + auto col4 = CreateWaterFlow<40>(change, false, true); + // 外部嵌套scroll + auto scroll5 = createOutsideNested(true, false, "col5"); + auto scroll6 = createOutsideNested(false, false, "col6"); + // 内部嵌套waterFlow + auto col7 = createInsideNested(true, false, "col7"); + auto col8 = createInsideNested(false, false, "col8"); + auto col9 = createInsideNested(true, true, "col9"); + auto col10 = createInsideNested(false, true, "col10"); + col1->SetId("col1"); + col2->SetId("col2"); + col3->SetId("col3"); + col4->SetId("col4"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(scroll5); + row2->AddChild(scroll6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// ScrollToIndex 超出一屏 +napi_value WaterFlowScrollTest::CreateNativeNodeScrollToIndex(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + // 收集测试滚动参数,待button点击滚动 + typedef std::tuple, int32_t> ClickParam1; + typedef std::tuple, int32_t, bool> ClickParam2; + typedef std::tuple, int32_t, bool, int32_t> ClickParam3; + std::vector clickVector1; + std::vector clickVector2; + std::vector clickVector3; + + ScrollToIndex1CallBack change1Param = [&clickVector1]( + std::shared_ptr waterFlow, int32_t index) { + waterFlow->SetPercentWidth(0.23); + clickVector1.emplace_back(waterFlow, index); + }; + ScrollToIndex2CallBack change2Param = [&clickVector2](std::shared_ptr waterFlow, int32_t index, + bool animation) { + waterFlow->SetPercentWidth(0.23); + clickVector2.emplace_back(waterFlow, index, animation); + }; + ScrollToIndex3CallBack change3Param = [&clickVector3](std::shared_ptr waterFlow, int32_t index, + bool animation, int32_t alignment) { + waterFlow->SetPercentWidth(0.23); + clickVector3.emplace_back(waterFlow, index, animation, alignment); + }; + int32_t alignment0 = -1; + int32_t alignment1 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_START; + int32_t alignment2 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_CENTER; + int32_t alignment3 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_END; + int32_t alignment4 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_AUTO; + int32_t alignment5 = 4; + + // NODE_WATER_FLOW_SCROLL_TO_INDEX + auto col1 = CreateWaterFlow<60>(change1Param, 100); + auto col2 = CreateWaterFlow<60>(change1Param, 30); + auto col3 = CreateWaterFlow<60>(change1Param, -100); + auto col4 = CreateWaterFlow<60>(change2Param, 30, true); + auto col5 = CreateWaterFlow<60>(change3Param, 30, false, alignment0); + auto col6 = CreateWaterFlow<60>(change3Param, 30, false, alignment1); + auto col7 = CreateWaterFlow<60>(change3Param, 30, false, alignment2); + auto col8 = CreateWaterFlow<60>(change3Param, 30, false, alignment3); + auto col9 = CreateWaterFlow<60>(change3Param, 30, false, alignment4); + auto col10 = CreateWaterFlow<60>(change3Param, 30, false, alignment5); + auto btn = std::make_shared(); + btn->SetWidth(100); + btn->SetHeight(50); + btn->SetBackgroundColor(COLOR_TRANSPARENT); + btn->SetId("btn"); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(btn); + btn->RegisterOnClick([clickVector1, clickVector2, clickVector3]() { + for (auto item : clickVector1) { + auto waterFlow = std::get<0>(item); + auto index = std::get<1>(item); + waterFlow->SetWaterFlowScrollToIndex(index); + } + for (auto item : clickVector2) { + auto waterFlow = std::get<0>(item); + auto index = std::get<1>(item); + auto animation = std::get<2>(item); + waterFlow->SetWaterFlowScrollToIndex(index, animation); + } + for (auto item : clickVector3) { + auto waterFlow = std::get<0>(item); + auto index = std::get<1>(item); + auto animation = std::get<2>(item); + auto alignment = std::get<3>(item); + waterFlow->SetWaterFlowScrollToIndex(index, animation, alignment); + } + }); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +// ScrollToIndex 不满一屏 +napi_value WaterFlowScrollTest::CreateNativeNodeScrollToIndex8(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", "GetContext env or info is null"); + return nullptr; + } + + ScrollToIndex3CallBack change3Param = [](std::shared_ptr waterFlow, int32_t index, + bool animation, int32_t alignment) { + std::thread scrollToIndex([waterFlow, index, animation, alignment]() { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + waterFlow->SetWaterFlowScrollToIndex(index, animation, alignment); + }); + scrollToIndex.detach(); + }; + int32_t alignment1 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_START; + int32_t alignment2 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_CENTER; + int32_t alignment3 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_END; + int32_t alignment4 = ArkUI_ScrollAlignment::ARKUI_SCROLL_ALIGNMENT_AUTO; + + // NODE_WATER_FLOW_SCROLL_TO_INDEX + // 8个FlowItem不满一屏 + auto col1 = CreateWaterFlow<8>(change3Param, 4, false, alignment1); + auto col2 = CreateWaterFlow<8>(change3Param, 4, false, alignment2); + auto col3 = CreateWaterFlow<8>(change3Param, 4, false, alignment3); + auto col4 = CreateWaterFlow<8>(change3Param, 4, false, alignment4); + auto col5 = CreateWaterFlow<8>(change3Param, 0, false, alignment1); + auto col6 = CreateWaterFlow<8>(change3Param, 0, false, alignment2); + auto col7 = CreateWaterFlow<8>(change3Param, 0, false, alignment3); + auto col8 = CreateWaterFlow<8>(change3Param, 0, false, alignment4); + auto col9 = CreateWaterFlow<8>(change3Param, 8, false, alignment1); + auto col10 = CreateWaterFlow<8>(change3Param, 8, false, alignment2); + auto col11 = CreateWaterFlow<8>(change3Param, 8, false, alignment3); + auto col12 = CreateWaterFlow<8>(change3Param, 8, false, alignment4); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row1->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row2->AddChild(col7); + row2->AddChild(col8); + row3->AddChild(col9); + row3->AddChild(col10); + row3->AddChild(col11); + row3->AddChild(col12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowScrollBarTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_scroll_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_scroll_test.h new file mode 100644 index 0000000000000000000000000000000000000000..ddcecfd688326e37f0f4489c8f1ddb600e66f2f7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_scroll_test.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPIDEMO_WATERFLOW_SCROLL_TEST_H +#define CAPIDEMO_WATERFLOW_SCROLL_TEST_H + +#include "../common/common.h" +#include "column_component.h" +#include "text_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { +constexpr int32_t FLOW_ITEM_COUNT = 15; + +class WaterFlowScrollTest { +public: + ~WaterFlowScrollTest() = default; + // testWaterFlowScroll001 + static napi_value CreateNativeNodeDisplayMode(napi_env env, napi_callback_info info); + // testWaterFlowScroll002 + static napi_value CreateNativeNodeWidth(napi_env env, napi_callback_info info); + // testWaterFlowScroll003 + static napi_value CreateNativeNodeColor(napi_env env, napi_callback_info info); + // testWaterFlowScroll004 + static napi_value CreateNativeNodeFriction(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeEdgeEffect(napi_env env, napi_callback_info info); + // testWaterFlowScroll006 + static napi_value CreateNativeNodeOffset2(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOffset6(napi_env env, napi_callback_info info); + static napi_value CreateNativeNodeOffsetCurve(napi_env env, napi_callback_info info); + // testWaterFlowScroll008 + static napi_value CreateNativeNodeEdge(napi_env env, napi_callback_info info); + // testWaterFlowScroll009 + static napi_value CreateNativeNodePage(napi_env env, napi_callback_info info); + // testWaterFlowScroll010 + static napi_value CreateNativeNodeBy(napi_env env, napi_callback_info info); + // testWaterFlowScroll011 + static napi_value CreateNativeNodeEnableScrollInteraction(napi_env env, napi_callback_info info); + // testWaterFlowScroll012 + static napi_value CreateNativeNodeScrollToIndex(napi_env env, napi_callback_info info); + // testWaterFlowScroll013 + static napi_value CreateNativeNodeScrollToIndex8(napi_env env, napi_callback_info info); + +private: + template + static std::shared_ptr CreateWaterFlow( + std::function, Args...)> change, Args... args) + { + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + + waterFlow->SetWidth(110); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetWaterFlowColumnsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetColumnsTemplate("1fr 1fr"); + waterFlow->SetRowsTemplate("1fr 1fr"); + + for (int i = 0; i < size; i++) { + auto col = std::make_shared(); + col->SetWidth(40); + col->SetHeight(40); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / size) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + column->AddChild(waterFlow); + if (change) { + change(waterFlow, args...); + } + return column; + } +}; +} // namespace ArkUICApiDemo +#endif // CAPIDEMO_WATERFLOW_SCROLL_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_option.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_option.h new file mode 100644 index 0000000000000000000000000000000000000000..bf3363b2f794b146e61ba83e8fe5bc263e350e84 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_option.h @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_WATERFALOW_SECTION_OPTION_H +#define ARKUI_CAPI_DEMO_WATERFALOW_SECTION_OPTION_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "text_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +static WaterFlowSection DEFAULT_SECTION = { 10, 4, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr }; +static std::vector DEFAULT_INDEX_SECTION { { 8, 4, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, + { 4, 2, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }, { 6, 3, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr } }; + +typedef float (*GetItemMainSizeByIndex)(int32_t itemIndex); + +class WaterFlowSectionOptionTest { +public: + ~WaterFlowSectionOptionTest() = default; + static std::shared_ptr CreateWaterFlowExample1( + const std::vector& sections, int32_t size) + { + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + // set water flow section option + auto options = std::make_shared(); + int32_t totalCount = 0; + options->SetSize(size); + for (int i = 0; i < size; i++) { + options->SetSection(i, sections[i]); + auto temp = options->GetSection(i); + totalCount += temp.itemsCount; + if (sections[i].crossCount > 0 && sections[i].crossCount != temp.crossCount) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionOptionTest", "crossCount error"); + waterFlow->SetBackgroundColor(COLOR_RED); + return column; + } + } + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetWaterFlowRowsGap(10); + waterFlow->SetBackgroundColor(COLOR_GRAY + size * 0x0101B1); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetWaterFlowSectionOption(0, options); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + + for (int i = 0; i < totalCount; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / totalCount) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; + } + static std::shared_ptr CreateWaterFlowExample2( + const WaterFlowSection& sections = DEFAULT_SECTION, bool isRowGap = false) + { + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + // set water flow section option + auto options = std::make_shared(); + options->SetSize(1); + options->SetSection(0, sections); + auto temp = options->GetSection(0); + + waterFlow->SetWidth(155); + waterFlow->SetHeight(170); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetWaterFlowSectionOption(0, options); + if (isRowGap) { + waterFlow->SetLayoutDirection(0); + } else { + waterFlow->SetLayoutDirection(1); + } + if (temp.columnsGap != sections.columnsGap) { + waterFlow->SetBackgroundColor(COLOR_RED); + } + if (temp.rowsGap != sections.rowsGap) { + waterFlow->SetBackgroundColor(COLOR_GREEN); + } + if (temp.margin.top != sections.margin.top || temp.margin.bottom != sections.margin.bottom || + temp.margin.left != sections.margin.left || temp.margin.right != sections.margin.right) { + waterFlow->SetBackgroundColor(COLOR_BLUE); + } + + for (int i = 0; i < sections.itemsCount; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / sections.itemsCount) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; + } + + static std::shared_ptr CreateWaterFlowExample3( + GetItemMainSizeByIndex getItemMainSizeByIndex, bool isRow = false) + { + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + // set water flow section option + auto options = std::make_shared(); + int32_t totalCount = 0; + options->SetSize(DEFAULT_INDEX_SECTION.size()); + for (int i = 0; i < DEFAULT_INDEX_SECTION.size(); i++) { + DEFAULT_INDEX_SECTION[i].onGetItemMainSizeByIndex = getItemMainSizeByIndex; + options->SetSection(i, DEFAULT_INDEX_SECTION[i]); + auto temp = options->GetSection(i); + totalCount += temp.itemsCount; + } + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetWaterFlowSectionOption(0, options); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + if (isRow) { + waterFlow->SetLayoutDirection(0); + } else { + waterFlow->SetLayoutDirection(1); + } + + for (int i = 0; i < totalCount; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / totalCount) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; + } + + static std::shared_ptr CreateWaterFlowExample4(bool isDestroy = false) + { + auto column = std::make_shared(); + auto waterFlow = std::make_shared(); + auto input = std::vector>(); + auto adapter = std::make_shared>(input); + // set water flow section option + auto options = std::make_shared(); + int32_t totalCount = 0; + options->SetSize(DEFAULT_INDEX_SECTION.size()); + for (int i = 0; i < DEFAULT_INDEX_SECTION.size(); i++) { + options->SetSection(i, DEFAULT_INDEX_SECTION[i]); + auto temp = options->GetSection(i); + totalCount += temp.itemsCount; + } + waterFlow->SetWidth(155); + waterFlow->SetHeight(200); + waterFlow->SetBackgroundColor(COLOR_GRAY); + waterFlow->SetLazyAdapter(adapter); + waterFlow->SetWaterFlowSectionOption(0, options); + waterFlow->SetBorderWidth(1, 1, 1, 1); + waterFlow->SetBorderColor(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + if (isDestroy) { + options.reset(); + waterFlow->ReleaseSectionOption(); + if (!options) { + waterFlow->SetBackgroundColor(COLOR_GREEN); + } + } + + for (int i = 0; i < totalCount; i++) { + auto col = std::make_shared(); + col->SetWidth(38); + col->SetHeight(30); + col->SetBackgroundColor(((i + 1) * 0xFFFFFF / totalCount) | 0xFF000000); + col->SetBorderRadius(10, 10, 10, 10); + // When debugging, this code should be enabled to display the code number. + // col->SetBackgroundColor(COLOR_WHITE); + // auto text = std::make_shared(); + // text->SetTextContent(std::to_string(i)); + // col->AddChild(text); + adapter->InsertItem(i, col); + } + + column->AddChild(waterFlow); + return column; + } +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_WATERFALOW_SECTION_OPTION_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eba0da68da0ed5a46a8109afbfb69d2a0717c907 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_test.cpp @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "waterflow_section_test.h" + +#include + +#include "../manager/plugin_manager.h" +#include "row_component.h" +#include "text_component.h" +#include "waterflow_component.h" +#include "waterflow_section_option.h" + +namespace ArkUICApiDemo { +static std::vector SIZE_SECTION { { 10, 4, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr }, + { 6, 3, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr }, { 10, 4, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr } }; +static std::vector ITEM_COUNT_SECTION { { 10, 4, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr }, + { 0, 2, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr }, { -10, 3, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr } }; +static std::vector CROSS_COUNT_SECTION1 { { 15, -4, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr } }; +static std::vector CROSS_COUNT_SECTION2 { { 15, 0, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr } }; +static std::vector CROSS_COUNT_SECTION3 { { 15, 4, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr } }; + +static WaterFlowSection COLUMN_GAP_SECTION1 = { 20, 3, -20, 5, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection COLUMN_GAP_SECTION2 = { 20, 3, 0, 5, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection COLUMN_GAP_SECTION3 = { 20, 3, 20, 5, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection ROW_GAP_SECTION1 = { 20, 3, 5, -20, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection ROW_GAP_SECTION2 = { 20, 3, 5, 0, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection ROW_GAP_SECTION3 = { 20, 3, 5, 20, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection MARGIN_GAP_SECTION1 = { 20, 3, 0, 0, { -10, -10, -10, -10 }, nullptr, nullptr }; +static WaterFlowSection MARGIN_GAP_SECTION2 = { 20, 3, 0, 0, { 0, 0, 0, 0 }, nullptr, nullptr }; +static WaterFlowSection MARGIN_GAP_SECTION3 = { 20, 3, 0, 0, { 10, 10, 10, 10 }, nullptr, nullptr }; + +static WaterFlowSection INDEX_SECTION1 = { 20, 2, 5, 5, { 0, 0, 0, 0 }, nullptr, nullptr }; + +napi_value WaterFlowSectionTest::CreateNativeNode1(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // OH_ArkUI_WaterFlowSectionOption_SetSize + auto col1 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(SIZE_SECTION, 3); + auto col2 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(SIZE_SECTION, -2); + auto col3 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(SIZE_SECTION, 1); + // OH_ArkUI_WaterFlowSectionOption_SetItemCount + // OH_ArkUI_WaterFlowSectionOption_GetItemCount + auto col4 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(ITEM_COUNT_SECTION, 1); + auto col5 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(ITEM_COUNT_SECTION, 2); + auto col6 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(ITEM_COUNT_SECTION, 3); + // OH_ArkUI_WaterFlowSectionOption_SetCrossCount + // OH_ArkUI_WaterFlowSectionOption_GetCrossCount + auto col7 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(CROSS_COUNT_SECTION1, 1); + auto col8 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(CROSS_COUNT_SECTION2, 1); + auto col9 = WaterFlowSectionOptionTest::CreateWaterFlowExample1(CROSS_COUNT_SECTION3, 1); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value WaterFlowSectionTest::CreateNativeNode2(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // OH_ArkUI_WaterFlowSectionOption_SetColumnGap + // OH_ArkUI_WaterFlowSectionOption_GetColumnGap + auto col1 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(COLUMN_GAP_SECTION1); + auto col2 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(COLUMN_GAP_SECTION2); + auto col3 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(COLUMN_GAP_SECTION3); + // OH_ArkUI_WaterFlowSectionOption_SetRowGap + // OH_ArkUI_WaterFlowSectionOption_GetRowGap + auto col4 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(ROW_GAP_SECTION1, true); + auto col5 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(ROW_GAP_SECTION2, true); + auto col6 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(ROW_GAP_SECTION3, true); + // OH_ArkUI_WaterFlowSectionOption_SetMargin + // OH_ArkUI_WaterFlowSectionOption_GetMargin + auto col7 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(MARGIN_GAP_SECTION1); + auto col8 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(MARGIN_GAP_SECTION2); + auto col9 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(MARGIN_GAP_SECTION3); + auto col10 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(MARGIN_GAP_SECTION1, true); + auto col11 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(MARGIN_GAP_SECTION2, true); + auto col12 = WaterFlowSectionOptionTest::CreateWaterFlowExample2(MARGIN_GAP_SECTION3, true); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + auto row4 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + row4->AddChild(col10); + row4->AddChild(col11); + row4->AddChild(col12); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + column->AddChild(row4); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} + +napi_value WaterFlowSectionTest::CreateNativeNode3(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + + // OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndex + auto col1 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return -30; }); + auto col2 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return 0; }); + auto col3 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return 30; }); + auto col4 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return -30; }, true); + auto col5 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return 0; }, true); + auto col6 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return 30; }, true); + // OH_ArkUI_WaterFlowSectionOption_Dispose + auto col7 = WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return index * 3; }); + auto col8 = + WaterFlowSectionOptionTest::CreateWaterFlowExample3([](int32_t index) -> float { return index * 3; }, true); + auto col9 = WaterFlowSectionOptionTest::CreateWaterFlowExample4(true); + + // parent node + auto column = new ColumnComponent(); + auto row1 = std::make_shared(); + auto row2 = std::make_shared(); + auto row3 = std::make_shared(); + row1->AddChild(col1); + row1->AddChild(col2); + row1->AddChild(col3); + row2->AddChild(col4); + row2->AddChild(col5); + row2->AddChild(col6); + row3->AddChild(col7); + row3->AddChild(col8); + row3->AddChild(col9); + column->AddChild(row1); + column->AddChild(row2); + column->AddChild(row3); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode( + PluginManager::GetInstance()->GetNativeXComponent(id), column->GetComponent()) == INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "WaterFlowSectionTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_test.h new file mode 100644 index 0000000000000000000000000000000000000000..36da676d7ad96fbe89471897cf59db0b8c14a2c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/waterflow/waterflow_section_test.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_WATERFLOW_SECTION_TEST_H +#define ARKUI_CAPI_DEMO_WATERFLOW_SECTION_TEST_H + +#include +#include +#include + +#include "../common/common.h" +#include "column_component.h" +#include "waterflow_component.h" + +namespace ArkUICApiDemo { + +class WaterFlowSectionTest { +public: + ~WaterFlowSectionTest() = default; + // testWaterFlowSection001 + static napi_value CreateNativeNode1(napi_env env, napi_callback_info info); + // testWaterFlowSection002 + static napi_value CreateNativeNode2(napi_env env, napi_callback_info info); + // testWaterFlowSection003 + static napi_value CreateNativeNode3(napi_env env, napi_callback_info info); +}; +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_WATERFLOW_SECTION_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/xcomponent/xcomponent_id_test.cpp b/function/ui_compare/capidemo/entry/src/main/cpp/xcomponent/xcomponent_id_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b2426205a759ca24d1fdebeb84ef3a086a670bbd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/xcomponent/xcomponent_id_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xcomponent_id_test.h" + +#include +#include + +#include "../manager/plugin_manager.h" + +namespace ArkUICApiDemo { + +static auto SetWidth(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float width) +{ + ArkUI_NumberValue width_value[] = { { .f32 = width } }; + ArkUI_AttributeItem width_item = { width_value, sizeof(width_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_WIDTH, &width_item); + return nodeHandle; +} + +static auto SetHeight(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float height) +{ + ArkUI_NumberValue height_value[] = { { .f32 = height } }; + ArkUI_AttributeItem height_item = { height_value, sizeof(height_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_HEIGHT, &height_item); + return nodeHandle; +} + +static auto SetBackgroundColor(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle nodeHandle, uint32_t color) +{ + ArkUI_NumberValue color_value[] = { { .u32 = color } }; + ArkUI_AttributeItem color_item = { color_value, sizeof(color_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_BACKGROUND_COLOR, &color_item); + return nodeHandle; +} + +static auto SetMargin(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, float margin) +{ + ArkUI_NumberValue margin_value[] = { { .f32 = margin } }; + ArkUI_AttributeItem margin_item = { margin_value, sizeof(margin_value) / sizeof(ArkUI_NumberValue) }; + nodeAPI->setAttribute(nodeHandle, NODE_MARGIN, &margin_item); + return nodeHandle; +} + +static auto SetXComponentId(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + ArkUI_AttributeItem item = {}; + item.string = id; + nodeAPI->setAttribute(nodeHandle, NODE_XCOMPONENT_ID, &item); + const ArkUI_AttributeItem* result = nodeAPI->getAttribute(nodeHandle, NODE_XCOMPONENT_ID); + if (std::strcmp(item.string, result->string) == 0) { + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_GREEN); + } + return nodeHandle; +} + +static auto SetXComponent(ArkUI_NativeNodeAPI_1* nodeAPI, ArkUI_NodeHandle& nodeHandle, const char* id) +{ + nodeHandle = SetWidth(nodeAPI, nodeHandle, SIZE_200); + nodeHandle = SetHeight(nodeAPI, nodeHandle, SIZE_100); + nodeHandle = SetBackgroundColor(nodeAPI, nodeHandle, COLOR_YELLOW); + nodeHandle = SetMargin(nodeAPI, nodeHandle, PARAM_1); + nodeHandle = SetXComponentId(nodeAPI, nodeHandle, id); + return nodeHandle; +} + +napi_value XComponentIdTest::CreateNativeNode(napi_env env, napi_callback_info info) +{ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponentIdTest", "CreateNativeNode"); + + size_t argc = PARAM_1; + napi_value args[PARAM_1] = { nullptr }; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + size_t length = PARAM_64; + size_t strLength = PARAM_0; + char xComponentID[PARAM_64] = { PARAM_0 }; + napi_get_value_string_utf8(env, args[PARAM_0], xComponentID, length, &strLength); + + if ((env == nullptr) || (info == nullptr)) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponentIdTest", "GetContext env or info is null"); + return nullptr; + } + + ArkUI_NativeNodeAPI_1* nodeAPI = nullptr; + OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); + auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN); + auto xComponent1 = nodeAPI->createNode(ARKUI_NODE_XCOMPONENT); + auto xComponent2 = nodeAPI->createNode(ARKUI_NODE_XCOMPONENT); + auto xComponent3 = nodeAPI->createNode(ARKUI_NODE_XCOMPONENT); + auto xComponent4 = nodeAPI->createNode(ARKUI_NODE_XCOMPONENT); + auto xComponent5 = nodeAPI->createNode(ARKUI_NODE_XCOMPONENT); + + nodeAPI->addChild(column, xComponent1); + nodeAPI->addChild(column, xComponent2); + nodeAPI->addChild(column, xComponent3); + nodeAPI->addChild(column, xComponent4); + nodeAPI->addChild(column, xComponent5); + + xComponent1 = SetXComponent(nodeAPI, xComponent1, "XComponentId1"); + xComponent2 = SetXComponent(nodeAPI, xComponent2, "X C o mponentId2、XComponentId3+-*/."); + xComponent3 = SetXComponent(nodeAPI, xComponent3, ""); + // 128 characters + xComponent4 = SetXComponent(nodeAPI, xComponent4, + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678"); + // 129 characters + xComponent5 = SetXComponent(nodeAPI, xComponent5, + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456" + "7890123456789012345678901234567890123456789"); + + std::string id(xComponentID); + if (OH_NativeXComponent_AttachNativeRootNode(PluginManager::GetInstance()->GetNativeXComponent(id), column) == + INVALID_PARAM) { + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponentIdTest", + "OH_NativeXComponent_AttachNativeRootNode failed"); + } + napi_value exports; + if (napi_create_object(env, &exports) != napi_ok) { + napi_throw_type_error(env, NULL, "napi_create_object failed"); + return nullptr; + } + + return exports; +} +} // namespace ArkUICApiDemo \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/cpp/xcomponent/xcomponent_id_test.h b/function/ui_compare/capidemo/entry/src/main/cpp/xcomponent/xcomponent_id_test.h new file mode 100644 index 0000000000000000000000000000000000000000..efac312735533425f05d657c5846411673cf4771 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/cpp/xcomponent/xcomponent_id_test.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARKUI_CAPI_DEMO_XCOMPONENT_ID_TEST_H +#define ARKUI_CAPI_DEMO_XCOMPONENT_ID_TEST_H + +#include +#include +#include + +#include "../common/common.h" + +namespace ArkUICApiDemo { + +class XComponentIdTest { +public: + ~XComponentIdTest(); + static napi_value CreateNativeNode(napi_env env, napi_callback_info info); +}; + +} // namespace ArkUICApiDemo +#endif // ARKUI_CAPI_DEMO_XCOMPONENT_ID_TEST_H diff --git a/function/ui_compare/capidemo/entry/src/main/ets/componet/CommonView.ets b/function/ui_compare/capidemo/entry/src/main/ets/componet/CommonView.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd3064660aec25ff11ba1d30f4e9a335baad02b3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/componet/CommonView.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct CommonView { + pageTag: string = ''; + + build() { + Column() { + Column({ space: 10 }) { + XComponent({ + id: this.pageTag, + type: 'node', + libraryname: 'nativerender' + }).onDestroy(() => { + console.log('onDestroy'); + }).backgroundColor('#FFEEEEEE') + .width('100%') + .height('100%') + }.margin(20) + .height('100%') + .width('100%') + } + .id(this.pageTag) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/EntryAbility.ets b/function/ui_compare/capidemo/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ee72503510a6c6a0d7a6c684c4d5bb9b6c1aad7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/EntryAbility.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/EntryAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..831ac54dfe1ba983183a629f64819a0366d0c325 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/EntryAbility.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionDelayTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionDelayTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c7e6cf8f921a1372300d33284433028f394cc40 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionDelayTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimateOptionDelayTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimateOptionDelayTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionDurationTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionDurationTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..f28c0f6aa7551f8655022a4f02fa0e10ec90fbda --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionDurationTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimateOptionDurationTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimateOptionDurationTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionIterationsTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionIterationsTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec79c1546480d3ad52af7de35f3fa6fa1f55903e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimateOptionIterationsTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimateOptionIterationsTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimateOptionIterationsTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionDurationTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionDurationTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..85487ba43390593abf07bf5c6370f1ab02f8d4fe --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionDurationTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimatorOptionDurationTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimatorOptionDurationTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionInterpolationTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionInterpolationTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..50e60d1f1eb239b56b2ed27a8d9bd6d3bea92175 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionInterpolationTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimatorOptionInterpolationTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimatorOptionInterpolationTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionIterationsTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionIterationsTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d2b6c9da00338b037fc1ce69d752a05ae1c638e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionIterationsTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimatorOptionIterationsTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimatorOptionIterationsTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionStateTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionStateTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b86ce3b127a69adeb12c8d0bfe440a0a8fdf40e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateAnimatorOptionStateTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateAnimatorOptionStateTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateAnimatorOptionStateTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateCurveTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateCurveTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..da10052e6ed7b3c24f959b68e13571ec1116d356 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateCurveTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateCurveTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateCurveTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionDoubleTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionDoubleTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca3fd1c88ce6abdaede4c7d82274331ef52ea86e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionDoubleTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateGeometryTransitionDoubleTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateGeometryTransitionDoubleTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionMultiTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionMultiTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..2887408750ec7bb793f2d7eff2d4df94fb3333f7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionMultiTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateGeometryTransitionMultiTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateGeometryTransitionMultiTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionNormalTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionNormalTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..92be6d34cb3e9844e5dbeb0039a433d78a4c6501 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateGeometryTransitionNormalTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateGeometryTransitionNormalTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateGeometryTransitionNormalTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionDelayTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionDelayTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0bc654277a23aec0fcc60b0d1528b333b09043b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionDelayTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateKeyframeAnimateOptionDelayTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateKeyframeAnimateOptionDelayTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionDurationTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionDurationTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee16e85496c3f0bbef1763e76ce0f97c5ee2dbf0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionDurationTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateKeyframeAnimateOptionDurationTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateKeyframeAnimateOptionDurationTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionIterationsTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionIterationsTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ed17f004693f593956a05be3c25b8fd95514c08 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/animation/AnimateKeyframeAnimateOptionIterationsTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class AnimateKeyframeAnimateOptionIterationsTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/animation/AnimateKeyframeAnimateOptionIterationsTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c7317bc9ef3052f708dc9d9272edb225483b2d69 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage10Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage10Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..91e4476e378c9c7ed1244fc0cd33e82b6e82b174 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage11Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage11Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c948040035d998ed86078d42fcefbd1713560a64 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage12Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage12Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b87c5eaabbde5a478cd4531ab90a91bb22f5173 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage13Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage13Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3428723318c505fa4772d2f3ca86c17bdf762e9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage14Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage14Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..67bd89de46edc863dfefb392ed633e7c025a42ec --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage15Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage15Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..93ef495f1992baa2648e57fa907759acd0b4cdb6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage16Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage16Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b352835a51d773b5b7a3a0c1375dc847356bbaa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage1Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage1Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed7ec8a61fcda1eb1e41555daaf19e4791f721d4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage2Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage2Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..afc31d7e49785f016a8d037286e7a65fb0307f7a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage3Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage3Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a663ac87eaf16448dfe2ea22f51502ebb64f126 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage4Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage4Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..a87275e4a75e514ec97fc704286517b56a6b361d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage5Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage5Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..7fdc9aba691467e22c7e01b0a9cb05b5d1174b5c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage6Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage6Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..2cc6cf9f86dceefecabed580c8ad563dd45ae372 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage7Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage7Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a11ff589b04eb67b626ac66594b2ff306eca427 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage8Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage8Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f91c45afea1472a2f4ef0da8eda0caf36004e4b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsExpandSafeAreaPage9Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsExpandSafeAreaPage9Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit1Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit1Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..15c799a0227928bae136021156d435f10790a1d5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit1Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsRenderFit1Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsRenderFit1Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit2Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit2Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d3095762ea147db4917de9cf2d2eb85bcd93659 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit2Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsRenderFit2Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsRenderFit2Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit3Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit3Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed0f31757b5f20ebd19eddf155d2043c1045d5ba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit3Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsRenderFit3Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsRenderFit3Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit4Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit4Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..33f6fe495aebc2d06f062516b61d1daac162f03b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit4Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsRenderFit4Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsRenderFit4Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit5Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit5Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ea206bff5654fd58ecd2776c6436f38325cbf70 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsRenderFit5Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsRenderFit5Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsRenderFit5Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransformCenterTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransformCenterTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..4439f5b6cdcaaaaab81719ebd63311f152371aba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransformCenterTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransformCenterTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransformCenterTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionAsymmetricTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionAsymmetricTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..d05d768b58fe354fcd41cfadbc1be15e852a8117 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionAsymmetricTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransitionAsymmetricTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransitionAsymmetricTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionMoveTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionMoveTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..36139afde3515dc2fb743e4047b24f18fee61bc7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionMoveTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransitionMoveTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransitionMoveTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionOpacityTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionOpacityTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbc080297e1106e74b632980f939526542adb835 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionOpacityTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransitionOpacityTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransitionOpacityTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionRotateTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionRotateTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..4af72d652cfffe0afcccb641a032f0ba62233006 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionRotateTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransitionRotateTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransitionRotateTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionScaleTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionScaleTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..06f17f36b79bd23ae1a74d023e883fda7cf55ccd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionScaleTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransitionScaleTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransitionScaleTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionTranslateTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionTranslateTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a760c42fa5d5bfcb78029c7fc0a1332175e9765 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/commonattrs/CommonAttrsTransitionTranslateTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CommonAttrsTransitionTranslateTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/commonattrs/CommonAttrsTransitionTranslateTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/customdialog/CustomDialogContentTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/customdialog/CustomDialogContentTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..f411418bc02eeba496315e553bfd3760e7d879ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/customdialog/CustomDialogContentTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class CustomDialogContentTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/customdialog/CustomDialogContentTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/imageanimator/ImageAnimatorIterationsTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/imageanimator/ImageAnimatorIterationsTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..c41c075c49b2804ae3a670caa4cd9737ab67de8a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/imageanimator/ImageAnimatorIterationsTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ImageAnimatorIterationsTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/imageanimator/ImageAnimatorIterationsTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/imageanimator/ImageAnimatorTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/imageanimator/ImageAnimatorTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..0eea573824fe18369d08bd8fd872f8eb29d267ac --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/imageanimator/ImageAnimatorTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ImageAnimatorTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/imageanimator/ImageAnimatorTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollOffset6Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollOffset6Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a54c0fa19f5ba7d3eb122e4333ff5eccaa65b62 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollOffset6Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ListScrollOffset6Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/list/ListScrollOffset6Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollPageTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollPageTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..4066ff32a3e31943bddca27e26c39f9631fc3953 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollPageTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ListScrollPageTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/list/ListScrollPageTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollToIndexTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollToIndexTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..ddd4e5feae1334f45a0f02647456ee185d3bf037 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/list/ListScrollToIndexTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ListScrollToIndexTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/list/ListScrollToIndexTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/refresh/RefreshForContentAndRatioAbnormalTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/refresh/RefreshForContentAndRatioAbnormalTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..73bb5227d185a23b48e4f2349f82635367ff8b57 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/refresh/RefreshForContentAndRatioAbnormalTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class RefreshForContentAndRatioAbnormalTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/refresh/RefreshForContentAndRatioAbnormalTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/refresh/RefreshForContentAndRatioTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/refresh/RefreshForContentAndRatioTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..b183c602739408095930bd4318515a60bf70b729 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/refresh/RefreshForContentAndRatioTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class RefreshForContentAndRatioTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/refresh/RefreshForContentAndRatioTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/requirement/RequirementPinchAndPanGestureTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/requirement/RequirementPinchAndPanGestureTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..260ff72fbf544696cf6c2d966842181f7012ed56 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/requirement/RequirementPinchAndPanGestureTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class RequirementPinchAndPanGestureTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/requirement/RequirementPinchAndPanGestureTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetCurveTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetCurveTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..604e123703428e53f44507d5c37225d5d0a8fff4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetCurveTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ScrollScrollOffsetCurveTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/scroll/ScrollScrollOffsetCurveTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetOtherTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetOtherTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d8d58f136576553088e0dd0912fd129d9082f77 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetOtherTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ScrollScrollOffsetOtherTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/scroll/ScrollScrollOffsetOtherTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d9641c578c9643975334ce6516382332d8aa1fc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollOffsetTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ScrollScrollOffsetTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/scroll/ScrollScrollOffsetTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollPageTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollPageTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..421df5a31854a888214799c49012e1aa770a8549 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/scroll/ScrollScrollPageTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class ScrollScrollPageTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/scroll/ScrollScrollPageTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeFadeTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeFadeTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e8f855188a0be0734fb0e52cd1afcba3f2ed6a0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeFadeTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class SwiperEffectModeFadeTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/swiper/SwiperEffectModeFadeTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeInterruptTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeInterruptTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa30e475b03272bea4ae611d260364ad40987ae5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeInterruptTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class SwiperEffectModeInterruptTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/swiper/SwiperEffectModeInterruptTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeMultipleTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeMultipleTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..caa7ff0d27a465f21dbe7b565f8abb5a7f2aba40 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeMultipleTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class SwiperEffectModeMultipleTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/swiper/SwiperEffectModeMultipleTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeNoneTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeNoneTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..636a9bf41d289addeba8f7f690b5f5634e38021d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeNoneTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class SwiperEffectModeNoneTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/swiper/SwiperEffectModeNoneTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeSpringTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeSpringTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a27a0a3dbb46b725df1a58aea6358bc56ab59f7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperEffectModeSpringTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class SwiperEffectModeSpringTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/swiper/SwiperEffectModeSpringTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperNestedScrollTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperNestedScrollTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d5078017820cb021b5975e55fcb13ba97c18958 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/swiper/SwiperNestedScrollTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class SwiperNestedScrollTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/swiper/SwiperNestedScrollTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/text/TextEnableDataDetectorTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/text/TextEnableDataDetectorTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..049d65aa216e0929cfa01ec533afc67aac296c08 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/text/TextEnableDataDetectorTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class TextEnableDataDetectorTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/text/TextEnableDataDetectorTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaCaretPositionTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaCaretPositionTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..687d4aad20b74b51b5a8e90a3f06d0bd7c6b6379 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaCaretPositionTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class TextAreaCaretPositionTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/textarea/TextAreaCaretPositionTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaGetCaretOffsetTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaGetCaretOffsetTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..cba73fba4b902d6ceb7f6831615214860a007732 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaGetCaretOffsetTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class TextAreaGetCaretOffsetTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/textarea/TextAreaGetCaretOffsetTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaShowCounterTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaShowCounterTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..4bd65f8b94879b4ece86134c7bfb5e0a0fadbeaa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textarea/TextAreaShowCounterTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class TextAreaShowCounterTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/textarea/TextAreaShowCounterTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/textinput/TextInputCaretPositionTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textinput/TextInputCaretPositionTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..7951d326e420aadfb15e1e5b99ce676422cd1c1d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textinput/TextInputCaretPositionTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class TextInputCaretPositionTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/textinput/TextInputCaretPositionTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/textinput/TextInputGetCaretOffsetTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textinput/TextInputGetCaretOffsetTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..32b2feddf7cf25497bc1d6db64e174013a95615e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/textinput/TextInputGetCaretOffsetTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class TextInputGetCaretOffsetTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/textinput/TextInputGetCaretOffsetTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollBarDisplayModeTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollBarDisplayModeTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..7427462398b39a4ba7413768774194a5d35750ca --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollBarDisplayModeTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollBarDisplayModeTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollBarDisplayModeTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollEdgeEffectTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollEdgeEffectTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..595a2a3e7dfd24e3b098873b6b5e989459e33a17 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollEdgeEffectTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollEdgeEffectTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollEdgeEffectTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollFrictionTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollFrictionTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b0b992d94384de6080d5abf4fd8b664d4b4bf6b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollFrictionTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollFrictionTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollFrictionTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollOffset6Test.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollOffset6Test.ts new file mode 100644 index 0000000000000000000000000000000000000000..01cd810795f2cbf1f53632daa27b9f9d5e3e5e47 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollOffset6Test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollOffset6Test extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollOffset6Test', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollOffsetCurveTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollOffsetCurveTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcff7ebcfac40541c894c08a1caec8873a12181e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollOffsetCurveTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollOffsetCurveTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollOffsetCurveTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollPageTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollPageTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..57445d811ea8c3047306fdedfbbb4fb0c5f92ce6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollPageTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollPageTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollPageTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollToIndexTest.ts b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollToIndexTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec0af5f11b9398f0d42e90ca9cee36c0649d6786 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entryability/waterflow/WaterFlowScrollToIndexTest.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class WaterFlowScrollToIndexTest extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/waterflow/WaterFlowScrollToIndexTest', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/function/ui_compare/capidemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/function/ui_compare/capidemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7f4ee43788d45f15e56fb439ccf4f4b9aee167e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/Index.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a1c5bde604c6adc46dacca48fe15e5e149aeafd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from "libnativerender.so" +@Entry +@Component +struct Index { + build() { + Column() { + Column() { + + XComponent({ + id: 'xComponentId', + type: XComponentType.NODE, + libraryname: 'nativerender' + }).onDestroy(() => { + console.log('onDestroy'); + }).onAppear(() => { + render.listItemGroupDividerTest('xComponentId'); + + }).width('100%') + .height('100%') + }.margin({ + top: 27, + left: 12, + right: 12 + }) + .height('100%') + .width('100%') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionDelayTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionDelayTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1e43ea30c991629d385310b851cd55387db24714 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionDelayTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimateOptionDelayTest { + PAGE_TAG: string = 'AnimateAnimateOptionDelayTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimateOptionDelayTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionDurationTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionDurationTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..06a383858ad1d15361474568aba207f34c567d10 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionDurationTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimateOptionDurationTest { + PAGE_TAG: string = 'AnimateAnimateOptionDurationTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimateOptionDurationTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionIterationsTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionIterationsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..07145245d54dd43af8288c5150675cdd68cf9365 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimateOptionIterationsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimateOptionIterationsTest { + PAGE_TAG: string = 'AnimateAnimateOptionIterationsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimateOptionIterationsTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionDurationTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionDurationTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..69ae31d00f335e3444d09eef9678cfe8c55f6d4f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionDurationTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimatorOptionDurationTest { + PAGE_TAG: string = 'AnimateAnimatorOptionDurationTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimatorOptionDurationTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionInterpolationTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionInterpolationTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0a75b42027d609beae36bca4616edcdb7f67f90 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionInterpolationTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimatorOptionInterpolationTest { + PAGE_TAG: string = 'AnimateAnimatorOptionInterpolationTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimatorOptionInterpolationTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionIterationsTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionIterationsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..42cd5be361ed635c29486f95c4ba8b3aba91326e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionIterationsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimatorOptionIterationsTest { + PAGE_TAG: string = 'AnimateAnimatorOptionIterationsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimatorOptionIterationsTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionStateTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionStateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..051f3d441e523bed0ab55be2aefebd601d9de297 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateAnimatorOptionStateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateAnimatorOptionStateTest { + PAGE_TAG: string = 'AnimateAnimatorOptionStateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateAnimatorOptionStateTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateCurveTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateCurveTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..800017217f2788ded55df17d46abfcf321f7c9d8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateCurveTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateCurveTest { + PAGE_TAG: string = 'AnimateCurveTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateCurveTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionDoubleTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionDoubleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..42b1c71f027045b18881305c5215fdedb12f56b1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionDoubleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateGeometryTransitionDoubleTest { + PAGE_TAG: string = 'AnimateGeometryTransitionDoubleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateGeometryTransitionDoubleTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionMultiTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionMultiTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a448a2b0b721eade52c84f24a01a0a499ff5133 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionMultiTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateGeometryTransitionMultiTest { + PAGE_TAG: string = 'AnimateGeometryTransitionMultiTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateGeometryTransitionMultiTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionNormalTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionNormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4ac1599fa6cd0acc4c4a6f7c417399110cce0ee --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateGeometryTransitionNormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateGeometryTransitionNormalTest { + PAGE_TAG: string = 'AnimateGeometryTransitionNormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateGeometryTransitionNormalTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionDelayTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionDelayTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5436197b4efac59bf2deb2a34f6ca24a66a79529 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionDelayTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateKeyframeAnimateOptionDelayTest { + PAGE_TAG: string = 'AnimateKeyframeAnimateOptionDelayTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateKeyframeAnimateOptionDelayTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionDurationTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionDurationTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b570fe37e7ad1ac17b4205e39ca7659a40ddd0e4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionDurationTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateKeyframeAnimateOptionDurationTest { + PAGE_TAG: string = 'AnimateKeyframeAnimateOptionDurationTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateKeyframeAnimateOptionDurationTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionIterationsTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionIterationsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..be1a2a222bf44b01d770c7d9ab4aef3241e885f8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/animation/AnimateKeyframeAnimateOptionIterationsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AnimateKeyframeAnimateOptionIterationsTest { + PAGE_TAG: string = 'AnimateKeyframeAnimateOptionIterationsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.animateKeyframeAnimateOptionIterationsTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..135c0e04500b8beb9b5b332752cf52a9319df74a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage10Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage10Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage10Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4ba09fede455c803af70e72db477b80d3c15412 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage11Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage11Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage11Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9f0c4220bca075ca420009a746c95909fc2cf8b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage12Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage12Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage12Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0db91a0f72ffd60c1bd18489c55bfe058f2727c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage13Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage13Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage13Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5cc463c05e9a9304f9a5843bfa5cead283d18a3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage14Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage14Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage14Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..54b6546330862181c188998eb8ae440c1215d287 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage15Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage15Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage15Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd2c45e1737f84c4f56a9bf3ec31e08881184b2a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage16Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage16Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage16Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d117d74552e65404b8d67591aeefeee87aa337d9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage1Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..351b6cd56bbfaad0a3a9e3f7187887fed1e4976f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage2Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8d5c787459645ac0c47c596ec9ee5c4dcce09d9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage3Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..72faae1bd8df74c9e60114662f89468231e13b39 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage4Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage4Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage4Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..068410f6e28b2b65d5f1e1947d04327a4b4d83e0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage5Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage5Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage5Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3c0fb5a3184ec05652a908a1e003ea6d692c9ad --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage6Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage6Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage6Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..afc46accefb61797a4eb09365fbd33f6f645f085 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage7Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage7Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage7Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6825b160aae6e36f8a58ee5047e2485c3b6aabf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage8Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage8Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage8Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..088ee52046e4c2c79e71150a2a037a7a64ff7849 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsExpandSafeAreaPage9Test { + PAGE_TAG: string = 'CommonAttrsExpandSafeAreaPage9Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsExpandSafeAreaPage9Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit1Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..48359b733eacb231fbb1a1eea28fc20ce0ced485 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRenderFit1Test { + PAGE_TAG: string = 'CommonAttrsRenderFit1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRenderFit1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit2Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..092df60efc372a4d8c747c5921010ee1afa2cff5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRenderFit2Test { + PAGE_TAG: string = 'CommonAttrsRenderFit2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRenderFit2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit3Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..34a435b6bd36f9d983b5daca05a83c776417d778 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRenderFit3Test { + PAGE_TAG: string = 'CommonAttrsRenderFit3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRenderFit3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit4Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit4Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0df09576b269e008c4317e98db35bf8606f47c23 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit4Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRenderFit4Test { + PAGE_TAG: string = 'CommonAttrsRenderFit4Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRenderFit4Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit5Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit5Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f442868e576522280b5b4f9b5d467447d0d487a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsRenderFit5Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRenderFit5Test { + PAGE_TAG: string = 'CommonAttrsRenderFit5Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRenderFit5Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransformCenterTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransformCenterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5f2ebed88b06ac04fc03b9de0816d606cba520d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransformCenterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransformCenterTest { + PAGE_TAG: string = 'CommonAttrsTransformCenterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransformCenterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionAsymmetricTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionAsymmetricTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f6eb4f2de5244c09bb1c42a7b9341cb9f4f5dcf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionAsymmetricTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransitionAsymmetricTest { + PAGE_TAG: string = 'CommonAttrsTransitionAsymmetricTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransitionAsymmetricTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionMoveTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionMoveTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdaa4e107f7a09711699e96928568ddf42bff10b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionMoveTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransitionMoveTest { + PAGE_TAG: string = 'CommonAttrsTransitionMoveTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransitionMoveTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionOpacityTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionOpacityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d9c41436accae27d58181415f5a50e4ad4d53ac --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionOpacityTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransitionOpacityTest { + PAGE_TAG: string = 'CommonAttrsTransitionOpacityTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransitionOpacityTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionRotateTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionRotateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..606206a0cd8efc51a2fddb187889c90b92923894 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionRotateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransitionRotateTest { + PAGE_TAG: string = 'CommonAttrsTransitionRotateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransitionRotateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionScaleTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionScaleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d711e9870f5d46bf469db8b3d6c08e08e3b14fb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionScaleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransitionScaleTest { + PAGE_TAG: string = 'CommonAttrsTransitionScaleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransitionScaleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionTranslateTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionTranslateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..29b785a4f61500e15cd9b67086a057e824fb36f1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/commonattrs/CommonAttrsTransitionTranslateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTransitionTranslateTest { + PAGE_TAG: string = 'CommonAttrsTransitionTranslateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTransitionTranslateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/customdialog/CustomDialogContentTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/customdialog/CustomDialogContentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a97a269f92d1dc63bb5342317dd8fa665418f15d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/customdialog/CustomDialogContentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomDialogContentTest { + PAGE_TAG: string = 'CustomDialogContentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customDialogContentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/imageanimator/ImageAnimatorIterationsTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/imageanimator/ImageAnimatorIterationsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..38510e4dd5ed56540e0b987e6aad59e05673a8dc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/imageanimator/ImageAnimatorIterationsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorIterationsTest { + PAGE_TAG: string = 'ImageAnimatorIterationsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorIterationsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/imageanimator/ImageAnimatorTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/imageanimator/ImageAnimatorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7ae7dbdc46070b20f4f9be3717008407d32e7f4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/imageanimator/ImageAnimatorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorTest { + PAGE_TAG: string = 'ImageAnimatorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollOffset6Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollOffset6Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7a31b0eda198f072eb592484167cea3e45eb900 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollOffset6Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollOffset6Test { + PAGE_TAG: string = 'ListScrollOffset6Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollOffset6Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollPageTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollPageTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1cbe49c3032d810df6690a7624c7f01affba271 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollPageTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollPageTest { + PAGE_TAG: string = 'ListScrollPageTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollPageTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollToIndexTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollToIndexTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d2c8f980e4720848a7197061922404e1f271227 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/list/ListScrollToIndexTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollToIndexTest { + PAGE_TAG: string = 'ListScrollToIndexTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollToIndexTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/refresh/RefreshForContentAndRatioAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/refresh/RefreshForContentAndRatioAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c6005d04a8bf022ab59874b5b2454513812a182 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/refresh/RefreshForContentAndRatioAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshForContentAndRatioAbnormalTest { + PAGE_TAG: string = 'RefreshForContentAndRatioAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshForContentAndRatioTest(this.PAGE_TAG,-1); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/refresh/RefreshForContentAndRatioTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/refresh/RefreshForContentAndRatioTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5c9b5634a8b36f0c23d8882efc372441d1db67e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/refresh/RefreshForContentAndRatioTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshForContentAndRatioTest { + PAGE_TAG: string = 'RefreshForContentAndRatioTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshForContentAndRatioTest(this.PAGE_TAG,0.3); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/requirement/RequirementPinchAndPanGestureTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/requirement/RequirementPinchAndPanGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f828e37de973f1d5a57263e8a294b075d2f4357a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/requirement/RequirementPinchAndPanGestureTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RequirementPinchAndPanGestureTest { + PAGE_TAG: string = 'RequirementPinchAndPanGestureTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.requirementPinchAndPanGestureTest(this.PAGE_TAG, $r("app.media.icon")); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetCurveTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetCurveTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b6aebcb4e596e0751117546885cae732bfd10de --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetCurveTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollOffsetCurveTest { + PAGE_TAG: string = 'ScrollScrollOffsetCurveTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollOffsetCurveTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetOtherTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetOtherTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0225a843fa94d9a229d5a53185bb1154b475f432 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetOtherTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollOffsetOtherTest { + PAGE_TAG: string = 'ScrollScrollOffsetOtherTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollOffsetOtherTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..eaea2ad861830b1b00152ed1edd0ada214a720fd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollOffsetTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollOffsetTest { + PAGE_TAG: string = 'ScrollScrollOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollOffsetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollPageTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollPageTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a998fb02612981e5ec734cede3d82ea34950578 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/scroll/ScrollScrollPageTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollPageTest { + PAGE_TAG: string = 'ScrollScrollPageTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollPageTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeFadeTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeFadeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..312f560a8a45288c0c42aa8a45bf3d8d757a2a86 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeFadeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeFadeTest { + PAGE_TAG: string = 'SwiperEffectModeFadeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeFadeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeInterruptTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeInterruptTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac48034bccfccaf74c467f0117ace44be6bcfac3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeInterruptTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeInterruptTest { + PAGE_TAG: string = 'SwiperEffectModeInterruptTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeInterruptTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeMultipleTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeMultipleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..60ac936d99695059bcfa183f3662d55e685970d8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeMultipleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeMultipleTest { + PAGE_TAG: string = 'SwiperEffectModeMultipleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeMultipleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeNoneTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeNoneTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..76c4f767d5d14547a16f6bd1e8c093dcf3704260 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeNoneTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeNoneTest { + PAGE_TAG: string = 'SwiperEffectModeNoneTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeNoneTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeSpringTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeSpringTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d35b7fe9068014da7827b0f4198cbc93ae9a55bf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperEffectModeSpringTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeSpringTest { + PAGE_TAG: string = 'SwiperEffectModeSpringTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeSpringTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperNestedScrollTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperNestedScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4fc4568bb22f5f334169d5ee70724cbb2ab308c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/swiper/SwiperNestedScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperNestedScrollTest { + PAGE_TAG: string = 'SwiperNestedScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperNestedScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/text/TextEnableDataDetectorTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/text/TextEnableDataDetectorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ef4a226286e8bd73cb13f3f10bfaa7298f17bcc9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/text/TextEnableDataDetectorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextEnableDataDetectorTest { + PAGE_TAG: string = 'TextEnableDataDetectorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textEnableDataDetectorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaCaretPositionTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaCaretPositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9892328b5a5cf589105892198b93830bb6e09be --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaCaretPositionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct TextAreaCaretPositionTest { + PAGE_TAG: string = 'TextAreaCaretPositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaCaretPositionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaGetCaretOffsetTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaGetCaretOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d39728b58e56c9e5ded42a4b4ec8bd48b43f0419 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaGetCaretOffsetTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaGetCaretOffsetTest { + PAGE_TAG: string = 'TextAreaGetCaretOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaGetCaretOffsetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaShowCounterTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaShowCounterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..17873dcf8d66c12bc85f94e1f4a6c711b332c5e0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/textarea/TextAreaShowCounterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaShowCounterTest { + PAGE_TAG: string = 'TextAreaShowCounterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaShowCounterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/textinput/TextInputCaretPositionTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/textinput/TextInputCaretPositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..596d5a4fb926eb09af8e3fe2287e019a77a19d17 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/textinput/TextInputCaretPositionTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCaretPositionTest { + PAGE_TAG: string = 'TextInputCaretPositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCaretPositionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/textinput/TextInputGetCaretOffsetTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/textinput/TextInputGetCaretOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fa27c48778f943b6e31d775f79abbc757fbf637 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/textinput/TextInputGetCaretOffsetTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputGetCaretOffsetTest { + PAGE_TAG: string = 'TextInputGetCaretOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputGetCaretOffsetTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollBarDisplayModeTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollBarDisplayModeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4e4dbe20e34866691c1f99a618d9ea0dddf25ea --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollBarDisplayModeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollBarDisplayModeTest { + PAGE_TAG: string = 'WaterFlowScrollBarDisplayModeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollBarDisplayModeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollEdgeEffectTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollEdgeEffectTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0191502a3a1734de1fa88c24ed118e746613817 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollEdgeEffectTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollEdgeEffectTest { + PAGE_TAG: string = 'WaterFlowScrollEdgeEffectTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollEdgeEffectTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollFrictionTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollFrictionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0258dac78ee6d6c9df93d7b724944bf5a91a542a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollFrictionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollFrictionTest { + PAGE_TAG: string = 'WaterFlowScrollFrictionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollFrictionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollOffset6Test.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollOffset6Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e6f9548ebeed7fb600c8863959cf256caa307b8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollOffset6Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollOffset6Test { + PAGE_TAG: string = 'WaterFlowScrollOffset6Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollOffset6Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollOffsetCurveTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollOffsetCurveTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4290484af354b5cbae4b82edf4430bced4e4607 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollOffsetCurveTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollOffsetCurveTest { + PAGE_TAG: string = 'WaterFlowScrollOffsetCurveTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollOffsetCurveTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollPageTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollPageTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e375ac72ffac5e81a5f9886ce9cb68a026480fab --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollPageTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollPageTest { + PAGE_TAG: string = 'WaterFlowScrollPageTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollPageTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollToIndexTest.ets b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollToIndexTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..baadd973b3601912b422dc0dbbd688cf36c0a81e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/ets/pages/waterflow/WaterFlowScrollToIndexTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollToIndexTest { + PAGE_TAG: string = 'WaterFlowScrollToIndexTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollToIndexTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/main/module.json5 b/function/ui_compare/capidemo/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1d62f45f00f035133ee95daeb2c164f2797808c2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/module.json5 @@ -0,0 +1,1303 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollBarDisplayModeTest", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollBarDisplayModeTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollEdgeEffectTest", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollEdgeEffectTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollOffset6Test", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollOffset6Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollOffsetCurveTest", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollOffsetCurveTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollPageTest", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollPageTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollToIndexTest", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollToIndexTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "WaterFlowScrollFrictionTest", + "srcEntry": "./ets/entryability/waterflow/WaterFlowScrollFrictionTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ImageAnimatorTest", + "srcEntry": "./ets/entryability/imageanimator/ImageAnimatorTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ImageAnimatorIterationsTest", + "srcEntry": "./ets/entryability/imageanimator/ImageAnimatorIterationsTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SwiperEffectModeSpringTest", + "srcEntry": "./ets/entryability/swiper/SwiperEffectModeSpringTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SwiperEffectModeFadeTest", + "srcEntry": "./ets/entryability/swiper/SwiperEffectModeFadeTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SwiperEffectModeNoneTest", + "srcEntry": "./ets/entryability/swiper/SwiperEffectModeNoneTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SwiperEffectModeMultipleTest", + "srcEntry": "./ets/entryability/swiper/SwiperEffectModeMultipleTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SwiperEffectModeInterruptTest", + "srcEntry": "./ets/entryability/swiper/SwiperEffectModeInterruptTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "SwiperNestedScrollTest", + "srcEntry": "./ets/entryability/swiper/SwiperNestedScrollTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimateOptionDelayTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimateOptionDelayTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimateOptionDurationTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimateOptionDurationTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimateOptionIterationsTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimateOptionIterationsTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimatorOptionDurationTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimatorOptionDurationTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimatorOptionInterpolationTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimatorOptionInterpolationTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimatorOptionIterationsTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimatorOptionIterationsTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateAnimatorOptionStateTest", + "srcEntry": "./ets/entryability/animation/AnimateAnimatorOptionStateTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateCurveTest", + "srcEntry": "./ets/entryability/animation/AnimateCurveTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateGeometryTransitionDoubleTest", + "srcEntry": "./ets/entryability/animation/AnimateGeometryTransitionDoubleTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateGeometryTransitionMultiTest", + "srcEntry": "./ets/entryability/animation/AnimateGeometryTransitionMultiTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateGeometryTransitionNormalTest", + "srcEntry": "./ets/entryability/animation/AnimateGeometryTransitionNormalTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateKeyframeAnimateOptionDelayTest", + "srcEntry": "./ets/entryability/animation/AnimateKeyframeAnimateOptionDelayTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateKeyframeAnimateOptionDurationTest", + "srcEntry": "./ets/entryability/animation/AnimateKeyframeAnimateOptionDurationTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "AnimateKeyframeAnimateOptionIterationsTest", + "srcEntry": "./ets/entryability/animation/AnimateKeyframeAnimateOptionIterationsTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CustomDialogContentTest", + "srcEntry": "./ets/entryability/customdialog/CustomDialogContentTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage1Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage1Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage2Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage2Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage3Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage3Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage4Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage4Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage5Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage5Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage6Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage6Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage7Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage7Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage8Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage8Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage9Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage9Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage10Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage10Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage11Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage11Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage12Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage12Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage13Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage13Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage14Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage14Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage15Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage15Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsExpandSafeAreaPage16Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsExpandSafeAreaPage16Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsRenderFit1Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsRenderFit1Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsRenderFit2Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsRenderFit2Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsRenderFit3Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsRenderFit3Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsRenderFit4Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsRenderFit4Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsRenderFit5Test", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsRenderFit5Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransformCenterTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransformCenterTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransitionAsymmetricTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransitionAsymmetricTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransitionMoveTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransitionMoveTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransitionOpacityTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransitionOpacityTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransitionRotateTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransitionRotateTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransitionScaleTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransitionScaleTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CommonAttrsTransitionTranslateTest", + "srcEntry": "./ets/entryability/commonattrs/CommonAttrsTransitionTranslateTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ScrollScrollOffsetTest", + "srcEntry": "./ets/entryability/scroll/ScrollScrollOffsetTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ScrollScrollOffsetCurveTest", + "srcEntry": "./ets/entryability/scroll/ScrollScrollOffsetCurveTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ScrollScrollOffsetOtherTest", + "srcEntry": "./ets/entryability/scroll/ScrollScrollOffsetOtherTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ScrollScrollPageTest", + "srcEntry": "./ets/entryability/scroll/ScrollScrollPageTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "RefreshForContentAndRatioAbnormalTest", + "srcEntry": "./ets/entryability/refresh/RefreshForContentAndRatioAbnormalTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "RefreshForContentAndRatioTest", + "srcEntry": "./ets/entryability/refresh/RefreshForContentAndRatioTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "RequirementPinchAndPanGestureTest", + "srcEntry": "./ets/entryability/requirement/RequirementPinchAndPanGestureTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TextInputCaretPositionTest", + "srcEntry": "./ets/entryability/textinput/TextInputCaretPositionTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TextInputGetCaretOffsetTest", + "srcEntry": "./ets/entryability/textinput/TextInputGetCaretOffsetTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TextAreaCaretPositionTest", + "srcEntry": "./ets/entryability/textarea/TextAreaCaretPositionTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TextAreaGetCaretOffsetTest", + "srcEntry": "./ets/entryability/textarea/TextAreaGetCaretOffsetTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TextAreaShowCounterTest", + "srcEntry": "./ets/entryability/textarea/TextAreaShowCounterTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TextEnableDataDetectorTest", + "srcEntry": "./ets/entryability/text/TextEnableDataDetectorTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ListScrollOffset6Test", + "srcEntry": "./ets/entryability/list/ListScrollOffset6Test.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ListScrollPageTest", + "srcEntry": "./ets/entryability/list/ListScrollPageTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "ListScrollToIndexTest", + "srcEntry": "./ets/entryability/list/ListScrollToIndexTest.ts", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.SYSTEM_FLOAT_WINDOW" + }, + { + "name": "ohos.permission.INTERNET" + } + ] + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/element/color.json b/function/ui_compare/capidemo/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/element/string.json b/function/ui_compare/capidemo/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b976fb6d0379b826204087d18a5f01872ce4d54 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/animated_circle.svg b/function/ui_compare/capidemo/entry/src/main/resources/base/media/animated_circle.svg new file mode 100644 index 0000000000000000000000000000000000000000..8bb7fcc7cc115822846c9c5ed42403fe17f69490 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/media/animated_circle.svg @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/animated_circle_stop.svg b/function/ui_compare/capidemo/entry/src/main/resources/base/media/animated_circle_stop.svg new file mode 100644 index 0000000000000000000000000000000000000000..80c03f252ab18562a2c45f78dfe7113e1870735c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/media/animated_circle_stop.svg @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/background.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_blue.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_blue.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_green.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_green.png new file mode 100644 index 0000000000000000000000000000000000000000..385aee55284cd8a5ebde3910bf82c494f057fecf Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_green.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_red.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_red.png new file mode 100644 index 0000000000000000000000000000000000000000..742044d80325e183663d8dffd8a2e5a37c6bed90 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_red.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_yellow.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..1fa2f73575caef6b5fcf736b6eb2e8ff34802713 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/background_yellow.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/blue.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/blue.png new file mode 100644 index 0000000000000000000000000000000000000000..9be5cd611a85c72ac680b3786d626fcee91c1c8b Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/blue.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/foreground.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/foreground.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/green.jpg b/function/ui_compare/capidemo/entry/src/main/resources/base/media/green.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0c85caca7844dce5d4fc519f38eb13d656658b5e Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/green.jpg differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/icon.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/icon.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/icon_small.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/icon_small.png new file mode 100644 index 0000000000000000000000000000000000000000..adb226051b3771a741509382c683606d029e5b25 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/icon_small.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/layered_image.json b/function/ui_compare/capidemo/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..16cf3219a2997a071cd6f0cd4816d3e173b18d15 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/maskL1_133.svg b/function/ui_compare/capidemo/entry/src/main/resources/base/media/maskL1_133.svg new file mode 100644 index 0000000000000000000000000000000000000000..a0fb3a9c08b612ad80c4c1e87f6543e0e0f10676 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/media/maskL1_133.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/pink.heif b/function/ui_compare/capidemo/entry/src/main/resources/base/media/pink.heif new file mode 100644 index 0000000000000000000000000000000000000000..2033b4328c97682d96b8f4fa23f5d16494f4eaff Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/pink.heif differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/red.gif b/function/ui_compare/capidemo/entry/src/main/resources/base/media/red.gif new file mode 100644 index 0000000000000000000000000000000000000000..211e82074b07136320cb02f10a1718e423840771 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/red.gif differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/src.jpg b/function/ui_compare/capidemo/entry/src/main/resources/base/media/src.jpg new file mode 100644 index 0000000000000000000000000000000000000000..36a19cd6b90bb98511116f5015c74fe2f860249d Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/src.jpg differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/startIcon.png b/function/ui_compare/capidemo/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/startIcon.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/test.svg b/function/ui_compare/capidemo/entry/src/main/resources/base/media/test.svg new file mode 100644 index 0000000000000000000000000000000000000000..6ac80a136763acfea8ab07213c058443ae51254a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/media/test.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/media/yellow.bmp b/function/ui_compare/capidemo/entry/src/main/resources/base/media/yellow.bmp new file mode 100644 index 0000000000000000000000000000000000000000..11e011e7469191715cf0ececaa13c6363b620293 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/base/media/yellow.bmp differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/profile/backup_config.json b/function/ui_compare/capidemo/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..d742c2f96e7dd0f406f499941f3147345e998f95 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/base/profile/main_pages.json b/function/ui_compare/capidemo/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..8e45563589605037b37182483e36812da29762e5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,79 @@ +{ + "src": [ + "pages/Index", + "pages/waterflow/WaterFlowScrollBarDisplayModeTest", + "pages/waterflow/WaterFlowScrollOffset6Test", + "pages/waterflow/WaterFlowScrollOffsetCurveTest", + "pages/waterflow/WaterFlowScrollEdgeEffectTest", + "pages/waterflow/WaterFlowScrollPageTest", + "pages/waterflow/WaterFlowScrollToIndexTest", + "pages/waterflow/WaterFlowScrollFrictionTest", + "pages/imageanimator/ImageAnimatorTest", + "pages/imageanimator/ImageAnimatorIterationsTest", + "pages/swiper/SwiperEffectModeFadeTest", + "pages/swiper/SwiperEffectModeInterruptTest", + "pages/swiper/SwiperEffectModeMultipleTest", + "pages/swiper/SwiperEffectModeNoneTest", + "pages/swiper/SwiperEffectModeSpringTest", + "pages/swiper/SwiperNestedScrollTest", + "pages/animation/AnimateAnimateOptionDelayTest", + "pages/animation/AnimateAnimateOptionDurationTest", + "pages/animation/AnimateAnimateOptionIterationsTest", + "pages/animation/AnimateAnimatorOptionDurationTest", + "pages/animation/AnimateAnimatorOptionInterpolationTest", + "pages/animation/AnimateAnimatorOptionIterationsTest", + "pages/animation/AnimateAnimatorOptionStateTest", + "pages/animation/AnimateCurveTest", + "pages/animation/AnimateGeometryTransitionDoubleTest", + "pages/animation/AnimateGeometryTransitionMultiTest", + "pages/animation/AnimateGeometryTransitionNormalTest", + "pages/animation/AnimateKeyframeAnimateOptionDelayTest", + "pages/animation/AnimateKeyframeAnimateOptionDurationTest", + "pages/animation/AnimateKeyframeAnimateOptionIterationsTest", + "pages/commonattrs/CommonAttrsTransformCenterTest", + "pages/commonattrs/CommonAttrsTransitionAsymmetricTest", + "pages/commonattrs/CommonAttrsTransitionMoveTest", + "pages/commonattrs/CommonAttrsTransitionOpacityTest", + "pages/commonattrs/CommonAttrsTransitionRotateTest", + "pages/commonattrs/CommonAttrsTransitionScaleTest", + "pages/commonattrs/CommonAttrsTransitionTranslateTest", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage1Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage2Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage3Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage4Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage5Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage6Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage7Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage8Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage9Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage10Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage11Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage12Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage13Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage14Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage15Test", + "pages/commonattrs/CommonAttrsExpandSafeAreaPage16Test", + "pages/commonattrs/CommonAttrsRenderFit1Test", + "pages/commonattrs/CommonAttrsRenderFit2Test", + "pages/commonattrs/CommonAttrsRenderFit3Test", + "pages/commonattrs/CommonAttrsRenderFit4Test", + "pages/commonattrs/CommonAttrsRenderFit5Test", + "pages/customdialog/CustomDialogContentTest", + "pages/scroll/ScrollScrollOffsetTest", + "pages/scroll/ScrollScrollOffsetCurveTest", + "pages/scroll/ScrollScrollOffsetOtherTest", + "pages/scroll/ScrollScrollPageTest", + "pages/textinput/TextInputCaretPositionTest", + "pages/textinput/TextInputGetCaretOffsetTest", + "pages/textarea/TextAreaCaretPositionTest", + "pages/textarea/TextAreaGetCaretOffsetTest", + "pages/textarea/TextAreaShowCounterTest", + "pages/text/TextEnableDataDetectorTest", + "pages/refresh/RefreshForContentAndRatioAbnormalTest", + "pages/refresh/RefreshForContentAndRatioTest", + "pages/requirement/RequirementPinchAndPanGestureTest", + "pages/list/ListScrollOffset6Test", + "pages/list/ListScrollPageTest", + "pages/list/ListScrollToIndexTest" + ] +} diff --git a/function/ui_compare/capidemo/entry/src/main/resources/en_US/element/string.json b/function/ui_compare/capidemo/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b976fb6d0379b826204087d18a5f01872ce4d54 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/main/resources/rawfile/HomeVideoBold.ttf b/function/ui_compare/capidemo/entry/src/main/resources/rawfile/HomeVideoBold.ttf new file mode 100644 index 0000000000000000000000000000000000000000..589971e9dbd8ee24062a68d987d3af656abab014 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/rawfile/HomeVideoBold.ttf differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/rawfile/background_yellow.png b/function/ui_compare/capidemo/entry/src/main/resources/rawfile/background_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..1fa2f73575caef6b5fcf736b6eb2e8ff34802713 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/main/resources/rawfile/background_yellow.png differ diff --git a/function/ui_compare/capidemo/entry/src/main/resources/zh_CN/element/string.json b/function/ui_compare/capidemo/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..cab069eb230dd1cc6d3c24cd0f1aa46d54af9cc9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/Application/AbilityStage.ts b/function/ui_compare/capidemo/entry/src/ohosTest/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..252a037b7bb5bb0fbeb7fc5fed3007a54b33392e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/Application/AbilityStage.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityStage from '@ohos.app.ability.AbilityStage'; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log('[Demo] MyAbilityStage onCreate'); + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/MainAbility.ts b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..df86f7d09e1caaa43dc791682553d9cc15dec670 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/MainAbility.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.app.ability.UIAbility'; +import Settings from '../test/common/Settings'; + +const TAG: string = '[createWindow]' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log(`${TAG} MainAbility onCreate`); + globalThis.abilityWant = want; + globalThis.abilityLaunchParam = launchParam; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log(`${TAG} MainAbility onDestroy`); + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log(`${TAG} MainAbility onWindowStageCreate windowStage=` + windowStage); + globalThis.windowStage = windowStage; + globalThis.context = this.context; + + setTimeout(() => { + console.info(`${TAG} setTimeout`) + Settings.createWindow('MainAbility/pages/DemoIndex', { + width: 1344, height: 2560, dpi: 400 + }) + }, 1000) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log(`${TAG} MainAbility onWindowStageDestroy`); + } + + onForeground() { + // Ability has brought to foreground + console.log(`${TAG} MainAbility onForeground`); + } + + onBackground() { + // Ability has back to background + console.log(`${TAG} MainAbility onBackground`); + } +}; \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/componet/CommonView.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/componet/CommonView.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd3064660aec25ff11ba1d30f4e9a335baad02b3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/componet/CommonView.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct CommonView { + pageTag: string = ''; + + build() { + Column() { + Column({ space: 10 }) { + XComponent({ + id: this.pageTag, + type: 'node', + libraryname: 'nativerender' + }).onDestroy(() => { + console.log('onDestroy'); + }).backgroundColor('#FFEEEEEE') + .width('100%') + .height('100%') + }.margin(20) + .height('100%') + .width('100%') + } + .id(this.pageTag) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/DemoIndex.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/DemoIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6b9102852b403ed32b49e742095547cfcc7a1cc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/DemoIndex.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; + +@Entry +@Component +struct DemoIndex { + aboutToAppear() { + setTimeout(() => { + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, 2000) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ARKUI CAPI DEMO') + .fontSize(36) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/attributesetting/AttributeSettingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/attributesetting/AttributeSettingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6423497f10cac115848cc13949e2e05ae0d89f8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/attributesetting/AttributeSettingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct AttributeSettingTest { + PAGE_TAG: string = 'AttributeSettingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.attributeSettingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/button/ButtonTypeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/button/ButtonTypeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..572fefbf693f950efe7b959cae19e1b641d895b4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/button/ButtonTypeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ButtonTypeTest { + PAGE_TAG: string = 'ButtonTypeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.buttonTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..31b5b07d2326cee08ed09dbce80e1d2a066fa686 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage1Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..540afc3a7aff997f9b622e1e99abf68639b44449 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage2Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d5074e7b69bfa7f76c2f2c5d9124ddaf51e0405 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage3Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage4Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage4Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b2e7824d9c5465e56d6a37d9df8a4c06fb6cdc3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage4Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage4Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage4Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage4Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage5Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage5Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a37b259a77231631a839e85daa0a52f38042f287 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage5Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage5Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage5Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage5Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage6Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage6Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b120aeaef5f3ce36293b393f73a7df1666de743 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage6Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage6Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage6Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage6Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage7Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage7Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..473683e3381fa3c5d45dc352e0749c86eaf56c92 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage7Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage7Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage7Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage7Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage8Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage8Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ab4f5a953f3857dea40cafeb14f69df29e24d67 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage8Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CalendarPickerHintRadiusPage8Test { + PAGE_TAG: string = 'CalendarPickerHintRadiusPage8Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerHintRadiusPage8Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..11d29b61f117cadaed3daac59bd7b24dbe9e7711 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage1Test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { systemTime } from '@kit.BasicServicesKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// time对应的时间为2021-01-20 02:36:25 +let time = 1611081385000; +try { + systemTime.setTime(time, (error: BusinessError) => { + if (error) { + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); + return; + } + console.info(`Succeeded in setting time`); + }); +} catch(e) { + let error = e as BusinessError; + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); +} + +@Entry +@Component +struct CalendarPickerSelectedDatePage1Test { + PAGE_TAG: string = 'CalendarPickerSelectedDatePage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerSelectedDatePage1Test(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..24199574b33da1a493eb19c4e2b3b26e67db393b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage2Test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { systemTime } from '@kit.BasicServicesKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// time对应的时间为2021-01-20 02:36:25 +let time = 1611081385000; +try { + systemTime.setTime(time, (error: BusinessError) => { + if (error) { + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); + return; + } + console.info(`Succeeded in setting time`); + }); +} catch(e) { + let error = e as BusinessError; + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); +} + +@Entry +@Component +struct CalendarPickerSelectedDatePage2Test { + PAGE_TAG: string = 'CalendarPickerSelectedDatePage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerSelectedDatePage2Test(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d2696ef09b1d047b69d05efa4a657c5c58a16cb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage3Test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { systemTime } from '@kit.BasicServicesKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// time对应的时间为2021-01-20 02:36:25 +let time = 1611081385000; +try { + systemTime.setTime(time, (error: BusinessError) => { + if (error) { + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); + return; + } + console.info(`Succeeded in setting time`); + }); +} catch(e) { + let error = e as BusinessError; + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); +} + +@Entry +@Component +struct CalendarPickerSelectedDatePage3Test { + PAGE_TAG: string = 'CalendarPickerSelectedDatePage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerSelectedDatePage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage4Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage4Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7d927283d269fb8e422abe1151a8fd69d5a0808 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage4Test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { systemTime } from '@kit.BasicServicesKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// time对应的时间为2021-01-20 02:36:25 +let time = 1611081385000; +try { + systemTime.setTime(time, (error: BusinessError) => { + if (error) { + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); + return; + } + console.info(`Succeeded in setting time`); + }); +} catch(e) { + let error = e as BusinessError; + console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); +} + +@Entry +@Component +struct CalendarPickerSelectedDatePage4Test { + PAGE_TAG: string = 'CalendarPickerSelectedDatePage4Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.calendarPickerSelectedDatePage4Test(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnAlignItemsMoreAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnAlignItemsMoreAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..041c6cc6b4e4b1b6a6ceab962040eb5c5bc9253f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnAlignItemsMoreAttributeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ColumnAlignItemsMoreAttributeTest { + PAGE_TAG: string = 'ColumnAlignItemsMoreAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.columnAlignItemsMoreAttributeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnAlignItemsTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnAlignItemsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..01ab28c2d5f6eacb06cc20742e17efe6635e9389 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnAlignItemsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ColumnAlignItemsTest { + PAGE_TAG: string = 'ColumnAlignItemsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.columnAlignItemsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnJustifyContentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnJustifyContentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..879c519c2642a4a9e3217fd7b1d88c99972fb988 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/column/ColumnJustifyContentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ColumnJustifyContentTest { + PAGE_TAG: string = 'ColumnJustifyContentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.columnJustifyContentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityRoleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityRoleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad4f5dd75e3f7f4e47a17253da0e717fd5378026 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityRoleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAccessibilityRoleTest { + PAGE_TAG: string = 'CommonAttrsAccessibilityRoleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAccessibilityRoleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityStateTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityStateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..13849976c3e093a7952b40858209b36b78262c0b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityStateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAccessibilityStateTest { + PAGE_TAG: string = 'CommonAttrsAccessibilityStateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAccessibilityStateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityValueTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityValueTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c6bf1e6ef24914b27d00fd7795ce17b17f23be9b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAccessibilityValueTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAccessibilityValueTest { + PAGE_TAG: string = 'CommonAttrsAccessibilityValueTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAccessibilityValueTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..28d4845ec7eb2aaa06c359e65bbef149f5940e16 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAlignmentPage1Test { + PAGE_TAG: string = 'CommonAttrsAlignmentPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAlignmentPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e2968cd0539ffd689a766f3adbb285cc4db642b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAlignmentPage2Test { + PAGE_TAG: string = 'CommonAttrsAlignmentPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAlignmentPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b13a25ea05fcdb9dea3015a0434a3192c22a9a4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAlignmentPage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAlignmentPage3Test { + PAGE_TAG: string = 'CommonAttrsAlignmentPage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAlignmentPage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAspectRatioTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAspectRatioTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a0cd12b499dbae4859b944492eb2d5bcd36d5cc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsAspectRatioTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsAspectRatioTest { + PAGE_TAG: string = 'CommonAttrsAspectRatioTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsAspectRatioTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundBlurStyleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundBlurStyleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5bd673d60fd8b2ed4bb3ece388f3d6780b1189a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundBlurStyleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBackgroundBlurStyleTest { + PAGE_TAG: string = 'CommonAttrsBackgroundBlurStyleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBackgroundBlurStyleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePixelMapTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePixelMapTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..62b344230884e0c138b21867db1b454b78c30a24 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePixelMapTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBackgroundImagePixelMapTest { + PAGE_TAG: string = 'CommonAttrsBackgroundImagePixelMapTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBackgroundImagePixelMapTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePositionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..adbf6f76557a0145b2471b9bf8785e834f672f61 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePositionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBackgroundImagePositionTest { + PAGE_TAG: string = 'CommonAttrsBackgroundImagePositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBackgroundImagePositionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImageResourceStrTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImageResourceStrTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fa69b5aa9c4c43586f68ee139dd5b65aae41d36 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImageResourceStrTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBackgroundImageResourceStrTest { + PAGE_TAG: string = 'CommonAttrsBackgroundImageResourceStrTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBackgroundImageResourceStrTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImageSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImageSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..70016ab98ab389b394d1bc5210b96893bc601179 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBackgroundImageSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBackgroundImageSizeTest { + PAGE_TAG: string = 'CommonAttrsBackgroundImageSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBackgroundImageSizeTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBlurTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBlurTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..46abd6c234a6016e880d36690c1c92c25da6a784 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBlurTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBlurTest { + PAGE_TAG: string = 'CommonAttrsBlurTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBlurTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBrightnessTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBrightnessTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..020b57ec440d4a7dafab9e698f97a1067ffc2ef8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsBrightnessTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsBrightnessTest { + PAGE_TAG: string = 'CommonAttrsBrightnessTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsBrightnessTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainMode1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainMode1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e0563696967dae502ac1e0b6864cc6446f3914 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainMode1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsChainMode1Test { + PAGE_TAG: string = 'CommonAttrsChainMode1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsChainMode1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainMode2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainMode2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b136853aa94c548d84252874aba2b40f4a985360 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainMode2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsChainMode2Test { + PAGE_TAG: string = 'CommonAttrsChainMode2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsChainMode2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainModeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainModeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6112db1a9cb9ba2adc6e3caa8f6712dbedf6238 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsChainModeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsChainModeTest { + PAGE_TAG: string = 'CommonAttrsChainModeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsChainModeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsClipShapeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsClipShapeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa85d8f32f783b0f25db6ff1fceae3c61ab695a9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsClipShapeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsClipShapeTest { + PAGE_TAG: string = 'CommonAttrsClipShapeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsClipShapeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsColorBlendTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsColorBlendTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..65ab7dc4461c6cafa698729d0c0666b45a717c83 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsColorBlendTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsColorBlendTest { + PAGE_TAG: string = 'CommonAttrsColorBlendTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsColorBlendTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsCustomShadowTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsCustomShadowTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..349ea48c3db49ddc94fed82c7dd864653f7948e5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsCustomShadowTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsCustomShadowTest { + PAGE_TAG: string = 'CommonAttrsCustomShadowTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsCustomShadowTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..518e6b8444063d7a4def11ddae5af13d88872fd9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsDefaultFocusAbnormalTest { + PAGE_TAG: string = 'CommonAttrsDefaultFocusAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsDefaultFocusAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusMultiTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusMultiTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..728853baa6844a9f789f9d88ff5ba3773d1204be --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusMultiTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsDefaultFocusMultiTest { + PAGE_TAG: string = 'CommonAttrsDefaultFocusMultiTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsDefaultFocusMultiTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusNoneTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusNoneTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f564885466ee551a94b62b199dfe3ffd2bb6254c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusNoneTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsDefaultFocusNoneTest { + PAGE_TAG: string = 'CommonAttrsDefaultFocusNoneTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsDefaultFocusNoneTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusSingleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusSingleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..021f878803641ff7fd2c2e33269be12f33309425 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDefaultFocusSingleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsDefaultFocusSingleTest { + PAGE_TAG: string = 'CommonAttrsDefaultFocusSingleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsDefaultFocusSingleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDisplayPriorityTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDisplayPriorityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..03ca2a3a87a36b8c8971ee142b8fd69471d0fb1d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsDisplayPriorityTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsDisplayPriorityTest { + PAGE_TAG: string = 'CommonAttrsDisplayPriorityTest'; + PARENT_CONTAINER: number = 3; + DIRECTION: number = 2; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsDisplayPriorityTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsFocusOnTouchTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsFocusOnTouchTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..99cde187854e9717fa49c08fef2ac2dd3a05ef6b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsFocusOnTouchTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsFocusOnTouchTest { + PAGE_TAG: string = 'CommonAttrsFocusOnTouchTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsFocusOnTouchTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsFocusStatusTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsFocusStatusTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6dd795fe048ec46725bd11f3802ff709ce68014 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsFocusStatusTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsFocusStatusTest { + PAGE_TAG: string = 'CommonAttrsFocusStatusTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsFocusStatusTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsForegroundColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsForegroundColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba8a7fec6c1532396c0f0d4635b224d20f355f39 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsForegroundColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsForegroundColorTest { + PAGE_TAG: string = 'CommonAttrsForegroundColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsForegroundColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsLayoutWeightTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsLayoutWeightTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..13ddb2d8eaf8a8c34f76693d966e6033a8941d0a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsLayoutWeightTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsLayoutWeightTest { + PAGE_TAG: string = 'CommonAttrsLayoutWeightTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsLayoutWeightTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsMarkAnchorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsMarkAnchorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bffda25608f3337440f3333a6e5585e965bf441e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsMarkAnchorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsMarkAnchorTest { + PAGE_TAG: string = 'CommonAttrsMarkAnchorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsMarkAnchorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOffsetTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..15ba8e2ec9db55bc04990ea6604b350fc94f658a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOffsetTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsOffsetTest { + PAGE_TAG: string = 'CommonAttrsOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsOffsetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOutlineColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOutlineColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..31b99afef91689f98ed66a74c46492dc893cbbc8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOutlineColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsOutlineColorTest { + PAGE_TAG: string = 'CommonAttrsOutlineColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsOutlineColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOutlineWidthTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOutlineWidthTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8415a1542f8641afa71036adc860085bfda52401 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOutlineWidthTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsOutlineWidthTest { + PAGE_TAG: string = 'CommonAttrsOutlineWidthTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsOutlineWidthTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOverlayTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOverlayTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7797c09b5729f219836ee71ea23e757f945d3c98 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsOverlayTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsOverlayTest { + PAGE_TAG: string = 'CommonAttrsOverlayTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsOverlayTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsPaddingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsPaddingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..3dfd70a139149a1b4f42e57f615f59827b010c5a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsPaddingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsPaddingTest { + PAGE_TAG: string = 'CommonAttrsPaddingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsPaddingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsRenderGroupTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsRenderGroupTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a3ac595c78887d90a6404b661ca8706fc168fdb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsRenderGroupTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRenderGroupTest { + PAGE_TAG: string = 'CommonAttrsRenderGroupTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRenderGroupTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsResponseRegionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsResponseRegionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0024068de997665593275361f1465367616adc64 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsResponseRegionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsResponseRegionTest { + PAGE_TAG: string = 'CommonAttrsResponseRegionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsResponseRegionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsRotateTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsRotateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..022000b8bae4888dc7a3eb1e6960328140a6ee61 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsRotateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsRotateTest { + PAGE_TAG: string = 'CommonAttrsRotateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsRotateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsSaturateTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsSaturateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9c0e66d7e90717e2c64eefc1ad801dc2ec892f4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsSaturateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsSaturateTest { + PAGE_TAG: string = 'CommonAttrsSaturateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsSaturateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsScaleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsScaleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..814e1d57c0fe8679eed39e3e822e1bf83b974b1f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsScaleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsScaleTest { + PAGE_TAG: string = 'CommonAttrsScaleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsScaleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..51769fc35fc69ed6b94155c4e7266db29bc88c5f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsSizeTest { + PAGE_TAG: string = 'CommonAttrsSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsTouchAbleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsTouchAbleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..47664106a3c08ede505c47e9f321d5342d0943e4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsTouchAbleTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTouchAbleTest { + PAGE_TAG: string = 'CommonAttrsTouchAbleTest'; + PARENT_CONTAINER: number = 3; + DIRECTION: number = 3; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTouchAbleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsTranslateTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsTranslateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..79d090638b1eb386dd7d46fb4fe4303b8937227c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsTranslateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsTranslateTest { + PAGE_TAG: string = 'CommonAttrsTranslateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsTranslateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsVisibilityTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsVisibilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fec858877cf23d3de6882350095988533cfc4ee3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsVisibilityTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsVisibilityTest { + PAGE_TAG: string = 'CommonAttrsVisibilityTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsVisibilityTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de5c05b99999bb251e0ff53a28dd2935e3121b6e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsZIndexPage1Test { + PAGE_TAG: string = 'CommonAttrsZIndexPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsZIndexPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..090c6fd8678281687d7a55395e5ccb8ede2b625f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsZIndexPage2Test { + PAGE_TAG: string = 'CommonAttrsZIndexPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsZIndexPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..04d8d4b40dee53240d1b68e8411a9fd9821529d1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonattrs/CommonAttrsZIndexPage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonAttrsZIndexTestPage3 { + PAGE_TAG: string = 'CommonAttrsZIndexTestPage3'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonAttrsZIndexPage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..97aa9e1cdfe92bda4a4ac1dd50ae57495aab7dd7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonEventTest { + PAGE_TAG: string = 'CommonEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnHoverEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnHoverEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1171c1b016c1cd50d457383d254910ae171a3951 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnHoverEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonOnHoverEventTest { + PAGE_TAG: string = 'CommonOnHoverEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonHoverEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnMouseEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnMouseEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..3129b708859dd73eeb8202699fbe4e3206e374eb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnMouseEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonOnMouseEventTest { + PAGE_TAG: string = 'CommonOnMouseEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonOnMouseEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnTouchInterceptEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnTouchInterceptEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a18190d8168d0a19bc9adc8c5d93bda7bdb180b0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnTouchInterceptEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonOnTouchInterceptEventTest { + PAGE_TAG: string = 'CommonOnTouchInterceptEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonOnTouchInterceptEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnVisibleAreaChangeEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnVisibleAreaChangeEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..158073c8bb3a4612072e2332c4d7b37230a2d137 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/commonevent/CommonOnVisibleAreaChangeEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CommonOnVisibleAreaChangeEventTest { + PAGE_TAG: string = 'CommonOnVisibleAreaChangeEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.commonOnVisibleAreaChangeEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentCustomEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentCustomEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..142c5362b016cdb11622650d26b9ad8577a7cce0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentCustomEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentCustomEventTest { + PAGE_TAG: string = 'CustomComponentCustomEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentCustomEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentDrawContextTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentDrawContextTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4da1d2b8ebee1fc0f76a0e15965b3153fc52099e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentDrawContextTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentDrawContextTest { + PAGE_TAG: string = 'CustomComponentDrawContextTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentDrawContextTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetChildAtTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetChildAtTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7818022f6b5416e17ecbfbca3d5206efff91dca9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetChildAtTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentGetChildAtTest { + PAGE_TAG: string = 'CustomComponentGetChildAtTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentGetChildAtTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetFirstChildTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetFirstChildTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbcf6e80f07ae57587a22960c0de4d8a841e272a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetFirstChildTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentGetFirstChildTest { + PAGE_TAG: string = 'CustomComponentGetFirstChildTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentGetFirstChildTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetLastChildTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetLastChildTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca9a40b3ab4d076f2c7014ffe8b82c75df97476e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetLastChildTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentGetLastChildTest { + PAGE_TAG: string = 'CustomComponentGetLastChildTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentGetLastChildTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetLayoutPositionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetLayoutPositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a83dcc7f30211e69b2fef274c715c9f0e754406f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetLayoutPositionTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentGetLayoutPositionTest { + PAGE_TAG: string = 'CustomComponentGetLayoutPositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentGetLayoutPositionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetPreviousNextSiblingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetPreviousNextSiblingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d50845c8c2e59ff99c2f707b8647152f5a46f73 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetPreviousNextSiblingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentGetPreviousNextSiblingTest { + PAGE_TAG: string = 'CustomComponentGetPreviousNextSiblingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentGetPreviousNextSiblingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetTotalChildCountTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetTotalChildCountTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..76b0acb121318a575227c1d37d19051da99b6fb8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentGetTotalChildCountTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentGetTotalChildCountTest { + PAGE_TAG: string = 'CustomComponentGetTotalChildCountTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentGetTotalChildCountTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutAgainTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutAgainTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc426b219409ecef81b017cb40d2ea6cd3f36f64 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutAgainTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentLayoutAgainTest { + PAGE_TAG: string = 'CustomComponentLayoutAgainTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentLayoutAgainTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutConstraintTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutConstraintTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..68a703624a9d548ae4fc87916e796b4bc01be671 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutConstraintTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentLayoutConstraintTest { + PAGE_TAG: string = 'CustomComponentLayoutConstraintTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentLayoutConstraintTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutPositionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutPositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6a66179fd769bba3a81102fa740abb9a41bc33b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentLayoutPositionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentLayoutPositionTest { + PAGE_TAG: string = 'CustomComponentLayoutPositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentLayoutPositionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentMeasuredSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentMeasuredSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d76e0b252e5904bc3b055660304b7389bfda741 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentMeasuredSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentMeasuredSizeTest { + PAGE_TAG: string = 'CustomComponentMeasuredSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentMeasuredSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentUnregisterCustomEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentUnregisterCustomEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bee56715229a53e19a5b45810327bc4661b85e68 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customcomponent/CustomComponentUnregisterCustomEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomComponentUnregisterCustomEventTest { + PAGE_TAG: string = 'CustomComponentUnregisterCustomEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customComponentUnregisterCustomEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customdialog/CustomDialogContentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customdialog/CustomDialogContentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a97a269f92d1dc63bb5342317dd8fa665418f15d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/customdialog/CustomDialogContentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct CustomDialogContentTest { + PAGE_TAG: string = 'CustomDialogContentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.customDialogContentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/eventcallback/EventCallbackGlobalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/eventcallback/EventCallbackGlobalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed6bfef950f1a0434a3224f90324b2766c2115eb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/eventcallback/EventCallbackGlobalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct EventCallbackGlobalTest { + PAGE_TAG: string = 'EventCallbackGlobalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.eventCallbackGlobalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/eventcallback/EventCallbackSpecifyNodeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/eventcallback/EventCallbackSpecifyNodeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..82f087cd49f7f8a0e5141e59003a99e9b486cdc1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/eventcallback/EventCallbackSpecifyNodeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct EventCallbackSpecifyNodeTest { + PAGE_TAG: string = 'EventCallbackSpecifyNodeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.eventCallbackSpecifyNodeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/flex/FlexOptionsTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/flex/FlexOptionsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e260bd1e5f6fd46654192a4461e05db047579029 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/flex/FlexOptionsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct FlexOptionsTest { + PAGE_TAG: string = 'FlexOptionsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.flexOptionsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b30904a76706c3814c42757a855a687c9ee667a4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GestureGesture1Test { + PAGE_TAG: string = 'GestureGesture1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gestureGesture1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..69bf9b2eacc517775a7e6da64982035ef91045c9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GestureGesture2Test { + PAGE_TAG: string = 'GestureGesture2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gestureGesture2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..80ec5f1e60f574b305df644428c24bd90ca4b741 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGesture3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GestureGesture3Test { + PAGE_TAG: string = 'GestureGesture3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gestureGesture3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGestureTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6381451297620458ac87d837da8dceda4e195dbf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/gesture/GestureGestureTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GestureGestureTest { + PAGE_TAG: string = 'GestureGestureTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gestureGestureTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridCachedCountTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridCachedCountTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0732d2f70ce1bd9b530e018b98329aa479dc5877 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridCachedCountTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GridCachedCountTest { + PAGE_TAG: string = 'GridCachedCountTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gridCachedCountTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridResetAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridResetAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..259749960abfc609ddda23dfc2236ee015894828 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridResetAttributeTest.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GridResetAttributeTest { + PAGE_TAG: string = 'GridResetAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gridResetAttributeTest(this.PAGE_TAG); + }) + } + } +} + diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..af8daeb044512a6d476870e12a96043ef09a58ec --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/grid/GridTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct GridTest { + PAGE_TAG: string = 'GridTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.gridTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageDraggableTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageDraggableTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ebf9d781d883203f17a1b4e29cb3019b27671c2b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageDraggableTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageDraggableTest { + PAGE_TAG: string = 'ImageDraggableTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageDraggableTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageFillColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageFillColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b179f8991bae08317ef76b5f3af7b30e600ceb8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageFillColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageFillColorTest { + PAGE_TAG: string = 'ImageFillColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageFillColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageFitOriginalSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageFitOriginalSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d98a97f877bcafefc975a968bc334073f3f18723 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageFitOriginalSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageFitOriginalSizeTest { + PAGE_TAG: string = 'ImageFitOriginalSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageFitOriginalSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageObjectFitResetAndAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageObjectFitResetAndAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..15c746487b3210b6e65192bd77356abc1d2ba8aa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageObjectFitResetAndAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageObjectFitResetAndAbnormalTest { + PAGE_TAG: string = 'ImageObjectFitResetAndAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageObjectFitResetAndAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageObjectFitTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageObjectFitTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..96629b123046408ff81b29b094550d09e77b8ca1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageObjectFitTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageObjectFitTest { + PAGE_TAG: string = 'ImageObjectFitTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageObjectFitTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageOnDownloadProgressTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageOnDownloadProgressTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4161b9f4e03b6bef3c7e358f8d3386d4e2ad8a0b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageOnDownloadProgressTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageOnDownloadProgressTest { + PAGE_TAG: string = 'ImageOnDownloadProgressTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageDownProgressTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageOnfinishTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageOnfinishTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8d103a6d1cf7a1df830ae9fbc5dfb15e871643c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageOnfinishTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageOnfinishTest { + PAGE_TAG: string = 'ImageOnfinishTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + + + render.imageOnfinishTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImagePixelMapSrcTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImagePixelMapSrcTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e7a19504ce5616d7b62e49f991d9441b175386b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImagePixelMapSrcTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImagePixelMapSrcTest { + PAGE_TAG: string = 'ImagePixelMapSrcTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imagePixelMapSrcTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageRenderModeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageRenderModeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b362b7ccd040ce1d541a7939d6ad3c4dcc2c35 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageRenderModeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageRenderModeTest { + PAGE_TAG: string = 'ImageRenderModeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageRenderModeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageResizableTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageResizableTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c44c21f8587e39b9671f31635812bef64681f88 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageResizableTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageResizableTest { + PAGE_TAG: string = 'ImageResizableTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageResizableTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageSrcTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageSrcTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8080683c94ba3febd37d428ad334ad9bc9e486a2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/image/ImageSrcTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageSrcTest { + PAGE_TAG: string = 'ImageSrcTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageSrcTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorDurationTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorDurationTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0e4b39702d882ace7246c34f2c05e1f0179e3e3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorDurationTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorDurationTest { + PAGE_TAG: string = 'ImageAnimatorDurationTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorDurationTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorFillModeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorFillModeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..40cbb4fbf5e749c1f5e8546c37b8959c72196ff2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorFillModeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorFillModeTest { + PAGE_TAG: string = 'ImageAnimatorFillModeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorFillModeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorFixedSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorFixedSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..16a07255f0faf836d06fc931b6de004f5994bba3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorFixedSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorFixedSizeTest { + PAGE_TAG: string = 'ImageAnimatorFixedSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorFixedSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorIterationsTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorIterationsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..38510e4dd5ed56540e0b987e6aad59e05673a8dc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorIterationsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorIterationsTest { + PAGE_TAG: string = 'ImageAnimatorIterationsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorIterationsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorResetAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorResetAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..64e155467c40f915babade133cf4cbda6e5a00de --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorResetAttributeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorResetAttributeTest { + PAGE_TAG: string = 'ImageAnimatorResetAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorResetAttributeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorReverseTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorReverseTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7309c9dd8cfba7efab917f492615bbb6ba89e0d3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorReverseTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageAnimatorReverseTest { + PAGE_TAG: string = 'ImageAnimatorReverseTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorReverseTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1d415a154b293afe50d7905693a2bf55476429f6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageAnimatorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageSrcTest { + PAGE_TAG: string = 'ImageAnimatorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageAnimatorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..db4a11a5dd5a1418aba502c28c1609f1e69a9aad --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageFrameInfoAbnormalTest { + PAGE_TAG: string = 'ImageFrameInfoAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageFrameInfoAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoDrawableAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoDrawableAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd0286f5f2666352b316615e4a8e1864903867c5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoDrawableAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageFrameInfoDrawableAbnormalTest { + PAGE_TAG: string = 'ImageFrameInfoDrawableAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageFrameInfoDrawableAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoDrawableTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoDrawableTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d64883bfab04d762e0db08932fddfa5c162a1734 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoDrawableTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageFrameInfoDrawableTest { + PAGE_TAG: string = 'ImageFrameInfoDrawableTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageFrameInfoDrawableTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8850c2fb137a4ae9cc11fc4af1f268d4700db3b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imageanimator/ImageFrameInfoTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageFrameInfoTest { + PAGE_TAG: string = 'ImageFrameInfoTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageFrameInfoTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanAltAndOnClickTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanAltAndOnClickTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a23860413fc120dbbad548f005b0139b5d6404ec --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanAltAndOnClickTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageSpanAltAndOnClickTest { + PAGE_TAG: string = 'ImageSpanAltAndOnClickTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageSpanAltAndOnClickTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanPixelMapSrcTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanPixelMapSrcTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f576a78244f0175cf5f9ce154e97fccc4fddf61 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanPixelMapSrcTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageSpanPixelMapSrcTest { + PAGE_TAG: string = 'ImageSpanPixelMapSrcTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageSpanPixelMapSrcTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanSrcTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanSrcTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..20fa5602e5238fd36876c04c49a8c85d43215b7d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/imagespan/ImageSpanSrcTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ImageSpanSrcTest { + PAGE_TAG: string = 'ImageSpanSrcTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.imageSpanSrcTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/inputevent/InputEventTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/inputevent/InputEventTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..216c2ad347679a937e2be520dd3ae5431eac4f7a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/inputevent/InputEventTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct InputEventTest { + PAGE_TAG: string = 'InputEventTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.inputEventTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachDisposeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachDisposeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1ee83adb1f697b51f8a13b8b537d0073829d985 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachDisposeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachDisposeTest { + PAGE_TAG: string = 'LazyForEachDisposeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachDisposeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachGetAllItemTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachGetAllItemTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..3dc5e7fea1655ff1ab9979a37b96c6fae1f29d6c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachGetAllItemTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachGetAllItemTest { + PAGE_TAG: string = 'LazyForEachGetAllItemTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachGetAllItemTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachGetRemovedNodeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachGetRemovedNodeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7841deb932b4c212f474fbd7d7400f72fd641d1f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachGetRemovedNodeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachGetRemovedNodeTest { + PAGE_TAG: string = 'LazyForEachGetRemovedNodeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachGetRemovedNodeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachHostNodeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachHostNodeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..74c9e4e61c84c138cc543e7993d8c2b37c760e42 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachHostNodeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachHostNodeTest { + PAGE_TAG: string = 'LazyForEachHostNodeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachHostNodeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachInsertItemBigTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachInsertItemBigTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbc154880e712ef851b91d5929754d6de8988ed8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachInsertItemBigTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachInsertItemBigTest { + PAGE_TAG: string = 'LazyForEachInsertItemBigTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachInsertItemBigTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachInsertItemTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachInsertItemTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..447c7a049242ebff2d12e74613d50f2141a66bce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachInsertItemTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachInsertItemTest { + PAGE_TAG: string = 'LazyForEachInsertItemTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachInsertItemTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachMoveItemBigTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachMoveItemBigTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..de3b9ba241568123dd038c9fe58dfc7642f5db1d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachMoveItemBigTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachMoveItemBigTest { + PAGE_TAG: string = 'LazyForEachMoveItemBigTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachMoveItemBigTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachMoveItemTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachMoveItemTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..72de408dd9d6469551746ae3425bb53e0136ca64 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachMoveItemTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachMoveItemTest { + PAGE_TAG: string = 'LazyForEachMoveItemTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachMoveItemTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachNodeIdTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachNodeIdTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..34e47e122036c288c30240249b83c88c7c977299 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachNodeIdTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachNodeIdTest { + PAGE_TAG: string = 'LazyForEachNodeIdTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachNodeIdTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadAllItemsTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadAllItemsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..87a8befb2d39873d0ff22b9905951b1d167d5bc2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadAllItemsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachReloadAllItemsTest { + PAGE_TAG: string = 'LazyForEachReloadAllItemsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachReloadAllItemsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadItemBigTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadItemBigTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5895690e228f2784bcf6454934d7096ad4409e2e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadItemBigTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachReloadItemBigTest { + PAGE_TAG: string = 'LazyForEachReloadItemBigTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachReloadItemBigTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadItemTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadItemTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..38ac086762d5a0b6d0d0cc2d77f85db79f6be505 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachReloadItemTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachReloadItemTest { + PAGE_TAG: string = 'LazyForEachReloadItemTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachReloadItemTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachRemoveItemBigTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachRemoveItemBigTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b111534435f1fc50c7f744f0f68c93788673ddc4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachRemoveItemBigTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachRemoveItemBigTest { + PAGE_TAG: string = 'LazyForEachRemoveItemBigTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachRemoveItemBigTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachRemoveItemTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachRemoveItemTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc72a48c58fded6ef3805e7f22d772bf363103ab --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachRemoveItemTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachRemoveItemTest { + PAGE_TAG: string = 'LazyForEachRemoveItemTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachRemoveItemTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachTotalCountTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachTotalCountTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bff6f9984283d6c985d9d89b12ba874582972a8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachTotalCountTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachTotalCountTest { + PAGE_TAG: string = 'LazyForEachTotalCountTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachTotalCountTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachUnregisterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachUnregisterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe3f9f4cdd4da4927fe659c00d8815231749df33 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/lazyforeach/LazyForEachUnregisterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct LazyForEachUnregisterTest { + PAGE_TAG: string = 'LazyForEachUnregisterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.lazyForEachUnregisterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListChildrenMainSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListChildrenMainSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6d305cfa5300bdab9e9cc663f4021a7f85f1d92 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListChildrenMainSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListChildrenMainSizeTest { + PAGE_TAG: string = 'ListChildrenMainSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listChildrenMainSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListCloseAllTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListCloseAllTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a952e12907dd26b9f7d48fb353435522f964fe5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListCloseAllTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListCloseAllTest { + PAGE_TAG: string = 'ListCloseAllTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listCloseAllTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListDividerAndInitialIndexTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListDividerAndInitialIndexTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e07d41b251d6f42460cd785e946e2f3bc088646 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListDividerAndInitialIndexTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListDividerAndInitialIndexTest { + PAGE_TAG: string = 'ListDividerAndInitialIndexTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listDividerAndInitialIndexTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListNestedScrollSmallTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListNestedScrollSmallTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..76c4ba40ebe62cd69c467f86d76c146362386c3c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListNestedScrollSmallTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListNestedScrollSmallTest { + PAGE_TAG: string = 'ListNestedScrollSmallTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listNestedScrollSmallTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListNestedScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListNestedScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c6fd90f1ea2b1bcd8b24b0ccb03ae070d69c8d9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListNestedScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListNestedScrollTest { + PAGE_TAG: string = 'ListNestedScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listNestedScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollBarWidthAndColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollBarWidthAndColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0bf7b16bf1441b67d450496398e94e7d1e700159 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollBarWidthAndColorTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollBarWidthAndColorTest { + PAGE_TAG: string = 'ListScrollBarWidthAndColorTest'; + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollBarWidthAndColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollByTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollByTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c133d377f4d26ba2fa39a7a05231dacba5a7142a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollByTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollByTest { + PAGE_TAG: string = 'ListScrollByTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollByTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollEdgeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollEdgeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..76ae5642be09f9de48fb82b93612de36637506ba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollEdgeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollEdgeTest { + PAGE_TAG: string = 'ListScrollEdgeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollEdgeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollOffset2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollOffset2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7ffa5138e5f5c9101bfd2b1114e7de7bfa6a637 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollOffset2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollOffset2Test { + PAGE_TAG: string = 'ListScrollOffset2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollOffset2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollOffset6Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollOffset6Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7a31b0eda198f072eb592484167cea3e45eb900 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollOffset6Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollOffset6Test { + PAGE_TAG: string = 'ListScrollOffset6Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollOffset6Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollPageTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollPageTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1cbe49c3032d810df6690a7624c7f01affba271 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollPageTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollPageTest { + PAGE_TAG: string = 'ListScrollPageTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollPageTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollToIndexTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollToIndexTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d2c8f980e4720848a7197061922404e1f271227 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListScrollToIndexTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListScrollToIndexTest { + PAGE_TAG: string = 'ListScrollToIndexTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listScrollToIndexTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListSpaceAndAlignmentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListSpaceAndAlignmentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a9f0f4ab9a9d3bc558500e382305fa784c0c76a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/list/ListSpaceAndAlignmentTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListSpaceAndAlignmentTest { + PAGE_TAG: string = 'ListSpaceAndAlignmentTest'; + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listSpaceAndAlignmentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/listitemgroup/ListItemGroupDividerTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/listitemgroup/ListItemGroupDividerTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..317295611f7e1a08fb784c3754715633cbb50bae --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/listitemgroup/ListItemGroupDividerTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListItemGroupDividerTest { + PAGE_TAG: string = 'ListItemGroupDividerTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listItemGroupDividerTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/listitemgroup/ListItemGroupHeaderAndFooterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/listitemgroup/ListItemGroupHeaderAndFooterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8cac8990e5ae25ea9669cdbc1f653526feb96b11 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/listitemgroup/ListItemGroupHeaderAndFooterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ListItemGroupHeaderAndFooterTest { + PAGE_TAG: string = 'ListItemGroupHeaderAndFooterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.listItemGroupHeaderAndFooterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/mix/MixGetNodeHandleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/mix/MixGetNodeHandleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0902bff7e556923d3a55860e6400f49063dcaf6a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/mix/MixGetNodeHandleTest.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { UIContext, ComponentContent } from '@kit.ArkUI'; +@Builder +function mixedRow() { + Row() { + Image($r("app.media.background")) + .width(200) + .height(200) + .backgroundColor(Color.Blue) + } + .width(200) + .height(200) + .backgroundColor(Color.Gray) +} + +// 提供创建ArkTS组件的入口函数。 +export function createMixedRow(uiContent:UIContext): ComponentContent<[]> { + // 通过ComponentContent创建Row组件并将它封装起来。 + return new ComponentContent<[]>(uiContent!, wrapBuilder<[]>(mixedRow)); +} + + +@Entry +@Component +struct MixGetNodeHandleTest { + PAGE_TAG: string = 'MixGetNodeHandleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.mixGetNodeHandleTest(this.PAGE_TAG, createMixedRow, this.getUIContext()) + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeInsertTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeInsertTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7a72480e7030f9ade470082fa6e307551babb1e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeInsertTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct NodeTreeInsertTest { + PAGE_TAG: string = 'NodeTreeInsertTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.nodeTreeInsertTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeRemoveTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeRemoveTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..20455ba5091e50490d3ff9a334ee1aca36367cb2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeRemoveTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct NodeTreeRemoveTest { + PAGE_TAG: string = 'NodeTreeRemoveTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.nodeTreeRemoveTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeXComponentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeXComponentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4ac4010398180bfe8d26d57730314654f5b6462 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/nodetree/NodeTreeXComponentTest.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' + +@Entry +@Component +struct NodeTreeXComponentTest { + PAGE_TAG_DETACH: string = 'NodeTreeXComponentTest1'; + PAGE_TAG: string = 'NodeTreeXComponentTest2'; + + build() { + Column() { + Column() { + Column() { + XComponent({ + id: this.PAGE_TAG_DETACH, + type: XComponentType.NODE, + libraryname: 'nativerender' + }).onAppear(() => { + render.nodeTreeInsertTest(this.PAGE_TAG_DETACH); + }).width('100%') + .height('60%') + .margin(10) + XComponent({ + id: this.PAGE_TAG, + type: XComponentType.NODE, + libraryname: 'nativerender' + }).onDestroy(() => { + console.log('onDestroy'); + }).onAppear(() => { + render.nodeTreeXComponentTest(this.PAGE_TAG,this.PAGE_TAG_DETACH); + }).width('100%') + .height('40%') + .margin(10) + }.margin({ + top: 27, + left: 12, + right: 12 + }) + .height('100%') + .width('100%') + } + .width('100%') + .height('100%') + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/progress/ProgressTypeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/progress/ProgressTypeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..646150e6c3e101713be108fc23ca6b60ec52e1d9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/progress/ProgressTypeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ProgressTypeTest { + PAGE_TAG: string = 'ProgressTypeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.progressTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/progress/ProgressValueAndTotalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/progress/ProgressValueAndTotalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a775b4a819a6596410630b297abb07518c397561 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/progress/ProgressValueAndTotalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ProgressValueAndTotalTest { + PAGE_TAG: string = 'ProgressValueAndTotalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.progressValueAndTotalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioCheckedTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioCheckedTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb9f51b3f5f540510763853b0cc162300494360f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioCheckedTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RadioCheckedTest { + PAGE_TAG: string = 'RadioCheckedTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.radioCheckedTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioResetAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioResetAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb8d496ee5b8bca6314ba173c55c621ae1d34d11 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioResetAttributeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RadioRestAttributeTest { + PAGE_TAG: string = 'RadioResetAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.radioResetAttributeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioStyleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioStyleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b72271b2de0e67cd9c62d236d14a47bcb662e0f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioStyleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RadioStyleTest { + PAGE_TAG: string = 'RadioStyleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.radioStyleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioValueAndGroupTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioValueAndGroupTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a90f17f241f447bcab9a7f07568380257b2f6b3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/radio/RadioValueAndGroupTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RadioValueAndGroupTest { + PAGE_TAG: string = 'RadioValueAndGroupTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.radioValueAndGroupTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForContentAndRatioAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForContentAndRatioAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c6005d04a8bf022ab59874b5b2454513812a182 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForContentAndRatioAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshForContentAndRatioAbnormalTest { + PAGE_TAG: string = 'RefreshForContentAndRatioAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshForContentAndRatioTest(this.PAGE_TAG,-1); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForContentAndRatioTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForContentAndRatioTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5c9b5634a8b36f0c23d8882efc372441d1db67e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForContentAndRatioTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshForContentAndRatioTest { + PAGE_TAG: string = 'RefreshForContentAndRatioTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshForContentAndRatioTest(this.PAGE_TAG,0.3); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForRefreshingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForRefreshingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..64b436b5ac9056e31e4bbb54a2c557128f353784 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshForRefreshingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshForRefreshingTest { + PAGE_TAG: string = 'RefreshForRefreshingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshForRefreshingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshNestedScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshNestedScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a590e4fe59c6017dab438e4565fb57a59c1f4eaa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshNestedScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshNestedScrollTest { + PAGE_TAG: string = 'RefreshNestedScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshNestedScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b205a693b3fc0a26a158b45aa66f6a1e57183d67 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshPullToRefreshAbnormalTest { + PAGE_TAG: string = 'RefreshPullToRefreshAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshTest(this.PAGE_TAG,-100,-1); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshFalseTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshFalseTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1465205337bb5abc9c1fa73bae8a4b752b3679b1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshFalseTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshTest { + PAGE_TAG: string = 'RefreshPullToRefreshFalseTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshTest(this.PAGE_TAG,20,0); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshTrueAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshTrueAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..45db534cc0705e55d307bd37f03a155dfdb25640 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshTrueAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshPullToRefreshTrueAbnormalTest { + PAGE_TAG: string = 'RefreshPullToRefreshTrueAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshTest(this.PAGE_TAG,800,1); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshTrueTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshTrueTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..74690395c3c26c969dae1cb6a416ad79b210ac2f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshPullToRefreshTrueTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshPullToRefreshTrueTest { + PAGE_TAG: string = 'RefreshPullToRefreshTrueTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshTest(this.PAGE_TAG,20,1); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshResetAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshResetAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..dea8d0465bb1b00c2554771d078039674ae0dca1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/refresh/RefreshResetAttributeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RefreshResetAttributeTest { + PAGE_TAG: string = 'RefreshResetAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.refreshResetAttributeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RelativeContainerBarrierTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RelativeContainerBarrierTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..091e8b6fcf570561118545384e5d4f9ba0036170 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RelativeContainerBarrierTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RelativeContainerBarrierTest { + PAGE_TAG: string = 'RelativeContainerBarrierTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.relativeContainerBarrierTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RelativeContainerGuideLineTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RelativeContainerGuideLineTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb609615ddf82697b26487043c63439b55b8a766 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RelativeContainerGuideLineTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RelativeContainerGuidelineTest { + PAGE_TAG: string = 'RelativeContainerGuideLineTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.relativeContainerGuideLineTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RuleOptionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RuleOptionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..06e21e877c8dda9185d523c6745e126de73ffd83 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/relativecontainer/RuleOptionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RuleOptionTest { + PAGE_TAG: string = 'RuleOptionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.ruleOptionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/requirement/RequirementPanGestureTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/requirement/RequirementPanGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4e3ce1a7159dcc974d35e9a8f88da4ddffc0a26 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/requirement/RequirementPanGestureTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import Utils from '../../../test/common/Utils'; +import events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct RequirementPanGestureTest { + PAGE_TAG: string = 'RequirementPanGestureTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.requirementPanGestureTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/requirement/RequirementRouterPageStateTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/requirement/RequirementRouterPageStateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a592494943e51c2d8be6f6b30daad3df883f1329 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/requirement/RequirementRouterPageStateTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { resourceManager } from '@kit.LocalizationKit'; + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + + +@Entry +@Component +struct RequirementRouterPageStateTest { + PAGE_TAG: string = 'RequirementRouterPageStateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.requirementRouterPageStateTest(this.PAGE_TAG) + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/resourcenapivalue/ResourceNapiValueTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/resourcenapivalue/ResourceNapiValueTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1bb3a6de45b808f7a8716e7fef071ba1cb1b4947 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/resourcenapivalue/ResourceNapiValueTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +@Entry +@Component +struct ResourceNapiValueTest { + PAGE_TAG: string = 'ResourceNapiValueTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.resourceNapiValueTest(this.PAGE_TAG, $r("[entry].media.src")); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowAlignItemsMoreAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowAlignItemsMoreAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bfabc2255a914c8e78a75af57d0bfb4521d682a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowAlignItemsMoreAttributeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RowAlignItemsMoreAttributeTest { + PAGE_TAG: string = 'RowAlignItemsMoreAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.rowAlignItemsMoreAttributeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowAlignItemsTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowAlignItemsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..47142ab617a0a76056f9093ccbb33b9828b9d082 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowAlignItemsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RowAlignItemsTest { + PAGE_TAG: string = 'RowAlignItemsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.rowAlignItemsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowJustifyContentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowJustifyContentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f3c32b0c1f1932759e6ebf0a3eadeb98e85ab83 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/row/RowJustifyContentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct RowJustifyContentTest { + PAGE_TAG: string = 'RowJustifyContentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.rowJustifyContentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollEnablePagingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollEnablePagingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..10e6bbea654792f9fe81c18e645310eca8bc1bbe --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollEnablePagingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollEnablePagingTest { + PAGE_TAG: string = 'ScrollEnablePagingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollEnablePagingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollBarWidthTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollBarWidthTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e4d4ba12c525581b7b1fcb927cc7714bc41853fa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollBarWidthTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollBarWidthTest { + PAGE_TAG: string = 'ScrollScrollBarWidthTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollBarWidthTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollByTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollByTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..deb30e4ccf06a96fbd75f585e3fddd10780ec6e9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollByTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollByTest { + PAGE_TAG: string = 'ScrollScrollByTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollByTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollEdgeHorizontalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollEdgeHorizontalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cce051bee22b0ac913be279ac19c000b905f3034 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollEdgeHorizontalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollEdgeHorizontalTest { + PAGE_TAG: string = 'ScrollScrollEdgeHorizontalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollEdgeHorizontalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollEdgeVerticalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollEdgeVerticalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a995dad22109f8ef48d3938386ea6252c85b88f5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/scroll/ScrollScrollEdgeVerticalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ScrollScrollEdgeVerticalTest { + PAGE_TAG: string = 'ScrollScrollEdgeVerticalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.scrollScrollEdgeVerticalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/slider/SliderTrackThicknessPage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/slider/SliderTrackThicknessPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b1452363af46bcdcb8cc0ad5f51e4684ba44867 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/slider/SliderTrackThicknessPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SliderTrackThicknessPage1Test { + PAGE_TAG: string = 'SliderTrackThicknessPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.sliderTrackThicknessPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/slider/SliderTrackThicknessPage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/slider/SliderTrackThicknessPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..55f81c25e0c7d9338cda8376d4cc300e2edeff6a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/slider/SliderTrackThicknessPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SliderTrackThicknessPage2Test { + PAGE_TAG: string = 'SliderTrackThicknessPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.sliderTrackThicknessPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanBaseLineOffsetTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanBaseLineOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..49f4f54c4b73213954ff39a1f2fa4286bc8831b9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanBaseLineOffsetTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SpanBaseLineOffsetTest { + PAGE_TAG: string = 'SpanBaseLineOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.spanBaseLineOffsetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanFontFamilyTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanFontFamilyTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e11d2d3431de6de71b8ea586767e4d355d97410 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanFontFamilyTest.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { font } from '@kit.ArkUI'; + +@Entry +@Component +struct SpanFontFamilyTest { + PAGE_TAG: string = 'SpanFontFamilyTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + font.registerFont({ + familyName: 'HomeVideoBold', + familySrc: $rawfile('HomeVideoBold.ttf') + }) + render.spanFontFamilyTest(this.PAGE_TAG); + + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanTextBackgroundStyleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanTextBackgroundStyleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5173640b047595287c1119f2e9451fac26fc295 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanTextBackgroundStyleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SpanTextBackgroundStyleTest { + PAGE_TAG: string = 'SpanTextBackgroundStyleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.spanTextBackgroundStyleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanTextShadow.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanTextShadow.ets new file mode 100644 index 0000000000000000000000000000000000000000..31782db5707c6ca2049ea35cb654cffa20bb640d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanTextShadow.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SpanTextShadowTest { + PAGE_TAG: string = 'SpanTextShadowTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.spanTextShadowTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanValueTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanValueTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f21090e57c43b08d7f000616433506c1f51af13f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/span/SpanValueTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SpanValueTest { + PAGE_TAG: string = 'SpanValueTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.spanValueTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/stack/StackAlignContentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/stack/StackAlignContentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b5f1c1db1fc70a60a84ac25c8d210fe38c99bf4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/stack/StackAlignContentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct StackAlignContentTest { + PAGE_TAG: string = 'StackAlignContentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.stackAlignContentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperAdapterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperAdapterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..06cb01f8be0fd0357d095765bb072752ced716e2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperAdapterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperAdapterTest { + PAGE_TAG: string = 'SwiperAdapterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperAdapterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperChangeIndexTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperChangeIndexTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e652397855736bec82c67d9dba465bea5d6a8fc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperChangeIndexTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperChangeIndexTest { + PAGE_TAG: string = 'SwiperChangeIndexTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperChangeIndexTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperDotIndicatorAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperDotIndicatorAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0786a7e2f1acb9bbea549c80485da6df012c4f03 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperDotIndicatorAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperDotIndicatorAbnormalTest { + PAGE_TAG: string = 'SwiperDotIndicatorAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperDotIndicatorAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperDotIndicatorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperDotIndicatorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0fc9452e4d2e09d4a5fe2b8848a21d0b21bd6ed8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperDotIndicatorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperDotIndicatorTest { + PAGE_TAG: string = 'SwiperDotIndicatorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperDotIndicatorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..00fd5407025d5f96de80c1952cecf57fe8a47ec3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeAbnormalTest { + PAGE_TAG: string = 'SwiperEffectModeAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeFadeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeFadeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..312f560a8a45288c0c42aa8a45bf3d8d757a2a86 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeFadeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeFadeTest { + PAGE_TAG: string = 'SwiperEffectModeFadeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeFadeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeInterruptTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeInterruptTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac48034bccfccaf74c467f0117ace44be6bcfac3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeInterruptTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeInterruptTest { + PAGE_TAG: string = 'SwiperEffectModeInterruptTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeInterruptTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeMultipleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeMultipleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..60ac936d99695059bcfa183f3662d55e685970d8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeMultipleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeMultipleTest { + PAGE_TAG: string = 'SwiperEffectModeMultipleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeMultipleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeNoneTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeNoneTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..76c4f767d5d14547a16f6bd1e8c093dcf3704260 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeNoneTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeNoneTest { + PAGE_TAG: string = 'SwiperEffectModeNoneTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeNoneTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeSpringTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeSpringTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d35b7fe9068014da7827b0f4198cbc93ae9a55bf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEffectModeSpringTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEffectModeSpringTest { + PAGE_TAG: string = 'SwiperEffectModeSpringTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEffectModeSpringTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEventOnDidScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEventOnDidScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cfdccd8017007118233b89dd30fcf6ee97bc84ac --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEventOnDidScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEventOnDidScrollTest { + PAGE_TAG: string = 'SwiperEventOnDidScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEventOnDidScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEventOnGestureTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEventOnGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd02ecc2ba6218a61e0d9abaf9031540e9bf3331 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperEventOnGestureTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperEventOnGestureTest { + PAGE_TAG: string = 'SwiperEventOnGestureTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperEventOnGestureTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperMarginTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperMarginTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d0af052544e66cacbf31cbdeb79024d9f406046 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperMarginTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperMarginTest { + PAGE_TAG: string = 'SwiperMarginTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperMarginTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba88b5ae65589a8815920aaa5e986379e61883dd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperNestedScrollAbnormalTest { + PAGE_TAG: string = 'SwiperNestedScrollAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperNestedScrollAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollChildTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollChildTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..35e853f1a45d9179b3263b4105e5fab097e0486c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollChildTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperNestedScrollChildTest { + PAGE_TAG: string = 'SwiperNestedScrollChildTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperNestedScrollChildTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4fc4568bb22f5f334169d5ee70724cbb2ab308c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNestedScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperNestedScrollTest { + PAGE_TAG: string = 'SwiperNestedScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperNestedScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNextMarginAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNextMarginAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..866b8d5d71a2ac615bfcc25679fa80c46ea3c5e4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNextMarginAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperNextMarginAbnormalTest { + PAGE_TAG: string = 'SwiperNextMarginAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperNextMarginAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNextMarginTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNextMarginTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..91902d00762f06b19eb06cf81f9d6dcd2e47b39e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperNextMarginTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperNextMarginTest { + PAGE_TAG: string = 'SwiperNextMarginTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperNextMarginTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperOnAnimationTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperOnAnimationTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b33d429c81022297fb2fb917b5a92c1446a637b0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperOnAnimationTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperOnAnimationTest { + PAGE_TAG: string = 'SwiperOnAnimationTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperOnAnimationTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperOnChangeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperOnChangeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fba076650907b6ce0a6bc18ba5e04cfdd9393b9b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperOnChangeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperOnChangeTest { + PAGE_TAG: string = 'SwiperOnChangeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperOnChangeTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperPrevMarginAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperPrevMarginAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f6e37bf021042a50cdf4e05b0324326bacd5d32 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperPrevMarginAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperPrevMarginAbnormalTest { + PAGE_TAG: string = 'SwiperPrevMarginAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperPrevMarginAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperPrevMarginTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperPrevMarginTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..430c57f8f00909168838e76c60599bc79ca28266 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperPrevMarginTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperPrevMarginTest { + PAGE_TAG: string = 'SwiperPrevMarginTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperPrevMarginTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperResetAttributeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperResetAttributeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e10e37d904efbb2cd6797c2a5f3ab92ecb46deee --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/swiper/SwiperResetAttributeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct SwiperResetAttributeTest { + PAGE_TAG: string = 'SwiperResetAttributeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.swiperResetAttributeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextContentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextContentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a324c1ef81c831ce91271a32a1f380d32b70bd1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextContentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextContentTest { + PAGE_TAG: string = 'TextContentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textContentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextDataDetectorConfigTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextDataDetectorConfigTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..63112cd826fccc6727d30090bec41aa688a39b3b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextDataDetectorConfigTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextDataDetectorConfigTest { + PAGE_TAG: string = 'TextDataDetectorConfigTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textDataDetectorConfigTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextDecorationStyleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextDecorationStyleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ad0562ce3771b7a848509d0af41b94bba062497 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextDecorationStyleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextDecorationStyleTest { + PAGE_TAG: string = 'TextDecorationStyleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textDecorationStyleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextEllipsisModeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextEllipsisModeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f54686f5bcb2ccd344d8357935e5db181499b78 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextEllipsisModeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextEllipsisModeTest { + PAGE_TAG: string = 'TextEllipsisModeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textEllipsisModeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextEnableDataDetectorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextEnableDataDetectorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ef4a226286e8bd73cb13f3f10bfaa7298f17bcc9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextEnableDataDetectorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextEnableDataDetectorTest { + PAGE_TAG: string = 'TextEnableDataDetectorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textEnableDataDetectorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureFirstTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureFirstTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bfaf936a901fa22528c7261e67733645eb9cdd0b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureFirstTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextFontFeatureFirstTest { + PAGE_TAG: string = 'TextFontFeatureFirstTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textFontFeatureFirstTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureSecondTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureSecondTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0bf3d84e3a67571ee57875db1fbede36084e8b11 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureSecondTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextFontFeatureSecondTest { + PAGE_TAG: string = 'TextFontFeatureSecondTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textFontFeatureSecondTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureThirdTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureThirdTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e940036bcb20b5b1f366ce4081483475b7228924 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextFontFeatureThirdTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextFontFeatureThirdTest { + PAGE_TAG: string = 'TextFontFeatureThirdTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textFontFeatureThirdTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextLineSpacingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextLineSpacingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..38a3a8d129d3e308775e11289c1fe63052b68850 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextLineSpacingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextLineSpacingTest { + PAGE_TAG: string = 'TextLineSpacingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textLineSpacingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextParagraphTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextParagraphTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb7f7aaf4b1f90f08afb1abf614baa56f09c2b66 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextParagraphTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextParagraphTest { + PAGE_TAG: string = 'TextParagraphTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textParagraphTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextSelectedBackgroundColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextSelectedBackgroundColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e70ef27178aa52e72730a418b9a95d58d64d0260 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextSelectedBackgroundColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextSelectedBackgroundColorTest { + PAGE_TAG: string = 'TextSelectedBackgroundColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textSelectedBackgroundColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextWordBreakTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextWordBreakTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4fa2beaf1871eb938b23ec6c0aa983c47114066 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/text/TextWordBreakTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextWordBreakTest { + PAGE_TAG: string = 'TextWordBreakTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textWordBreakTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaBlurOnSubmitTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaBlurOnSubmitTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4bd45737dfbcdff68ac4684a29ae1d7240f304f8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaBlurOnSubmitTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaBlurOnSubmitTest { + PAGE_TAG: string = 'TextAreaBlurOnSubmitTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaBlurOnSubmitTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaCaretPositionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaCaretPositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..248644e736ee63dd31233531c50c46c0cc3dbb28 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaCaretPositionTest.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import Utils from '../../../test/common/Utils'; +import { CommonView } from '../../componet/CommonView'; +import events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct TextAreaCaretPositionTest { + PAGE_TAG: string = 'TextAreaCaretPositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaCaretPositionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaContentTypePageOneTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaContentTypePageOneTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a9e2caccbbaa3c7aab1cd841e250964eb1df43c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaContentTypePageOneTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputContentTypePageOneTest { + PAGE_TAG: string = 'TextInputContentTypePageOneTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaContentTypePageOneTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaContentTypePageTwoTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaContentTypePageTwoTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..933eaf62a0a96a51166d80b6b9dfd68f0e8c9b09 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaContentTypePageTwoTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputContentTypePageTwoTest { + PAGE_TAG: string = 'TextInputContentTypePageTwoTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaContentTypePageTwoTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaControllerTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaControllerTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..becd8c068f839b32f04a5f70333cacfcb8cf0635 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaControllerTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaControllerTest { + PAGE_TAG: string = 'TextAreaControllerTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaControllerTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableAutoFillTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableAutoFillTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..51f3a7a81439803356b916bd63c428d2bc8364ba --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableAutoFillTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnableAutoFillTest { + PAGE_TAG: string = 'TextAreaEnableAutoFillTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnableAutoFillTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5747b7850f445796382a3e68a57c16ddf81db6a5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnableKeyboardOnFocusAbnormalTest { + PAGE_TAG: string = 'TextAreaEnableKeyboardOnFocusAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnableKeyboardOnFocusAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusDisableTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusDisableTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6657069c6893ba5d14d6d33a6a21772e5268a88f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusDisableTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnableKeyboardOnFocusDisableTest { + PAGE_TAG: string = 'TextAreaEnableKeyboardOnFocusDisableTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnableKeyboardOnFocusDisableTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusResetTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusResetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbc9a9f83afcb28249b1890d067cc4c8e894ed9e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusResetTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnableKeyboardOnFocusResetTestTest { + PAGE_TAG: string = 'TextAreaEnableKeyboardOnFocusResetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnableKeyboardOnFocusResetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9aa7b92fcc7fb242309eafe7a5377bac6269ffa2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnableKeyboardOnFocusTest { + PAGE_TAG: string = 'TextAreaEnableKeyboardOnFocusTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnableKeyboardOnFocusTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1347c2c57accf494e4ced76096c2043626f87ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeAbnormalTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeDoneTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeDoneTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e6216d663cecace307b6a9c3cecda3544d59546 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeDoneTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeDoneTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeDoneTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeNewLineTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeNewLineTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4b18c664cd3ecc00a0ab1cc7a3e2a23a912dee5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeNewLineTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeNewLineTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeNewLineTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeNextTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeNextTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5113503e7202ddc6c01133e2fd342d71ec29632 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeNextTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeNextTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeNextTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypePreviousTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypePreviousTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..64c20b56b90dbd7c4ea5f87c0afeae33c74e0b86 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypePreviousTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypePreviousTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypePreviousTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeSearchTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeSearchTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..77b5fa8b09a81d3715f519b689b87ae11450ef84 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeSearchTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeSearchTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeSearchTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeSendTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeSendTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdb1c39889a64d87de182b422808d47415126ef1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeSendTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeSendTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeSendTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a248fcae2a3aca9d53de0095ec254ecf1e470698 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaEnterKeyTypeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaEnterKeyTypeTest { + PAGE_TAG: string = 'TextAreaEnterKeyTypeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaEnterKeyTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureFirstTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureFirstTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2aad6c95658a430502c23666e4fd08c853a9c822 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureFirstTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaFontFeatureFirstTest { + PAGE_TAG: string = 'TextAreaFontFeatureFirstTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaFontFeatureFirstTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureSecondTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureSecondTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b8d29de60f4c029871a755845833b4d0e28bb1b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureSecondTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaFontFeatureSecondTest { + PAGE_TAG: string = 'TextAreaFontFeatureSecondTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaFontFeatureSecondTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureThirdTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureThirdTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a13c1c141577c42da2bf7ad1e73d4d1c17223731 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaFontFeatureThirdTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaFontFeatureThirdTest { + PAGE_TAG: string = 'TextAreaFontFeatureThirdTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaFontFeatureThirdTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaGetCaretOffsetTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaGetCaretOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d39728b58e56c9e5ded42a4b4ec8bd48b43f0419 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaGetCaretOffsetTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaGetCaretOffsetTest { + PAGE_TAG: string = 'TextAreaGetCaretOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaGetCaretOffsetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaInputFilterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaInputFilterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..43d3dfbb106bd2eca05793e7075a7a16ba99fa2e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaInputFilterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaInputFilterTest { + PAGE_TAG: string = 'TextAreaInputFilterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaInputFilterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaMaxLinesTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaMaxLinesTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d025da1581a93b32d5ff21bfd0836e822a78a2a9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaMaxLinesTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaMaxLinesTest { + PAGE_TAG: string = 'TextAreaMaxLinesTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaMaxLinesTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaNumberOfLinesTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaNumberOfLinesTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..def7bb1a07d9c7923c113baa95c131f619e78bfc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaNumberOfLinesTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaNumberOfLinesTest{ + PAGE_TAG: string = 'TextAreaNumberOfLinesTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaNumberOfLinesTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectedBackgroundColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectedBackgroundColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..558d2036cc5dd5fcbc7ddcad55b8e1a00df40da2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectedBackgroundColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaSelectedBackgroundColorTest { + PAGE_TAG: string = 'TextAreaSelectedBackgroundColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaSelectedBackgroundColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c6c2553036d4d0d810b324a9cc7a9ec142f6a932 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaSelectionMenuHiddenAbnormalTest { + PAGE_TAG: string = 'TextAreaSelectionMenuHiddenAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaSelectionMenuHiddenTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenDisableTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenDisableTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b485c07ffe89aed8ab8b49c895609c9a5839cb98 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenDisableTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaSelectionMenuHiddenDisableTest { + PAGE_TAG: string = 'TextAreaSelectionMenuHiddenDisableTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaSelectionMenuHiddenTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..21ca0b4b5abcdf2f12b6116d0de6ee8920f1d770 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSelectionMenuHiddenTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaSelectionMenuHiddenTest { + PAGE_TAG: string = 'TextAreaSelectionMenuHiddenTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaSelectionMenuHiddenTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSetTextSelectionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSetTextSelectionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e952e884ac2f9ffcc2d41b46d127669ca5445769 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaSetTextSelectionTest.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import Utils from '../../../test/common/Utils'; +import { CommonView } from '../../componet/CommonView'; +import events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct TextAreaSetTextSelectionTest { + PAGE_TAG: string = 'TextAreaSetTextSelectionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaSetTextSelectionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowCounterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowCounterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..17873dcf8d66c12bc85f94e1f4a6c711b332c5e0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowCounterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaShowCounterTest { + PAGE_TAG: string = 'TextAreaShowCounterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaShowCounterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..46dcf281ac92397e828438500e9d36f6c155067e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaShowKeyboardOnFocusAbnormalTest { + PAGE_TAG: string = 'TextAreaShowKeyboardOnFocusAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaShowKeyboardOnFocusAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f56868a3604b198f89817c325004372a56a56daf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextAreaShowKeyboardOnFocusTest { + PAGE_TAG: string = 'TextAreaShowKeyboardOnFocusTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaShowKeyboardOnFocusTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaTextPlaceholderTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaTextPlaceholderTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2baef433759f3be90f301c30183e8341b7698a61 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaTextPlaceholderTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import Utils from '../../../test/common/Utils'; +import { CommonView } from '../../componet/CommonView'; +import events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct TextAreaTextPlaceholderTest { + PAGE_TAG: string = 'TextAreaTextPlaceholderTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaTextPlaceholderTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaTypeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaTypeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..2daeda74eacbc9e51dacd4fea522fa26ef08fc00 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textarea/TextAreaTypeTest.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import Utils from '../../../test/common/Utils'; +import { CommonView } from '../../componet/CommonView'; +import events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct TextAreaTypeTest { + PAGE_TAG: string = 'TextAreaTypeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textAreaTypeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputBlurOnSubmitTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputBlurOnSubmitTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd78f87091730bd2dae119f61ad8304e03d57468 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputBlurOnSubmitTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputBlurOnSubmitTest { + PAGE_TAG: string = 'TextInputBlurOnSubmitTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputBlurOnSubmitTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCancelButtonTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCancelButtonTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9238b8eb5481864b601abaea864399189e752d67 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCancelButtonTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCancelButtonTest { + PAGE_TAG: string = 'TextInputCancelButtonTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCancelButtonTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCaretPositionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCaretPositionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..596d5a4fb926eb09af8e3fe2287e019a77a19d17 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCaretPositionTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCaretPositionTest { + PAGE_TAG: string = 'TextInputCaretPositionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCaretPositionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputContentTypePage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputContentTypePage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..153292b527d3ec3b782b639dc0e5389ca4fa13b0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputContentTypePage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputContentTypePage1Test { + PAGE_TAG: string = 'TextInputContentTypePage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputContentTypePage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputControllerTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputControllerTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..61a8b53565d54208aab3676fdb633632e6407d45 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputControllerTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputControllerTest { + PAGE_TAG: string = 'TextInputControllerTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputControllerTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b6709a1fb0cae32d8d0b427c51a4b26400e957c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCustomKeyboardPage1Test { + PAGE_TAG: string = 'TextInputCustomKeyboardPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCustomKeyboardPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..352e76defdfdddbdd83fdcc0aa2ae04bc07cb2f1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCustomKeyboardPage2Test { + PAGE_TAG: string = 'TextInputCustomKeyboardPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCustomKeyboardPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..39973495f83be31fc61425f30426a2d979a72a2d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCustomKeyboardPage3Test { + PAGE_TAG: string = 'TextInputCustomKeyboardPage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCustomKeyboardPage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage4Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage4Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..38a6f73aa74fffd7c127547e5f05e31fdd97af18 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage4Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCustomKeyboardPage4Test { + PAGE_TAG: string = 'TextInputCustomKeyboardPage4Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCustomKeyboardPage4Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage5Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage5Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a01a894e135b4ddce3a6404c0b9af16b833af588 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage5Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCustomKeyboardPage5Test { + PAGE_TAG: string = 'TextInputCustomKeyboardPage5Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCustomKeyboardPage5Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage6Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage6Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..805dab4804d2bda2f68ecc5e351191a86d399b09 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputCustomKeyboardPage6Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputCustomKeyboardPage6Test { + PAGE_TAG: string = 'TextInputCustomKeyboardPage6Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputCustomKeyboardPage6Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputEnableAutoFillTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputEnableAutoFillTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d239bc78a84d01d9e90406b81ac85e47f485e335 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputEnableAutoFillTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputEnableAutoFillTest { + PAGE_TAG: string = 'TextInputEnableAutoFillTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputEnableAutoFillTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f5114ac306aeb136070445e09f850a9d2ebb841 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputFontFeaturePage1Test { + PAGE_TAG: string = 'TextInputFontFeaturePage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputFontFeaturePage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed13313ebc77f8efad9f7e7cdf0c655b57aeb0db --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputFontFeaturePage2Test { + PAGE_TAG: string = 'TextInputFontFeaturePage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputFontFeaturePage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..09d44f2c4bdad368d1a19d1ba790ce204f3db9df --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputFontFeaturePage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputFontFeaturePage3Test { + PAGE_TAG: string = 'TextInputFontFeaturePage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputFontFeaturePage3Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputGetCaretOffsetTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputGetCaretOffsetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fa27c48778f943b6e31d775f79abbc757fbf637 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputGetCaretOffsetTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputGetCaretOffsetTest { + PAGE_TAG: string = 'TextInputGetCaretOffsetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputGetCaretOffsetTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputInputFilterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputInputFilterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..75f4e072be26c73e21d6f35b0ffe356e07881f7a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputInputFilterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputInputFilterTest { + PAGE_TAG: string = 'TextInputInputFilterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputInputFilterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputMaxLinesTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputMaxLinesTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1138a5f6a387512e187cb7ebc357f078c60f930 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputMaxLinesTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputMaxLinesTest { + PAGE_TAG: string = 'TextInputMaxLinesTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputMaxLinesTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputMinFontSizeAndMaxFontSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputMinFontSizeAndMaxFontSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..97e8fc7a9f06fb513e7363ede9a4d3f2d2604dbc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputMinFontSizeAndMaxFontSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputMinFontSizeAndMaxFontSizeTest { + PAGE_TAG: string = 'TextInputMinFontSizeAndMaxFontSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputMinFontSizeAndMaxFontSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputNumberOfLinesTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputNumberOfLinesTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d8bb34c7e733669a862535c9fc474598f44cba10 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputNumberOfLinesTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputNumberOfLinesTest { + PAGE_TAG: string = 'TextInputNumberOfLinesTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputNumberOfLinesTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage1Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage1Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb4f19b52ed1ab111b312c92bb23a768d4ed14b3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage1Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputPasswordRulesPage1Test { + PAGE_TAG: string = 'TextInputPasswordRulesPage1Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputPasswordRulesPage1Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e29a146f38859a583085c9dddc9a4d54dcedbb36 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputPasswordRulesPage2Test { + PAGE_TAG: string = 'TextInputPasswordRulesPage2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputPasswordRulesPage2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage3Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage3Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c7941ca33028b58f94c277d3e818ed3808efce4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputPasswordRulesPage3Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputPasswordRulesPage3Test { + PAGE_TAG: string = 'TextInputPasswordRulesPage3Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputPasswordRulesPage3Test(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSelectAllTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSelectAllTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..884a3a4dfb1c238e102c6c8df0bfeda80ef686e1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSelectAllTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputSelectAllTest { + PAGE_TAG: string = 'TextInputSelectAllTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputSelectAllTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSelectionMenuHiddenTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSelectionMenuHiddenTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..7203cf4ffeb562c723d7a7d66104d7008fd1e4f1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSelectionMenuHiddenTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputSelectionMenuHiddenTest { + PAGE_TAG: string = 'TextInputSelectionMenuHiddenTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputSelectionMenuHiddenTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSetTextSelectionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSetTextSelectionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ec99fd42749aac404d79cb6492d09150a37b8d6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputSetTextSelectionTest.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputSetTextSelectionTest { + PAGE_TAG: string = 'TextInputSetTextSelectionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputSetTextSelectionTest(this.PAGE_TAG); + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputShowKeyboardOnFocusAbnormalTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputShowKeyboardOnFocusAbnormalTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..27afca22f5d9f57cbf904f2c0414c5509a60877f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputShowKeyboardOnFocusAbnormalTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputShowKeyboardOnFocusAbnormalTest { + PAGE_TAG: string = 'TextInputShowKeyboardOnFocusAbnormalTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputShowKeyboardOnFocusAbnormalTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputShowKeyboardOnFocusTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputShowKeyboardOnFocusTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdfda4b25f44b19c58bbe96a446b946c9c80c940 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputShowKeyboardOnFocusTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputShowKeyboardOnFocusTest { + PAGE_TAG: string = 'TextInputShowKeyboardOnFocusTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputShowKeyboardOnFocusTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputStyleTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputStyleTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..606ba6536220e9920a3aa2dabfce7b073fb70a69 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputStyleTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputStyleTest { + PAGE_TAG: string = 'TextInputStyleTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputStyleTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputTextPlaceholderTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputTextPlaceholderTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b20277eea468bbbbbf41a4714ae0ba87ee4679c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputTextPlaceholderTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputTextPlaceholderTest { + PAGE_TAG: string = 'TextInputTextPlaceholderTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputTextPlaceholderTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputUnderlineColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputUnderlineColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a4fd73c88960e81350fd0d6085d1028802fb1fe --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputUnderlineColorTest.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputUnderlineColorTest { + PAGE_TAG: string = 'TextInputUnderlineColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + + render.textInputUnderlineColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputWordBreakTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputWordBreakTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee93078f3d9e8b91813f0b62cca108b39aba0694 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/textinput/TextInputWordBreakTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct TextInputWordBreakTest { + PAGE_TAG: string = 'TextInputWordBreakTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.textInputWordBreakTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/toggle/ToggleUnSelectedColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/toggle/ToggleUnSelectedColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..b86b1ca2deefdc67564ab1003ce656a88558c051 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/toggle/ToggleUnSelectedColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ToggleUnSelectedColorTest { + PAGE_TAG: string = 'ToggleUnSelectedColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.toggleUnSelectedColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/tools/ToolsLayoutRectInLandscapeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/tools/ToolsLayoutRectInLandscapeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3eda080996f191b657a97ec5fbe5f9e1d21388a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/tools/ToolsLayoutRectInLandscapeTest.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; +import { window } from '@kit.ArkUI'; +import common from '@ohos.app.ability.common'; + +@Entry +@Component +struct ToolsLayoutRectInLandscapeTest { + PAGE_TAG: string = 'ToolsLayoutRectInLandscapeTest'; + + private changeOrientation(isLandscape: boolean) { + let context = getContext(this) as common.UIAbilityContext; + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT) + }); + } + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + // Change the orientation to landscape + this.changeOrientation(true); + render.toolsLayoutRectTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/tools/ToolsLayoutRectTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/tools/ToolsLayoutRectTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0756f7037084214af880c1768f1c9dfbb6dd41c3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/tools/ToolsLayoutRectTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct ToolsLayoutRectTest { + PAGE_TAG: string = 'ToolsLayoutRectTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.toolsLayoutRectTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitLengthMetricsTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitLengthMetricsTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6914ec355604196a05879db7f8413ffd54072a6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitLengthMetricsTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct UnitLengthMetricsTest { + PAGE_TAG: string = 'UnitLengthMetricsTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.unitLengthMetricsTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentBorderRadiusTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentBorderRadiusTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..61da600dc44c85e9510ee503133066890bce36b4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentBorderRadiusTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct UnitPercentBorderRadiusTest { + PAGE_TAG: string = 'UnitPercentBorderRadiusTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.unitPercentBorderRadiusTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentPaddingTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentPaddingTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f94aa37f0850c1973db1687d415f1a6423cfd192 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentPaddingTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct UnitPercentPaddingTest { + PAGE_TAG: string = 'UnitPercentPaddingTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.unitPercentPaddingTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9412e88a47953dff743f1a71a244bd715f8f640d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/unit/UnitPercentTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct UnitPercentTest { + PAGE_TAG: string = 'UnitPercentTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.unitPercentTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowCachedCountTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowCachedCountTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb6aedd13621171b03bb1d5d2318c48a66e67b52 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowCachedCountTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowCachedCountTest { + PAGE_TAG: string = 'WaterFlowCachedCountTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowCachedCountTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowColumnsRowsGapTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowColumnsRowsGapTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb7e38e72d34ea249ed8cde54ddac6bf8c5d333e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowColumnsRowsGapTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowColumnsRowsGapTest { + PAGE_TAG: string = 'WaterFlowColumnsRowsGapTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowColumnsRowsGapTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowColumnsRowsTemplateTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowColumnsRowsTemplateTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb3dee21132d57334949bec1be6d3cbe155d5a57 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowColumnsRowsTemplateTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowColumnsRowsTemplateTest { + PAGE_TAG: string = 'WaterFlowColumnsRowsTemplateTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowColumnsRowsTemplateTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowEnableScrollInteractionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowEnableScrollInteractionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc5688d183c7da3cb74c4eb2eeb8aadccd2aae74 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowEnableScrollInteractionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowEnableScrollInteractionTest { + PAGE_TAG: string = 'WaterFlowEnableScrollInteractionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowEnableScrollInteractionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowFooterTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowFooterTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf9e3c8f2eadef419ecf003431914c89785f8be3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowFooterTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowFooterTest { + PAGE_TAG: string = 'WaterFlowFooterTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowFooterTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowItemConstraintSizeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowItemConstraintSizeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..13c3d26a9d6a35f768c0a78a878867db292a6990 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowItemConstraintSizeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowItemConstraintSizeTest { + PAGE_TAG: string = 'WaterFlowItemConstraintSizeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowItemConstraintSizeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowLayoutDirectionTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowLayoutDirectionTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..922f46d4e702af64d6b9243205c9ed53bdcb3346 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowLayoutDirectionTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowLayoutDirectionTest { + PAGE_TAG: string = 'WaterFlowLayoutDirectionTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowLayoutDirectionTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollResetTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollResetTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..bdd7c724dcfb4c2628d2891813a41564fe4f3b6a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollResetTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowNestedScrollResetTest { + PAGE_TAG: string = 'WaterFlowNestedScrollResetTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowNestedScrollResetTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollSmallTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollSmallTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8777d8144e03b4dde8b582d2410e187084343455 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollSmallTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowNestedScrollSmallTest { + PAGE_TAG: string = 'WaterFlowNestedScrollSmallTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowNestedScrollSmallTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc25126de161c8d4f6ac76c04a56930a58f7ab72 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowNestedScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowNestedScrollTest { + PAGE_TAG: string = 'WaterFlowNestedScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowNestedScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnDidScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnDidScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..91ab1e74ad0d95bb5514e92af58fbed7e57f5b46 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnDidScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowOnDidScrollTest { + PAGE_TAG: string = 'WaterFlowOnDidScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowOnDidScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnStartEndStopTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnStartEndStopTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8be34a33dc594d97bd633d1dd869e4ed9084f98 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnStartEndStopTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowOnStartEndStopTest { + PAGE_TAG: string = 'WaterFlowOnStartEndStopTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowOnStartEndStopTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnWillScrollTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnWillScrollTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0425f1f1d7334ebfd2c956617259a21b27f38f3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowOnWillScrollTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowOnWillScrollTest { + PAGE_TAG: string = 'WaterFlowOnWillScrollTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowOnWillScrollTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollBarColorTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollBarColorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ff9d21948a4571f37017a89ec3ed5347e4c99de --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollBarColorTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollBarColorTest { + PAGE_TAG: string = 'WaterFlowScrollBarColorTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollBarColorTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollBarWidthTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollBarWidthTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..4099c85928af9f77791fbf1035eafe7d96a72887 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollBarWidthTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollBarWidthTest { + PAGE_TAG: string = 'WaterFlowScrollBarWidthTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollBarWidthTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollByTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollByTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c527752fd93d3daeed6dbda8fc2e7b344f00c64a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollByTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollByTest { + PAGE_TAG: string = 'WaterFlowScrollByTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollByTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollEdgeTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollEdgeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..df6a7f312ade3b4af605722a1e1e12bd2162975f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollEdgeTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollEdgeTest { + PAGE_TAG: string = 'WaterFlowScrollEdgeTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollEdgeTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollOffset2Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollOffset2Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c6356d8f07922b184cc0cc9d57f0ca2833ab77d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollOffset2Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollOffset2Test { + PAGE_TAG: string = 'WaterFlowScrollOffset2Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollOffset2Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollPageTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollPageTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e375ac72ffac5e81a5f9886ce9cb68a026480fab --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollPageTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollPageTest { + PAGE_TAG: string = 'WaterFlowScrollPageTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollPageTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollToIndex8Test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollToIndex8Test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6cb049a930539aec87a3df5ab12c07cc3be28779 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollToIndex8Test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollToIndex8Test { + PAGE_TAG: string = 'WaterFlowScrollToIndex8Test'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollToIndex8Test(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollToIndexTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollToIndexTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..baadd973b3601912b422dc0dbbd688cf36c0a81e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowScrollToIndexTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowScrollToIndexTest { + PAGE_TAG: string = 'WaterFlowScrollToIndexTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowScrollToIndexTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest1.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest1.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ae3cb977f1a0abd1ccefb05176c4d038e678831 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest1.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowSectionTest1 { + PAGE_TAG: string = 'WaterFlowSectionTest1'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowSectionTest1(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest2.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest2.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9ea469db70a8f11cb656fed539b06eed1b42dec --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest2.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowSectionTest2 { + PAGE_TAG: string = 'WaterFlowSectionTest2'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowSectionTest2(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest3.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest3.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b07f879277bb13b0b68fce92a75be1c7d64881f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/waterflow/WaterFlowSectionTest3.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct WaterFlowSectionTest3 { + PAGE_TAG: string = 'WaterFlowSectionTest3'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.waterFlowSectionTest3(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/xcomponent/XComponentIdTest.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/xcomponent/XComponentIdTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e60126b2db7a7fc1673e2fd648d7ca6bad617049 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/MainAbility/pages/xcomponent/XComponentIdTest.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import render from 'libnativerender.so' +import { CommonView } from '../../componet/CommonView'; + +@Entry +@Component +struct XComponentIdTest { + PAGE_TAG: string = 'XComponentIdTest'; + + build() { + Column() { + CommonView({ + pageTag: this.PAGE_TAG, + }).onAppear(() => { + render.xComponentIdTest(this.PAGE_TAG); + }) + } + } +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/List.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d7a168c617bf2f19328d665671c15d079c724407 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import listChildrenMainSizeTest from './list/ListChildrenMainSizeTest.test' +import listCloseAllTest from './list/ListCloseAllTest.test' +import listDividerAndInitialIndexTest from './list/ListDividerAndInitialIndexTest.test' +import listNestedScrollTest from './list/ListNestedScrollTest.test' +import listScrollTest from './list/ListScrollTest.test' +import listSpaceAndAlignmentTest from './list/ListSpaceAndAlignmentTest.test' +import listItemGroupDividerTest from './listitemgroup/ListItemGroupDividerTest.test' +import listItemGroupHeaderAndFooterTest from './listitemgroup/ListItemGroupHeaderAndFooterTest.test' +import ListScrollBarTest from './list/ListScrollBarTest.test' +import columnJustifyContentTest from './column/ColumnJustifyContentTest.test' +import columnAlignItemsTest from './column/ColumnAlignItemsTest.test' +import rowJustifyContentTest from './row/RowJustifyContentTest.test' +import rowAlignItemsTest from './row/RowAlignItemsTest.test' +import flexOptionsTest from './flex/FlexOptinsTest.test' +import radioTest from './radio/RadioTest.test' +import gridTest from './grid/GridTest.test' +import gestureGestureTest from './gesture/GestureGestureTest.test' +import requirementPanGestureTest from './requirement/RequirementPanGestureTest.test' +import requirementRouterPageStateTest from './requirement/RequirementRouterPageStateTest.test' +import resourceNapiValueTest from './resourcenapivalue/ResourceNapiValueTest.test' +import lazyForEachTest from './lazyforeach/LazyForEachTest.test' +import refreshTest from './refresh/RefreshTest.test' +import toggleUnSelectedColorTest from './toggle/ToggleUnSelectedColorTest.test' +import imageAnimatorTest from './imageanimator/ImageAnimatorTest.test' +import imageFrameInfoTest from './imageanimator/ImageFrameInfoTest.test' +import swiperEffectModeTest from './swiper/SwiperEffectModeTest.test' +import swiperAdapterTest from './swiper/SwiperAdapterTest.test' +import swiperMarginTest from './swiper/SwiperMarginTest.test' +import swiperNestedScrollTest from './swiper/SwiperNestedScrollTest.test' +import swiperChangeIndexTest from './swiper/SwiperChangeIndexTest.test' +import swiperDotIndicatorTest from './swiper/SwiperDotIndicatorTest.test' +import swiperEventTest from './swiper/SwiperEventTest.test' +import swiperOnChangeTest from './swiper/SwiperOnChangeTest.test' +import swiperOnAnimationTest from './swiper/SwiperOnAnimationTest.test' +import swiperResetAttributeTest from './swiper/SwiperResetAttributeTest.test' +import customDialogContentTest from './customdialog/CustomDialogContentTest.test' +import buttonTypeTest from './button/ButtonTypeTest.test' +import calendarPickerHintRadiusTest from './calendarpicker/CalendarPickerHintRadiusTest.test' +import calendarPickerSelectedDateTest from './calendarpicker/CalendarPickerSelectedDateTest.test' +import sliderTrackThicknessTest from './slider/SliderTrackThicknessTest.test' +import stackAlignContentTest from './stack/StackAlignContentTest.test' +import waterFlowCachedCountTest from './waterflow/WaterFlowCachedCountTest.test' +import waterFlowSectionTest from './waterflow/WaterFlowSectionTest.test' +import waterFlowLayoutDirectionTest from './waterflow/WaterFlowLayoutDirectionTest.test' +import waterFlowColumnsRowsTemplateTest from './waterflow/WaterFlowColumnsRowsTemplateTest.test' +import waterFlowColumnsRowsGapTest from './waterflow/WaterFlowColumnsRowsGap.test' +import waterFlowNestedScrollTest from './waterflow/WaterFlowNestedScrollTest.test' +import waterFlowScrollTest from './waterflow/WaterFlowScrollTest.test' +import waterFlowItemConstraintSizeTest from './waterflow/WaterFlowItemConstraintSizeTest.test' +import waterFlowFooterTest from './waterflow/WaterFlowFooterTest.test' +import waterFlowEventTest from './waterflow/WaterFlowEventTest.test' +import xComponentIdTest from './xcomponent/XComponentIdTest.test' +import scrollScrollBarWidthTest from './scroll/ScrollScrollBarWidthTest.test' +import scrollScrollByTest from './scroll/ScrollScrollByTest.test' +import scrollEnablePagingTest from './scroll/ScrollEnablePagingTest.test' +import scrollScrollEdgeTest from './scroll/ScrollScrollEdgeTest.test' +import spanTextBackgroundStyleTest from './span/SpanTextBackgroundStyleTest.test' +import spanValueTest from './span/SpanValueTest.test' +import spanBaseLineOffsetTest from './span/SpanBaseLineOffsetTest.test' +import spanTextShadowTest from './span/SpanTextShadowTest.test' +import spanFontFamilyTest from './span/SpanFontFamilyTest.test' +import progressValueAndTotalTest from './progress/ProgressValueAndTotalTest.test' +import progressTypeTest from './progress/ProgressTypeTest.test' +import textContentTest from './text/TextContentTest.test' +import textDecorationStyleTest from './text/TextDecorationStyleTest.test' +import textWordBreakTest from './text/TextWordBreakTest.test' +import textEllipsisModeTest from './text/TextEllipsisModeTest.test' +import textLineSpacingTest from './text/TextLineSpacingTest.test' +import textFontFeatureTest from './text/TextFontFeatureTest.test' +import textSelectedBackgroundColorTest from './text/TextSelectedBackgroundColorTest.test' +import textEnableDataDetectorTest from './text/TextEnableDataDetectorTest.test' +import textDataDetectorConfigTest from './text/TextDataDetectorConfigTest.test' +import textParagraphTest from './text/TextParagraphTest.test' +import textAreaTextPlaceholderTest from './textarea/TextAreaTextPlaceholderTest.test' +import textAreaTypeTest from './textarea/TextAreaTypeTest.test' +import textAreaShowCounterTest from './textarea/TextAreaShowCounterTest.test' +import textAreaFontFeatureTest from './textarea/TextAreaFontFeatureTest.test' +import textAreaMaxLinesTest from './textarea/TextAreaMaxLinesTest.test' +import textAreaSelectionMenuHiddenTest from './textarea/TextAreaSelectionMenuHddenTest.test' +import textAreaInputFilterTest from './textarea/TextAreaInputFilterTest.test' +import textAreaSelectedBackgroundColorTest from './textarea/TextAreaSelectedBackgroundColorTest.test' +import textAreaEnterKeyTypeTest from './textarea/TextAreaEnterKeyTypeTest.test' +import textAreaEnableKeyboardOnFocusTest from './textarea/TextAreaEnableKeyboardOnFocusTest.test' +import textAreaBlurOnSubmitTest from './textarea/TextAreaBlurOnSubmitTest.test' +import textAreaShowKeyboardOnFocusTest from './textarea/TextAreaShowKeyboardOnFocusTest.test' +import textAreaGetCaretOffsetTest from './textarea/TextAreaGetCaretOffsetTest.test' +import textAreaCaretPositionTest from './textarea/TextAreaCaretPositionTest.test' +import textAreaControllerTest from './textarea/TextAreaControllerTest.test' +import textAreaSetTextSelectionTest from './textarea/TextAreaSetTextSelectionTest.test' +import textAreaEnableAutoFillTest from './textarea/TextAreaEnableAutoFillTest.test' +import textAreaContentTypeTest from './textarea/TextAreaContentTypeTest.test' +import textAreaNumberOfLinesTest from './textarea/TextAreaNumberOfLinesTest.test' +import textInputCustomKeyboardTest from './textinput/TextInputCustomKeyboardTest.test' +import textInputEnableAutoFillTest from './textinput/TextInputEnableAutoFillTest.test' +import textInputContentTypeTest from './textinput/TextInputContentTypeTest.test' +import textInputPasswordRulesTest from './textinput/TextInputPasswordRulesTest.test' +import textInputSelectAllTest from './textinput/TextInputSelectAllTest.test' +import textInputSelectionMenuHiddenTest from './textinput/TextInputSelectionMenuHiddenTest.test' +import textInputFontFeatureTest from './textinput/TextInputFontFeatureTest.test' +import textInputTextPlaceholderTest from './textinput/TextInputTextPlaceholderTest.test' +import textInputCancelButtonTest from './textinput/TextInputCancelButtonTest.test' +import textInputSetTextSelectionTest from './textinput/TextInputSetTextSelectionTest.test' +import textInputUnderlineColorTest from './textinput/TextInputUnderlineColorTest.test' +import textInputWordBreakTest from './textinput/TextInputWordBreakTest.test' +import textInputStyleTest from './textinput/TextInputStyleTest.test' +import textInputMinFontSizeAndMaxFontSizeTest from './textinput/TextInputMinFontSizeAndMaxFontSizeTest.test' +import textInputMaxLinesTest from './textinput/TextInputMaxLinesTest.test' +import textInputNumberOfLinesTest from './textinput/TextInputNumberOfLinesTest.test' +import textInputInputFilterTest from './textinput/TextInputInputFilterTest.test' +import textInputShowKeyboardOnFocusTest from './textinput/TextInputShowKeyboardOnFocusTest.test' +import textInputBlurOnSubmitTest from './textinput/TextInputBlurOnSubmitTest.test' +import textInputGetCaretOffsetTest from './textinput/TextInputGetCaretOffsetTest.test' +import textInputCaretPositionTest from './textinput/TextInputCaretPositionTest.test' +import textInputControllerTest from './textinput/TextInputControllerTest.test' +import commonAttrsZIndexTest from './commonattrs/CommonAttrsZIndexTest.test' +import commonAttrsOutlineColorTest from './commonattrs/CommonAttrsOutlineColorTest.test' +import commonAttrsSizeTest from './commonattrs/CommonAttrsSizeTest.test' +import commonAttrsPaddingTest from './commonattrs/CommonAttrsPaddingTest.test' +import commonAttrsAccessibilityRoleTest from './commonattrs/CommonAttrsAccessibilityRoleTest.test' +import commonAttrsAccessibilityStateTest from './commonattrs/CommonAttrsAccessibilityStateTest.test' +import commonAttrsAccessibilityValueTest from './commonattrs/CommonAttrsAccessibilityValueTest.test' +import commonAttrsFocusOnTouchTest from './commonattrs/CommonAttrsFocusOnTouchTest.test' +import commonAttrsAlignmentTest from './commonattrs/CommonAttrsAlignmentTest.test' +import commonAttrsTranslateTest from './commonattrs/CommonAttrsTranslateTest.test' +import commonAttrsTouchAbleTest from './commonattrs/CommonAttrsTouchAbleTest.test' +import commonAttrsRotateTest from './commonattrs/CommonAttrsRotateTest.test' +import commonAttrsRenderGroupTest from './commonattrs/CommonAttrsRenderGroupTest.test' +import commonAttrsLayoutWeightTest from './commonattrs/CommonAttrsLayoutWeightTest.test' +import commonAttrsDisplayPriorityTest from './commonattrs/CommonAttrsDisplayPriorityTest.test' +import commonAttrsOutlineWidthTest from './commonattrs/CommonAttrsOutlineWidthTest.test' +import commonAttrsColorBlendTest from './commonattrs/CommonAttrsColorBlendTest.test' +import commonAttrsChainModeTest from './commonattrs/CommonAttrsChainModeTest.test' +import commonAttrsBackgroundBlurStyleTest from './commonattrs/CommonAttrsBackgroundBlurStyleTest.test' +import commonAttrsBackgroundImageTest from './commonattrs/CommonAttrsBackgroundImageTest.test' +import commonAttrsBackgroundImageSizeTest from './commonattrs/CommonAttrsBackgroundImageSizeTest.test' +import commonAttrsBackgroundImagePositionTest from './commonattrs/CommonAttrsBackgroundImagePositionTest.test' +import commonAttrsBrightnessTest from './commonattrs/CommonAttrsBrightnessTest.test' +import commonAttrsSaturateTest from './commonattrs/CommonAttrsSaturateTest.test' +import commonAttrsBlurTest from './commonattrs/CommonAttrsBlurTest.test' +import commonAttrsClipShapeTest from './commonattrs/CommonAttrsClipShapeTest.test' +import commonAttrsCustomShadowTest from './commonattrs/CommonAttrsCustomShadowTest.test' +import commonAttrsVisibilityTest from './commonattrs/CommonAttrsVisibilityTest.test' +import commonAttrsDefaultFocusTest from './commonattrs/CommonAttrsDefaultFocusTest.test' +import commonAttrsFocusStatusTest from './commonattrs/CommonAttrsFocusStatusTest.test' +import commonAttrsAspectRatioTest from './commonattrs/CommonAttrsAspectRatioTest.test' +import commonAttrsForegroundColorTest from './commonattrs/CommonAttrsForegroundColorTest.test' +import commonAttrsMarkAnchorTest from './commonattrs/CommonAttrsMarkAnchorTest.test' +import commonAttrsOffsetTest from './commonattrs/CommonAttrsOffsetTest.test' +import commonAttrsOverlayTest from './commonattrs/CommonAttrsOverlayTest.test' +import commonAttrsResponseRegionTest from './commonattrs/CommonAttrsResponseRegionTest.test' +import commonAttrsScaleTest from './commonattrs/CommonAttrsScaleTest.test' +import commonEventTest from "./commonevent/CommonEventTest.test" +import nodeTreeTest from "./nodetree/NodeTreeTest.test" +import eventCallbackTest from "./eventcallback/EventCallbackTest.test" +import attributeSettingTest from "./attributesetting/AttributeSettingTest.test" +import inputEvent from "./inputevent/InputEventTest.test" +import imageSrcTest from './image/ImageSrcTest.test' +import imageResizableTest from './image/ImageResizableTest.test' +import imageDraggableTest from './image/ImageDraggableTest.test' +import imageRenderModeTest from './image/ImageRenderModeTest.test' +import imageObjectFitTest from './image/ImageObjectFitTest.test' +import imageFitOriginalSizeTest from './image/ImageFitOriginalSizeTest.test' +import imageFillColorTest from './image/ImageFillColorTest.test' +import imageOnfinishTest from './image/ImageOnfinishTest.test' +import imageOnDownloadProgressTest from './image/ImageOnDownloadProgressTest.test' +import imageSpanAltAndOnClickTest from './imagespan/ImageSpanAltAndOnClickTest.test' +import imageSpanSrcTest from './imagespan/ImageSpanSrcTest.test' +import relativeContainerGuideLineTest from "./relativecontainer/RelativeContainerGuideLine.test" +import relativeContainerBarrierTest from "./relativecontainer/RelativeContainerBarrier.test" +import ruleOptionTest from "./relativecontainer/RuleOption.test" +import unitLengthMetricsTest from './unit/UnitLengthMetricsTest.test' +import unitPercentTest from './unit/UnitPercentTest.test' +import mixGetNodeHandleTest from './mix/MixGetNodeHandleTest.test' +import toolsLayoutRectTest from './tools/ToolsLayoutRectTest.test' +import customComponentLayoutPositionTest from './customcomponent/CustomComponentLayoutPositionTest.test' +import customComponentLayoutConstraintTest from './customcomponent/CustomComponentLayoutConstraintTest.test' +import customComponentMeasuredSizeTest from './customcomponent/CustomComponentMeasureSizeTest.test' +import customComponentDrawContextTest from './customcomponent/CustomComponentDrawContextTest.test' +import customComponentGetTotalChildCountTest from './customcomponent/CustomComponentGetTotalChildCountTest.test' +import customComponentGetChildAtTest from './customcomponent/CustomComponentGetChildAtTest.test' +import customComponentGetFirstChildTest from './customcomponent/CustomComponentGetFirstChildTest.test' +import customComponentGetLastChildTest from './customcomponent/CustomComponentGetLastChildTest.test' +import customComponentGetPreviousNextSiblingTest from './customcomponent/CustomComponentGetPreviousNextSiblingTest.test' +import customComponentCustomEventTest from './customcomponent/CustomComponentCustomEventTest.test' +import customComponentLayoutAgainTest from './customcomponent/CustomComponentLayoutAgainTest.test' + +export default function testsuite() { + columnJustifyContentTest() + columnAlignItemsTest() + rowJustifyContentTest() + rowAlignItemsTest() + flexOptionsTest() + radioTest() + gridTest() + gestureGestureTest() + requirementPanGestureTest() + requirementRouterPageStateTest() + resourceNapiValueTest() + lazyForEachTest() + refreshTest() + toggleUnSelectedColorTest() + imageFrameInfoTest() + imageAnimatorTest() + swiperEffectModeTest() + swiperAdapterTest() + swiperMarginTest() + swiperNestedScrollTest() + swiperChangeIndexTest() + swiperDotIndicatorTest() + swiperEventTest() + swiperOnChangeTest() + swiperOnAnimationTest() + swiperResetAttributeTest() + customDialogContentTest() + buttonTypeTest() + calendarPickerHintRadiusTest() + calendarPickerSelectedDateTest() + sliderTrackThicknessTest() + stackAlignContentTest() + waterFlowCachedCountTest() + waterFlowSectionTest() + waterFlowLayoutDirectionTest() + waterFlowColumnsRowsTemplateTest() + waterFlowColumnsRowsGapTest() + waterFlowNestedScrollTest() + waterFlowScrollTest() + waterFlowItemConstraintSizeTest() + waterFlowFooterTest() + waterFlowEventTest() + xComponentIdTest() + scrollScrollBarWidthTest() + scrollScrollByTest() + scrollEnablePagingTest() + scrollScrollEdgeTest() + spanTextBackgroundStyleTest() + spanTextShadowTest() + spanValueTest() + spanBaseLineOffsetTest() + spanFontFamilyTest() + progressValueAndTotalTest() + progressTypeTest() + textContentTest() + textDecorationStyleTest() + textWordBreakTest() + textEllipsisModeTest() + textLineSpacingTest() + textFontFeatureTest() + textSelectedBackgroundColorTest() + textDataDetectorConfigTest() + textEnableDataDetectorTest() + textParagraphTest() + textAreaTextPlaceholderTest() + textAreaTypeTest() + textAreaShowCounterTest() + textAreaFontFeatureTest() + textAreaMaxLinesTest() + textAreaSelectionMenuHiddenTest() + textAreaInputFilterTest() + textAreaSelectedBackgroundColorTest() + textAreaEnterKeyTypeTest() + textAreaEnableKeyboardOnFocusTest() + textAreaBlurOnSubmitTest() + textAreaShowKeyboardOnFocusTest() + textAreaGetCaretOffsetTest() + textAreaCaretPositionTest() + textAreaControllerTest() + textAreaSetTextSelectionTest() + textAreaEnableAutoFillTest() + textAreaContentTypeTest() + textAreaNumberOfLinesTest() + textInputCustomKeyboardTest() + textInputSelectAllTest() + textInputEnableAutoFillTest() + textInputContentTypeTest() + textInputPasswordRulesTest() + textInputSelectionMenuHiddenTest() + textInputFontFeatureTest() + textInputTextPlaceholderTest() + textInputCancelButtonTest() + textInputSetTextSelectionTest() + textInputUnderlineColorTest() + textInputWordBreakTest() + textInputStyleTest() + textInputMinFontSizeAndMaxFontSizeTest() + textInputMaxLinesTest() + textInputNumberOfLinesTest() + textInputInputFilterTest() + textInputShowKeyboardOnFocusTest() + textInputBlurOnSubmitTest() + textInputGetCaretOffsetTest() + textInputCaretPositionTest() + textInputControllerTest() + commonAttrsZIndexTest() + commonAttrsAccessibilityRoleTest() + commonAttrsAccessibilityStateTest() + commonAttrsAccessibilityValueTest() + commonAttrsFocusOnTouchTest() + commonAttrsAlignmentTest() + commonAttrsOutlineColorTest() + commonAttrsSizeTest() + commonAttrsPaddingTest() + commonAttrsTranslateTest() + commonAttrsTouchAbleTest() + commonAttrsRotateTest() + commonAttrsRenderGroupTest() + commonAttrsLayoutWeightTest() + commonAttrsDisplayPriorityTest() + commonAttrsOutlineWidthTest() + commonAttrsColorBlendTest() + commonAttrsChainModeTest() + commonAttrsBackgroundBlurStyleTest() + commonAttrsBackgroundImageTest() + commonAttrsBackgroundImageSizeTest() + commonAttrsBackgroundImagePositionTest() + commonAttrsBrightnessTest() + commonAttrsSaturateTest() + commonAttrsBlurTest() + commonAttrsClipShapeTest() + commonAttrsCustomShadowTest() + commonAttrsVisibilityTest() + commonAttrsDefaultFocusTest() + commonAttrsFocusStatusTest() + commonAttrsAspectRatioTest() + commonAttrsForegroundColorTest() + commonAttrsMarkAnchorTest() + commonAttrsOffsetTest() + commonAttrsOverlayTest() + commonAttrsResponseRegionTest() + commonAttrsScaleTest() + commonEventTest() + nodeTreeTest() + eventCallbackTest() + attributeSettingTest() + inputEvent() + imageSrcTest() + imageResizableTest() + imageDraggableTest() + imageRenderModeTest() + imageFitOriginalSizeTest() + imageFillColorTest() + imageOnfinishTest() + imageOnDownloadProgressTest() + imageSpanAltAndOnClickTest() + imageSpanSrcTest() + imageObjectFitTest() + relativeContainerGuideLineTest() + relativeContainerBarrierTest() + ruleOptionTest() + unitLengthMetricsTest() + unitPercentTest() + mixGetNodeHandleTest() + toolsLayoutRectTest() + customComponentGetTotalChildCountTest() + customComponentGetChildAtTest() + customComponentMeasuredSizeTest() + customComponentLayoutPositionTest() + customComponentDrawContextTest() + customComponentGetFirstChildTest() + customComponentGetLastChildTest() + customComponentGetPreviousNextSiblingTest() + customComponentCustomEventTest() + customComponentLayoutConstraintTest() + customComponentLayoutAgainTest() + listChildrenMainSizeTest() + listCloseAllTest() + listDividerAndInitialIndexTest() + listNestedScrollTest() + listScrollTest() + listSpaceAndAlignmentTest() + listItemGroupDividerTest() + listItemGroupHeaderAndFooterTest() + ListScrollBarTest() +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/attributesetting/AttributeSettingTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/attributesetting/AttributeSettingTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e6c3232c19ca5d9bd5df71a7b71b281088c5738 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/attributesetting/AttributeSettingTest.test.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function AttributeSettingTest() { + + describe('AttributeSettingTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // setAttribute,resetAttribute,getAttribute + it('testAttributeSetting001', 0, async (done: Function) => { + let PAGE_TAG = 'AttributeSettingTest'; + await Utils.pushPage(`attributesetting/${PAGE_TAG}`); + await Utils.clickComponent('reset'); + await Utils.sleep(2000) + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/button/ButtonTypeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/button/ButtonTypeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb906a4a622de3647275dc3d3d3b064a9bbc08f0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/button/ButtonTypeTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function buttonTypeTest() { + + describe('ButtonTypeTest', () => { + + let PAGE_TAG = 'ButtonTypeTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`button/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testButtonType001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/calendarpicker/CalendarPickerHintRadiusTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/calendarpicker/CalendarPickerHintRadiusTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4efa69118a457b8661d7b827fe364af8521770c8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/calendarpicker/CalendarPickerHintRadiusTest.test.ets @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function calendarPickerHintRadiusTest() { + + describe('CalendarPickerHintRadiusTest', () => { + let PAGE_TAG_1 = 'CalendarPickerHintRadiusPage1Test'; + let PAGE_TAG_2 = 'CalendarPickerHintRadiusPage2Test'; + let PAGE_TAG_3 = 'CalendarPickerHintRadiusPage3Test'; + let PAGE_TAG_4 = 'CalendarPickerHintRadiusPage4Test'; + let PAGE_TAG_5 = 'CalendarPickerHintRadiusPage5Test'; + let PAGE_TAG_6 = 'CalendarPickerHintRadiusPage6Test'; + let PAGE_TAG_7 = 'CalendarPickerHintRadiusPage7Test'; + let PAGE_TAG_8 = 'CalendarPickerHintRadiusPage8Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + it('testCalendarPickerHintRadius001', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_1}`); + await Utils.clickComponent("calendarPicker1"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius002', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_2}`); + await Utils.clickComponent("calendarPicker2"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius003', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_3}`); + await Utils.clickComponent("calendarPicker3"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius004', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_4}`); + await Utils.clickComponent("calendarPicker4"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius005', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_5}`); + await Utils.clickComponent("calendarPicker5"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius006', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_6}`); + await Utils.clickComponent("calendarPicker6"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius007', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_7}`); + await Utils.clickComponent("calendarPicker7"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerHintRadius008', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_8}`); + await Utils.clickComponent("calendarPicker8"); + await Utils.sleep(2000); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/calendarpicker/CalendarPickerSelectedDateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/calendarpicker/CalendarPickerSelectedDateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f98288acc704ee953e1488b9fb171680d67c8e1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/calendarpicker/CalendarPickerSelectedDateTest.test.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function calendarPickerSelectedDateTest() { + + describe('CalendarPickerSelectedDateTest', () => { + let PAGE_TAG_1 = 'CalendarPickerSelectedDatePage1Test'; + let PAGE_TAG_2 = 'CalendarPickerSelectedDatePage2Test'; + let PAGE_TAG_3 = 'CalendarPickerSelectedDatePage3Test'; + let PAGE_TAG_4 = 'CalendarPickerSelectedDatePage4Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + it('testCalendarPickerSelectedDate001', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_1}`); + await Utils.clickComponent("calendarPicker1"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerSelectedDate002', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_2}`); + await Utils.clickComponent("calendarPicker2"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerSelectedDate003', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_3}`); + await Utils.clickComponent("calendarPicker3"); + await Utils.sleep(2000); + done() + }) + + it('testCalendarPickerSelectedDate004', 0, async (done: Function) => { + await Utils.pushPage(`calendarpicker/${PAGE_TAG_4}`); + await Utils.clickComponent("calendarPicker4"); + await Utils.sleep(2000); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/column/ColumnAlignItemsTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/column/ColumnAlignItemsTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d394d21e8d049e0622805ed3848152d4a59cf6ee --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/column/ColumnAlignItemsTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function columnAlignItemsTest() { + + describe('ColumnAlignItemsTest', () => { + + let PAGE_TAG = 'ColumnAlignItemsTest'; + let PAGE_TAG2 = 'ColumnAlignItemsMoreAttributeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testColumnAlignItems001', 0, async (done: Function) => { + await Utils.pushPage(`column/${PAGE_TAG}`, done); + }); + + it('testColumnAlignItems002', 0, async (done: Function) => { + await Utils.pushPage(`column/${PAGE_TAG2}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/column/ColumnJustifyContentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/column/ColumnJustifyContentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..540e59c050aaf28e9ae8156e919a66a39e0d9006 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/column/ColumnJustifyContentTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function columnJustifyContentTest() { + + describe('ColumnJustifyContentTest', () => { + + let PAGE_TAG = 'ColumnJustifyContentTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testColumnJustifyContent001', 0, async (done: Function) => { + await Utils.pushPage(`column/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Interfaces.d.ts b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Interfaces.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ad4cf063e2f0a6fe3fa8fb292f1dcf4f11b1b0b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Interfaces.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ComponentInfo { + $type: string; + $rect: Object[]; +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Settings.ts b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Settings.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2c5b1b5707ae0ea8585e4377c48b0ee64034663 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Settings.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import screen from '@ohos.screen'; +import window from '@ohos.window'; + +const TAG: string = '[SettingsCApiDemo]' + +class Settings { + sleep(time) { + return new Promise((resolve) => { + setTimeout(resolve, time) + }); + } + + windowClass: window.Window = null + + //为悬浮窗设置位置 + changeWindowPosition(windowClass, X, Y) { + windowClass.moveWindowTo(X, Y, (err) => { + if (err.code) { + console.error(`${TAG}, Fail to move the window. Cause: ${JSON.stringify(err)}`); + return; + } + }) + } + + //为悬浮窗设置大小 + changeWindowSize(windowClass, width, height) { + windowClass.resize(width, height, (err) => { + if (err.code) { + console.error(`${TAG}, Fail to change the window size. Cause: ${JSON.stringify(err)}`); + return; + } + }) + } + + loadContent(windowClass, pageURI) { + //为悬浮窗加载对应的目标页面 + windowClass.setUIContent(pageURI, (err) => { + if (err.code) { + console.error(`${TAG}, Fail to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + console.info(`${TAG}, Succeeded in loading the content.`); + + //显示悬浮窗 + windowClass.showWindow((err) => { + if (err.code) { + console.error(`${TAG}, Fail to show the window. Cause: ${JSON.stringify(err)}`); + return; + } + console.info(`${TAG}, Succeeded in showing the window.`); + }) + + }) + } + + changeDpi(dpi) { + let screenClass = null; + screen.getAllScreens((err, data) => { + if (err.code) { + console.error(`${TAG}, Fail to get all screens. Cause: ${JSON.stringify(err)}`); + return; + } + console.info(`${TAG}, Succeeded in geting all screens.`); + + screenClass = data[0]; + //设置设备dpi + screenClass.setDensityDpi(dpi, (err, data) => { + if (err.code) { + console.error(`${TAG}, Fail to set the piexl density. Cause: ${JSON.stringify(err)}`); + return; + } + console.info(`${TAG}, Succeeded in seting the piexl density.`) + }) + }) + } + + destroyWindow() { + //销毁窗口 + let windowClass = null; + try { + windowClass = window.findWindow('floatWindow'); + console.info(`${TAG}, find window success.`) + } catch (exception) { + console.error(`${TAG}, Fail to find the window. Cause: ${JSON.stringify(exception)}`); + } + windowClass.destroyWindow((err) => { + if (err.code) { + console.error(`${TAG}, Fail to destroy the window. Cause: ${JSON.stringify(err)}`); + return; + } + console.info(`${TAG}, Succeeded in destroying the window.`) + }) + } + + createWindow(pageURI: String, {X=0,Y=0,width=1344,height=2560,dpi=400}={}) { + console.info(`${TAG}, params, pageURI=${pageURI}}, X=${X}, Y=${Y}, width=${width}, height=${height}, dpi=${dpi}`) + + this.changeDpi(dpi); + this.sleep(1000); + let windowClass = null; + let config = { + name: 'floatWindow', windowType: window.WindowType.TYPE_FLOAT, ctx: globalThis.context + } + window.createWindow(config, (err, data) => { + if (err.code) { + console.error(`${TAG}, Fail to create the floatWindow. Cause: ${JSON.stringify(err)}`); + return; + } + console.info(`${TAG}, Succeeded in creating the floatWindow.`) + windowClass = data; + this.windowClass = data; + + this.changeWindowPosition(windowClass, X, Y) + this.changeWindowSize(windowClass, width, height) + this.loadContent(windowClass, pageURI) + }) + } +} + +export default new Settings() \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Snap.ts b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Snap.ts new file mode 100644 index 0000000000000000000000000000000000000000..827a1cb472983758539d2c9e278713cd72578f0b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Snap.ts @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import window from '@ohos.window'; +import image from '@ohos.multimedia.image'; +import fs from '@ohos.file.fs'; +import { Driver, Rect } from '@ohos.UiTest'; + +const TAG: string = '[WindowSnap]' +const INFO = { + 'img': { + prefix: 'IMG_', + suffix: '.webp' + }, + 'txt': { + prefix: 'TXT_', + suffix: '.txt' + } +} + +class WindowSnap { + async sleep(time) { + return new Promise((resolve) => { + setTimeout(resolve, time) + }); + } + + createFile(context: any, type, page) { + console.info(`${TAG}, createFile start`) + let pathDir = context.filesDir; + console.info(`${TAG}, createFile pathDir = ${pathDir}`) + let name = page + let info = INFO[type] + let displayName = `${info.prefix}${name}${info.suffix}` + let filePath = pathDir + '/' + displayName + console.info(`${TAG}, createFile filePath = ${filePath}`) + let exists = fs.accessSync(filePath) + console.info(`${TAG}, oldFile exists = ${exists}`) + if (exists) { + fs.unlinkSync(filePath) + console.info(`${TAG}, remove file succeed`) + } + return fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) + } + + async save(data: image.PixelMap, context: any, page) { + console.info(`${TAG}, start save image`) + let packOpts: image.PackingOption = { + format: 'image/webp', quality: 100 + } + let imagePackerApi = image.createImagePacker() + let arrayBuffer = await imagePackerApi.packing(data, packOpts) + let file = null + while (file == null) { + file = this.createFile(context, 'img', page) + } + let exists = fs.accessSync(file.path) + console.info(`${TAG}, createFile exists = ${exists}`) + let fd = file.fd + console.info(`${TAG}, createFile fd = ${fd}`) + imagePackerApi.release() + try { + fs.writeSync(fd, arrayBuffer) + } catch (err) { + console.error(`${TAG}, write failed, code is ${err.code}, message is ${err.message}}`) + } + fs.closeSync(file) + console.info(`${TAG}, write picture done`) + } + + /** + * 获取窗口截图&文件保存 + * 入参必须为ability的context + * + * save:设备保存路径:/data/app/el2/100/base/{bundle_name}/haps/entry_test/files/IMG_test.webp + */ + async snapShot(context, page, done?) { + console.info(`${TAG}, start snapshot`) + await this.sleep(2000); + let windowClass = null + try { + windowClass = window.findWindow('floatWindow') + console.info(`${TAG}, find window success`) + } catch (exception) { + console.error(`${TAG}, Failed to find the window. Cause: ${JSON.stringify(exception)}`) + } + + windowClass.snapshot(async (err, data) => { + console.info(`${TAG}, windowClass.snapshot`) + if (err.code) { + console.error(`${TAG}, Failed to snapshot window. Cause: ${JSON.stringify(err)}`) + return + } + await this.save(data, context, page) + data.release() + if (done) { + done(); + } + }) + } + + async snapShotNext(context, page, done?) { + console.info(`${TAG}, start snapshot`) + let windowClass = null + try { + windowClass = window.findWindow('floatWindow'); + } catch (exception) { + console.error(`${TAG}, Failed to find the window. Cause: ${JSON.stringify(exception)}`) + } + await this.sleep(600); + windowClass.snapshot(async (err, data) => { + console.info(`${TAG}, windowClass.snapshot`) + + if (err.code) { + console.error(`${TAG}, Failed to snapshot window. Cause: ${JSON.stringify(err)}`) + return + } + await this.save(data, context, page) + data.release() + if (done) { + done(); + } + }) + } + + async snapShotByDriver(context, page, done?) { + console.info(`Start snapshot by driver`) + await this.sleep(2000); + let file = null + while (file == null) { + file = this.createFile(context, 'img', page) + } + let exists = fs.accessSync(file.path) + console.info(`${TAG}, createFile exists = ${exists}`) + + try { + let windowClass = window.findWindow('floatWindow') + console.info(`${TAG}, find window success`) + let windowRect = windowClass.getWindowProperties().windowRect; + console.info(`${TAG}, windowRct is ${JSON.stringify(windowRect)}`) + let driver = Driver.create(); + await driver.screenCapture(file.path, { + left: windowRect.left, + top: windowRect.top, + right: windowRect.width, + bottom: windowRect.height + }); + } catch (exception) { + console.error(`${TAG}, Failed to snap shot. Cause: ${JSON.stringify(exception)}`) + } + + if (done) { + done(); + } + } +} + +export default new WindowSnap() \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Utils.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..da612f94c43222f36aa6d8816f256d12701fb0fd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/common/Utils.ets @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import events_emitter from '@ohos.events.emitter'; +import { Driver, ON, PointerMatrix, Rect } from '@ohos.UiTest'; +import { ComponentInfo } from './Interfaces'; +import systemDateTime from '@ohos.systemDateTime'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry' +import fs from '@ohos.file.fs'; +import router from '@ohos.router'; + +export default class Utils { + static sleep(time: number) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve("ok") + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getSystemTime() { + return systemDateTime.getTime(true) / 1000 + } + + static getSandboxFileDir() { + let sandboxFileDir = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext().filesDir + "/" + console.log(`[getSandboxFileDir] return ${sandboxFileDir}`); + return sandboxFileDir; + } + + static deleteFile(filePath: string) { + console.info("[deleteFile] filePath:" + filePath); + try { + fs.unlinkSync(filePath) + } catch (error) { + console.info("[deleteFile] error:" + error); + } + } + + static isFileExist(filePath: string): boolean { + console.info("[isFileExist] filePath:" + filePath); + try { + let fileExist = fs.accessSync(filePath) + console.info("[isFileExist] return:" + fileExist); + return fileExist + } catch (error) { + console.info("[isFileExist] error:" + error); + return false + } + } + + static getComponentInfoByKey(key: string): ComponentInfo { + let strJson = getInspectorByKey(key); + let obj: ComponentInfo = JSON.parse(strJson); + console.info('[getInspectorByKey] current component info: ' + JSON.stringify(obj)); + return obj; + } + + + static async flingComponent(key: string, isHorizontal: boolean, isForward: boolean) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X1 = centerX - 100; + let X2 = centerX + 100; + let Y1 = centerY - 100; + let Y2 = centerY + 100; + let stepLen = 20; + let speed = 10000; + if (isHorizontal) { + if (isForward) { + await driver.fling({ + x: X2, y: centerY + }, { + x: X1, y: centerY + }, stepLen, speed); + } else { + await driver.fling({ + x: X1, y: centerY + }, { + x: X2, y: centerY + }, stepLen, speed); + } + } else { + if (isForward) { + await driver.fling({ + x: centerX, y: Y2 + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: Y1 + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } + } + } + + static async clickComponent(id: string) { + let driver = Driver.create(); + let component = await driver.findComponent(ON.id(id)); + await component.click(); + } + + static async doubleClickComponent(id: string) { + let driver = Driver.create(); + let component = await driver.findComponent(ON.id(id)); + await component.click(); + await component.click(); + } + + static async clickLocation(X: number, Y: number) { + let driver = Driver.create(); + await driver.click(X, Y); + } + + static async triggerKey(id: number) { + let driver = Driver.create(); + await driver.triggerKey(id); + } + + static async longClickComponent(id: string) { + let driver = Driver.create(); + let component = await driver.findComponent(ON.id(id)); + await component.longClick(); + } + + static async clickComponentByText(text: string) { + let driver = Driver.create(); + let component = await driver.findComponent(ON.text(text)); + await component.click(); + } + + static async fingerZoom(key: string, isOut: boolean) { + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let fingerUpCenterY = centerY - 100; + let fingerDownCenterY = centerY + 100; + let driver: Driver = Driver.create(); + let pointers: PointerMatrix = PointerMatrix.create(2, 3); + pointers.setPoint(0, 0, { + x: centerX, y: fingerUpCenterY - (isOut ? 40 : 120) + }); + pointers.setPoint(0, 1, { + x: centerX, y: fingerUpCenterY - 80 + }); + pointers.setPoint(0, 2, { + x: centerX, y: fingerUpCenterY - (isOut ? 120 : 40) + }); + pointers.setPoint(1, 0, { + x: centerX, y: fingerDownCenterY + (isOut ? 40 : 120) + }); + pointers.setPoint(1, 1, { + x: centerX, y: fingerDownCenterY + 80 + }); + pointers.setPoint(1, 2, { + x: centerX, y: fingerDownCenterY + (isOut ? 120 : 40) + }); + await driver.injectMultiPointerAction(pointers); + } + + static registerEvent(pageTag: string, eventId: number, callBack: Function) { + events_emitter.on({ + eventId: eventId, + priority: events_emitter.EventPriority.LOW + }, (eventData: events_emitter.EventData) => { + console.info("Value Change CallBack"); + if (eventData != null && eventData.data != null) { + if (pageTag == eventData.data.PAGE_TAG) { + console.info("CallBack value:" + JSON.stringify(eventData)); + callBack(eventData.data.VALUE); + } + } + }) + } + + static emitEvent(pageTag: string, emitValue: number | string | object, eventId: number) { + try { + let backData: events_emitter.EventData = { + data: { + "PAGE_TAG": pageTag, + "VALUE": emitValue + } + } + let backEvent: events_emitter.InnerEvent = { + eventId: eventId, + priority: events_emitter.EventPriority.LOW + } + console.info("start to emit page state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit page state err: " + JSON.stringify(err)); + } + } + + static async pushPage(pageTag: string, done?: Function) { + let options: router.RouterOptions = { + url: `MainAbility/pages/${pageTag}`, + } + try { + router.clear(); + let pages = router.getState(); + console.info(`get ${pageTag} state success ` + JSON.stringify(pages)); + if (pageTag.indexOf(pages.name) < 0) { + console.info(`get ${pageTag} state success ` + JSON.stringify(pages.name)); + let result = await router.pushUrl(options); + await Utils.sleep(2000); + console.info(`push ${pageTag} page success ` + JSON.stringify(result)); + } + } catch (err) { + console.error(`push ${pageTag} page error: ` + err); + } + if (done) { + done(); + } + } + + static getComponentRect(key: string): Rect { + let strJson = getInspectorByKey(key); + let obj: ComponentInfo = JSON.parse(strJson); + console.info('[getInspectorByKey] key is: ' + key); + return Utils.getComponentRectByObj(obj); + } + + static getComponentRectByObj(obj: ComponentInfo): Rect { + console.info('[getInspectorByKey] current component is: ' + obj.$type); + let rectInfo: Object[] = JSON.parse('[' + obj.$rect + ']'); + let rect_value: Rect = { + left: JSON.parse('[' + rectInfo[0] + ']')[0], + top: JSON.parse('[' + rectInfo[0] + ']')[1], + right: JSON.parse('[' + rectInfo[1] + ']')[0], + bottom: JSON.parse('[' + rectInfo[1] + ']')[1] + }; + console.info(JSON.stringify(rect_value)); + return rect_value; + } + + static getRectHorizontalCenterX(rect: Rect): number { + return Number.parseInt(Number((rect.right - rect.left) / 2 + rect.left).toFixed(0)); + } + + static getRectVerticalCenterY(rect: Rect): number { + return Number.parseInt(Number((rect.bottom - rect.top) / 2 + rect.top).toFixed(0)); + } + + static async mouseMoveTo(X: number, Y: number) { + let driver = Driver.create(); + await driver.mouseMoveTo({ + x: X, y: Y + }); + } + + static async mouseMoveToCurrentComponent(componentId: string) { + let driver = Driver.create(); + let component = await driver.findComponent(ON.id(componentId)); + let point = await component.getBounds(); + await driver.mouseMoveTo({ + x: point.left + 10, y: point.bottom - 10 + }); + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityRoleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityRoleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3565f7b9f28f12e29af01f11fbad6c683ebc6a6f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityRoleTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsAccessibilityRoleTest() { + + describe('CommonAttrsAccessibilityRoleTest', () => { + + let PAGE_TAG = 'CommonAttrsAccessibilityRoleTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsAccessibilityRole001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityStateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityStateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1b3c1f6f0ce7e52cf5685212ad1cd450817d624 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityStateTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsAccessibilityStateTest() { + + describe('CommonAttrsAccessibilityStateTest', () => { + + let PAGE_TAG = 'CommonAttrsAccessibilityStateTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsAccessibilityState001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityValueTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityValueTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..db5f309c13792c5bdb6466908896ea3fedebf11c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAccessibilityValueTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsAccessibilityValueTest() { + + describe('CommonAttrsAccessibilityValueTest', () => { + + let PAGE_TAG = 'CommonAttrsAccessibilityValueTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsAccessibilityValue001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAlignmentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAlignmentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d39f3218bfe4866373739483fe98174db9d49cb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAlignmentTest.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsAlignmentTest() { + + describe('CommonAttrsAlignmentTest', () => { + + let PAGE_TAG_1 = 'CommonAttrsAlignmentPage1Test'; + let PAGE_TAG_2 = 'CommonAttrsAlignmentPage2Test'; + let PAGE_TAG_3 = 'CommonAttrsAlignmentPage3Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsAlignment001', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG_1}`, done); + done(); + }) + + it('testCommonAttrsAlignment002', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG_2}`, done); + done(); + }) + + it('testCommonAttrsAlignment003', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG_3}`, done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAspectRatioTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAspectRatioTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad60d450700458345018a41f8040b03b2e40fd6e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsAspectRatioTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsAspectRatioTest() { + + describe('CommonAttrsAspectRatioTest', () => { + + let PAGE_TAG = 'CommonAttrsAspectRatioTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsAspectRatio001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundBlurStyleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundBlurStyleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..55b2a917d35d38446180c5f39a19b96e2c90e621 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundBlurStyleTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsBackgroundBlurStyleTest() { + + describe('CommonAttrsBackgroundBlurStyleTest', () => { + + let PAGE_TAG = 'CommonAttrsBackgroundBlurStyleTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsBackgroundBlurStyle001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImagePositionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImagePositionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c76807c5cd9d79a9b4c1d74c0f539556ee5f5db --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImagePositionTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsBackgroundImagePositionTest() { + + describe('CommonAttrsBackgroundImagePositionTest', () => { + + let PAGE_TAG = 'CommonAttrsBackgroundImagePositionTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsBackgroundImagePosition001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImageSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImageSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b7472789986dcb647c6d4a75393039ad24a6901 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImageSizeTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsBackgroundImageSizeTest() { + + describe('CommonAttrsBackgroundImageSizeTest', () => { + + let PAGE_TAG = 'CommonAttrsBackgroundImageSizeTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsBackgroundImageSize001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImageTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImageTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..248eae47350b9df20b9c76ecf0fef6acfaadda05 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBackgroundImageTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsBackgroundImageTest() { + + describe('CommonAttrsBackgroundImageTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsBackgroundImage001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsBackgroundImageResourceStrTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + + it('testCommonAttrsBackgroundImage002', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsBackgroundImagePixelMapTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBlurTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBlurTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3a9d2ebe65a96c7e86948adf958f8d1e51b1623 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBlurTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsBlurTest() { + + describe('CommonAttrsBlurTest', () => { + + let PAGE_TAG = 'CommonAttrsBlurTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsBlur001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBrightnessTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBrightnessTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4c1ef35a0b573872fe7925f5803ac0c6aa4a2ff --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsBrightnessTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsBrightnessTest() { + + describe('CommonAttrsBrightnessTest', () => { + + let PAGE_TAG = 'CommonAttrsBrightnessTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsBrightness001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsChainModeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsChainModeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e939d0bf980d91fc74d762572e8607afaab4f02a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsChainModeTest.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsChainModeTest() { + + describe('CommonAttrsChainModeTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsChainMode001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsChainModeTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + done(); + }) + + it('testCommonAttrsChainMode002', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsChainMode1Test'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + done(); + }) + + it('testCommonAttrsChainMode003', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsChainMode2Test'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsClipShapeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsClipShapeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e2a3270cb91bd258a42da715f73e21e22238e0a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsClipShapeTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsClipShapeTest() { + + describe('CommonAttrsClipShapeTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsClipShape001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsClipShapeTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsColorBlendTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsColorBlendTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9632268705b04b50fc355cf50ad42cd8663a895b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsColorBlendTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsColorBlendTest() { + + describe('CommonAttrsColorBlendTest', () => { + + let PAGE_TAG = 'CommonAttrsColorBlendTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsColorBlend001', 0, async (done: Function) => { + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsCustomShadowTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsCustomShadowTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2cc6b44024535075ece39f2cc10bf07daf9fd0f8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsCustomShadowTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsCustomShadowTest() { + + describe('CommonAttrsCustomShadowTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsCustomShadow001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsCustomShadowTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsDefaultFocusTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsDefaultFocusTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b89d9afaba42dc40e050adb1904eec4ae558af41 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsDefaultFocusTest.test.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsDefaultFocusTest() { + + describe('CommonAttrsDefaultFocusTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsDefaultFocus001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsDefaultFocusSingleTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + + it('testCommonAttrsDefaultFocus002', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsDefaultFocusNoneTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + + it('testCommonAttrsDefaultFocus003', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsDefaultFocusMultiTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + + it('testCommonAttrsDefaultFocus004', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsDefaultFocusAbnormalTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsDisplayPriorityTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsDisplayPriorityTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..278c56af6057bf0c9752c427d642bb368a42ace1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsDisplayPriorityTest.test.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@ohos.UiTest'; + +export default function commonAttrsDisplayPriorityTest() { + + describe('CommonAttrsDisplayPriorityTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsDisplayPriority001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsDisplayPriorityTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsFocusOnTouchTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsFocusOnTouchTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1289475d51f5ab99ebac69111d7f86ce75688184 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsFocusOnTouchTest.test.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsFocusOnTouchTest() { + + describe('CommonAttrsFocusOnTouchTest', () => { + + let PAGE_TAG = 'CommonAttrsFocusOnTouchTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsFocusOnTouch001', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + await Utils.clickComponent("text1"); + await Utils.sleep(2000); + done(); + }) + + it('testCommonAttrsFocusOnTouch002', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + await Utils.clickComponent("text2"); + await Utils.sleep(2000); + done(); + }) + + it('testCommonAttrsFocusOnTouch003', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + await Utils.clickComponent("text3"); + await Utils.sleep(2000); + done(); + }) + + it('testCommonAttrsFocusOnTouch004', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + await Utils.clickComponent("text4"); + await Utils.sleep(2000); + done(); + }) + + it('testCommonAttrsFocusOnTouch005', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + await Utils.clickComponent("text5"); + await Utils.sleep(2000); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsFocusStatusTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsFocusStatusTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9eb8bd1c3fd241f0be5290f4d610bf0b0218fa8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsFocusStatusTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +export default function commonAttrsFocusStatusTest() { + + describe('CommonAttrsFocusStatusTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsFocusStatus001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsFocusStatusTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + await Utils.clickComponent('Button'); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsForegroundColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsForegroundColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc2c9c5537886dde4275128ec46669c6d1ab4a3f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsForegroundColorTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsForegroundColorTest() { + + describe('CommonAttrsForegroundColorTest', () => { + + let PAGE_TAG = 'CommonAttrsForegroundColorTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsForegroundColor001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsLayoutWeightTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsLayoutWeightTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b64dffb5c1bc66c5ca9ea56b24f6c06b3d5639a4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsLayoutWeightTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsLayoutWeightTest() { + + describe('CommonAttrsLayoutWeightTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsLayoutWeight001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsLayoutWeightTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsMarkAnchorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsMarkAnchorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..df3dc97de0ca451fa3edb1a236b7aadafc32829b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsMarkAnchorTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsMarkAnchorTest() { + + describe('CommonAttrsMarkAnchorTest', () => { + + let PAGE_TAG = 'CommonAttrsMarkAnchorTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsMarkAnchor001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOffsetTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOffsetTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f64e5b9acfb74ebdeb8540754915e25ff7af628 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOffsetTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsOffsetTest() { + + describe('CommonAttrsOffsetTest', () => { + + let PAGE_TAG = 'CommonAttrsOffsetTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsOffset001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOutlineColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOutlineColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c383681ac002b1af830c7ba7c9695a80612bad4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOutlineColorTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsOutlineColorTest() { + + describe('CommonAttrsOutlineColorTest', () => { + + let PAGE_TAG = 'CommonAttrsOutlineColorTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsOutlineColor001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOutlineWidthTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOutlineWidthTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..975389ec0305a57a26a0745125b900c0bc11bd14 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOutlineWidthTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsOutlineWidthTest() { + + describe('CommonAttrsOutlineWidthTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsOutlineWidth001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsOutlineWidthTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOverlayTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOverlayTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4823f756f981fc576c5801a39364e679612cf129 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsOverlayTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsOverlayTest() { + + describe('CommonAttrsOverlayTest', () => { + + let PAGE_TAG = 'CommonAttrsOverlayTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsOverlay001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsPaddingTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsPaddingTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..079f2b22a61c4db9cb5d56755941df40148af631 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsPaddingTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsPaddingTest() { + + describe('CommonAttrsPaddingTest', () => { + + let PAGE_TAG = 'CommonAttrsPaddingTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsPadding001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsRenderGroupTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsRenderGroupTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f42465bd665a37abad6074d9245c95a6ff0b62c2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsRenderGroupTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsRenderGroupTest() { + + describe('CommonAttrsRenderGroupTest', () => { + + let PAGE_TAG = 'CommonAttrsRenderGroupTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsRenderGroup001', 0, async (done: Function) => { + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsResponseRegionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsResponseRegionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7752396eb0e5c40296074a395bd48e02c4f5564 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsResponseRegionTest.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON, MouseButton } from '@kit.TestKit'; + +async function clickLeft(id: string, done: Function, x = 40, y = 35) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.click(point.left + x, point.top + y) +} + +async function clickRight(id: string, done: Function, x = 40, y = 35) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.click(point.right - x, point.top + y) +} + +export default function commonAttrsResponseRegionTest() { + + describe('CommonAttrsResponseRegionTest', () => { + + let PAGE_TAG = 'CommonAttrsResponseRegionTest'; + let driver = Driver.create(); + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // 点击各组件的左侧或右侧 + it('testCommonAttrsResponseRegion001', 0, async (done: Function) => { + await clickLeft("BTN1", done); + await clickRight("BTN2", done); + await clickLeft("BTN3", done); + await clickRight("BTN4", done); + await clickRight("BTN5", done); + await clickRight("BTN6", done); + await clickRight("BTN7", done); + await clickLeft("BTN8", done); + await clickRight("BTN9", done); + await clickLeft("BTN10", done); + await clickLeft("BTN12", done); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsRotateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsRotateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..28ab68d080ecbd74b2d7ef25983bac068febff0d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsRotateTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsRotateTest() { + + describe('CommonAttrsRotateTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsRotate001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsRotateTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsSaturateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsSaturateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de943785eb25f37d42380d85b4c847bc6de5abb7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsSaturateTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsSaturateTest() { + + describe('CommonAttrsSaturateTest', () => { + + let PAGE_TAG = 'CommonAttrsSaturateTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsSaturate001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsScaleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsScaleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..261a8ba4e3e875ac0f57cc14154fb2158ea5e675 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsScaleTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsScaleTest() { + + describe('CommonAttrsScaleTest', () => { + + let PAGE_TAG = 'CommonAttrsScaleTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsScale001', 0, async (done: Function) => { + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6bdc36a09f17c99058583a74f7a2db62821d4c0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsSizeTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsSizeTest() { + + describe('CommonAttrsSizeTest', () => { + + let PAGE_TAG = 'CommonAttrsSizeTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsSize001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsTouchAbleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsTouchAbleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de0f24946ef277f33cb587bbd2e853a11434afa5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsTouchAbleTest.test.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsTouchAbleTest() { + + describe('CommonAttrsTouchAbleTest', () => { + + let PAGE_TAG = 'CommonAttrsTouchAbleTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsTouchAble001', 0, async (done: Function) => { + await Utils.clickComponent("button1") + await Utils.clickComponent("button2") + await Utils.clickComponent("button3") + await Utils.clickComponent("button4") + await Utils.clickComponent("button5") + await Utils.clickComponent("button6") + await Utils.clickComponent("button7") + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsTranslateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsTranslateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ceff55b5d23a2fbbf9db78869d1e7d26a6143f4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsTranslateTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsTranslateTest() { + + describe('CommonAttrsTranslateTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsTranslate001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsTranslateTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`); + Utils.sleep(200) + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsVisibilityTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsVisibilityTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b8270d71844b6b547495edad0d07f36c8569eb6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsVisibilityTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function commonAttrsVisibilityTest() { + + describe('CommonAttrsVisibilityTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsVisibility001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonAttrsVisibilityTest'; + await Utils.pushPage(`commonattrs/${PAGE_TAG}`, done); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsZIndexTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsZIndexTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..efb10317bec45db70486564367ca85136cdb61bf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonattrs/CommonAttrsZIndexTest.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON, Component } from '@ohos.UiTest'; + +// 点击 +async function click(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + await component.click(); + await Utils.sleep(1000); +} + +export default function commonAttrsZIndexTest() { + + describe('CommonAttrsZIndexTest', () => { + + let PAGE_TAG_1 = 'CommonAttrsZIndexPage1Test'; + let PAGE_TAG_2 = 'CommonAttrsZIndexPage2Test'; + let PAGE_TAG_3 = 'CommonAttrsZIndexPage3Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCommonAttrsZIndex001', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG_1}`, done); + done(); + }) + + it('testCommonAttrsZIndex002', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG_2}`, done); + await click("button3", done); + done(); + }) + + it('testCommonAttrsZIndex003', 0, async (done: Function) => { + await Utils.pushPage(`commonattrs/${PAGE_TAG_3}`, done); + await click("button4", done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonevent/CommonEventTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonevent/CommonEventTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd5ce3680d5c895eb6922538b571ddd88a95d78c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/commonevent/CommonEventTest.test.ets @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON,MouseButton } from '@kit.TestKit'; + +async function doIt(id: string, done: Function, speed: number = 400) { + let driver = Driver.create(); + let button = await driver.findComponent(ON.id(id)); + let point = await button.getBounds(); + await driver.swipe(point.left + 100, point.bottom, point.left + 100, point.bottom - 300, speed); +} +async function MouseClickComponent(id: string, mouseButton: MouseButton , done?: Function) { + let driver = Driver.create(); + let button = await driver.findComponent(ON.id(id)); + let point = await button.getBounds(); + await driver.mouseClick({x:point.left+10, y:point.top+10}, mouseButton); +} + +export default function CommonEventTest() { + + describe('CommonEventTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // addChild,removeChild + // onDisappear:NODE_EVENT_ON_DISAPPEAR + // onTouch:NODE_TOUCH_EVENT(支持冒泡:OH_ArkUI_PointerEvent_SetStopPropagation) + it('testCommonEventTest001', 0, async (done: Function) => { + let PAGE_TAG = 'CommonEventTest'; + await Utils.pushPage(`commonevent/${PAGE_TAG}`); + await Utils.clickComponent('onTouchTest') + await Utils.sleep(2000); + done(); + }) + //OnHover + it('testCommonEventTest002', 0, async (done: Function) => { + let PAGE_TAG = 'CommonOnHoverEventTest'; + await Utils.pushPage(`commonevent/${PAGE_TAG}`); + await Utils.mouseMoveToCurrentComponent("onHoverTest") + await Utils.sleep(2000); + done(); + }) + //OnVisibleAreaChange + it('testCommonEventTest003', 0, async (done: Function) => { + let PAGE_TAG = 'CommonOnVisibleAreaChangeEventTest'; + await Utils.pushPage(`commonevent/${PAGE_TAG}`); + await doIt('OnVisibleAreaChange',done,10000); + await Utils.sleep(2000); + done(); + }) + //OnMouse + it('testCommonEventTest004', 0, async (done: Function) => { + let PAGE_TAG = 'CommonOnMouseEventTest'; + await Utils.pushPage(`commonevent/${PAGE_TAG}`); + await MouseClickComponent('onMouseRightTest',MouseButton.MOUSE_BUTTON_RIGHT); + await MouseClickComponent('onMouseLeftTest',MouseButton.MOUSE_BUTTON_LEFT); + await MouseClickComponent('onMouseMiddleTest',MouseButton.MOUSE_BUTTON_MIDDLE); + await MouseClickComponent('onMouseMoveTest',MouseButton.MOUSE_BUTTON_LEFT); + await Utils.sleep(2000) + done() + }) + // onTouchIntercept + it('testCommonEventTest005', 0, async (done: Function) => { + let PAGE_TAG = 'CommonOnTouchInterceptEventTest'; + await Utils.pushPage(`commonevent/${PAGE_TAG}`); + await Utils.clickComponent('HitTestModeDefault') + await Utils.clickComponent('HitTestModeBlock') + await Utils.clickComponent('HitTestModeTransparent') + await Utils.clickComponent('HitTestModeNone') + await Utils.sleep(2000) + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentCustomEventTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentCustomEventTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c034ab10334918418c0fc0c57828924804653e80 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentCustomEventTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentCustomEventTest() { + + describe('CustomComponentCustomEventTest', () => { + + let PAGE_TAG1 = 'CustomComponentCustomEventTest'; + let PAGE_TAG2 = 'CustomComponentUnregisterCustomEventTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentCustomEvent001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG1}`, done); + }); + + it('testCustomComponentCustomEvent002', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG2}`, done); + }); + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetChildAtTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetChildAtTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..63d7767217d02d0bafd147129b6d9f895b2cbc28 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetChildAtTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentGetChildAtTest() { + + describe('CustomComponentGetChildAtTest', () => { + + let PAGE_TAG = 'CustomComponentGetChildAtTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentGetChildAt001', 0, async (done: Function) => { + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetFirstChildTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetFirstChildTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..21fe7b36ddf4e1f7d384f4eeaac6dd2cb653aa17 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetFirstChildTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentGetFirstChildTest() { + + describe('CustomComponentGetFirstChildTest', () => { + + let PAGE_TAG = 'CustomComponentGetFirstChildTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentGetFirstChild001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + }); + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetLastChildTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetLastChildTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..35a2539c57c929df7243736cbe75b5df77ce3837 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetLastChildTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentGetLastChildTest() { + + describe('CustomComponentGetLastChildTest', () => { + + let PAGE_TAG = 'CustomComponentGetLastChildTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentGetLastChild001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + }); + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetPreviousNextSiblingTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetPreviousNextSiblingTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d443d17ea0c3cc2e5823ced2252ca649b6b66e44 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetPreviousNextSiblingTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentGetPreviousNextSiblingTest() { + + describe('CustomComponentGetPreviousNextSiblingTest', () => { + + let PAGE_TAG = 'CustomComponentGetPreviousNextSiblingTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentGetPreviousNextSibling001', 0, async (done: Function) => { + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetTotalChildCountTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetTotalChildCountTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a5c9453132e68ae2d3d0f66c4c4a756fe97ed0d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentGetTotalChildCountTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentGetTotalChildCountTest() { + + describe('CustomComponentGetTotalChildCountTest', () => { + + let PAGE_TAG = 'CustomComponentGetTotalChildCountTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentGetTotalChildCount001', 0, async (done: Function) => { + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutAgainTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutAgainTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..717f35041dd58b0cc33993e6ed36985190b5597d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutAgainTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentLayoutAgainTest() { + + describe('CustomComponentLayoutAgainTest', () => { + + let PAGE_TAG = 'CustomComponentLayoutAgainTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentLayoutAgain001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutConstraintTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutConstraintTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..308b9e080bd75889df8f91dc1fc77f0452ed7c23 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutConstraintTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentLayoutConstraintTest() { + + describe('CustomComponentLayoutConstraintTest', () => { + + let PAGE_TAG = 'CustomComponentLayoutConstraintTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentLayoutConstraint001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutPositionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutPositionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1cd9faaebf9a442aa8cca12fc8968c1bbc2a100 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentLayoutPositionTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function CustomComponentLayoutPositionTest() { + + describe('CustomComponentLayoutPositionTest', () => { + + let PAGE_TAG = 'CustomComponentLayoutPositionTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentLayoutPosition001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentMeasureSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentMeasureSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..341db513cc4a3eda3f5a15d4b5afdcf93325c6e2 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomComponentMeasureSizeTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function customComponentMeasuredSizeTest() { + + describe('CustomComponentMeasuredSizeTest', () => { + let PAGE_TAG = 'CustomComponentMeasuredSizeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentMeasuredSize001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomcomponentDrawContextTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomcomponentDrawContextTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd68746bdca48a4877efdd1a1b3f4ff48af8ca72 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customcomponent/CustomcomponentDrawContextTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function customComponentDrawContextTest() { + +describe('CustomComponentDrawContextTest', () => { + + let PAGE_TAG = 'CustomComponentDrawContextTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomComponentDrawContextTest001', 0, async (done: Function) => { + await Utils.pushPage(`customcomponent/${PAGE_TAG}`, done); + }); +}) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customdialog/CustomDialogContentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customdialog/CustomDialogContentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecda5296b204de5267563a232697f73301737e7d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/customdialog/CustomDialogContentTest.test.ets @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@ohos.UiTest'; + +async function pressBack() { + let driver: Driver = Driver.create(); + await driver.pressBack(); +} + +export default function customDialogContentTest() { + + describe('CustomDialogContentTest', () => { + + let PAGE_TAG = 'CustomDialogContentTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testCustomDialogContent001', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button1"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent002', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button2"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent003', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button3"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent004', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button4"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent005', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button5"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent006', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button6"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent007', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button7"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent008', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button8"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent009', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button9"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent010', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button10"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent011', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button11"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent012', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button12"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent013', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button13"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent014', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button14"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent015', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button15"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent016', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button16"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent017', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button17"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent018', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button18"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent019', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button19"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent020', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button20"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent021', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button21"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent022', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button22"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent023', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button23"); + await Utils.sleep(2000); + await Utils.clickComponent("button23"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent024', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button24"); + await Utils.sleep(2000); + await Utils.clickComponent("button24"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent025', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button25"); + await Utils.sleep(2000); + await Utils.clickComponent("button25"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent026', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button26"); + await Utils.sleep(2000); + await Utils.clickComponent("button26"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent027', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button27"); + await Utils.sleep(2000); + await Utils.clickComponent("button27"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent028', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button28"); + await Utils.sleep(2000); + await Utils.clickComponent("button28"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent029', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button29"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent030', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button30"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent031', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button31"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent032', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button32"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent033', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button33"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent034', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button34"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent035', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button35"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent036', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button36"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent037', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button37"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent038', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button38"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent039', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button39"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent040', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button40"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent041', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button41"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent042', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button42"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent043', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button43"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent044', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button44"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent045', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button45"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent046', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button46"); + await Utils.sleep(2000); + await Utils.clickComponent("button46"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent047', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button47"); + await Utils.sleep(2000); + await Utils.clickComponent("button47"); + await Utils.sleep(20000); + done() + }) + + it('testCustomDialogContent048', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button48"); + await Utils.sleep(2000); + await Utils.clickComponent("button48"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent049', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button49"); + await Utils.sleep(2000); + await Utils.clickComponent("button49"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent050', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button50"); + await Utils.sleep(2000); + await Utils.clickComponent("button50"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent051', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button51"); + await Utils.sleep(2000); + await pressBack(); + await Utils.sleep(1000); + await pressBack(); + done() + }) + + it('testCustomDialogContent052', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button51"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent053', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button52"); + await Utils.sleep(2000); + await Utils.clickComponent("button1"); + await Utils.sleep(2000); + done() + }) + + it('testCustomDialogContent054', 0, async (done: Function) => { + await Utils.pushPage(`customdialog/${PAGE_TAG}`); + await Utils.clickComponent("button52"); + await Utils.sleep(2000); + await pressBack(); + await Utils.sleep(2000); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/eventcallback/EventCallbackTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/eventcallback/EventCallbackTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbde9baf7e5a16515812006a8b98ced6d14061a8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/eventcallback/EventCallbackTest.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function EventCallbackTest() { + + describe('EventCallbackTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // addNodeEventReceiver,removeNodeEventReceiver,registerNodeEvent,unregisterNodeEvent + it('testEventCallback001', 0, async (done: Function) => { + let PAGE_TAG = 'EventCallbackSpecifyNodeTest'; + await Utils.pushPage(`eventcallback/${PAGE_TAG}`, done); + await Utils.clickComponent('UnregisterAndRemove'); + await Utils.clickComponent('Remove'); + await Utils.clickComponent('Unregister'); + await Utils.sleep(2000) + }); + + // addNodeEventReceiver,removeNodeEventReceiver,registerNodeEvent,unregisterNodeEvent + it('testEventCallback002', 0, async (done: Function) => { + let PAGE_TAG = 'EventCallbackGlobalTest'; + await Utils.pushPage(`eventcallback/${PAGE_TAG}`, done); + await Utils.clickComponent('column'); + await Utils.clickComponent('text'); + await Utils.sleep(2000) + }); + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/flex/FlexOptinsTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/flex/FlexOptinsTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cbba6f3522e4522818c626ea023e3f6fac1f7121 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/flex/FlexOptinsTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function flexOptionsTest() { + + describe('FlexOptionsTest', () => { + + let PAGE_TAG = 'FlexOptionsTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testFlexOptions001', 0, async (done: Function) => { + await Utils.pushPage(`flex/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/gesture/GestureGestureTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/gesture/GestureGestureTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4331a82c95f54722e7f67dd954b8b04aa72ea99 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/gesture/GestureGestureTest.test.ets @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import { Driver, ON, PointerMatrix } from '@kit.TestKit'; +import { Point } from '@ohos.UiTest'; +import WindowSnap from '../common/Snap'; + +async function panGesture(id: string, x1: number, y1: number, x2: number, y2: number) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let rect = await refresh.getBounds(); + const p1: Point = { + x: rect.left + x1, + y: rect.top + y1 + }; + const p2: Point = { + x: rect.left + x2, + y: rect.top + y2 + }; + await driver.fling(p1, p2, 5, 200) +} + +async function pinchGesture(id: string) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let rect = await refresh.getBounds(); + let point: PointerMatrix = PointerMatrix.create(2, 4); + point.setPoint(0, 0, { x: rect.left + 50, y: rect.top + 50 }); + point.setPoint(0, 1, { x: rect.left + 40, y: rect.top + 40 }); + point.setPoint(0, 2, { x: rect.left + 30, y: rect.top + 30 }); + point.setPoint(0, 3, { x: rect.left + 20, y: rect.top + 20 }); + point.setPoint(1, 0, { x: rect.left + 60, y: rect.top + 60 }); + point.setPoint(1, 1, { x: rect.left + 70, y: rect.top + 70 }); + point.setPoint(1, 2, { x: rect.left + 80, y: rect.top + 80 }); + point.setPoint(1, 3, { x: rect.left + 90, y: rect.top + 90 }); + await driver.injectMultiPointerAction(point, 200); +} + +async function rotationGesture(id: string) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let rect = await refresh.getBounds(); + let point: PointerMatrix = PointerMatrix.create(2, 4); + point.setPoint(0, 0, { x: rect.left + 50, y: rect.top + 50 }); + point.setPoint(0, 1, { x: rect.left + 50, y: rect.top + 40 }); + point.setPoint(0, 2, { x: rect.left + 50, y: rect.top + 30 }); + point.setPoint(0, 3, { x: rect.left + 50, y: rect.top + 20 }); + point.setPoint(1, 0, { x: rect.left + 60, y: rect.top + 60 }); + point.setPoint(1, 1, { x: rect.left + 60, y: rect.top + 70 }); + point.setPoint(1, 2, { x: rect.left + 60, y: rect.top + 80 }); + point.setPoint(1, 3, { x: rect.left + 60, y: rect.top + 90 }); + await driver.injectMultiPointerAction(point, 200); +} + +export default function gestureGestureTest() { + + describe('GestureGestureTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testGestureGesture001', 0, async (done: Function) => { + let PAGE_TAG = 'GestureGestureTest'; + await Utils.pushPage(`gesture/${PAGE_TAG}`); + await Utils.clickComponent('button1') + await Utils.clickComponent('button2') + await Utils.clickComponent('button3') + await Utils.clickComponent('button4') + await Utils.longClickComponent('button5') + await Utils.longClickComponent('button6') + await Utils.longClickComponent('button7') + await Utils.longClickComponent('button8') + await Utils.sleep(600) + done(); + }) + + it('testGestureGesture002', 0, async (done: Function) => { + let PAGE_TAG = 'GestureGesture1Test'; + await Utils.pushPage(`gesture/${PAGE_TAG}`); + await panGesture('column1', 40, 40, 80, 40) + await panGesture('column2', 80, 40, 40, 40) + await panGesture('column3', 40, 40, 40, 80) + await panGesture('column4', 80, 40, 40, 40) + await panGesture('column5', 40, 40, 80, 40) + await panGesture('column6', 40, 80, 40, 40) + await panGesture('column7', 80, 40, 80, 80) + await panGesture('column8', 40, 40, 80, 40) + await panGesture('column9', 40, 40, 80, 40) + await panGesture('column10', 40, 40, 80, 40) + await panGesture('column11', 40, -5, 40, 105) + await panGesture('column12', 40, 40, 155, 40) + await Utils.sleep(600) + done(); + }) + + it('testGestureGesture003', 0, async (done: Function) => { + let PAGE_TAG = 'GestureGesture2Test'; + await Utils.pushPage(`gesture/${PAGE_TAG}`); + await pinchGesture('column1') + await pinchGesture('column2') + await pinchGesture('column3') + await rotationGesture('column4') + await rotationGesture('column5') + await rotationGesture('column6') + await rotationGesture('column7') + await rotationGesture('column8') + await Utils.sleep(600) + done(); + }) + + it('testGestureGesture004', 0, async (done: Function) => { + let PAGE_TAG = 'GestureGesture3Test'; + await Utils.pushPage(`gesture/${PAGE_TAG}`, ()=>{ + setTimeout(()=>{}, 1000) + }); + await panGesture('column1', 40, 40, 80, 40) + await panGesture('column2', 80, 40, 40, 40) + await panGesture('column3', 40, 40, 40, 80) + await panGesture('column4', 80, 40, 40, 40) + await panGesture('column5', 40, 40, 80, 40) + await panGesture('column6', 40, 80, 40, 40) + await panGesture('column7', 80, 40, 80, 80) + await panGesture('column8', 40, 40, 80, 40) + await panGesture('column9', 40, 40, 40, 80) + await panGesture('column10', 40, 40, 80, 40) + await panGesture('column11', 40, -5, 40, 105) + await panGesture('column12', 40, 40, 155, 40) + Utils.sleep(1000) + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/grid/GridTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/grid/GridTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..af4dc8f71c760a2e88c76aef75ab8f3fe633f2b3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/grid/GridTest.test.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@ohos.UiTest'; + +export default function gridTest() { + + describe('GridTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + //Grid组件测试 + // NODE_GRID_COLUMN_TEMPLATE + // NODE_GRID_ROW_TEMPLATE + // NODE_GRID_COLUMN_GAP + // NODE_GRID_ROW_GAP + // NODE_GRID_NODE_ADAPTER + it('testGrid001', 0, async (done: Function) => { + let PAGE_TAG = 'GridTest'; + await Utils.pushPage(`grid/${PAGE_TAG}`); + let driver = Driver.create(); + await Utils.sleep(1000); + let component = await driver.findComponent(ON.id("grid1")); + let point = await component.getBounds(); + await driver.swipe(point.left + 20, point.bottom - 10, point.left + 20, point.top - 300, 40000); + await Utils.sleep(2000); + component = await driver.findComponent(ON.id("grid2")); + point = await component.getBounds(); + await driver.swipe(point.right - 20, point.bottom - 20, point.left + 100, point.bottom - 20, 40000); + await Utils.sleep(3000) + done(); + }); + + // NODE_GRID_CACHED_COUNT + it('testGrid002', 0, async (done: Function) => { + let PAGE_TAG = 'GridCachedCountTest'; + await Utils.pushPage(`grid/${PAGE_TAG}`); + await Utils.clickComponent('gridClick'); + let driver = Driver.create(); + await Utils.sleep(1000); + let component = await driver.findComponent(ON.id("gridCachedCount1")); + let point = await component.getBounds(); + await driver.drag(point.right - 20, point.bottom - 20, point.left + 100 , point.bottom - 20, 40000); + await Utils.sleep(1000); + component = await driver.findComponent(ON.id("gridCachedCount2")); + point = await component.getBounds(); + await driver.drag(point.left + 20, point.bottom - 10, point.left + 20 , point.bottom - 200, 4000); + await Utils.sleep(1000); + component = await driver.findComponent(ON.id("gridCachedCount3")); + point = await component.getBounds(); + await driver.drag(point.right, point.bottom - 20, point.left - 20 , point.bottom - 20, 40000); + await Utils.sleep(3000) + done(); + }); + + // Reset Grid的属性: NODE_GRID_COLUMN_TEMPLATE, NODE_GRID_ROW_TEMPLATE,NODE_GRID_COLUMN_GAP, NODE_GRID_ROW_GAP + it('testGrid003', 0, async (done: Function) => { + let PAGE_TAG = 'GridResetAttributeTest'; + await Utils.pushPage(`grid/${PAGE_TAG}`); + await Utils.clickComponent('GridReset'); + await Utils.sleep(2000) + done(); + }); + }) +} + diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageDraggableTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageDraggableTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1ceebaa93f9b7f569b138e952c512347aa3a959 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageDraggableTest.test.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Component, Driver, ON } from '@ohos.UiTest'; + +export default function imageDraggableTest() { + + describe('ImageDraggableTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * Image组件draggable设置为true时可拖动的效果测试 + * Image组件draggable设置为false时不可拖动的效果测试 + */ + it('testImageDraggable001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageDraggableTest'; + await Utils.pushPage(`image/${PAGE_TAG}`); + let driver: Driver = Driver.create(); + await Utils.sleep(1000); + let imageTrue: Component = await driver.findComponent(ON.id('imageDragTrue')); + let dropTrue: Component = await driver.findComponent(ON.id('dropImageAreaTrue')); + await imageTrue.dragTo(dropTrue); + await Utils.sleep(1000); + let imageFalse: Component = await driver.findComponent(ON.id('imageDragFalse')); + let dropFalse: Component = await driver.findComponent(ON.id('dropImageAreaFalse')); + await imageFalse.dragTo(dropFalse); + await Utils.sleep(1000); + let imageReset: Component = await driver.findComponent(ON.id('imageDragReset')); + let dropReset: Component = await driver.findComponent(ON.id('dropImageAreaReset')); + await imageReset.dragTo(dropReset); + await Utils.sleep(2000); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageFillColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageFillColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..76ea456bc409b62cce51374e3f05f72932d2ddd1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageFillColorTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageFillColorTest() { + + describe('ImageFillColorTest', () => { + + let PAGE_TAG = 'ImageFillColorTest'; + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * 设置Image组件fillcolor属性时的效果测试 + * Image组件fillcolor属性设置Reset后的属性测试效果 + */ + it('testImageFillColor001', 0, async (done: Function) => { + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.clickComponent('resetFillColor'); + await Utils.sleep(2000); + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageFitOriginalSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageFitOriginalSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e71906880be8157fdd535f24fa45c7a897dea81 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageFitOriginalSizeTest.test.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageFitOriginalSizeTest() { + + describe('ImageFitOriginalSizeTest', () => { + + let PAGE_TAG = 'ImageFitOriginalSizeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * Image组件fitOriginalSize属性设置为1时的效果测试 + * Image组件fitOriginalSize属性设置为0时的效果测试 + * Image组件fitOriginalSize属性设置为1后Reset该属性的效果 + * Image组件fitOriginalSize属性设置为异常值-1时的效果测试 + */ + it('testImageFitOriginalSize001', 0, async (done: Function) => { + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.clickComponent('resetFitOriginalSize'); + await Utils.sleep(2000); + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageObjectFitTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageObjectFitTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..95a1bdd7c2b6e23d1054e6a44cc41b0b742c011f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageObjectFitTest.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@ohos.UiTest'; + +export default function imageObjectFitTest() { + + describe('ImageObjectFitTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * Image组件ObjectFit属性设置为ArkUI_ObjectFit枚举值时的效果测试 + */ + it('testImageObjectFit001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageObjectFitTest'; + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.sleep(1000); + done() + }) + /* + * Image组件ObjectFit属性设置为reset时的效果测试 + * Image组件ObjectFit属性设置为-1时的效果测试 + */ + it('testImageObjectFit002', 0, async (done: Function) => { + let PAGE_TAG = 'ImageObjectFitResetAndAbnormalTest'; + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.clickComponent('resetObjectFit'); + await Utils.sleep(2000); + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageOnDownloadProgressTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageOnDownloadProgressTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d47553a19ed287780c21ebf6d7b2c15bb8a0667 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageOnDownloadProgressTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@ohos.UiTest'; + +export default function imageOnDownloadProgressTest() { + + describe('ImageOnDownloadProgressTest', () => { + + let PAGE_TAG = 'ImageOnDownloadProgressTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * Image组件onDownloadProgress回调时的效果测试 + */ + it('testOnDownloadProgress001', 0, async (done: Function) => { + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.sleep(5000); + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageOnfinishTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageOnfinishTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7aebab50de17c05404456f2a0863089eee84dc6a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageOnfinishTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageOnfinishTest() { + + describe('ImageOnfinishTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * Image组件Onfinish回调,加载svg图片动画一直循环, 收不到Onfinish回调 + * Image组件Onfinish回调,加载svg图片动画5秒后停止, 可以收到Onfinish回调 + */ + it('testImageOnfinish001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageOnfinishTest'; + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.sleep(6000); + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageRenderModeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageRenderModeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a167cd4405f76c41a7895661f5f5bdeb0328cd03 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageRenderModeTest.test.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@ohos.UiTest'; + +export default function ImageRenderModeTest() { + + describe('ImageRenderModeTest', () => { + let PAGE_TAG = 'ImageRenderModeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + /* + * Image组件renderMode属性设置为ARKUI_IMAGE_RENDER_MODE_ORIGINAL时的效果测试 + * Image组件renderMode属性设置为ARKUI_IMAGE_RENDER_MODE_TEMPLATE时的效果测试 + * Image组件renderMode属性设置为ARKUI_IMAGE_RENDER_MODE_TEMPLATE后Reset该属性的效果 + * Image组件renderMode属性设置为异常值-1时的效果测试 + */ + it('testImageRenderMode001', 0, async (done: Function) => { + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.clickComponent('resetRenderMode'); + await Utils.sleep(2000); + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageResizableTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageResizableTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc3fdd665a5d2f1859cf13c2aa28709ed973de50 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageResizableTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageResizableTest() { + + describe('ImageResizableTest', () => { + + let PAGE_TAG = 'ImageResizableTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + /* + * Image组件Resizable参数设置正常值及异常值的显示效果 + */ + it('testImageResizable001', 0, async (done: Function) => { + await Utils.pushPage(`image/${PAGE_TAG}`); + await Utils.clickComponent("ImageResizableReset"); + await Utils.sleep(2000) + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageSrcTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageSrcTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..242a0f62c322436287c3b62aa93e9632d3bcdf8d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/image/ImageSrcTest.test.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageSrcTest() { + + describe('ImageSrcTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + /* + * Image组件src参数设置为./resources/base/media/icon.png时的显示效果测试 + * Image组件src参数设置为./resources/base/media/src.jpg时的显示效果测试 + * Image组件src参数设置为""时的显示效果测试 + * Image组件src参数设置为错误路径时的显示效果测试 + * Image组件src参数设置为https://gitee.com/openharmony/docs/raw/master/zh-cn/application-dev/ + * reference/apis-arkui/arkui-ts/figures/edgewidths.png时的显示效果测试 + */ + it('testImageSrc001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageSrcTest'; + await Utils.pushPage(`image/${PAGE_TAG}`, done); + done() + }) + /* + * Image组件src参数设置为pixmap时的显示效果测试 + * Image组件src参数设置为pixelmap数组时的显示效果测试 + * Image组件src参数设置为nullptr数组时的显示效果测试 + */ + it('testImageSrc002', 0, async (done: Function) => { + let PAGE_TAG = 'ImagePixelMapSrcTest'; + await Utils.pushPage(`image/${PAGE_TAG}`); + Utils.sleep(2000) + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imageanimator/ImageAnimatorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imageanimator/ImageAnimatorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4df16db99f1f34849ff477e1ad3982bb7f6d3282 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imageanimator/ImageAnimatorTest.test.ets @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@ohos.UiTest'; + +async function doIt(done: Function) { + await Utils.sleep(2000) + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(1000) + done() +} + +export default function imageAnimatorTest() { + describe('ImageAnimatorTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // ImageAnimator组件state属性设置正常值、异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_INITIAL, + // ARKUI_ANIMATION_STATUS_RUNNING, + // ARKUI_ANIMATION_STATUS_PAUSED, + // ARKUI_ANIMATION_STATUS_STOPPED, + // -1, + // 4 + // NODE_IMAGE_ANIMATOR_IMAGES:输入5张图片, width:300, height:100, left:10, top:30, duration:3000 + // NODE_IMAGE_ANIMATOR_ITERATION:1 + // NODE_IMAGE_ANIMATOR_FIXED_SIZE: false + // NODE_IMAGE_ANIMATOR_REVERSE: false + // NODE_IMAGE_ANIMATOR_FILL_MODE:ARKUI_ANIMATION_FILL_MODE_FORWARDS + it('testImageAnimator001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件duration属性设置正常值、异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_DURATION:3000, 0, -5 + // NODE_IMAGE_ANIMATOR_IMAGES:输入5张图片, width:300, height:300, left:10, top:30 + // NODE_IMAGE_ANIMATOR_ITERATION: -1 + // NODE_IMAGE_ANIMATOR_FIXED_SIZE: true + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + // 组件宽度:200,高度:100 + it('testImageAnimator002', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorDurationTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件reverse属性设置正常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_REVERSE: true, false + // NODE_IMAGE_ANIMATOR_IMAGES:输入5张图片, width:300, height:300, left:10, top:30, duration:3000 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + // NODE_IMAGE_ANIMATOR_FILL_MODE:ARKUI_ANIMATION_FILL_MODE_FORWARDS, ARKUI_ANIMATION_FILL_MODE_BACKWARDS + it('testImageAnimator003', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorReverseTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件fixedSize属性设置正常值、异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_FIXED_SIZE: false, true + // NODE_IMAGE_ANIMATOR_IMAGES:输入5张图片, width:300, height:300, left:10, top:30, duration:1000 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + // 组件宽度:200,高度:100 + it('testImageAnimator004', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorFixedSizeTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件fillMode属性设置正常值、异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_FILL_MODE:ARKUI_ANIMATION_FILL_MODE_NONE, + // ARKUI_ANIMATION_FILL_MODE_FORWARDS, + // ARKUI_ANIMATION_FILL_MODE_BACKWARDS, + // ARKUI_ANIMATION_FILL_MODE_BOTH, + // -1, + // 4 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + // NODE_IMAGE_ANIMATOR_FIXED_SIZE: false + // NODE_IMAGE_ANIMATOR_IMAGES:输入5张图片, width:300, height:100, left:10, top:30, duration:1000 + it('testImageAnimator005', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorFillModeTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件iterations属性设置正常值、异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_IMAGES:输入5张图片, width:300, height:100, left:10, top:30, duration:3000 + // NODE_IMAGE_ANIMATOR_ITERATION: -5, 0, -1 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + it('testImageAnimator006', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorIterationsTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件reset fillMode, fixedSize, iteration属性显示结果测试 + // 触发Button组件onClick事件,事件内处理reset属性值 + it('testImageAnimator007', 0, async (done: Function) => { + let PAGE_TAG = 'ImageAnimatorResetAttributeTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await Utils.clickComponent("ResetImageAnimator"); + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(5000) + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imageanimator/ImageFrameInfoTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imageanimator/ImageFrameInfoTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cbc1dc058f7b1e04dd33d162164119d32c031d29 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imageanimator/ImageFrameInfoTest.test.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@ohos.UiTest'; + +async function doIt(done: Function) { + await Utils.sleep(2000) + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(1000) + done() +} + +export default function imageFrameInfoTest() { + + describe('ImageFrameInfoTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // ImageAnimator组件ImageFrameInfo的src,width, height, left, top,duration设置正常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_IMAGES:输入3张图片 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + it('testImageFrameInfo001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageFrameInfoTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件ImageFrameInfo的src,width, height, left, top,duration设置异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_IMAGES:输入3张图片 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + it('testImageFrameInfo002', 0, async (done: Function) => { + let PAGE_TAG = 'ImageFrameInfoAbnormalTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件ImageFrameInfo:src(drawable), width, height, left, top,duration设置正常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_IMAGES:输入3张图片 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + it('testImageFrameInfo003', 0, async (done: Function) => { + let PAGE_TAG = 'ImageFrameInfoDrawableTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + + // ImageAnimator组件ImageFrameInfo:src(drawable), width, height, left, top,duration设置异常值的显示效果测试 + // NODE_IMAGE_ANIMATOR_IMAGES:输入3张图片 + // NODE_IMAGE_ANIMATOR_STATE:ARKUI_ANIMATION_STATUS_RUNNING + it('testImageFrameInfo004', 0, async (done: Function) => { + let PAGE_TAG = 'ImageFrameInfoDrawableAbnormalTest'; + await Utils.pushPage(`imageanimator/${PAGE_TAG}`); + await doIt(done); + await Utils.sleep(2000); + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imagespan/ImageSpanAltAndOnClickTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imagespan/ImageSpanAltAndOnClickTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..01ad8fac1965b4f69dcebd80034825dc0607c965 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imagespan/ImageSpanAltAndOnClickTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageSpanAltAndOnClickTest() { + + describe('ImageSpanAltAndOnClickTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + /* + * Image组件设置Alt参数设置为字符串时的显示效果测试 + * Image组件点击设置回调的显示效果测试 + */ + it('testImageSpanAltAndOnClick001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageSpanAltAndOnClickTest'; + await Utils.pushPage(`imagespan/${PAGE_TAG}`); + await Utils.clickComponent('imageSpanClick'); + await Utils.sleep(2000); + done(); + }); + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imagespan/ImageSpanSrcTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imagespan/ImageSpanSrcTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d958445e9e9b64f9ad74a462cb2ce9dfce9b731c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/imagespan/ImageSpanSrcTest.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function imageSpanSrcTest() { + + describe('ImageSpanSrcTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + /* + * Image组件src参数设置为字符串时的显示效果测试 + */ + it('testImageSpanSrc001', 0, async (done: Function) => { + let PAGE_TAG = 'ImageSpanSrcTest'; + await Utils.pushPage(`imagespan/${PAGE_TAG}`); + await Utils.sleep(7000); + done(); + }); + + /* + * Image组件src参数设置为pixmap时的显示效果测试 + * Image组件src参数设置为pixelmap数组时的显示效果测试 + * Image组件src参数设置为nullptr数组时的显示效果测试 + */ + it('testImageSpanSrc002', 0, async (done: Function) => { + let PAGE_TAG = 'ImageSpanPixelMapSrcTest'; + await Utils.pushPage(`imagespan/${PAGE_TAG}`); + await Utils.sleep(2000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/inputevent/InputEventTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/inputevent/InputEventTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e356b0686d5527382437baaa15559969f9993cd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/inputevent/InputEventTest.test.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON, PointerMatrix, Rect,MouseButton } from '@ohos.UiTest'; + +export default function InputEventTest() { + + describe('InputEventTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testInputEvent001', 0, async (done: Function) => { + let PAGE_TAG = 'InputEventTest'; + await Utils.pushPage(`inputevent/${PAGE_TAG}`); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('buttonMouse')); + let point = await button.getBounds(); + await driver.mouseClick({x:point.left+10, y:point.top+10}, MouseButton.MOUSE_BUTTON_RIGHT); + + let rect = Utils.getComponentRect("textTouch"); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X = centerX + 20; + let Y = centerY + 20; + let pointers: PointerMatrix = PointerMatrix.create(2,2); + pointers.setPoint(0,0,{x: Math.round(X),y: Math.round(Y)}); + pointers.setPoint(0,1,{x: Math.round(Y),y: Math.round(Y + vp2px(20))}); + pointers.setPoint(1,0,{x: Math.round(X),y: Math.round(Y)}); + pointers.setPoint(1,1,{x: Math.round(X),y: Math.round(Y + vp2px(20))}); + await driver.injectMultiPointerAction(pointers); + await Utils.sleep(2000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/lazyforeach/LazyForEachTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/lazyforeach/LazyForEachTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f83cb2ea8211ffd24d14ccbcf684f40094e4e3e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/lazyforeach/LazyForEachTest.test.ets @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +async function flingComponentV(key: string, isForward: boolean, speed: number = 500, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let Y1 = centerY - distance; + let Y2 = centerY + distance; + let stepLen = 20; + if (isForward) { + await driver.fling({ + x: centerX, y: Y2 + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: Y1 + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } +} +async function flingComponentH(key: string, isLeft: boolean, speed: number = 500, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X1 = centerX - distance; + let X2 = centerX + distance; + let stepLen = 20; + if (isLeft) { + await driver.fling({ + x: X2, y: centerY + }, { + x: X1, y: centerY + }, stepLen, speed); + } else { + await driver.fling({ + x: X1, y: centerY + }, { + x: X2, y: centerY + }, stepLen, speed); + } +} +export default function lazyForEachTest() { + + describe('LazyForEachTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + it('testLazyForEachGetAllItem001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachGetAllItemTest`, done); + await Utils.clickComponent("btn1") + await Utils.flingComponent("col1", false, true) + done(); + }); + it('testLazyForEachUnregister001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachUnregisterTest`, done); + done(); + }); + it('testLazyForEachTotalCount001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachTotalCountTest`, done); + done(); + }); + it('testLazyForEachNodeId001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachNodeIdTest`, done); + done(); + }); + it('testLazyForEachDispose001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachDisposeTest`, done); + done(); + }); + it('testLazyForEachHostNode001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachHostNodeTest`, done); + done(); + }); + it('testLazyForEachReloadAllItems001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachReloadAllItemsTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn"); + await flingComponentV("col1", true, 40000, 40) + await flingComponentV("col2", true, 40000, 40) + await flingComponentV("col3", true, 40000, 40) + done(); + }); + it('testLazyForEachReloadItem001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachReloadItemTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachReloadItem002', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachReloadItemBigTest`, ()=>{ + setTimeout(()=>{}, 3000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachRemoveItem001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachRemoveItemTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachRemoveItem002', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachRemoveItemBigTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachInsertItem001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachInsertItemTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachInsertItem002', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachInsertItemBigTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachMoveItem001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachMoveItemTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachMoveItem002', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachMoveItemBigTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + it('testLazyForEachGetRemovedNode001', 0, async (done: Function) => { + await Utils.pushPage(`lazyforeach/LazyForEachGetRemovedNodeTest`, ()=>{ + setTimeout(()=>{}, 30000) + }); + await Utils.clickComponent("btn1"); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListChildrenMainSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListChildrenMainSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae658f5587a846acd6c75953958fb7bce1ca0d4b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListChildrenMainSizeTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listChildrenMainSizeTest() { + + describe('ListChildrenMainSizeTest', () => { + + let PAGE_TAG = 'ListChildrenMainSizeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listChildrenMainSizeTest001', 0, async (done: Function) => { + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.clickComponent("button1"); + await Utils.clickComponent("button2"); + await Utils.clickComponent("button3"); + await Utils.sleep(1000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListCloseAllTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListCloseAllTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..944026572b0dbf8408ca856336426058b768c879 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListCloseAllTest.test.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +async function flingComponentV(key: string, isForward: boolean, speed: number = 10, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let Y1 = centerY - distance; + let Y2 = centerY + distance; + let stepLen = 20; + if (isForward) { + await driver.fling({ + x: centerX, y: centerY + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: centerY + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } +} + +async function flingComponentH(key: string, isLeft: boolean, speed: number = 10, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X1 = centerX - distance; + let X2 = centerX + distance; + let stepLen = 20; + if (isLeft) { + await driver.fling({ + x: centerX, y: centerY + }, { + x: X1, y: centerY + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: centerY + }, { + x: X2, y: centerY + }, stepLen, speed); + } +} + +export default function listCloseAllTest() { + + describe('ListCloseAllTest', () => { + + let PAGE_TAG = 'ListCloseAllTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listCloseAllTest001', 0, async (done: Function) => { + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(2000); + await flingComponentH("list1", true, 20000, 100); + await flingComponentV("list2", true, 2000, 100); + await flingComponentV("list3", true, 2000, 100); + await Utils.clickComponent("callbackButton1"); + await Utils.clickComponent("callbackButton2"); + await Utils.clickComponent("nullCallbackButton3"); + await Utils.sleep(2000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListDividerAndInitialIndexTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListDividerAndInitialIndexTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5062666e2fe5f5a6dde15a2c7ea1cc513a7bcbc9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListDividerAndInitialIndexTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listDividerAndInitialIndexTest() { + + describe('ListDividerAndInitialIndexTest', () => { + + let PAGE_TAG = 'ListDividerAndInitialIndexTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listDividerAndInitialIndexTest001', 0, async (done: Function) => { + await Utils.pushPage(`list/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListNestedScrollTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListNestedScrollTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5542a9257b2c699b379ddcd90be56192a3d8b116 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListNestedScrollTest.test.ets @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +async function flingComponentV(key: string, isForward: boolean, speed: number = 500, distance: number = 40) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let Y1 = centerY - distance; + let Y2 = centerY + distance; + let stepLen = 20; + if (isForward) { + await driver.fling({ + x: centerX, y: Y2 + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: Y1 + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } +} + +async function flingComponentH(key: string, isLeft: boolean, speed: number = 10, distance: number = 40) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X1 = centerX - distance; + let X2 = centerX + distance; + let stepLen = 20; + if (isLeft) { + await driver.fling({ + x: centerX, y: centerY + }, { + x: X1, y: centerY + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: centerY + }, { + x: X2, y: centerY + }, stepLen, speed); + } +} +export default function listNestedScrollTest() { + + describe('ListNestedScrollTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listNestedScrollTest001', 0, async (done: Function) => { + let PAGE_TAG = 'ListNestedScrollTest'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(2000); + await flingComponentV("scroll1", true, 40000) + await flingComponentV("scroll2", true, 40000) + await flingComponentV("scroll3", true, 40000) + await flingComponentV("scroll4", true, 40000) + await flingComponentV("scroll5", true, 40000) + await flingComponentV("scroll6", true, 40000) + await flingComponentH("scroll7", true, 40000) + await flingComponentH("scroll8", true, 40000) + await flingComponentH("scroll9", true, 40000) + await flingComponentH("scroll10", true, 40000) + await flingComponentH("scroll11", true, 40000) + await flingComponentH("scroll12", true, 40000) + await Utils.sleep(5000); + done(); + }); + + it('listNestedScrollTest002', 0, async (done: Function) => { + let PAGE_TAG = 'ListNestedScrollSmallTest'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(2000); + await flingComponentV("scroll1", true, 40000) + await flingComponentV("scroll2", true, 40000) + await flingComponentV("scroll3", true, 40000) + await flingComponentV("scroll4", true, 40000) + await flingComponentV("scroll5", true, 40000) + await flingComponentV("scroll6", true, 40000) + await flingComponentH("scroll7", true, 40000) + await flingComponentH("scroll8", true, 40000) + await flingComponentH("scroll9", true, 40000) + await flingComponentH("scroll10", true, 40000) + await flingComponentH("scroll11", true, 40000) + await flingComponentH("scroll12", true, 40000) + await Utils.sleep(5000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListScrollBarTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListScrollBarTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f96656910d4d09c507781eea8c4b6d1096e96947 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListScrollBarTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listScrollBarTest() { + + describe('ListScrollBarTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + //scrollBar 宽度和颜色 + it('listScrollBarTest001', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollBarWidthAndColorTest'; + await Utils.pushPage(`list/${PAGE_TAG}`, done); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListScrollTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListScrollTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8e9cc6e455b3d1290f7f84636315c1bd97a32e4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListScrollTest.test.ets @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listScrollTest() { + + describe('ListScrollTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + //scrollBy + it('listScrollTest001', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollByTest'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(2500); + done() + }) + + //scrollEdge + it('listScrollTest002', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollEdgeTest'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(1500); + done() + }) + + //scrollOffset2 + it('listScrollTest003', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollOffset2Test'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(1500); + done() + }) + + //scrollOffset6 + it('listScrollTest004', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollOffset6Test'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.clickComponent("btn"); + await Utils.sleep(1500); + done() + }) + + //scrollPage + it('listScrollTest005', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollPageTest'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.clickComponent("btn"); + await Utils.sleep(10000); + done() + }) + + //scrollToIndex + it('listScrollTest006', 0, async (done: Function) => { + let PAGE_TAG = 'ListScrollToIndexTest'; + await Utils.pushPage(`list/${PAGE_TAG}`); + await Utils.sleep(1000); + await Utils.clickComponent("btn"); + await Utils.sleep(5000); + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListSpaceAndAlignmentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListSpaceAndAlignmentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..08f113a68dd82d03697e58649a00ff6ee0457600 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/list/ListSpaceAndAlignmentTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listSpaceAndAlignmentTest() { + + describe('ListSpaceAndAlignmentTest', () => { + + let PAGE_TAG = 'ListSpaceAndAlignmentTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listSpaceAndAlignmentTest001', 0, async (done: Function) => { + await Utils.pushPage(`list/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/listitemgroup/ListItemGroupDividerTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/listitemgroup/ListItemGroupDividerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a56cf841faa3a8458cdaad37005f131d64bd7ed --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/listitemgroup/ListItemGroupDividerTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listItemGroupDividerTest() { + + describe('ListItemGroupDividerTest', () => { + + let PAGE_TAG = 'ListItemGroupDividerTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listItemGroupDividerTest001', 0, async (done: Function) => { + await Utils.pushPage(`listitemgroup/${PAGE_TAG}`); + await Utils.sleep(3000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/listitemgroup/ListItemGroupHeaderAndFooterTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/listitemgroup/ListItemGroupHeaderAndFooterTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e060e39d511c2430b270a854ab94ba8673d859e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/listitemgroup/ListItemGroupHeaderAndFooterTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function listItemGroupHeaderAndFooterTest() { + + describe('ListItemGroupHeaderAndFooterTest', () => { + + let PAGE_TAG = 'ListItemGroupHeaderAndFooterTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('listItemGroupHeaderAndFooterTest001', 0, async (done: Function) => { + await Utils.pushPage(`listitemgroup/${PAGE_TAG}`); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/mix/MixGetNodeHandleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/mix/MixGetNodeHandleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1718a565c937ae4819c5b25930eff3adb3befca --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/mix/MixGetNodeHandleTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function mixGetNodeHandleTest() { + + describe('MixGetNodeHandleTest', () => { + + let PAGE_TAG = 'MixGetNodeHandleTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testMixGetNodeHandle001', 0, async (done: Function) => { + await Utils.pushPage(`mix/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/nodetree/NodeTreeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/nodetree/NodeTreeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..55b4f0f219572bc1e15a370a57ac6997a51bd7bc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/nodetree/NodeTreeTest.test.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function NodeTreeTest() { + + describe('NodeTreeTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // InsertChildAt + // insertChildAfter + // insertChildBefore + // disposeNode + // getParent + it('testNodeTree001', 0, async (done: Function) => { + let PAGE_TAG = 'NodeTreeInsertTest'; + await Utils.pushPage(`nodetree/${PAGE_TAG}`); + await Utils.clickComponent('InsertChild'); + await Utils.clickComponent('DisposeNode'); + await Utils.sleep(3000); + done(); + }); + // OH_NativeXComponent_AttachNativeRootNode + // OH_NativeXComponent_DetachNativeRootNode + it('testNodeTree002', 0, async (done: Function) => { + let PAGE_TAG = 'NodeTreeXComponentTest'; + await Utils.pushPage(`nodetree/${PAGE_TAG}`); + await Utils.clickComponent('DetachNativeRootNode'); + await Utils.sleep(3000); + done(); + }); + // removeAllChildren + it('testNodeTree003', 0, async (done: Function) => { + let PAGE_TAG = 'NodeTreeRemoveTest'; + await Utils.pushPage(`nodetree/${PAGE_TAG}`); + await Utils.clickComponent('RemoveAllChild'); + await Utils.sleep(2000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/progress/ProgressTypeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/progress/ProgressTypeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b049ece85052cf6fb24d95510c846208dbb6a087 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/progress/ProgressTypeTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function progressTypeTest() { + + describe('ProgressTypeTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testProgressType001', 0, async (done: Function) => { + let PAGE_TAG = 'ProgressTypeTest'; + await Utils.pushPage(`progress/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/progress/ProgressValueAndTotalTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/progress/ProgressValueAndTotalTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0e6db6e3f6bad33ae840046fed2fe35bbc07177 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/progress/ProgressValueAndTotalTest.test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function progressValueAndTotalTest() { + describe('ProgressValueAndTotalTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testProgressValueAndTotal001', 0, async (done: Function) => { + let PAGE_TAG = 'ProgressValueAndTotalTest'; + await Utils.pushPage(`progress/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/radio/RadioTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/radio/RadioTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ee04ab4b94b386e876b21201d76be9bb9902916 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/radio/RadioTest.test.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function radioTest() { + + describe('RadioTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + //Radio组件Check属性分别设置为true、false时的显示效果测试。 默认值:false + it('testRadio001', 0, async (done: Function) => { + let PAGE_TAG = 'RadioCheckedTest'; + await Utils.pushPage(`radio/${PAGE_TAG}`, done); + }); + //Radio组件Style属性设置显示效果测试。 + it('testRadio002', 0, async (done: Function) => { + let PAGE_TAG = 'RadioStyleTest'; + await Utils.pushPage(`radio/${PAGE_TAG}`, done); + }); + //Radio组设置Value和Group + it('testRadio003', 0, async (done: Function) => { + let PAGE_TAG = 'RadioValueAndGroupTest'; + await Utils.pushPage(`radio/${PAGE_TAG}`, done); + }); + //Radio组件OnChange回调函数测试 + it('testRadio004', 0, async (done: Function) => { + let PAGE_TAG = 'RadioValueAndGroupTest'; + await Utils.pushPage(`radio/${PAGE_TAG}`); + await Utils.clickComponent('radioOnChange') + await Utils.sleep(2000); + done(); + }); + //Radio组件测试Reset以下属性:checked, radioStyle,value,group + it('testRadio005', 0, async (done: Function) => { + let PAGE_TAG = 'RadioResetAttributeTest'; + await Utils.pushPage(`radio/${PAGE_TAG}`); + await Utils.clickComponent('ResetRadio') + await Utils.sleep(3000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/refresh/RefreshTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/refresh/RefreshTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ad6b202eb9c1955a89bccbe5894e7b6ec54da89 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/refresh/RefreshTest.test.ets @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; + +async function doIt(id: string, done: Function, speed: number = 400, x = 100, y = 300) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.swipe(point.left + x, point.bottom - x, point.left + x, point.bottom + y , speed); + await WindowSnap.snapShot(globalThis.context, 'test'); + await Utils.sleep(3000); +} +async function doItNext(id: string, done: Function, speed: number = 400, x = 100, y = 300) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.swipe(point.left + x, point.bottom - x, point.left + x, point.bottom + y , speed); + await WindowSnap.snapShotNext(globalThis.context, 'test'); + await Utils.sleep(3000); +} + +export default function refreshTest() { + + describe('RefreshTest', () => { + afterEach(async (done: Function) => { + // WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(500) + done() + }) + + // Refresh设置NODE_REFRESH_REFRESHING + // NODE_REFRESH_OFFSET:20 + // NODE_REFRESH_PULL_TO_REFRESH:1 + // 能够刷新,对应radio组件从选中状态变到非选中状态 + it('testRefresh001', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshPullToRefreshTrueTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`); + await doIt('refresh', done, 10000); + done() + }) + // Refresh设置NODE_REFRESH_REFRESHING + // NODE_REFRESH_OFFSET:20 + // NODE_REFRESH_PULL_TO_REFRESH:0 + // 不能刷新,对应radio组件仍然是选中状态 + it('testRefresh002', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshPullToRefreshFalseTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`); + await doIt('refresh', done, 40000); + done() + }) + // Refresh设置NODE_REFRESH_REFRESHING + // NODE_REFRESH_OFFSET:-100 + // NODE_REFRESH_PULL_TO_REFRESH:-1 + // 能够刷新,对应radio组件从选中状态变到非选中状态 + it('testRefresh003', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshPullToRefreshAbnormalTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await doIt('refresh', done, 40000); + done() + }) + + // Refresh设置NODE_REFRESH_REFRESHING + // NODE_REFRESH_OFFSET:800 + // NODE_REFRESH_PULL_TO_REFRESH:1 + // 不能刷新,对应radio组件仍然是选中状态 + it('testRefresh004', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshPullToRefreshTrueAbnormalTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await doIt('refresh', done, 10000); + await Utils.sleep(2000) + done() + }) + + // Refresh组件设置 NODE_REFRESH_CONTENT:自定义component + // NODE_REFRESH_PULL_DOWN_RATIO:0.3 + // 动画工程看护 + it('testRefresh005', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshForContentAndRatioTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + doItNext('RefreshContent', done, 3000); + await Utils.sleep(2000) + done() + }) + // Refresh组件设置 NODE_REFRESH_CONTENT:自定义component + // NODE_REFRESH_PULL_DOWN_RATIO:-1 + // 由动画工程看护 + it('testRefresh006', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshForContentAndRatioAbnormalTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`,() => setTimeout(() => { + }, 12000)); + doItNext('RefreshContent', done, 2000); + await Utils.sleep(5000) + done() + }) + // Refresh测试refresing属性,在onRefresh回调中设置NODE_REFRESH_REFRESHING为0, 结束刷新状态 + // Refresh组件测试onOffsetChange回调函数,在回调中设置背景颜色变成黄色 + it('testRefresh007', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshForRefreshingTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await doIt('refresh', done, 40000); + await Utils.sleep(5000) + done() + }) + // Refresh组件中方式嵌套滚动组件,正常刷新 + it('testRefresh008', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshNestedScrollTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`); + await Utils.sleep(1000) + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id('refreshNested')); + let point = await refresh.getBounds(); + await driver.swipe(point.left + 20, point.bottom - 300, point.left + 20, point.bottom + 300, 10000); + await Utils.sleep(2000) + await WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(1000) + done() + }) + // Refresh组件中Reset属性:refreshOffset默认值为1,pullToRefresh默认值为0,pullDownRatio默认值为0 + it('testRefresh009', 0, async (done: Function) => { + let PAGE_TAG = 'RefreshResetAttributeTest'; + await Utils.pushPage(`refresh/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await Utils.clickComponent("ResetRefresh"); + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(5000) + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RelativeContainerBarrier.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RelativeContainerBarrier.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b96e9dd87becc883fbc59fe61dfe935da121b430 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RelativeContainerBarrier.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function relativeContainerBarrierTest() { + + describe('RelativeContainerBarrierTest', () => { + + let PAGE_TAG = 'RelativeContainerBarrierTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('relativeContainerBarrierTest1', 0, async (done: Function) => { + await Utils.pushPage(`relativecontainer/${PAGE_TAG}`, done); + }); + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RelativeContainerGuideLine.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RelativeContainerGuideLine.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..beb0becc0959a2cff7442af4891b34a6a817000e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RelativeContainerGuideLine.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function relativeContainerGuideLineTest() { + + describe('RelativeContainerGuideLineTest', () => { + + let PAGE_TAG = 'RelativeContainerGuideLineTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + //Row组件height参数分别设置为200、-50时的显示效果测试 + it('relativeContainerGuideLineTest1', 0, async (done: Function) => { + await Utils.pushPage(`relativecontainer/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RuleOption.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RuleOption.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fef815539234d232a8e863864ff1b45ac2537caf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/relativecontainer/RuleOption.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function ruleOptionTest() { + + describe('RuleOptionTest', () => { + + let PAGE_TAG = 'RuleOptionTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('ruleOptionTest1', 0, async (done: Function) => { + await Utils.pushPage(`relativecontainer/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/requirement/RequirementPanGestureTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/requirement/RequirementPanGestureTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1ec3fd9ea2c50c17f7aefa552e859c6cf94eb16 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/requirement/RequirementPanGestureTest.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; +import { Point } from '@ohos.UiTest'; + +async function panGesture(id: string, x1: number, y1: number, x2: number, y2: number) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let rect = await refresh.getBounds(); + const p1: Point = { + x: rect.left + x1, + y: rect.top + y1 + }; + const p2: Point = { + x: rect.left + x2, + y: rect.top + y2 + }; + await driver.fling(p1, p2, 5, 200) +} + +export default function requirementPanGestureTest() { + + describe('RequirementPanGestureTest', () => { + + let PAGE_TAG = 'RequirementPanGestureTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`requirement/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testRequirementPanGesture001', 0, async (done: Function) => { + await panGesture("swiper1", 20, 20, 10, 10) + await panGesture("swiper2", 20, 20, 20, 10) + await panGesture("swiper3", 20, 20, 30, 10) + await panGesture("swiper4", 20, 20, 30, 20) + await Utils.flingComponent("swiper5", true, true) + await panGesture("swiper6", 20, 20, 30, 30) + await panGesture("swiper7", 20, 20, 20, 30) + await panGesture("swiper8", 20, 20, 10, 30) + await panGesture("swiper9", 20, 20, 10, 20) + await Utils.flingComponent("swiper10", true, false) + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/requirement/RequirementRouterPageStateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/requirement/RequirementRouterPageStateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..44b1ed88cd2eafd7130a447cbb77225cd79fef31 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/requirement/RequirementRouterPageStateTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function requirementRouterPageStateTest() { + + describe('RequirementRouterPageStateTest', () => { + + let PAGE_TAG = 'RequirementRouterPageStateTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testRequirementRouterPageState001', 0, async (done: Function) => { + await Utils.pushPage(`requirement/${PAGE_TAG}`, done); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/resourcenapivalue/ResourceNapiValueTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/resourcenapivalue/ResourceNapiValueTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4be728ce270b70de9e7bde8354e93f537cbd254 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/resourcenapivalue/ResourceNapiValueTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function resourceNapiValueTest() { + + describe('ResourceNapiValueTest', () => { + + let PAGE_TAG = 'ResourceNapiValueTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testResourceNapiValue001', 0, async (done: Function) => { + await Utils.pushPage(`resourcenapivalue/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/row/RowAlignItemsTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/row/RowAlignItemsTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ef0abc15da6cc79c664cbf36c81dc4ab2945617 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/row/RowAlignItemsTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function rowAlignItemsTest() { + + describe('RowAlignItemsTest', () => { + + let PAGE_TAG = 'RowAlignItemsTest'; + let PAGE_TAG2 = 'RowAlignItemsMoreAttributeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testRowAlignItems001', 0, async (done: Function) => { + await Utils.pushPage(`row/${PAGE_TAG}`, done); + }); + + it('testRowAlignItems002', 0, async (done: Function) => { + await Utils.pushPage(`row/${PAGE_TAG2}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/row/RowJustifyContentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/row/RowJustifyContentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..169009e94dd6400298e33db2ec73578281f14fab --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/row/RowJustifyContentTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function rowJustifyContentTest() { + + describe('RowJustifyContentTest', () => { + + let PAGE_TAG = 'RowJustifyContentTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testRowJustifyContent001', 0, async (done: Function) => { + await Utils.pushPage(`row/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollEnablePagingTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollEnablePagingTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0673542d5903adf19b70109935700035cf5b3575 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollEnablePagingTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function scrollEnablePagingTest() { + + describe('ScrollEnablePagingTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testScrollEnablePaging001', 0, async (done: Function) => { + let PAGE_TAG = 'ScrollEnablePagingTest'; + await Utils.pushPage(`scroll/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollBarWidthTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollBarWidthTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..69c50c241d051c2f042704d9e84d4c97819c500a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollBarWidthTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function scrollScrollBarWidthTest() { + + describe('ScrollScrollBarWidthTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testScrollScrollBarWidth001', 0, async (done: Function) => { + let PAGE_TAG = 'ScrollScrollBarWidthTest'; + await Utils.pushPage(`scroll/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollByTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollByTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..09124d0d0ad603025b3a88aeb06d39537fbea6c6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollByTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function scrollScrollByTest() { + + describe('ScrollScrollByTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testScrollScrollBy001', 0, async (done: Function) => { + let PAGE_TAG = 'ScrollScrollByTest'; + await Utils.pushPage(`scroll/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollEdgeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollEdgeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..94daab5db377f302af430ba2cff23751eda7a7ff --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/scroll/ScrollScrollEdgeTest.test.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function scrollScrollEdgeTest() { + + describe('ScrollScrollEdgeTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testScrollScrollEdge001', 0, async (done: Function) => { + let PAGE_TAG = 'ScrollScrollEdgeHorizontalTest'; + await Utils.pushPage(`scroll/${PAGE_TAG}`); + await Utils.clickComponent('Button') + done(); + }) + + it('testScrollScrollEdge002', 0, async (done: Function) => { + let PAGE_TAG = 'ScrollScrollEdgeVerticalTest'; + await Utils.pushPage(`scroll/${PAGE_TAG}`); + await Utils.clickComponent('Button') + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/slider/SliderTrackThicknessTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/slider/SliderTrackThicknessTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc8bea2a7d6ee80b9a07fb6b68a98731d565be77 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/slider/SliderTrackThicknessTest.test.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function sliderTrackThicknessTest() { + + describe('SliderTrackThicknessTest', () => { + + let PAGE_TAG_1 = 'SliderTrackThicknessPage1Test'; + let PAGE_TAG_2 = 'SliderTrackThicknessPage2Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testSliderTrackThickness001', 0, async (done: Function) => { + await Utils.pushPage(`slider/${PAGE_TAG_1}`, done); + done(); + }) + + it('testSliderTrackThickness002', 0, async (done: Function) => { + await Utils.pushPage(`slider/${PAGE_TAG_2}`); + await Utils.flingComponent('slider18', true, true); + await Utils.sleep(2000); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanBaseLineOffsetTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanBaseLineOffsetTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c837c475d1bc39ca84897b098e1088226bc7ab4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanBaseLineOffsetTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function spanBaseLineOffsetTest() { + + describe('SpanBaseLineOffsetTest', () => { + + let PAGE_TAG = 'SpanBaseLineOffsetTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`span/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testSpanBaseLineOffset001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanFontFamilyTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanFontFamilyTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8698c90dcdc5c4df4586f1a72830a1c232ddb816 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanFontFamilyTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { font } from '@kit.ArkUI'; +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function spanFontFamilyTest() { + + describe('SpanFontFamilyTest', () => { + + let PAGE_TAG = 'SpanFontFamilyTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`span/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testSpanFontFamily001', 0, async (done: Function) => { + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanTextBackgroundStyleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanTextBackgroundStyleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b94974c4b8f53d6559babd72babd6a216610a13 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanTextBackgroundStyleTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function spanTextBackgroundStyleTest() { + + describe('SpanTextBackgroundStyleTest', () => { + + let PAGE_TAG = 'SpanTextBackgroundStyleTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`span/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testSpanTextBackgroundStyle001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanTextShadowTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanTextShadowTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e23ba68b86023ed6db18faca7df212e6e97f481e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanTextShadowTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function spanTextShadowTest() { + + describe('SpanTextShadow', () => { + + let PAGE_TAG = 'SpanTextShadow'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testSpanTextShadowTest001', 0, async (done: Function) => { + await Utils.pushPage(`span/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanValueTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanValueTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..49e5349ca880472fc5506d4aa59f10e7cab15128 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/span/SpanValueTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function spanValueTest() { + + describe('SpanValueTest', () => { + + let PAGE_TAG = 'SpanValueTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`span/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testSpanValue001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/stack/StackAlignContentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/stack/StackAlignContentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b8a6278f59c7bbd6cb08126f78000bea984fe5a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/stack/StackAlignContentTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function stackAlignContentTest() { + + describe('StackAlignContentTest', () => { + + let PAGE_TAG = 'StackAlignContentTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`stack/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testStackAlignContent001', 0, async (done: Function) => { + await Utils.sleep(2000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperAdapterTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperAdapterTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d55e205a2e70fa2e0e0917f0708b26cba76e42ce --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperAdapterTest.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@ohos.UiTest'; + +export default function swiperAdapterTest() { + + describe('SwiperAdapterTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件adapter设置正常值、异常值的显示结果测试 + // itemCount:5,0,1 + it('testSwiperAdapter001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperAdapterTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`, () => setTimeout(() => { + }, 10000)); + let driver = Driver.create(); + let component = await driver.findComponent(ON.id("swiper")); + let point = await component.getBounds(); + await driver.drag(point.right, point.top + 20, point.left, point.top + 20, 2000); + await Utils.sleep(1000); + component = await driver.findComponent(ON.id("swiper_second")); + point = await component.getBounds(); + await driver.drag(point.right, point.top + 20, point.left, point.top + 20, 10000); + await Utils.sleep(1000); + component = await driver.findComponent(ON.id("swiper_third")); + point = await component.getBounds(); + await driver.drag(point.right, point.top + 50, point.left, point.top + 20, 3000); + await Utils.sleep(1000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperChangeIndexTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperChangeIndexTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3844b2e86149774bcd1f4a1d58014526f7c26098 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperChangeIndexTest.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; + +async function doItById(done: Function, speed: number = 10000) { + let driver = Driver.create(); + const ids = ['SwiperChangeIndex', 'SwiperChangeIndexSecond', 'SwiperChangeIndexThird']; + for (let id of ids) { + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 20, point.left, point.top + 20, 10000); + } + WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(2000); + done(); +} + +export default function swiperChangeIndexTest() { + + describe('SwiperChangeIndexTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件的changeIndex属性设置为正常值、异常值的显示结果测试 + // NODE_SWIPER_SWIPE_TO_INDEX: {{.i32 = 2},{.i32 = true}}, {{.i32 = -1},{.i32 = true}},{{.i32 = 4},{.i32 = true}} + it('testSwiperChangeIndex001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperChangeIndexTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + await doItById(done); + }); + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperDotIndicatorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperDotIndicatorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f231106cc4fb7d5a8773a7bf5d1f9313a427aa8 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperDotIndicatorTest.test.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; + +async function doItById(done: Function, speed: number = 10000) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id('SwiperDotIndicator')); + let point = await refresh.getBounds(); + await driver.drag(point.left, point.top + 20, point.right, point.top + 20, 10000); + refresh = await driver.findComponent(ON.id('SwiperSecondDotIndicator')); + point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 20, point.left, point.top + 20, 10000); + WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(2000); + done(); +} + +export default function swiperDotIndicatorTest() { + + describe('SwiperDotIndicatorTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // 在RTL,LTR模式下Swiper组件DotIndicators正常值显示结果测试 + it('testSwiperDotIndicator001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperDotIndicatorTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + await doItById(done); + }); + + // Swiper组件DotIndicators异常值显示结果测试 + it('testSwiperDotIndicator002', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperDotIndicatorAbnormalTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + await doItById(done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperEffectModeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperEffectModeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b01ea008e59020696c3f36173952e40042bcef9f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperEffectModeTest.test.ets @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; + +async function doItById(id: string, done: Function, speed: number = 10000) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 50, point.left, point.top + 50, speed) + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(2000) + done() +} + +async function doDrag(id: string, done: Function, speed: number = 10000) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + for (let i = 0; i < 3; i++) { + await driver.drag(point.right, point.top + 50, point.left, point.top + 50, speed); + await Utils.sleep(2000) + } + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(2000) + done() +} + +async function doSwipe(id: string, done: Function, speed: number = 400, x = 100, y = 300) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.swipe(point.left + x, point.bottom - x, point.left + x, point.bottom + y, speed); + await Utils.sleep(2000); + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(1000); +} + +export default function swiperEffectModeTest() { + + describe('SwiperEffectModeTest', () => { + afterEach(async (done: Function) => { + // WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(1000) + done() + }); + + // Swiper组件的effectMode属性设置为Spring显示结果测试 + // NODE_SWIPER_EDGE_EFFECT_MODE: ARKUI_EDGE_EFFECT_SPRING + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_AUTO_PLAY: true + // NODE_SWIPER_INTERVAL: 800 + // 滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹 + it('testSwiperEffectMode001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEffectModeSpringTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + doItById('SwiperEffectModeSpring', done); + }); + + // Swiper组件的effectMode属性设置为Spring连续触发滑动显示结果测试 + // NODE_SWIPER_EDGE_EFFECT_MODE: ARKUI_EDGE_EFFECT_SPRING + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_AUTO_PLAY: true + // NODE_SWIPER_INTERVAL: 800 + // 多次滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹 + it('testSwiperEffectMode002', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEffectModeMultipleTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + doDrag('SwiperEffectModeSpring', done); + }); + + // Swiper组件的effectMode属性设置为Fade显示结果测试 + // NODE_SWIPER_EDGE_EFFECT_MODE: ARKUI_EDGE_EFFECT_FADE + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_AUTO_PLAY: true + // NODE_SWIPER_INTERVAL: 800 + // 滑动到边缘后会有圆弧状的阴影 + it('testSwiperEffectMode003', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEffectModeFadeTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + doItById('SwiperEffectModeFade', done); + }); + + // Swiper组件的effectMode属性设置为None显示结果测试 + // NODE_SWIPER_EDGE_EFFECT_MODE: ARKUI_EDGE_EFFECT_NONE + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_AUTO_PLAY: true + // NODE_SWIPER_INTERVAL: 800 + // 滑动到边缘无效果 + it('testSwiperEffectMode004', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEffectModeNoneTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + doItById('SwiperEffectModeNone', done); + }); + + // Swiper组件的effectMode属性设置异常值显示结果测试 + // NODE_SWIPER_EDGE_EFFECT_MODE: -1, 3 + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_AUTO_PLAY: true + // NODE_SWIPER_INTERVAL: 800 + // 滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹 + it('testSwiperEffectMode005', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEffectModeAbnormalTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + let driver = Driver.create(); + const ids = ['SwiperEffectModeAbnormal', 'SwiperEffectModeAbnormalSecond']; + for (let id of ids) { + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 100, point.left, point.top + 100, 10000); + } + + await Utils.sleep(1000); + WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(2000); + done(); + }); + + // Swiper组件动画打断显示结果测试 + // NODE_SWIPER_EDGE_EFFECT_MODE: -1 + // NODE_SWIPER_LOOP: true + // NODE_SWIPER_AUTO_PLAY: true + // NODE_SWIPER_INTERVAL: 800 + // 滑动Refresh组件,Swiper组件不受影响 + it('testSwiperEffectMode006', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEffectModeInterruptTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + await Utils.sleep(1000); + await doSwipe('RefreshContent', done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperEventTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperEventTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5bb6e7f613110c4aea24bbd68dd36e43e6c3d76d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperEventTest.test.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; + +async function doItById(id: string, done: Function, speed: number = 10000) { + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id(id)); + let point = await refresh.getBounds(); + await driver.swipe(point.right, point.top + 20, point.left, point.top + 20, 10000); + WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(2000); + done(); +} + +export default function swiperEventTest() { + + describe('SwiperEventTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件onGestureSwipe事件监听页面与手部滑动显示结果测试 + // 触发事件,设置当前节点背景色为COLOR_YELLOW + it('testSwiperEvent001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEventOnGestureTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + await doItById("OnGestureSwipe", done); + done(); + }); + + // Swiper组件onContentDidScroll事件监听页面滑动显示结果测试 + // 触发事件,设置当前节点背景色为COLOR_YELLOW + it('testSwiperEvent002', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperEventOnDidScrollTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id('OnContentDidScroll')); + let point = await refresh.getBounds(); + await driver.swipe(point.right, point.top + 20, point.left, point.top + 20, 10000); + refresh = await driver.findComponent(ON.id('OnContentDidScrollSecond')); + point = await refresh.getBounds(); + await driver.swipe(point.right, point.top + 20, point.left, point.top + 20, 10000); + WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(2000); + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperMarginTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperMarginTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b40c330d4dd2156e846bdae71cb9d8a5e330fb00 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperMarginTest.test.ets @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { beforeAll, afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function swiperMarginTest() { + + describe('SwiperMarginTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(2000); + }); + + // Swiper组件prevMargin以及新增的ignoreBlank参数为正常值显示结果测试 + // NODE_SWIPER_PREV_MARGIN: 10,{10, true} + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_DISPLAY_COUNT: 1 + it('testSwiperMargin001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperPrevMarginTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + + // Swiper组件prevMargin以及新增的ignoreBlank参数为异常值显示结果测试 + // NODE_SWIPER_PREV_MARGIN: 300,{300, true} + // NODE_SWIPER_NEXT_MARGIN: 10, {10, true} + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_DISPLAY_COUNT: 1 + // NODE_SWIPER_VERTICAL: false, true + it('testSwiperMargin002', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperPrevMarginAbnormalTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + + // Swiper组件nextMargin以及新增的ignoreBlank参数为正常值显示结果测试 + // NODE_SWIPER_NEXT_MARGIN: 10,{10, true} + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_DISPLAY_COUNT: 1 + it('testSwiperMargin003', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperNextMarginTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + + // Swiper组件nextMargin以及新增的ignoreBlank参数为异常值显示结果测试 + // NODE_SWIPER_NEXT_MARGIN: 300,{300, true} + // NODE_SWIPER_PREV_MARGIN: 10, {10, true} + // NODE_SWIPER_LOOP: false + // NODE_SWIPER_DISPLAY_COUNT: 1 + // NODE_SWIPER_VERTICAL: false, true + it('testSwiperMargin004', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperNextMarginAbnormalTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + + // Swiper组件prevMargin,nextMargin + // 新增的ignoreBlank参数为true的正常值、异常值显示结果测试 + // NODE_SWIPER_NEXT_MARGIN: {10, true}, {-10} + // NODE_SWIPER_PREV_MARGIN: {10, true}, {-10} + // NODE_SWIPER_LOOP: false, true + // NODE_SWIPER_DISPLAY_COUNT: 1 + it('testSwiperMargin005', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperMarginTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperNestedScrollTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperNestedScrollTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3fa981634fc8b8678b116e4654ee89059c352732 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperNestedScrollTest.test.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON } from '@kit.TestKit'; + +export default function swiperNestedScrollTest() { + + describe('SwiperNestedScrollTest', () => { + afterEach(async (done: Function) => { + //WindowSnap.snapShot(globalThis.context, 'test', done); + await Utils.sleep(1000) + done() + }); + + // Swiper组件nestedScroll属性为SELF_ONLY、SELF_FIRST多层嵌套滚动结果测试 + // NODE_SWIPER_NESTED_SCROLL: ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY,ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST + // ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY:与父组件不联动,显示Swiper组件节点,背景色为COLOR_PINK, + // ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST:与父组件联动,显示Swiper父组件节点,背景色为COLOR_PINK + // 调用drag,模拟从右到左滑动Swiper组件 + it('testSwiperNestedScroll001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperNestedScrollTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id('ChildSwiperNestedScroll')); + let point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 50, point.left, point.top + 50, 10000); + refresh = await driver.findComponent(ON.id('ChildSwiperNestedScrollSecond')); + point = await refresh.getBounds(); + await driver.drag(point.left, point.top + 20, point.right, point.top + 20, 10000); + await Utils.sleep(2000); + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件nestedScroll属性为正常值嵌套滚动结果测试 + // NODE_SWIPER_NESTED_SCROLL: ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY,ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST + // ARKUI_SWIPER_NESTED_SRCOLL_SELF_ONLY:与父组件不联动,显示Swiper组件节点,背景色为COLOR_PINK, + // ARKUI_SWIPER_NESTED_SRCOLL_SELF_FIRST:与父组件联动,显示Swiper父组件节点,背景色0xFF0000FF + // 调用drag,模拟从左到右滑动Swiper组件 + it('testSwiperNestedScroll002', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperNestedScrollChildTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id('SwiperNestedScroll')); + let point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 50, point.left, point.top + 50, 10000); + refresh = await driver.findComponent(ON.id('SwiperNestedScrollSecond')); + point = await refresh.getBounds(); + await driver.drag(point.left, point.top + 20, point.right, point.top + 20, 10000); + await Utils.sleep(1000); + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件nestedScroll属性异常值结果测试 + // NODE_SWIPER_NESTED_SCROLL: -1, 2 + // 与父组件不联动,显示Swiper组件节点,背景色为COLOR_YELLOW, + // 调用drag,模拟从右到左滑动Swiper组件 + it('testSwiperNestedScroll003', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperNestedScrollAbnormalTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`); + let driver = Driver.create(); + let refresh = await driver.findComponent(ON.id('SwiperNestedScroll')); + let point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 50, point.left, point.top + 50, 10000); + refresh = await driver.findComponent(ON.id('SwiperNestedScrollSecond')); + point = await refresh.getBounds(); + await driver.drag(point.right, point.top + 20, point.left, point.top + 20, 10000); + await Utils.sleep(1000); + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperOnAnimationTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperOnAnimationTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c8b76375a19abdfcb54b2e23f839fac5a712626 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperOnAnimationTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function swiperOnAnimationTest() { + + describe('SwiperOnAnimationTest', () => { + + let PAGE_TAG = 'SwiperOnAnimationTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件在滑动的情况下onAnimationStart、onAnimationEnd事件的功能测试 + // 触发onAnimationStart事件, Text组件显示获取Start Index,TargetIndex信息内容,设置Swiper背景色为COLOR.GREEN + // 触发onAnimationEnd事件,Text组件显示获取End Index,TargetIndex信息内容,设置Swiper背景色为COLOR.GREEN + it('testSwiperOnAnimation001', 0, async (done: Function) => { + done(); + }); + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperOnChangeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperOnChangeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b34d82c35db9e48c0fcabe8214c827a3ededa2d --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperOnChangeTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function swiperOnChangeTest() { + + describe('SwiperOnChangeTest', () => { + + let PAGE_TAG = 'SwiperOnChangeTest'; + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件在index变化的情况下onChange事件的功能测试 + // onChange事件内设置当前节点背景色为COLOR.RED,设置Text子控件的内容为Page与当前index组合 + it('testSwiperOnChange001', 0, async (done: Function) => { + await Utils.pushPage(`swiper/${PAGE_TAG}`, done); + }); + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperResetAttributeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperResetAttributeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5512ab7a2d2848a25c548d369497a915bee1243 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/swiper/SwiperResetAttributeTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function swiperResetAttributeTest() { + + describe('SwiperResetAttributeTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // Swiper组件reset effectMode, prevMargin, nextMargin属性显示结果测试 + // 触发Button组件onClick事件,事件内处理reset属性值 + // Text子控件背景色为COLOR.PINK,显示获取的reset属性值 + it('testSwiperResetAttribute001', 0, async (done: Function) => { + let PAGE_TAG = 'SwiperResetAttributeTest'; + await Utils.pushPage(`swiper/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await Utils.clickComponent("ResetSwiper"); + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(5000) + done() + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextContentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextContentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c28c9eb33e9556326af91a80cc378111e325bff7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextContentTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textContentTest() { + + describe('TextContentTest', () => { + + let PAGE_TAG = 'TextContentTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextContentTest001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextDataDetectorConfigTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextDataDetectorConfigTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e39cb2c7c20bc8a570009cc98b620aa544fe6bb --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextDataDetectorConfigTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textDataDetectorConfigTest() { + + describe('TextDataDetectorConfigTest', () => { + + let PAGE_TAG = 'TextDataDetectorConfigTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextDataDetectorConfig001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextDecorationStyleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextDecorationStyleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5bf3a27418c729f9e26a8b0b5fa3aa2f5fad36df --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextDecorationStyleTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textDecorationStyleTest() { + + describe('TextDecorationStyleTest', () => { + + let PAGE_TAG = 'TextDecorationStyleTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextDecorationStyle001', 0, async (done: Function) => { + Utils.sleep(500) + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextEllipsisModeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextEllipsisModeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d36489061557a9007b5f083f07719fd319cd832f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextEllipsisModeTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textEllipsisModeTest() { + + describe('TextEllipsisModeTest', () => { + + let PAGE_TAG = 'TextEllipsisModeTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextEllipsisMode001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextEnableDataDetectorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextEnableDataDetectorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de8706006bf10b06102f03e90ac6196495a758d0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextEnableDataDetectorTest.test.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON, Component, MouseButton } from '@ohos.UiTest'; + +async function rightClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + let point = await component.getBoundsCenter(); + await driver.mouseClick(point, MouseButton.MOUSE_BUTTON_RIGHT); +} + +export default function textEnableDataDetectorTest() { + + describe('TextEnableDataDetectorTest', () => { + + let PAGE_TAG = 'TextEnableDataDetectorTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextEnableDataDetector001', 0, async (done: Function) => { + done() + }) + + it('testTextEnableDataDetector002', 0, async (done: Function) => { + focusControl.requestFocus('text') + await Utils.sleep(1000) + await rightClick('text',done) + await Utils.sleep(1000) + done() + }) + + it('testTextEnableDataDetector003', 0, async (done: Function) => { + focusControl.requestFocus('text') + await Utils.sleep(1000) + await Utils.clickComponent('text') + await Utils.sleep(1000) + done() + }) + + it('testTextEnableDataDetector004', 0, async (done: Function) => { + focusControl.requestFocus('text1') + await Utils.sleep(1000) + await rightClick('text1',done) + await Utils.sleep(1000) + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextFontFeatureTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextFontFeatureTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a90d7cbb883f84a18c36fce0f0a1c292f9a1740 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextFontFeatureTest.test.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textFontFeatureTest() { + + describe('textFontFeatureTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // fontfeature 1-7 + it('testTextFontFeatureTest001', 0, async (done: Function) => { + let PAGE_TAG = 'TextFontFeatureFirstTest'; + await Utils.pushPage(`text/${PAGE_TAG}`, done); + done(); + }) + + // fontfeature 8-14 + it('testTextFontFeatureTest002', 0, async (done: Function) => { + let PAGE_TAG = 'TextFontFeatureSecondTest'; + await Utils.pushPage(`text/${PAGE_TAG}`, done); + done(); + }) + + // fontfeature 15-21 + it('testTextFontFeatureTest003', 0, async (done: Function) => { + let PAGE_TAG = 'TextFontFeatureThirdTest'; + await Utils.pushPage(`text/${PAGE_TAG}`, done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextLineSpacingTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextLineSpacingTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f54b33ef91a1166903cb09bda50d6f0303b767bf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextLineSpacingTest.test.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textLineSpacingTest() { + + describe('TextLineSpacingTest', () => { + + let PAGE_TAG = 'TextLineSpacingTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextLineSpacing001', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('text1') + await Utils.sleep(1000) + await Utils.doubleClickComponent('text1') + await Utils.sleep(1000) + await Utils.clickComponentByText('全选') + await Utils.sleep(1000) + done() + }) + + it('testTextLineSpacing002', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('text2') + await Utils.sleep(1000) + await Utils.doubleClickComponent('text2') + await Utils.sleep(1000) + await Utils.clickComponentByText('全选') + await Utils.sleep(1000) + done() + }) + + it('testTextLineSpacing003', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('text3') + await Utils.sleep(1000) + await Utils.doubleClickComponent('text3') + await Utils.sleep(1000) + await Utils.clickComponentByText('全选') + await Utils.sleep(1000) + done() + }) + + it('testTextLineSpacing004', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('text4') + await Utils.sleep(1000) + await Utils.doubleClickComponent('text4') + await Utils.sleep(1000) + await Utils.clickComponentByText('全选') + await Utils.sleep(1000) + done() + }) + + it('testTextLineSpacing005', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('text5') + await Utils.sleep(1000) + await Utils.doubleClickComponent('text5') + await Utils.sleep(1000) + await Utils.clickComponentByText('全选') + await Utils.sleep(1000) + done() + }) + + it('testTextLineSpacing006', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('text6') + await Utils.sleep(1000) + await Utils.doubleClickComponent('text6') + await Utils.sleep(1000) + await Utils.clickComponentByText('全选') + await Utils.sleep(1000) + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextParagraphTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextParagraphTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2be848436836458e4c0d47446b14fe27421f0e78 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextParagraphTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textParagraphTest() { + + describe('TextParagraphTest', () => { + + let PAGE_TAG = 'TextParagraphTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextParagraph001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextSelectedBackgroundColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextSelectedBackgroundColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..37585db6d7dde31cc2a4e4f0655ae0779cd33d1f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextSelectedBackgroundColorTest.test.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textSelectedBackgroundColorTest() { + + describe('TextSelectedBackgroundColorTest', () => { + + let PAGE_TAG = 'TextSelectedBackgroundColorTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextSelectedBackgroundColor001', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('green') + await Utils.sleep(1000) + await Utils.doubleClickComponent('green') + await Utils.sleep(1000) + done() + }) + + + it('testTextSelectedBackgroundColor002', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('abnormal') + await Utils.sleep(1000) + await Utils.doubleClickComponent('abnormal') + await Utils.sleep(1000) + + done() + }) + + it('testTextSelectedBackgroundColor003', 0, async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`); + focusControl.requestFocus('reset') + await Utils.sleep(1000) + await Utils.doubleClickComponent('reset') + await Utils.sleep(1000) + + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextWordBreakTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextWordBreakTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5333e536d4569a4a1c5f5d38136a4fe122941e22 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/text/TextWordBreakTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textWordBreakTest() { + + describe('TextWordBreakTest', () => { + + let PAGE_TAG = 'TextWordBreakTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`text/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextWordBreak001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaBlurOnSubmitTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaBlurOnSubmitTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..aaadbc426237f759ce8c1d872956c18d4d0e7494 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaBlurOnSubmitTest.test.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaBlurOnSubmitTest() { + + describe('TextAreaBlurOnSubmitTest', () => { + + let PAGE_TAG = 'TextAreaBlurOnSubmitTest'; + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextAreaBlurOnSubmitTest001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('BlurOnSubmitFalse') + await Utils.triggerKey(2054) + await Utils.sleep(200) + done(); + }) + + + it('testTextAreaBlurOnSubmitTest002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('BlurOnSubmitTrue') + await Utils.triggerKey(2054) + await Utils.sleep(2000) + done(); + }) + + it('testTextAreaBlurOnSubmitTest003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('BlurOnSubmitAbnormal') + await Utils.triggerKey(2054) + await Utils.sleep(2000) + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaCaretPositionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaCaretPositionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..333c5d469175ed1964d4ebabed5ab1f3ab71236e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaCaretPositionTest.test.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaCaretPositionTest() { + + describe('TextAreaCaretPositionTest', () => { + + let PAGE_TAG = 'TextAreaCaretPositionTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaCaretPosition001', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaCaretPositionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("textArea1"); + await Utils.clickComponent("TextAreaCaretPosition_id1"); + done(); + }) + + it('testTextAreaCaretPosition002', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaCaretPositionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("textArea1"); + await Utils.clickComponent("TextAreaCaretPosition_id2"); + done(); + }) + + it('testTextAreaCaretPosition003', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaCaretPositionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("textArea1"); + await Utils.clickComponent("TextAreaCaretPosition_id3"); + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaContentTypeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaContentTypeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..30266a48016b8b72a3bc4eb39b99efce3429eb08 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaContentTypeTest.test.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaContentTypeTest() { + + describe('TextAreaContentTypeTest', () => { + let PAGE_TAG_1 = 'TextAreaContentTypePageOneTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaContentType001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_1}`); + focusControl.requestFocus('textArea1') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textArea1') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textArea_1') + await Utils.sleep(1000) + await Utils.clickComponent('textArea_1') + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaControllerTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaControllerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bad04889a3aed658e9de65f40b000e3eca5af774 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaControllerTest.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaControllerTest() { + + describe('TextAreaControllerTest', () => { + + let PAGE_TAG = 'TextAreaControllerTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaController001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaControllerTest_textArea_id"); + await Utils.sleep(1000) + await Utils.clickComponent("TextAreaControllerTest_button_id"); + await Utils.sleep(1000) + done(); + }) + it('testTextAreaController002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaControllerTest_textArea_id"); + await Utils.sleep(1000) + await Utils.clickComponent("TextAreaControllerTest_button_id_2"); + await Utils.sleep(1000) + await Utils.clickComponent("TextAreaControllerTest_button_id"); + await Utils.sleep(1000) + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnableAutoFillTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnableAutoFillTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..99ccd93520140f9632f3b9fad990dad186c609e4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnableAutoFillTest.test.ets @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaEnableAutoFillTest() { + + describe('TextAreaEnableAutoFillTest', () => { + let PAGE_TAG = 'TextAreaEnableAutoFillTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaEnableAutoFill001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textArea') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textArea1') + await Utils.sleep(1000) + await Utils.clickComponent("textArea1"); + await Utils.sleep(1000); + done() + }) + + it('testTextAreaEnableAutoFill002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textArea') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textArea2') + await Utils.sleep(1000) + await Utils.clickComponent("textArea2"); + await Utils.sleep(1000); + done() + }) + + it('testTextAreaEnableAutoFill003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textArea') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textArea3') + await Utils.sleep(1000) + await Utils.clickComponent("textArea3"); + await Utils.sleep(1000); + done() + }) + + it('testTextAreaEnableAutoFill004', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textArea') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textArea4') + await Utils.sleep(1000) + await Utils.clickComponent("textArea4"); + await Utils.sleep(1000); + done() + }) + + it('testTextAreaEnableAutoFill005', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textArea') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textArea5') + await Utils.sleep(1000) + await Utils.clickComponent("textArea5"); + await Utils.sleep(1000); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnableKeyboardOnFocusTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnableKeyboardOnFocusTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5f918ff56aae03f3491fd5faada0615dde7a79f --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnableKeyboardOnFocusTest.test.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Component,Driver,UiWindow,ON } from '@ohos.UiTest' + +export default function textAreaEnableKeyboardOnFocusTest() { + + describe('TextAreaEnableKeyboardOnFocusTest', () => { + + let PAGE_TAG = 'TextAreaEnableKeyboardOnFocusTest'; + let PAGE_TAG_DISABLED = 'TextAreaEnableKeyboardOnFocusDisableTest'; + let PAGE_TAG_ABNORMAL = 'TextAreaEnableKeyboardOnFocusAbnormalTest'; + let PAGE_TAG_RESET = 'TextAreaEnableKeyboardOnFocusResetTest'; + + it('testTextAreaEnableKeyboardOnFocusTest001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_DISABLED}`, done); + focusControl.requestFocus('disable') + await Utils.sleep(1000) + await Utils.triggerKey(2049) + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextAreaEnableKeyboardOnFocusTest002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + focusControl.requestFocus('enable') + await Utils.sleep(1000) + await Utils.triggerKey(2049) + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextAreaEnableKeyboardOnFocusTest003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_ABNORMAL}`, done); + focusControl.requestFocus('abnormal') + await Utils.sleep(1000) + await Utils.triggerKey(2049) + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextAreaEnableKeyboardOnFocusTest004', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_RESET}`, done); + focusControl.requestFocus('reset') + await Utils.sleep(1000) + await Utils.triggerKey(2049) + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnterKeyTypeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnterKeyTypeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..99d7d24a3560719523a82da56089f705c73a22ad --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaEnterKeyTypeTest.test.ets @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Component,Driver,UiWindow,ON } from '@ohos.UiTest' + + +export default function textAreaEnterKeyTypeTest() { + + describe('TextAreaEnterKeyTypeTest', () => { + + let PAGE_TAG_TYPE_GO = 'TextAreaEnterKeyTypeTest'; + let PAGE_TAG_TYPE_SEARCH = 'TextAreaEnterKeyTypeSearchTest'; + let PAGE_TAG_TYPE_SEND = 'TextAreaEnterKeyTypeSendTest'; + let PAGE_TAG_TYPE_NEXT = 'TextAreaEnterKeyTypeNextTest'; + let PAGE_TAG_TYPE_DONE = 'TextAreaEnterKeyTypeDoneTest'; + let PAGE_TAG_TYPE_PREVIOUS = 'TextAreaEnterKeyTypePreviousTest'; + let PAGE_TAG_TYPE_NEWLINE = 'TextAreaEnterKeyTypeNewLineTest'; + let PAGE_TAG_TYPE_ABNORMAL = 'TextAreaEnterKeyTypeAbnormalTest'; + + //TextArea组件enterKeyType参数设置为ARKUI_ENTER_KEY_TYPE_GO时的显示效果测试 + + it('testTextAreaEnterKeyType001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_GO}`); + await Utils.clickComponent('OnClickTypeGo') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为ARKUI_ENTER_KEY_TYPE_SEARCH时的显示效果测试 + it('testTextAreaEnterKeyType002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_SEARCH}`); + await Utils.clickComponent('OnClickTypeSearch') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为ARKUI_ENTER_KEY_TYPE_SEND时的显示效果测试 + it('testTextAreaEnterKeyType003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_SEND}`); + await Utils.clickComponent('OnClickTypeSend') + await Utils.sleep(1000) + let driver =await Driver.create() + driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为ARKUI_ENTER_KEY_TYPE_NEXT时的显示效果测试 + it('testTextAreaEnterKeyType004', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_NEXT}`); + await Utils.clickComponent('OnClickTypeNext') + await Utils.sleep(1000) + let driver =await Driver.create() + driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为ARKUI_ENTER_KEY_TYPE_DONE时的显示效果测试 + it('testTextAreaEnterKeyType005', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_DONE}`); + await Utils.clickComponent('OnClickTypeDone') + await Utils.sleep(1000) + let driver =await Driver.create() + driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为ARKUI_ENTER_KEY_TYPE_PREVIOUS时的显示效果测试 + it('testTextAreaEnterKeyType006', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_PREVIOUS}`); + await Utils.clickComponent('OnClickTypePrevious') + await Utils.sleep(1000) + let driver =await Driver.create() + driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为时ARKUI_ENTER_KEY_TYPE_NEW_LINE的显示效果测试 + it('testTextAreaEnterKeyType007', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_NEWLINE}`); + await Utils.clickComponent('OnClickTypeNewLine') + await Utils.sleep(1000) + let driver =await Driver.create() + driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + + //TextArea组件enterKeyType参数设置为-1时的显示效果测试 + it('testTextAreaEnterKeyType008', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_TYPE_ABNORMAL}`); + await Utils.clickComponent('OnClickAbnormal') + await Utils.sleep(1000) + let driver =await Driver.create() + driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaFontFeatureTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaFontFeatureTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8af7a9875d9ecb1b93c6ad134cf8f9d89267d47 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaFontFeatureTest.test.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaFontFeatureTest() { + + describe('TextAreaFontFeatureTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // fontfeature 1-7 + it('testTextAreaFontFeatureTest001', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaFontFeatureFirstTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + done(); + }) + + // fontfeature 8-14 + it('testTextAreaFontFeatureTest002', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaFontFeatureSecondTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + done(); + }) + + // fontfeature 15-21 + it('testTextAreaFontFeatureTest003', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaFontFeatureThirdTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaGetCaretOffsetTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaGetCaretOffsetTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..74113d2d69530c6de8da38984573a3bfb228a994 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaGetCaretOffsetTest.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaGetCaretOffsetTest() { + + describe('TextAreaGetCaretOffsetTest', () => { + let PAGE_TAG = 'TextAreaGetCaretOffsetTest'; + beforeAll(async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaGetCaretOffset001', 0, async (done: Function) => { + + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaGetCaretOffsetTest_textArea_id1"); + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaGetCaretOffset002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaGetCaretOffsetTest_textArea_id1"); + await Utils.triggerKey(2024); + await Utils.sleep(2000) + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaInputFilterTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaInputFilterTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..03fc8cb43c0f962a06144532f57add15ff203a22 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaInputFilterTest.test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaInputFilterTest() { + + describe('TextAreaInputFilterTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaInputFilterTest001', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaInputFilterTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaMaxLinesTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaMaxLinesTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6198e3b5aa2dbe3814f652a57b5fa32de59abde5 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaMaxLinesTest.test.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaMaxLinesTest() { + + describe('TextAreaMaxLinesTest', () => { + let PAGE_TAG = 'TextAreaMaxLinesTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaMaxLinesTest001', 0, async (done: Function) => { + + await Utils.pushPage(`textarea/${PAGE_TAG}`); + done(); + }) + + it('testTextAreaMaxLinesTest002', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaMaxLinesTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea7') + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaNumberOfLinesTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaNumberOfLinesTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..60af76ca89bf9eb217f946a5e0c26aa95f9e6fb3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaNumberOfLinesTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaNumberOfLinesTest() { + + describe('TextAreaNumberOfLinesTest', () => { + + let PAGE_TAG = 'TextAreaNumberOfLinesTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaNumberOfLines001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSelectedBackgroundColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSelectedBackgroundColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..520d27ae9562b9a6f990dd88182fdf60b2c610c7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSelectedBackgroundColorTest.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaSelectedBackgroundColorTest() { + + describe('TextAreaSelectedBackgroundColorTest', () => { + + let PAGE_TAG = 'TextAreaSelectedBackgroundColorTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaSelectedBackgroundColor001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}` ); + await focusControl.requestFocus('green') + await Utils.sleep(1000) + await Utils.doubleClickComponent('green') + await Utils.sleep(1000) + done() + }) + + + it('testTextAreaSelectedBackgroundColor002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + await focusControl.requestFocus('textAreaAbnormal') + await Utils.sleep(1000) + await Utils.doubleClickComponent('textAreaAbnormal') + await Utils.sleep(1000) + done() + }) + + it('testTextAreaSelectedBackgroundColor003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textAreaReset') + await Utils.sleep(1000) + await Utils.doubleClickComponent('textAreaReset') + await Utils.sleep(1000) + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSelectionMenuHddenTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSelectionMenuHddenTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4fe532860ec797701ab8fa960e988927749bb676 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSelectionMenuHddenTest.test.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON, Component, MouseButton } from '@ohos.UiTest'; + +// 右键点击 +async function rightClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + let point = await component.getBoundsCenter(); + await driver.mouseClick(point, MouseButton.MOUSE_BUTTON_RIGHT); +} + +// 三击 +async function threeClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + await component.click(); + await component.click(); + await component.click(); +} + +export default function textAreaSelectionMenuHiddenTest() { + + describe('TextAreaSelectionMenuHiddenTest', () => { + + let PAGE_TAG = 'TextAreaSelectionMenuHiddenTest'; + + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // one click + it('testTextAreaSelectionMenuHiddenTest001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea1') + await Utils.clickComponent('textArea1') + await Utils.sleep(1000) + done(); + }) + + // double click + it('testTextAreaSelectionMenuHiddenTest002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea1') + await Utils.doubleClickComponent('textArea1') + await Utils.sleep(1000) + done(); + }) + + // triple click + it('testTextAreaSelectionMenuHiddenTest003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea1') + await threeClick('textArea1',done) + await Utils.sleep(1000) + done(); + }) + + // long click + it('testTextAreaSelectionMenuHiddenTest004', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea1') + await Utils.longClickComponent('textArea1') + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaSelectionMenuHiddenTest005', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea1') + await rightClick('textArea1',done) + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaSelectionMenuHiddenTest006', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea2') + await Utils.sleep(1000) + await Utils.clickComponent('textArea2') + await Utils.sleep(1000) + done(); + }) + + // double click + it('testTextAreaSelectionMenuHiddenTest007', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea2') + await Utils.doubleClickComponent('textArea2') + await Utils.sleep(1000) + done(); + }) + + // triple click + it('testTextAreaSelectionMenuHiddenTest008', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea2') + await threeClick('textArea2',done) + await Utils.sleep(1000) + done(); + }) + + // long click + it('testTextAreaSelectionMenuHiddenTest009', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea2') + await Utils.longClickComponent('textArea2') + await Utils.sleep(2000) + done(); + }) + + it('testTextAreaSelectionMenuHiddenTest010', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea2') + await rightClick('textArea2',done) + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaSelectionMenuHiddenTest011', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea3') + await Utils.clickComponent('textArea3') + await Utils.sleep(1000) + done(); + }) + + // double click + it('testTextAreaSelectionMenuHiddenTest012', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea3') + await Utils.doubleClickComponent('textArea3') + await Utils.sleep(1000) + done(); + }) + + // triple click + it('testTextAreaSelectionMenuHiddenTest013', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea3') + await threeClick('textArea3',done) + await Utils.sleep(1000) + done(); + }) + + // long click + it('testTextAreaSelectionMenuHiddenTest014', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea3') + await Utils.longClickComponent('textArea3') + await Utils.sleep(2000) + done(); + }) + + it('testTextAreaSelectionMenuHiddenTest015', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('textArea3') + await rightClick('textArea3',done) + await Utils.sleep(1000) + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSetTextSelectionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSetTextSelectionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..232702d1873e63e91e169920867f8ce644c64096 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaSetTextSelectionTest.test.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaSetTextSelectionTest() { + + describe('TextAreaSetTextSelectionTest', () => { + + let PAGE_TAG = 'TextAreaSetTextSelectionTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaSetTextSelection001', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaSetTextSelectionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaSetTextSelectionTest_textArea_id1"); + await Utils.clickComponent("TextAreaSetTextSelectionTest_id1"); + done(); + }) + + it('testTextAreaSetTextSelection002', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaSetTextSelectionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaSetTextSelectionTest_textArea_id1"); + await Utils.clickComponent("TextAreaSetTextSelectionTest_id2"); + done(); + }) + + it('testTextAreaSetTextSelection003', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaSetTextSelectionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaSetTextSelectionTest_textArea_id1"); + await Utils.clickComponent("TextAreaSetTextSelectionTest_id3"); + done(); + }) + + it('testTextAreaSetTextSelection004', 0, async (done: Function) => { + let PAGE_TAG = 'TextAreaSetTextSelectionTest'; + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus("TextAreaSetTextSelectionTest_textArea_id1"); + await Utils.clickComponent("TextAreaSetTextSelectionTest_id4"); + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaShowCounterTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaShowCounterTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0d9182bcf66d7ff7dbb77c13d407a11ce442168 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaShowCounterTest.test.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaShowCounterTest() { + + describe('TextAreaShowCounterTest', () => { + + let PAGE_TAG = 'TextAreaShowCounterTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaShowCounter001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('normal') + await Utils.triggerKey(2000) + await Utils.sleep(2000) + done(); + }) + + it('testTextAreaShowCounter002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('showNumber') + await Utils.triggerKey(2000) + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaShowCounter003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('blankFirst') + await Utils.triggerKey(2000) + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaShowCounter004', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('blankSecond') + await Utils.triggerKey(2000) + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaShowCounter005', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('abNormal') + await Utils.triggerKey(2000) + await Utils.sleep(1000) + done(); + }) + + it('testTextAreaShowCounter006', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('reset') + await Utils.triggerKey(2000) + await Utils.sleep(1000) + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaShowKeyboardOnFocusTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaShowKeyboardOnFocusTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f95588b40f3b17e67694dac6a0606214f4ef37b --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaShowKeyboardOnFocusTest.test.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Component,Driver,UiWindow,ON } from '@ohos.UiTest' + +export default function textAreaShowKeyboardOnFocusTest() { + + describe('TextAreaShowKeyboardOnFocusTest', () => { + + let PAGE_TAG = 'TextAreaShowKeyboardOnFocusTest'; + let PAGE_TAG_ABNORMAL = 'TextAreaShowKeyboardOnFocusAbnormalTest'; + + it('testTextAreaShowKeyboardOnFocusTest001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`) + focusControl.requestFocus('normal') + await Utils.sleep(1000) + await Utils.clickComponent('normal') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextAreaShowKeyboardOnFocusTest002', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`); + focusControl.requestFocus('abnormal') + await Utils.sleep(1000) + await Utils.clickComponent('abnormal') + await Utils.sleep(2000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextAreaShowKeyboardOnFocusTest003', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_ABNORMAL}`); + focusControl.requestFocus('disable') + await Utils.sleep(1000) + await Utils.clickComponent('disable') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextAreaShowKeyboardOnFocusTest004', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG_ABNORMAL}`); + focusControl.requestFocus('reset') + await Utils.sleep(1000) + await Utils.clickComponent('reset') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaTextPlaceholderTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaTextPlaceholderTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bbeff335327f4d3170ff78461566e9d0e47cca7 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaTextPlaceholderTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaTextPlaceholderTest() { + + describe('TextAreaTextPlaceholderTest', () => { + + let PAGE_TAG = 'TextAreaTextPlaceholderTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testTextAreaTextPlaceholderTest001', 0, async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaTypeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaTypeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2bed521a1358503698dc7de6a98fc8274bf353a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textarea/TextAreaTypeTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textAreaTypeTest() { + + describe('TextAreaTypeTest', () => { + let PAGE_TAG = 'TextAreaTypeTest'; + beforeAll(async (done: Function) => { + await Utils.pushPage(`textarea/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextAreaTypeTest001', 0, async (done: Function) => { + + await Utils.pushPage(`textarea/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputBlurOnSubmitTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputBlurOnSubmitTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..066288d8612ad434dadc4004ce5a889432839bd9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputBlurOnSubmitTest.test.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputBlurOnSubmitTest() { + + describe('TextInputBlurOnSubmitTest', () => { + + let PAGE_TAG = 'TextInputBlurOnSubmitTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + + it('testTextInputBlurOnSubmitTest001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('OnSubmitTestTextInput') + await Utils.sleep(2000) + await Utils.triggerKey(2054) + await Utils.sleep(200) + done(); + }) + + + it('testTextInputBlurOnSubmitTest002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('OnSubmitTestTextInputCompare') + await Utils.sleep(2000) + await Utils.triggerKey(2054) + await Utils.sleep(200) + done(); + }) + + it('testTextInputBlurOnSubmitTest003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('OnSubmitTestTextInputAbnormal') + await Utils.sleep(2000) + await Utils.triggerKey(2054) + await Utils.sleep(200) + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCancelButtonTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCancelButtonTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..78e501c650f841b0037e175ae450d2a726c7ad93 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCancelButtonTest.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputCancelButtonTest() { + + describe('TextInputCancelButtonTest', () => { + + let PAGE_TAG = 'TextInputCancelButtonTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputCancelButton001', 0, async (done: Function) => { + done() + }) + + it('testTextInputCancelButton002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput1') + await Utils.sleep(1000) + await Utils.clickComponent("textInput1"); + await Utils.triggerKey(2049) + await Utils.triggerKey(2054) + await Utils.sleep(1000) + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCaretPositionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCaretPositionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4be833f009580fe69f403685728690dc0c2815ac --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCaretPositionTest.test.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputCaretPositionTest() { + + describe('TextInputCaretPositionTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputCaretPosition001', 0, async (done: Function) => { + let PAGE_TAG = 'TextInputCaretPositionTest'; + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("textInput1"); + await Utils.clickComponent("textInput1"); + await Utils.clickComponent("TextInputCaretPositionTest_buttonId1"); + done(); + }) + + it('testTextInputCaretPosition002', 0, async (done: Function) => { + let PAGE_TAG = 'TextInputCaretPositionTest'; + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("textInput1"); + await Utils.clickComponent("textInput1"); + await Utils.clickComponent("TextInputCaretPositionTest_buttonId2"); + done(); + }) + + it('testTextInputCaretPosition003', 0, async (done: Function) => { + let PAGE_TAG = 'TextInputCaretPositionTest'; + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("textInput1"); + await Utils.clickComponent("TextInputCaretPositionTest_buttonId3"); + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputContentTypeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputContentTypeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..717aa092e518ed7f9eec5f394016c0c2c6c84a87 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputContentTypeTest.test.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputContentTypeTest() { + + describe('TextInputContentTypeTest', () => { + let PAGE_TAG_1 = 'TextInputContentTypePage1Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputContentType001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + focusControl.requestFocus('textInput1') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textInput1') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textInput2') + await Utils.sleep(1000) + await Utils.clickComponent('textInput2') + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputControllerTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputControllerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..97ee0f63d1ab4d98460fc68aa27e21cb086e0068 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputControllerTest.test.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { FocusController } from '@ohos.arkui.UIContext'; + +export default function textInputControllerTest() { + + describe('TextInputControllerTest', () => { + + let PAGE_TAG = 'TextInputControllerTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputController001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + await Utils.clickComponent("TextInputControllerTest_button_id"); + await Utils.sleep(1000) + done() + }) + + it('testTextInputController002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("TextInputControllerTest_textInput_id"); + await Utils.sleep(1000) + await Utils.clickComponent("TextInputControllerTest_button_id"); + await Utils.sleep(1000) + done() + }) + + it('testTextInputController003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("TextInputControllerTest_textInput_id"); + await Utils.sleep(1000) + await Utils.clickComponent("TextInputControllerTest_button_id2"); + await Utils.sleep(1000) + await Utils.clickComponent("TextInputControllerTest_button_id"); + await Utils.sleep(1000) + done() + }) + + it('testTextInputController004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("TextInputControllerTest_textInput_id"); + await Utils.sleep(1000) + await Utils.clickComponent("TextInputControllerTest_button_id2"); + await Utils.sleep(1000) + await Utils.triggerKey(2049) + await Utils.sleep(1000) + await Utils.clickComponent("TextInputControllerTest_button_id"); + await Utils.sleep(1000) + done() + }) + + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCustomKeyboardTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCustomKeyboardTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a993a0b3ac1f01af3c70f061c3162ae5f08795fd --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputCustomKeyboardTest.test.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputCustomKeyboardTest() { + + describe('TextInputCustomKeyboardTest', () => { + let PAGE_TAG_1 = 'TextInputCustomKeyboardPage1Test'; + let PAGE_TAG_2 = 'TextInputCustomKeyboardPage2Test'; + let PAGE_TAG_3 = 'TextInputCustomKeyboardPage3Test'; + let PAGE_TAG_4 = 'TextInputCustomKeyboardPage4Test'; + let PAGE_TAG_5 = 'TextInputCustomKeyboardPage5Test'; + let PAGE_TAG_6 = 'TextInputCustomKeyboardPage6Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // 点击textInput,不支持避让效果 + it('testTextInputCustomKeyboard001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput1"); + await Utils.sleep(2000); + done() + }) + + // 点击textInput,支持避让效果 + it('testTextInputCustomKeyboard002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput2"); + await Utils.sleep(2000); + done() + }) + + // 测试是否会拦截手势事件 + it('testTextInputCustomKeyboard003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`); + await Utils.clickComponent("textInput3"); + await Utils.sleep(2000); + await Utils.clickComponent("button1"); + await Utils.sleep(2000); + done() + }) + + // 测试输入控件失去焦点时,是否关闭自定义键盘 + it('testTextInputCustomKeyboard004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_4}`); + await Utils.clickComponent("textInput4"); + await Utils.sleep(2000); + await Utils.clickComponent("button"); + await Utils.sleep(2000); + done() + }) + + // 测试通过TextInputController.stopEditing方法控制键盘关闭,是否关闭自定义键盘 + it('testTextInputCustomKeyboard005', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_5}`); + await Utils.clickComponent("textInput5"); + await Utils.sleep(2000); + await Utils.clickComponent("button1"); + await Utils.sleep(2000); + done() + }) + + // 测试resetAttribute + it('testTextInputCustomKeyboard006', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_6}`); + await Utils.clickComponent("textInput6"); + await Utils.sleep(2000); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputEnableAutoFillTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputEnableAutoFillTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1d3e60a3ba8afcaa20e25c69dd03567d92818e5e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputEnableAutoFillTest.test.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputEnableAutoFillTest() { + + describe('TextInputEnableAutoFillTest', () => { + let PAGE_TAG = 'TextInputEnableAutoFillTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputEnableAutoFill001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput6') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textInput6') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textInput1') + await Utils.sleep(1000) + await Utils.clickComponent('textInput1') + done() + }) + + it('testTextInputEnableAutoFill002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput6') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textInput6') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textInput2') + await Utils.sleep(1000) + await Utils.clickComponent('textInput2') + done() + }) + + it('testTextInputEnableAutoFill003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput6') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textInput6') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textInput3') + await Utils.sleep(1000) + await Utils.clickComponent('textInput3') + done() + }) + + it('testTextInputEnableAutoFill004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput6') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textInput6') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textInput4') + await Utils.sleep(1000) + await Utils.clickComponent('textInput4') + done() + }) + + it('testTextInputEnableAutoFill005', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput6') + await Utils.sleep(1000); + await Utils.doubleClickComponent('textInput6') + await Utils.sleep(1000) + await Utils.clickComponentByText('复制') + await Utils.sleep(1000) + focusControl.requestFocus('textInput5') + await Utils.sleep(1000) + await Utils.clickComponent('textInput5') + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputFontFeatureTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputFontFeatureTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..73bbacb684e850e7606651ffcdeb93605a6fddfa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputFontFeatureTest.test.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputFontFeatureTest() { + + describe('TextInputFontFeatureTest', () => { + let PAGE_TAG_1 = 'TextInputFontFeaturePage1Test'; + let PAGE_TAG_2 = 'TextInputFontFeaturePage2Test'; + let PAGE_TAG_3 = 'TextInputFontFeaturePage3Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputFontFeature001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`, done); + done() + }) + + it('testTextInputFontFeature002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`, done); + done() + }) + + it('testTextInputFontFeature003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`, done); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputGetCaretOffsetTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputGetCaretOffsetTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..030694629892e2625bf2cbd80ae5a39e92bdd240 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputGetCaretOffsetTest.test.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputGetCaretOffsetTest() { + + describe('TextInputGetCaretOffsetTest', () => { + + let PAGE_TAG = 'TextInputGetCaretOffsetTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputGetCaretOffset001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("TextInputGetCaretOffsetTest_textInput_id1"); + await Utils.sleep(1000) + await Utils.triggerKey(2049); + done(); + }) + + it('testTextInputGetCaretOffset002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus("TextInputGetCaretOffsetTest_textInput_id1"); + await Utils.triggerKey(2024); + await Utils.sleep(2000) + done(); + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputInputFilterTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputInputFilterTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb024f03f7df8ab3c26388bee6f7bdfbbb6a69b6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputInputFilterTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputInputFilterTest() { + + describe('TextInputInputFilterTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputInputFilter001', 0, async (done: Function) => { + let PAGE_TAG = 'TextInputInputFilterTest'; + await Utils.pushPage(`textinput/${PAGE_TAG}`); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputMaxLinesTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputMaxLinesTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0e1a65e7601d71e61731516fc5fac7447f3c73a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputMaxLinesTest.test.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, afterEach, beforeAll } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputMaxLinesTest() { + + describe('TextInputMaxLinesTest', () => { + let PAGE_TAG = 'TextInputMaxLinesTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputMaxLinesTest001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('normal') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputMaxLinesTest002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('negative') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputMaxLinesTest003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('large') + await Utils.sleep(1000) + done(); + }) + it('testTextInputMaxLinesTest004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('normalTwo') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputMaxLinesTest005', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('negativeTwo') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputMaxLinesTest006', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('largeTwo') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputMaxLinesTest007', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('reset') + await Utils.sleep(1000) + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputMinFontSizeAndMaxFontSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputMinFontSizeAndMaxFontSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..da015b9b6973498565b5474501e01bd8d8d106c0 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputMinFontSizeAndMaxFontSizeTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputMinFontSizeAndMaxFontSizeTest() { + + describe('TextInputMinFontSizeAndMaxFontSizeTest', () => { + + let PAGE_TAG = 'TextInputMinFontSizeAndMaxFontSizeTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputMinFontSizeAndMaxFontSize001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputNumberOfLinesTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputNumberOfLinesTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e63beb169e59fb3788e5e84bc2521a58d9a13e4 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputNumberOfLinesTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputNumberOfLinesTest() { + + describe('TextInputNumberOfLinesTest', () => { + + let PAGE_TAG = 'TextInputNumberOfLinesTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputNumberOfLines001', 0, async (done: Function) => { + done() + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputPasswordRulesTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputPasswordRulesTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5744f4ef08e22f040cfb9ece2c626b8f5a0c82db --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputPasswordRulesTest.test.ets @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputPasswordRulesTest() { + + describe('TextInputPasswordRulesTest', () => { + let PAGE_TAG_1 = 'TextInputPasswordRulesPage1Test'; + let PAGE_TAG_2 = 'TextInputPasswordRulesPage2Test'; + let PAGE_TAG_3 = 'TextInputPasswordRulesPage3Test'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputPasswordRules001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput1"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput2"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput3"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput4"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules005', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput5"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules006', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput6"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules007', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput7"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules008', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput8"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules009', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput9"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules010', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput10"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules011', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput11"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules012', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_1}`); + await Utils.clickComponent("textInput12"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules013', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput1"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules014', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput2"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules015', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput3"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules016', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput4"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules017', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput5"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules018', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput6"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules019', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput7"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules020', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput8"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules021', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput9"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules022', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput10"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules023', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput11"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules024', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_2}`); + await Utils.clickComponent("textInput12"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules025', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`); + await Utils.clickComponent("textInput1"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules026', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`); + await Utils.clickComponent("textInput2"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules027', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`); + await Utils.clickComponent("textInput3"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules028', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`); + await Utils.clickComponent("textInput4"); + await Utils.sleep(2000); + done() + }) + + it('testTextInputPasswordRules029', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_3}`); + await Utils.clickComponent("textInput5"); + await Utils.sleep(2000); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSelectAllTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSelectAllTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..068da255b616a63bb3611d25c5a3916ee185e730 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSelectAllTest.test.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputSelectAllTest() { + + describe('TextInputSelectAllTest', () => { + let PAGE_TAG = 'TextInputSelectAllTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + // TextInput组件selectAll参数设置为1时的显示效果测试 + it('testTextInputSelectAll001', 0, async (done: Function) => { + await focusControl.requestFocus('textInput1') + await Utils.sleep(2000) + done(); + }); + + // TextInput组件selectAll参数设置为0时的显示效果测试 + it('testTextInputSelectAll002', 0, async (done: Function) => { + await focusControl.requestFocus('textInput2') + await Utils.sleep(2000) + done(); + }); + + // TextInput组件selectAll参数设置为-1时的显示效果测试 + it('testTextInputSelectAll003', 0, async (done: Function) => { + await focusControl.requestFocus('textInput3') + await Utils.sleep(2000) + done(); + }); + + // TextInput组件selectAll参数设置为1,内容为超长文本时的显示效果测试 + it('testTextInputSelectAll004', 0, async (done: Function) => { + await focusControl.requestFocus('textInput4') + await Utils.sleep(2000) + done(); + }); + + // TextInput组件selectAll参数设置为1,内容为空时的显示效果测试 + it('testTextInputSelectAll005', 0, async (done: Function) => { + await focusControl.requestFocus('textInput5') + await Utils.sleep(2000) + done(); + }); + + // TextInput组件resetAttribute selectAll + it('testTextInputSelectAll006', 0, async (done: Function) => { + await focusControl.requestFocus('textInput6') + await Utils.sleep(2000) + done(); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSelectionMenuHiddenTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSelectionMenuHiddenTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a57d57faa5e3428cb4618c78dba056260f65d7c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSelectionMenuHiddenTest.test.ets @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver, ON, Component, MouseButton } from '@ohos.UiTest'; + +// 点击光标 +async function click(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + await component.click(); + await Utils.sleep(1000); + await component.click(); +} + +// 双击 +async function doubleClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + await component.click(); + await component.click(); +} + +// 长按 +async function longClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + await component.longClick(); +} + +// 右键点击 +async function rightClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + let point = await component.getBoundsCenter(); + await driver.mouseClick(point, MouseButton.MOUSE_BUTTON_RIGHT); +} + +// 三击 +async function threeClick(id: string, done: Function) { + let driver: Driver = Driver.create(); + let component: Component = await driver.findComponent(ON.id(id)); + await component.click(); + await component.click(); + await component.click(); +} + +export default function textInputSelectionMenuHiddenTest() { + + describe('TextInputSelectionMenuHiddenTest', () => { + let PAGE_TAG = 'TextInputSelectionMenuHiddenTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // 点击效果 + it('testTextInputSelectionMenuHidden001', 0, async (done: Function) => { + await click("textInput1", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden002', 0, async (done: Function) => { + await click("textInput2", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden003', 0, async (done: Function) => { + await click("textInput3", done); + await Utils.sleep(1000) + done() + }) + + // 双击效果 + it('testTextInputSelectionMenuHidden004', 0, async (done: Function) => { + await doubleClick("textInput1", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden005', 0, async (done: Function) => { + await doubleClick("textInput2", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden006', 0, async (done: Function) => { + await doubleClick("textInput3", done); + await Utils.sleep(1000) + done() + }) + + // 长按效果 + it('testTextInputSelectionMenuHidden007', 0, async (done: Function) => { + await longClick("textInput1", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden008', 0, async (done: Function) => { + await longClick("textInput2", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden009', 0, async (done: Function) => { + await longClick("textInput3", done); + await Utils.sleep(1000) + done() + }) + + // 右键点击效果 + it('testTextInputSelectionMenuHidden010', 0, async (done: Function) => { + await rightClick("textInput1", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden011', 0, async (done: Function) => { + await rightClick("textInput2", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden012', 0, async (done: Function) => { + await rightClick("textInput3", done); + await Utils.sleep(1000) + done() + }) + + // 三击效果 + it('testTextInputSelectionMenuHidden013', 0, async (done: Function) => { + await threeClick("textInput1", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden014', 0, async (done: Function) => { + await threeClick("textInput2", done); + await Utils.sleep(1000) + done() + }) + + it('testTextInputSelectionMenuHidden015', 0, async (done: Function) => { + await threeClick("textInput3", done); + await Utils.sleep(1000) + done() + }) + + // resetAttribute 后的效果 + it('testTextInputSelectionMenuHidden016', 0, async (done: Function) => { + await click("textInput4", done); + await Utils.sleep(1000) + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSetTextSelectionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSetTextSelectionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de3a9373a37e2fefd284df9e3550fe79ece49daa --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputSetTextSelectionTest.test.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputSetTextSelectionTest() { + + describe('TextInputSetTextSelectionTest', () => { + + let PAGE_TAG = 'TextInputSetTextSelectionTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testTextInputSetTextSelection001', 0, async (done: Function) => { + focusControl.requestFocus("TextInputSetTextSelectionTest_textInput_id1"); + await Utils.sleep(1000); + await Utils.clickComponent("TextInputSetTextSelectionTest_id1"); + done(); + }) + + it('testTextInputSetTextSelection002', 1, async (done: Function) => { + focusControl.requestFocus("TextInputSetTextSelectionTest_textInput_id1"); + await Utils.sleep(1000); + await Utils.clickComponent("TextInputSetTextSelectionTest_id2"); + done(); + }) + + it('testTextInputSetTextSelection003', 0, async (done: Function) => { + focusControl.requestFocus("TextInputSetTextSelectionTest_textInput_id1"); + await Utils.sleep(1000); + await Utils.clickComponent("TextInputSetTextSelectionTest_id3"); + done(); + }) + + it('testTextInputSetTextSelection004', 0, async (done: Function) => { + focusControl.requestFocus("TextInputSetTextSelectionTest_textInput_id1"); + await Utils.sleep(1000); + await Utils.clickComponent("TextInputSetTextSelectionTest_id4"); + done(); + }) + + }) +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputShowKeyboardOnFocusTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputShowKeyboardOnFocusTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dcc75b5d2fb209d699492e84571a89a3865664a3 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputShowKeyboardOnFocusTest.test.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Component,Driver,UiWindow,ON } from '@ohos.UiTest' + +export default function textInputShowKeyboardOnFocusTest() { + + describe('TextInputShowKeyboardOnFocusTest', () => { + + let PAGE_TAG = 'TextInputShowKeyboardOnFocusTest'; + let PAGE_TAG_ABNORMAL = 'TextInputShowKeyboardOnFocusAbnormalTest'; + + it('testTextInputShowKeyboardOnFocusTest001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('OnFocusTestTextInputCompare') + await Utils.sleep(1000) + await Utils.clickComponent('OnFocusTestTextInputCompare') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextInputShowKeyboardOnFocusTest002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('OnFocusTestTextInput') + await Utils.sleep(1000) + await Utils.clickComponent('OnFocusTestTextInput') + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextInputShowKeyboardOnFocusTest003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_ABNORMAL}`); + focusControl.requestFocus("TextInputDisableTest") + await Utils.sleep(1000) + await Utils.clickComponent("TextInputDisableTest") + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + + it('testTextInputShowKeyboardOnFocusTest004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG_ABNORMAL}`); + focusControl.requestFocus("OnFocusTestTextInputReset") + await Utils.sleep(1000) + await Utils.clickComponent("OnFocusTestTextInputReset") + await Utils.sleep(1000) + let driver =await Driver.create() + await driver.screenCapture("/data/storage/el2/base/haps/entry_test/files/IMG_test.webp") + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputStyleTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputStyleTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d03975c29512f5fe60948c665b5b7b4d6d8d8148 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputStyleTest.test.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputStyleTest() { + + describe('TextInputStyleTest', () => { + + let PAGE_TAG = 'TextInputStyleTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testTextInputStyle001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('default') + await Utils.sleep(2000) + await Utils.clickComponent('default') + await Utils.sleep(2000) + }); + + it('testTextInputStyle002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('inline') + await Utils.sleep(2000) + await Utils.clickComponent('inline') + await Utils.sleep(2000) + }); + + it('testTextInputStyle003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('negative') + await Utils.sleep(2000) + await Utils.clickComponent('negative') + await Utils.sleep(2000) + }); + + it('testTextInputStyle004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('large') + await Utils.sleep(2000) + await Utils.clickComponent('large') + await Utils.sleep(2000) + }); + + it('testTextInputStyle005', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('reset') + await Utils.sleep(2000) + await Utils.clickComponent('reset') + await Utils.sleep(2000) + }); + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputTextPlaceholderTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputTextPlaceholderTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..76b4579c8fc31b37e1872f407ac03ba8413b1fc1 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputTextPlaceholderTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputTextPlaceholderTest() { + + describe('TextInputTextPlaceholderTest', () => { + + let PAGE_TAG = 'TextInputTextPlaceholderTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testTextInputTextPlaceholderTest001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + }); + + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputUnderlineColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputUnderlineColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d36152284a66962834289360f3adba575cda2496 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputUnderlineColorTest.test.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputUnderlineColorTest() { + + describe('TextInputUnderlineColorTest', () => { + + let PAGE_TAG = 'TextInputUnderlineColorTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testTextInputUnderlineColorTest001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput3') + await Utils.sleep(1000) + await Utils.clickComponent('textInput3') + await Utils.sleep(1000) + await Utils.triggerKey(2000) + await Utils.sleep(1000) + done(); + }) + + it('testTextInputUnderlineColorTest002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`); + focusControl.requestFocus('textInput2') + await Utils.sleep(1000) + await Utils.clickComponent('textInput2') + await Utils.sleep(1000) + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputWordBreakTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputWordBreakTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..99e6ea53be114a1c29264ba2605505c3b3f8496a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/textinput/TextInputWordBreakTest.test.ets @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function textInputWordBreakTest() { + + describe('TextInputWordBreakTest', () => { + + let PAGE_TAG = 'TextInputWordBreakTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done); + }); + + it('testTextInputWordBreak001', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput0') + await Utils.sleep(1000) + await Utils.clickComponent('textInput0') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak002', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput1') + await Utils.sleep(1000) + await Utils.clickComponent('textInput1') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak003', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput2') + await Utils.sleep(1000) + await Utils.clickComponent('textInput2') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak004', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput3') + await Utils.sleep(1000) + await Utils.clickComponent('textInput3') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak005', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput4') + await Utils.sleep(1000) + await Utils.clickComponent('textInput4') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak006', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput5') + await Utils.sleep(1000) + await Utils.clickComponent('textInput5') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak007', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput6') + await Utils.sleep(1000) + await Utils.clickComponent('textInput6') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak008', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput7') + await Utils.sleep(1000) + await Utils.clickComponent('textInput7') + await Utils.sleep(1000) + done(); + }) + + it('testTextInputWordBreak009', 0, async (done: Function) => { + await Utils.pushPage(`textinput/${PAGE_TAG}`, done); + focusControl.requestFocus('textInput8') + await Utils.sleep(1000) + await Utils.clickComponent('textInput8') + await Utils.sleep(1000) + done(); + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/toggle/ToggleUnSelectedColorTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/toggle/ToggleUnSelectedColorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c581909dc6a4c73acb3c9646a2742e2a7a1bc14 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/toggle/ToggleUnSelectedColorTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function toggleUnSelectedColorTest() { + + describe('ToggleUnSelectedColorTest', () => { + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // Toggle组件触发NODE_TOGGLE_UNSELECTED_COLOR以及reset的显示效果测试 + // NODE_TOGGLE_VALUE:false + // NODE_TOGGLE_UNSELECTED_COLOR:0xFFFF0000,COLOR_RED,100 + // NODE_MARGIN:30 + it('testToggleUnSelectedColor001', 0, async (done: Function) => { + let PAGE_TAG = 'ToggleUnSelectedColorTest'; + await Utils.pushPage(`toggle/${PAGE_TAG}`,() => setTimeout(() => { + }, 10000)); + await Utils.clickComponent("ResetToggle"); + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(5000) + done() + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/tools/ToolsLayoutRectTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/tools/ToolsLayoutRectTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..21538fe6f6c0aa1d55d892dc61417398125c2e00 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/tools/ToolsLayoutRectTest.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +async function doIt(done: Function) { + await Utils.sleep(2000) + WindowSnap.snapShot(globalThis.context, 'test', done) + await Utils.sleep(1000) + done() +} + +export default function toolsLayoutRectTest() { + + describe('ToolsLayoutRectTest', () => { + + let PAGE_TAG1 = 'ToolsLayoutRectTest'; + let PAGE_TAG2 = 'ToolsLayoutRectInLandscapeTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testToolsLayoutRect001', 0, async (done: Function) => { + await Utils.pushPage(`tools/${PAGE_TAG1}`, done); + }); + + it('testToolsLayoutRect002', 0, async (done: Function) => { + await Utils.pushPage(`tools/${PAGE_TAG2}`); + await doIt(done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/unit/UnitLengthMetricsTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/unit/UnitLengthMetricsTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..03adf38594ba4650fc2bdaf201d5f18d1be9584a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/unit/UnitLengthMetricsTest.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function unitLengthMetricsTest() { + + describe('UnitLengthMetricsTest', () => { + + let PAGE_TAG = 'UnitLengthMetricsTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testUnitLengthMetrics001', 0, async (done: Function) => { + await Utils.pushPage(`unit/${PAGE_TAG}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/unit/UnitPercentTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/unit/UnitPercentTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..31710166d71251a2cb8095253b841d128b0c6f18 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/unit/UnitPercentTest.test.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function unitPercentTest() { + + describe('UnitPercentTest', () => { + + let PAGE_TAG1 = 'UnitPercentTest'; + let PAGE_TAG2 = 'UnitPercentPaddingTest'; + let PAGE_TAG3 = 'UnitPercentBorderRadiusTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testUnitPercent001', 0, async (done: Function) => { + await Utils.pushPage(`unit/${PAGE_TAG1}`, done); + }); + + it('testUnitPercent002', 0, async (done: Function) => { + await Utils.pushPage(`unit/${PAGE_TAG2}`, done); + }); + + it('testUnitPercent003', 0, async (done: Function) => { + await Utils.pushPage(`unit/${PAGE_TAG3}`, done); + }); + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowCachedCountTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowCachedCountTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..be7ddf89c0af599a7875d2c51fa9875c1f18d967 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowCachedCountTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowCachedCountTest() { + + describe('WaterFlowCachedCountTest', () => { + + let PAGE_TAG = 'WaterFlowCachedCountTest'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // NODE_WATER_FLOW_CACHED_COUNT + // NODE_WATER_FLOW_NODE_ADAPTER + it('testWaterFlowCachedCount001', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG}`, done); + await Utils.clickComponent("btn"); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowColumnsRowsGap.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowColumnsRowsGap.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2064e6820294b389d8f26a84dd9976feb98ac30 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowColumnsRowsGap.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowColumnsRowsGapTest() { + + describe('WaterFlowColumnsRowsGapTest', () => { + + let PAGE_TAG = 'WaterFlowColumnsRowsGapTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // NODE_WATER_FLOW_COLUMN_GAP + // NODE_WATER_FLOW_ROW_GAP + it('testWaterFlowColumnsRowsGap001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowColumnsRowsTemplateTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowColumnsRowsTemplateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..be9ad56b7b1bd2ccfe37cf354c56f48d9b0ce088 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowColumnsRowsTemplateTest.test.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowColumnsRowsTemplateTest() { + + describe('WaterFlowColumnsRowsTemplateTest', () => { + + let PAGE_TAG = 'WaterFlowColumnsRowsTemplateTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + // NODE_WATER_FLOW_COLUMN_TEMPLATE + // NODE_WATER_FLOW_ROW_TEMPLATE + it('testWaterFlowColumnsRowsTemplate001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowEventTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowEventTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..15c6cfa28ca02e0c53f17d2d94c64cd9aae0b0a9 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowEventTest.test.ets @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +async function flingComponentV(key: string, isForward: boolean, speed: number = 500, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let Y1 = centerY - distance; + let Y2 = centerY + distance; + let stepLen = 20; + if (isForward) { + await driver.fling({ + x: centerX, y: Y2 + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: Y1 + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } +} +async function flingComponentH(key: string, isLeft: boolean, speed: number = 500, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X1 = centerX - distance; + let X2 = centerX + distance; + let stepLen = 20; + if (isLeft) { + await driver.fling({ + x: X2, y: centerY + }, { + x: X1, y: centerY + }, stepLen, speed); + } else { + await driver.fling({ + x: X1, y: centerY + }, { + x: X2, y: centerY + }, stepLen, speed); + } +} +export default function waterFlowEventTest() { + + describe('WaterFlowEventTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowEvent001', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowOnStartEndStopTest`, ()=>{}); + await Utils.clickComponent("btn"); + done(); + }) + // it('testWaterFlowEvent002', 0, async (done: Function) => { + // await Utils.pushPage(`waterflow/WaterFlowOnDidScrollTest`, done); + // await Utils.clickComponent("btn"); + // done(); + // }) + it('testWaterFlowEvent003', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowOnWillScrollTest`, ()=>{ + setTimeout(()=>{}, 7000); + }); + await Utils.clickComponent("btn"); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowFooterTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowFooterTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0cb857690727918f446f3294ea76265cc825b0f6 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowFooterTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowFooterTest() { + + describe('WaterFlowFooterTest', () => { + + let PAGE_TAG = 'WaterFlowFooterTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowFooter001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowItemConstraintSizeTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowItemConstraintSizeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a462647cd5fe9ab30eb6fe0a6476b18f84fd4972 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowItemConstraintSizeTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowItemConstraintSizeTest() { + + describe('WaterFlowItemConstraintSizeTest', () => { + + let PAGE_TAG = 'WaterFlowItemConstraintSizeTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowItemConstraintSize001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowLayoutDirectionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowLayoutDirectionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0dee3c0c3b488df69b3f45658c4c39ee734dd6fc --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowLayoutDirectionTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowLayoutDirectionTest() { + + describe('WaterFlowLayoutDirectionTest', () => { + + let PAGE_TAG = 'WaterFlowLayoutDirectionTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowLayoutDirection001', 0, async (done: Function) => { + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowNestedScrollTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowNestedScrollTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de00a9445bdcfcf0e53377181d54be4455586f2a --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowNestedScrollTest.test.ets @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, beforeEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +async function flingComponentV(key: string, isForward: boolean, speed: number = 500, distance: number = 40) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let Y1 = centerY - distance; + let Y2 = centerY + distance; + let stepLen = 20; + if (isForward) { + await driver.fling({ + x: centerX, y: Y2 + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: Y1 + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } +} + +export default function waterFlowNestedScrollTest() { + + describe('WaterFlowNestedScrollTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowNestedScroll001', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowNestedScrollTest`, ()=>{ + setTimeout(()=>{}, 7000); + }); + await flingComponentV("scroll1", false, 40000) + await flingComponentV("scroll2", false, 40000) + await flingComponentV("scroll3", false, 40000) + await flingComponentV("scroll4", false, 40000) + await flingComponentV("scroll5", false, 40000) + await flingComponentV("scroll6", false, 40000) + await flingComponentV("scroll7", true, 40000) + await flingComponentV("scroll8", true, 40000) + await flingComponentV("scroll9", true, 40000) + await flingComponentV("scroll10", true, 40000) + await flingComponentV("scroll11", true, 40000) + await flingComponentV("scroll12", true, 40000) + done(); + }) + it('testWaterFlowNestedScroll002', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowNestedScrollSmallTest`, ()=>{ + setTimeout(()=>{}, 7000); + }); + await flingComponentV("scroll1", false, 40000) + await flingComponentV("scroll2", false, 40000) + await flingComponentV("scroll3", false, 40000) + await flingComponentV("scroll4", false, 40000) + await flingComponentV("scroll5", false, 40000) + await flingComponentV("scroll6", false, 40000) + await flingComponentV("scroll7", true, 40000) + await flingComponentV("scroll8", true, 40000) + await flingComponentV("scroll9", true, 40000) + await flingComponentV("scroll10", true, 40000) + await flingComponentV("scroll11", true, 40000) + await flingComponentV("scroll12", true, 40000) + done(); + }) + it('testWaterFlowNestedScroll003', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowNestedScrollResetTest`, ()=>{ + setTimeout(()=>{}, 7000); + }); + await flingComponentV("scroll1", false, 40000) + await flingComponentV("scroll2", false, 40000) + await flingComponentV("scroll3", false, 40000) + await flingComponentV("scroll4", false, 40000) + await flingComponentV("scroll5", false, 40000) + await flingComponentV("scroll6", false, 40000) + await flingComponentV("scroll7", true, 40000) + await flingComponentV("scroll8", true, 40000) + await flingComponentV("scroll9", true, 40000) + await flingComponentV("scroll10", true, 40000) + await flingComponentV("scroll11", true, 40000) + await flingComponentV("scroll12", true, 40000) + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowScrollTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowScrollTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..597e3ba3b76a4d8b7ad1f43407af5305bf7b6615 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowScrollTest.test.ets @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, beforeEach, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; +import { Driver } from '@kit.TestKit'; + +async function flingComponentV(key: string, isForward: boolean, speed: number = 500, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let Y1 = centerY - distance; + let Y2 = centerY + distance; + let stepLen = 20; + if (isForward) { + await driver.fling({ + x: centerX, y: Y2 + }, { + x: centerX, y: Y1 + }, stepLen, speed); + } else { + await driver.fling({ + x: centerX, y: Y1 + }, { + x: centerX, y: Y2 + }, stepLen, speed); + } +} +async function flingComponentH(key: string, isLeft: boolean, speed: number = 500, distance: number = 20) { + let driver = Driver.create(); + let rect = Utils.getComponentRect(key); + let centerX = Utils.getRectHorizontalCenterX(rect) + let centerY = Utils.getRectVerticalCenterY(rect) + let X1 = centerX - distance; + let X2 = centerX + distance; + let stepLen = 20; + if (isLeft) { + await driver.fling({ + x: X2, y: centerY + }, { + x: X1, y: centerY + }, stepLen, speed); + } else { + await driver.fling({ + x: X1, y: centerY + }, { + x: X2, y: centerY + }, stepLen, speed); + } +} + +export default function waterFlowScrollTest() { + + describe('WaterFlowScrollTest', () => { + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowScroll002', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollBarWidthTest`, done); + done(); + }) + it('testWaterFlowScroll003', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollBarColorTest`, done); + done(); + }) + it('testWaterFlowScroll006', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollOffset2Test`, () => setTimeout(() => { + }, 1000)); + done(); + }) + it('testWaterFlowScroll008', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollEdgeTest`, done); + done(); + }) + it('testWaterFlowScroll009', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollPageTest`, done); + await Utils.clickComponent('btn'); + done(); + }) + it('testWaterFlowScroll010', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollByTest`, done); + done(); + }) + it('testWaterFlowScroll011', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowEnableScrollInteractionTest`, ()=>{ + setTimeout(() => { + }, 5000); + }); + await flingComponentV('col1', false); + await flingComponentV('col2', false); + await flingComponentH('col3', false); + await flingComponentH('col4', false); + await flingComponentV('col5', true, 1000); + await flingComponentV('col6', true, 1000); + await flingComponentV('col7', true, 1000, 70); + await flingComponentV('col8', true, 1000, 70); + await flingComponentH('col9', true, 1000, 40); + await flingComponentH('col10', true, 1000, 40); + done(); + }) + it('testWaterFlowScroll012', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollToIndexTest`, done); + done(); + }) + it('testWaterFlowScroll013', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/WaterFlowScrollToIndex8Test`, done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowSectionTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowSectionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..01287e4a467fabaecfcac3754ecf2cd1cfef3e64 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/waterflow/WaterFlowSectionTest.test.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function waterFlowSectionTest() { + + describe('WaterFlowSectionTest', () => { + + let PAGE_TAG1 = 'WaterFlowSectionTest1'; + let PAGE_TAG2 = 'WaterFlowSectionTest2'; + let PAGE_TAG3 = 'WaterFlowSectionTest3'; + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testWaterFlowSection001', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG1}`, done); + done(); + }) + it('testWaterFlowSection002', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG2}`, done); + done(); + }) + it('testWaterFlowSection003', 0, async (done: Function) => { + await Utils.pushPage(`waterflow/${PAGE_TAG3}`, done); + done(); + }) + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/xcomponent/XComponentIdTest.test.ets b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/xcomponent/XComponentIdTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c570d10a444907b335e20a9bbb3f5f5a17d1de66 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/test/xcomponent/XComponentIdTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { afterEach, beforeAll, describe, it } from '@ohos/hypium'; +import Utils from '../common/Utils'; +import WindowSnap from '../common/Snap'; + +export default function xComponentIdTest() { + + describe('XComponentIdTest', () => { + + let PAGE_TAG = 'XComponentIdTest'; + + beforeAll(async (done: Function) => { + await Utils.pushPage(`xcomponent/${PAGE_TAG}`, done); + }); + + afterEach(async (done: Function) => { + WindowSnap.snapShot(globalThis.context, 'test', done) + }) + + it('testXComponentId001', 0, async (done: Function) => { + done() + }) + + }) +} diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/function/ui_compare/capidemo/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..02823b530ec8c6074063266c903d39823509bacf --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +let abilityDelegator = undefined; +let abilityDelegatorArguments = undefined; + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]); + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}`; + } + } + return targetParams.trim(); +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a MainAbility' + + ' -b ' + abilityDelegatorArguments.bundleName; + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters); + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') { + cmd += ' -D'; + } + console.info('cmd : ' + cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }); + console.info('OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/module.json5 b/function/ui_compare/capidemo/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e719763fe5707a428ab325d7b0b0dd595416cd2e --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "srcEntry": "./ets/Application/AbilityStage.ts", + "description": "$string:module_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "MainAbility", + "srcEntry": "./ets/MainAbility/MainAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.SYSTEM_FLOAT_WINDOW" + }, + { + "name": "ohos.permission.INTERNET" + }, + { + "name": "ohos.permission.SET_TIME" + } + ] + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/color.json b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/float.json b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..789ad804a9877b106f6c08be3ad7dc31d1812eab --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/float.json @@ -0,0 +1,24 @@ +{ + "float": [ + { + "name": "300vp", + "value": "300vp" + }, + { + "name": "200vp", + "value": "200vp" + }, + { + "name": "100vp", + "value": "100vp" + }, + { + "name": "50vp", + "value": "50vp" + } + ,{ + "name": "10vp", + "value": "10vp" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/string.json b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b976fb6d0379b826204087d18a5f01872ce4d54 --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/background.png b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe9979eda9db82793df2873701e4beae14c44cc Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/background.png differ diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/icon.png b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/icon_transparent.png b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/icon_transparent.png new file mode 100644 index 0000000000000000000000000000000000000000..0ec2e1692ed4a280147f41fa7491fa6595958153 Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/icon_transparent.png differ diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/rectIcon.png b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/rectIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..4b68e9b07b4c30539ff093e43c193cfd61dc59fd Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/rectIcon.png differ diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/src.jpg b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/src.jpg new file mode 100644 index 0000000000000000000000000000000000000000..36a19cd6b90bb98511116f5015c74fe2f860249d Binary files /dev/null and b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/media/src.jpg differ diff --git a/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/profile/main_pages.json b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..74ee040269ae29af379fe3e142b35b505d2fdb6c --- /dev/null +++ b/function/ui_compare/capidemo/entry/src/ohosTest/resources/base/profile/main_pages.json @@ -0,0 +1,328 @@ +{ + "src": [ + "MainAbility/pages/list/ListSpaceAndAlignmentTest", + "MainAbility/pages/list/ListChildrenMainSizeTest", + "MainAbility/pages/list/ListCloseAllTest", + "MainAbility/pages/list/ListDividerAndInitialIndexTest", + "MainAbility/pages/list/ListNestedScrollTest", + "MainAbility/pages/list/ListNestedScrollSmallTest", + "MainAbility/pages/list/ListScrollByTest", + "MainAbility/pages/list/ListScrollEdgeTest", + "MainAbility/pages/list/ListScrollOffset2Test", + "MainAbility/pages/list/ListScrollOffset6Test", + "MainAbility/pages/list/ListScrollPageTest", + "MainAbility/pages/list/ListScrollToIndexTest", + "MainAbility/pages/list/ListScrollBarWidthAndColorTest", + "MainAbility/pages/listitemgroup/ListItemGroupDividerTest", + "MainAbility/pages/listitemgroup/ListItemGroupHeaderAndFooterTest", + "MainAbility/pages/DemoIndex", + "MainAbility/pages/column/ColumnJustifyContentTest", + "MainAbility/pages/column/ColumnAlignItemsTest", + "MainAbility/pages/column/ColumnAlignItemsMoreAttributeTest", + "MainAbility/pages/row/RowJustifyContentTest", + "MainAbility/pages/row/RowAlignItemsTest", + "MainAbility/pages/row/RowAlignItemsMoreAttributeTest", + "MainAbility/pages/flex/FlexOptionsTest", + "MainAbility/pages/radio/RadioCheckedTest", + "MainAbility/pages/radio/RadioStyleTest", + "MainAbility/pages/radio/RadioValueAndGroupTest", + "MainAbility/pages/radio/RadioResetAttributeTest", + "MainAbility/pages/grid/GridTest", + "MainAbility/pages/grid/GridCachedCountTest", + "MainAbility/pages/grid/GridResetAttributeTest", + "MainAbility/pages/gesture/GestureGestureTest", + "MainAbility/pages/gesture/GestureGesture1Test", + "MainAbility/pages/gesture/GestureGesture2Test", + "MainAbility/pages/gesture/GestureGesture3Test", + "MainAbility/pages/requirement/RequirementPanGestureTest", + "MainAbility/pages/requirement/RequirementRouterPageStateTest", + "MainAbility/pages/resourcenapivalue/ResourceNapiValueTest", + "MainAbility/pages/lazyforeach/LazyForEachGetAllItemTest", + "MainAbility/pages/lazyforeach/LazyForEachUnregisterTest", + "MainAbility/pages/lazyforeach/LazyForEachTotalCountTest", + "MainAbility/pages/lazyforeach/LazyForEachNodeIdTest", + "MainAbility/pages/lazyforeach/LazyForEachDisposeTest", + "MainAbility/pages/lazyforeach/LazyForEachHostNodeTest", + "MainAbility/pages/lazyforeach/LazyForEachReloadAllItemsTest", + "MainAbility/pages/lazyforeach/LazyForEachReloadItemTest", + "MainAbility/pages/lazyforeach/LazyForEachReloadItemBigTest", + "MainAbility/pages/lazyforeach/LazyForEachRemoveItemTest", + "MainAbility/pages/lazyforeach/LazyForEachRemoveItemBigTest", + "MainAbility/pages/lazyforeach/LazyForEachInsertItemTest", + "MainAbility/pages/lazyforeach/LazyForEachInsertItemBigTest", + "MainAbility/pages/lazyforeach/LazyForEachMoveItemTest", + "MainAbility/pages/lazyforeach/LazyForEachMoveItemBigTest", + "MainAbility/pages/lazyforeach/LazyForEachGetRemovedNodeTest", + "MainAbility/pages/refresh/RefreshForContentAndRatioTest", + "MainAbility/pages/refresh/RefreshForContentAndRatioAbnormalTest", + "MainAbility/pages/refresh/RefreshForRefreshingTest", + "MainAbility/pages/refresh/RefreshNestedScrollTest", + "MainAbility/pages/refresh/RefreshPullToRefreshTrueTest", + "MainAbility/pages/refresh/RefreshPullToRefreshFalseTest", + "MainAbility/pages/refresh/RefreshPullToRefreshAbnormalTest", + "MainAbility/pages/refresh/RefreshPullToRefreshTrueAbnormalTest", + "MainAbility/pages/refresh/RefreshResetAttributeTest", + "MainAbility/pages/toggle/ToggleUnSelectedColorTest", + "MainAbility/pages/imageanimator/ImageFrameInfoTest", + "MainAbility/pages/imageanimator/ImageFrameInfoAbnormalTest", + "MainAbility/pages/imageanimator/ImageFrameInfoDrawableTest", + "MainAbility/pages/imageanimator/ImageFrameInfoDrawableAbnormalTest", + "MainAbility/pages/imageanimator/ImageAnimatorTest", + "MainAbility/pages/imageanimator/ImageAnimatorDurationTest", + "MainAbility/pages/imageanimator/ImageAnimatorReverseTest", + "MainAbility/pages/imageanimator/ImageAnimatorFixedSizeTest", + "MainAbility/pages/imageanimator/ImageAnimatorFillModeTest", + "MainAbility/pages/imageanimator/ImageAnimatorIterationsTest", + "MainAbility/pages/imageanimator/ImageAnimatorResetAttributeTest", + "MainAbility/pages/swiper/SwiperEffectModeSpringTest", + "MainAbility/pages/swiper/SwiperEffectModeMultipleTest", + "MainAbility/pages/swiper/SwiperEffectModeFadeTest", + "MainAbility/pages/swiper/SwiperEffectModeNoneTest", + "MainAbility/pages/swiper/SwiperEffectModeAbnormalTest", + "MainAbility/pages/swiper/SwiperEffectModeInterruptTest", + "MainAbility/pages/swiper/SwiperAdapterTest", + "MainAbility/pages/swiper/SwiperPrevMarginTest", + "MainAbility/pages/swiper/SwiperPrevMarginAbnormalTest", + "MainAbility/pages/swiper/SwiperNextMarginTest", + "MainAbility/pages/swiper/SwiperNextMarginAbnormalTest", + "MainAbility/pages/swiper/SwiperMarginTest", + "MainAbility/pages/swiper/SwiperNestedScrollTest", + "MainAbility/pages/swiper/SwiperNestedScrollChildTest", + "MainAbility/pages/swiper/SwiperNestedScrollAbnormalTest", + "MainAbility/pages/swiper/SwiperChangeIndexTest", + "MainAbility/pages/swiper/SwiperDotIndicatorTest", + "MainAbility/pages/swiper/SwiperDotIndicatorAbnormalTest", + "MainAbility/pages/swiper/SwiperEventOnGestureTest", + "MainAbility/pages/swiper/SwiperEventOnDidScrollTest", + "MainAbility/pages/swiper/SwiperOnChangeTest", + "MainAbility/pages/swiper/SwiperOnAnimationTest", + "MainAbility/pages/swiper/SwiperResetAttributeTest", + "MainAbility/pages/customdialog/CustomDialogContentTest", + "MainAbility/pages/button/ButtonTypeTest", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage1Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage2Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage3Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage4Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage5Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage6Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage7Test", + "MainAbility/pages/calendarpicker/CalendarPickerHintRadiusPage8Test", + "MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage1Test", + "MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage2Test", + "MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage3Test", + "MainAbility/pages/calendarpicker/CalendarPickerSelectedDatePage4Test", + "MainAbility/pages/slider/SliderTrackThicknessPage1Test", + "MainAbility/pages/slider/SliderTrackThicknessPage2Test", + "MainAbility/pages/stack/StackAlignContentTest", + "MainAbility/pages/waterflow/WaterFlowCachedCountTest", + "MainAbility/pages/waterflow/WaterFlowSectionTest1", + "MainAbility/pages/waterflow/WaterFlowSectionTest2", + "MainAbility/pages/waterflow/WaterFlowSectionTest3", + "MainAbility/pages/waterflow/WaterFlowLayoutDirectionTest", + "MainAbility/pages/waterflow/WaterFlowColumnsRowsTemplateTest", + "MainAbility/pages/waterflow/WaterFlowColumnsRowsGapTest", + "MainAbility/pages/waterflow/WaterFlowNestedScrollTest", + "MainAbility/pages/waterflow/WaterFlowNestedScrollSmallTest", + "MainAbility/pages/waterflow/WaterFlowNestedScrollResetTest", + "MainAbility/pages/waterflow/WaterFlowScrollBarColorTest", + "MainAbility/pages/waterflow/WaterFlowScrollBarWidthTest", + "MainAbility/pages/waterflow/WaterFlowScrollOffset2Test", + "MainAbility/pages/waterflow/WaterFlowScrollEdgeTest", + "MainAbility/pages/waterflow/WaterFlowScrollPageTest", + "MainAbility/pages/waterflow/WaterFlowScrollByTest", + "MainAbility/pages/waterflow/WaterFlowEnableScrollInteractionTest", + "MainAbility/pages/waterflow/WaterFlowScrollToIndexTest", + "MainAbility/pages/waterflow/WaterFlowScrollToIndex8Test", + "MainAbility/pages/waterflow/WaterFlowItemConstraintSizeTest", + "MainAbility/pages/waterflow/WaterFlowFooterTest", + "MainAbility/pages/waterflow/WaterFlowOnStartEndStopTest", + "MainAbility/pages/waterflow/WaterFlowOnDidScrollTest", + "MainAbility/pages/waterflow/WaterFlowOnWillScrollTest", + "MainAbility/pages/xcomponent/XComponentIdTest", + "MainAbility/pages/scroll/ScrollScrollBarWidthTest", + "MainAbility/pages/scroll/ScrollScrollByTest", + "MainAbility/pages/scroll/ScrollEnablePagingTest", + "MainAbility/pages/scroll/ScrollScrollEdgeHorizontalTest", + "MainAbility/pages/scroll/ScrollScrollEdgeVerticalTest", + "MainAbility/pages/span/SpanTextBackgroundStyleTest", + "MainAbility/pages/span/SpanValueTest", + "MainAbility/pages/span/SpanTextShadow", + "MainAbility/pages/span/SpanBaseLineOffsetTest", + "MainAbility/pages/span/SpanFontFamilyTest", + "MainAbility/pages/progress/ProgressValueAndTotalTest", + "MainAbility/pages/progress/ProgressTypeTest", + "MainAbility/pages/text/TextContentTest", + "MainAbility/pages/text/TextDecorationStyleTest", + "MainAbility/pages/text/TextWordBreakTest", + "MainAbility/pages/text/TextEllipsisModeTest", + "MainAbility/pages/text/TextLineSpacingTest", + "MainAbility/pages/text/TextFontFeatureFirstTest", + "MainAbility/pages/text/TextFontFeatureSecondTest", + "MainAbility/pages/text/TextFontFeatureThirdTest", + "MainAbility/pages/text/TextSelectedBackgroundColorTest", + "MainAbility/pages/text/TextDataDetectorConfigTest", + "MainAbility/pages/text/TextEnableDataDetectorTest", + "MainAbility/pages/text/TextParagraphTest", + "MainAbility/pages/textarea/TextAreaTextPlaceholderTest", + "MainAbility/pages/textarea/TextAreaTypeTest", + "MainAbility/pages/textarea/TextAreaShowCounterTest", + "MainAbility/pages/textarea/TextAreaFontFeatureFirstTest", + "MainAbility/pages/textarea/TextAreaFontFeatureSecondTest", + "MainAbility/pages/textarea/TextAreaFontFeatureThirdTest", + "MainAbility/pages/textarea/TextAreaMaxLinesTest", + "MainAbility/pages/textarea/TextAreaSelectionMenuHiddenTest", + "MainAbility/pages/textarea/TextAreaSelectionMenuHiddenAbnormalTest", + "MainAbility/pages/textarea/TextAreaSelectionMenuHiddenDisableTest", + "MainAbility/pages/textarea/TextAreaInputFilterTest", + "MainAbility/pages/textarea/TextAreaSelectedBackgroundColorTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeSearchTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeSendTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeNextTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeDoneTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypePreviousTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeNewLineTest", + "MainAbility/pages/textarea/TextAreaEnterKeyTypeAbnormalTest", + "MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusTest", + "MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusDisableTest", + "MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusAbnormalTest", + "MainAbility/pages/textarea/TextAreaEnableKeyboardOnFocusResetTest", + "MainAbility/pages/textarea/TextAreaBlurOnSubmitTest", + "MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusTest", + "MainAbility/pages/textarea/TextAreaShowKeyboardOnFocusAbnormalTest", + "MainAbility/pages/textarea/TextAreaGetCaretOffsetTest", + "MainAbility/pages/textarea/TextAreaCaretPositionTest", + "MainAbility/pages/textarea/TextAreaControllerTest", + "MainAbility/pages/textarea/TextAreaSetTextSelectionTest", + "MainAbility/pages/textarea/TextAreaContentTypePageOneTest", + "MainAbility/pages/textarea/TextAreaEnableAutoFillTest", + "MainAbility/pages/textarea/TextAreaNumberOfLinesTest", + "MainAbility/pages/textinput/TextInputCustomKeyboardPage1Test", + "MainAbility/pages/textinput/TextInputCustomKeyboardPage2Test", + "MainAbility/pages/textinput/TextInputCustomKeyboardPage3Test", + "MainAbility/pages/textinput/TextInputCustomKeyboardPage4Test", + "MainAbility/pages/textinput/TextInputCustomKeyboardPage5Test", + "MainAbility/pages/textinput/TextInputCustomKeyboardPage6Test", + "MainAbility/pages/textinput/TextInputSelectAllTest", + "MainAbility/pages/textinput/TextInputEnableAutoFillTest", + "MainAbility/pages/textinput/TextInputContentTypePage1Test", + "MainAbility/pages/textinput/TextInputPasswordRulesPage1Test", + "MainAbility/pages/textinput/TextInputPasswordRulesPage2Test", + "MainAbility/pages/textinput/TextInputPasswordRulesPage3Test", + "MainAbility/pages/textinput/TextInputSelectionMenuHiddenTest", + "MainAbility/pages/textinput/TextInputFontFeaturePage1Test", + "MainAbility/pages/textinput/TextInputFontFeaturePage2Test", + "MainAbility/pages/textinput/TextInputFontFeaturePage3Test", + "MainAbility/pages/textinput/TextInputTextPlaceholderTest", + "MainAbility/pages/textinput/TextInputCancelButtonTest", + "MainAbility/pages/textinput/TextInputSetTextSelectionTest", + "MainAbility/pages/textinput/TextInputUnderlineColorTest", + "MainAbility/pages/textinput/TextInputWordBreakTest", + "MainAbility/pages/textinput/TextInputStyleTest", + "MainAbility/pages/textinput/TextInputMinFontSizeAndMaxFontSizeTest", + "MainAbility/pages/textinput/TextInputMaxLinesTest", + "MainAbility/pages/textinput/TextInputNumberOfLinesTest", + "MainAbility/pages/textinput/TextInputInputFilterTest", + "MainAbility/pages/textinput/TextInputShowKeyboardOnFocusTest", + "MainAbility/pages/textinput/TextInputShowKeyboardOnFocusAbnormalTest", + "MainAbility/pages/textinput/TextInputBlurOnSubmitTest", + "MainAbility/pages/textinput/TextInputGetCaretOffsetTest", + "MainAbility/pages/textinput/TextInputCaretPositionTest", + "MainAbility/pages/textinput/TextInputControllerTest", + "MainAbility/pages/commonattrs/CommonAttrsZIndexPage1Test", + "MainAbility/pages/commonattrs/CommonAttrsZIndexPage2Test", + "MainAbility/pages/commonattrs/CommonAttrsZIndexPage3Test", + "MainAbility/pages/commonattrs/CommonAttrsOutlineColorTest", + "MainAbility/pages/commonattrs/CommonAttrsSizeTest", + "MainAbility/pages/commonattrs/CommonAttrsPaddingTest", + "MainAbility/pages/commonattrs/CommonAttrsAccessibilityRoleTest", + "MainAbility/pages/commonattrs/CommonAttrsAccessibilityStateTest", + "MainAbility/pages/commonattrs/CommonAttrsAccessibilityValueTest", + "MainAbility/pages/commonattrs/CommonAttrsFocusOnTouchTest", + "MainAbility/pages/commonattrs/CommonAttrsAlignmentPage1Test", + "MainAbility/pages/commonattrs/CommonAttrsAlignmentPage2Test", + "MainAbility/pages/commonattrs/CommonAttrsAlignmentPage3Test", + "MainAbility/pages/commonattrs/CommonAttrsTranslateTest", + "MainAbility/pages/commonattrs/CommonAttrsTouchAbleTest", + "MainAbility/pages/commonattrs/CommonAttrsRotateTest", + "MainAbility/pages/commonattrs/CommonAttrsRenderGroupTest", + "MainAbility/pages/commonattrs/CommonAttrsLayoutWeightTest", + "MainAbility/pages/commonattrs/CommonAttrsDisplayPriorityTest", + "MainAbility/pages/commonattrs/CommonAttrsOutlineWidthTest", + "MainAbility/pages/commonattrs/CommonAttrsChainModeTest", + "MainAbility/pages/commonattrs/CommonAttrsChainMode1Test", + "MainAbility/pages/commonattrs/CommonAttrsChainMode2Test", + "MainAbility/pages/commonattrs/CommonAttrsColorBlendTest", + "MainAbility/pages/commonattrs/CommonAttrsBackgroundBlurStyleTest", + "MainAbility/pages/commonattrs/CommonAttrsBackgroundImageResourceStrTest", + "MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePixelMapTest", + "MainAbility/pages/commonattrs/CommonAttrsBackgroundImageSizeTest", + "MainAbility/pages/commonattrs/CommonAttrsBackgroundImagePositionTest", + "MainAbility/pages/commonattrs/CommonAttrsBrightnessTest", + "MainAbility/pages/commonattrs/CommonAttrsSaturateTest", + "MainAbility/pages/commonattrs/CommonAttrsBlurTest", + "MainAbility/pages/commonattrs/CommonAttrsClipShapeTest", + "MainAbility/pages/commonattrs/CommonAttrsCustomShadowTest", + "MainAbility/pages/commonattrs/CommonAttrsVisibilityTest", + "MainAbility/pages/commonattrs/CommonAttrsDefaultFocusSingleTest", + "MainAbility/pages/commonattrs/CommonAttrsDefaultFocusNoneTest", + "MainAbility/pages/commonattrs/CommonAttrsDefaultFocusMultiTest", + "MainAbility/pages/commonattrs/CommonAttrsDefaultFocusAbnormalTest", + "MainAbility/pages/commonattrs/CommonAttrsFocusStatusTest", + "MainAbility/pages/commonattrs/CommonAttrsAspectRatioTest", + "MainAbility/pages/commonattrs/CommonAttrsForegroundColorTest", + "MainAbility/pages/commonattrs/CommonAttrsMarkAnchorTest", + "MainAbility/pages/commonattrs/CommonAttrsOffsetTest", + "MainAbility/pages/commonattrs/CommonAttrsOverlayTest", + "MainAbility/pages/commonattrs/CommonAttrsResponseRegionTest", + "MainAbility/pages/commonattrs/CommonAttrsScaleTest", + "MainAbility/pages/commonevent/CommonEventTest", + "MainAbility/pages/commonevent/CommonOnHoverEventTest", + "MainAbility/pages/commonevent/CommonOnVisibleAreaChangeEventTest", + "MainAbility/pages/commonevent/CommonOnMouseEventTest", + "MainAbility/pages/commonevent/CommonOnTouchInterceptEventTest", + "MainAbility/pages/nodetree/NodeTreeInsertTest", + "MainAbility/pages/nodetree/NodeTreeXComponentTest", + "MainAbility/pages/nodetree/NodeTreeRemoveTest", + "MainAbility/pages/eventcallback/EventCallbackSpecifyNodeTest", + "MainAbility/pages/eventcallback/EventCallbackGlobalTest", + "MainAbility/pages/attributesetting/AttributeSettingTest", + "MainAbility/pages/inputevent/InputEventTest", + "MainAbility/pages/image/ImageSrcTest", + "MainAbility/pages/image/ImagePixelMapSrcTest", + "MainAbility/pages/image/ImageDraggableTest", + "MainAbility/pages/image/ImageRenderModeTest", + "MainAbility/pages/image/ImageFitOriginalSizeTest", + "MainAbility/pages/image/ImageFillColorTest", + "MainAbility/pages/image/ImageOnfinishTest", + "MainAbility/pages/image/ImageOnDownloadProgressTest", + "MainAbility/pages/image/ImageResizableTest", + "MainAbility/pages/image/ImageObjectFitResetAndAbnormalTest", + "MainAbility/pages/image/ImageObjectFitTest", + "MainAbility/pages/imagespan/ImageSpanSrcTest", + "MainAbility/pages/imagespan/ImageSpanPixelMapSrcTest", + "MainAbility/pages/imagespan/ImageSpanAltAndOnClickTest", + "MainAbility/pages/relativecontainer/RelativeContainerBarrierTest", + "MainAbility/pages/relativecontainer/RelativeContainerGuideLineTest", + "MainAbility/pages/relativecontainer/RuleOptionTest", + "MainAbility/pages/unit/UnitLengthMetricsTest", + "MainAbility/pages/unit/UnitPercentTest", + "MainAbility/pages/unit/UnitPercentBorderRadiusTest", + "MainAbility/pages/unit/UnitPercentPaddingTest", + "MainAbility/pages/mix/MixGetNodeHandleTest", + "MainAbility/pages/tools/ToolsLayoutRectTest", + "MainAbility/pages/tools/ToolsLayoutRectInLandscapeTest", + "MainAbility/pages/customcomponent/CustomComponentMeasuredSizeTest", + "MainAbility/pages/customcomponent/CustomComponentLayoutPositionTest", + "MainAbility/pages/customcomponent/CustomComponentDrawContextTest", + "MainAbility/pages/customcomponent/CustomComponentGetTotalChildCountTest", + "MainAbility/pages/customcomponent/CustomComponentGetChildAtTest", + "MainAbility/pages/customcomponent/CustomComponentGetFirstChildTest", + "MainAbility/pages/customcomponent/CustomComponentGetLastChildTest", + "MainAbility/pages/customcomponent/CustomComponentGetPreviousNextSiblingTest", + "MainAbility/pages/customcomponent/CustomComponentCustomEventTest", + "MainAbility/pages/customcomponent/CustomComponentUnregisterCustomEventTest", + "MainAbility/pages/customcomponent/CustomComponentLayoutConstraintTest", + "MainAbility/pages/customcomponent/CustomComponentLayoutAgainTest" + ] +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/hvigor/hvigor-config.json5 b/function/ui_compare/capidemo/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b4886e292b5c51a798793e64804b56fd936d4f45 --- /dev/null +++ b/function/ui_compare/capidemo/hvigor/hvigor-config.json5 @@ -0,0 +1,5 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + } +} \ No newline at end of file diff --git a/function/ui_compare/capidemo/hvigorfile.ts b/function/ui_compare/capidemo/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..159890e9ee8c4dc8cfff2a03e6207edb86abb0b5 --- /dev/null +++ b/function/ui_compare/capidemo/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/function/ui_compare/capidemo/oh-package.json5 b/function/ui_compare/capidemo/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8cde42f47fc4dbfc5fcb8e0388316d4e6f892cc8 --- /dev/null +++ b/function/ui_compare/capidemo/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} \ No newline at end of file