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