diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index aeb53e3ef790eba04a9c4724234d4faf901804d0..a1ffebc463678b9d3d6730161699866fc9aeaeb4 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -36,6 +36,7 @@ group("multimedia") { "image/image_js_standard/imageModifyProperty:image_modifyProperty_js_hap", "image/image_js_standard/imagePacking:image_packing_js_hap", "image/image_js_standard/imagePixelMapFramework:image_pixelmapframework_js_hap", + "image/image_js_standard/imagePixelMapNDK:image_pixel_map_ndk_js_hap", "image/image_js_standard/imageRGBA:image_rgba_js_hap", "image/image_js_standard/imageRaw:image_raw_js_hap", "image/image_js_standard/imageReceiver:image_receiver_js_hap", diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/BUILD.gn b/multimedia/image/image_js_standard/imagePixelMapNDK/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a2c80199a2ffd1fe115a0b08623d643b58173ffd --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("image_pixel_map_ndk_js_hap") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_third_ets_assets", + ":ace_third_ets_resources", + ":ace_third_ets_test_assets", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsImagePixelMapNdkJsTest" + subsystem_name = "multimedia" + part_name = "multimedia_image_framework" + shared_libraries = [ "./entry/src/main/cpp:ImagePixelMapNDKTest" ] +} + +ohos_js_assets("ace_third_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_js_assets("ace_third_ets_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} +ohos_resources("ace_third_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/Test.json b/multimedia/image/image_js_standard/imagePixelMapNDK/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..0ee8c774b728557b6f6daa5e0e4e1210f7cfb5ad --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "testcase-timeout": "300000", + "bundle-name": "ohos.acts.multimedia.imagePixelMapNDK", + "package-name": "ohos.acts.multimedia.imagePixelMapNDK", + "shell-timeout": "600000" + }, + "kits": [{ + "test-file-name": [ + "ActsImagePixelMapNdkJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }] +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..3f2518f3ea3aa67a80b36aaf8cb0bd105b3f31eb --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json @@ -0,0 +1,130 @@ +{ + "app": { + "bundleName": "ohos.acts.multimedia.imagePixelMapNDK", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.multimedia.imagePixelMapNDK", + "name": ".MyApplication", + "mainAbility": "ohos.acts.multimedia.imagePixelMapNDK.MainAbility", + "deviceType": [ + "tablet", + "default", + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "reqPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "use ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "use ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "use ohos.permission.WRITE_MEDIA" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "formsEnabled": false, + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/BUILD.gn b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d08908f961c7397a8cda7fe041979ad855f06e1c --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/ohos/config.gni") +import("//build/ohos.gni") +import("//foundation/arkui/napi/napi.gni") + +config("config") { + visibility = [ ":*" ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Wunused-variable", + ] +} + +ohos_shared_library("ImagePixelMapNDKTest") { + sources = [ "./napi/image_pixel_map_imgndk_test.cpp" ] + if (target_cpu == "arm") { + libs = [ "${clang_base_path}/../libcxx-ndk/lib/arm-linux-ohos/c++/libc++_shared.so" ] + } else if (target_cpu == "arm64") { + libs = [ "${clang_base_path}/../libcxx-ndk/lib/aarch64-linux-ohos/c++/libc++_shared.so" ] + } else { + libs = [] + } + include_dirs = [ "../cpp" ] + configs = [ ":config" ] + + external_deps = [ + "multimedia_image_framework:pixelmap_ndk", + "napi:ace_napi", + ] + + output_extension = "so" + subsystem_name = "multimedia" + part_name = "multimedia_image_framework" +} diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/napi/image_pixel_map_imgndk_test.cpp b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/napi/image_pixel_map_imgndk_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5364791c0e9c7dc98515dd375da2389c8b3c792b --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/napi/image_pixel_map_imgndk_test.cpp @@ -0,0 +1,637 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "image_pixel_map_imgndk_test.h" +#include "node_api.h" +#include "image_pixel_map_napi.h" + +namespace { + constexpr uint32_t NUM_0 = 0; + constexpr uint32_t NUM_1 = 1; + constexpr uint32_t NUM_2 = 2; + constexpr uint32_t NUM_3 = 3; + constexpr uint32_t NUM_4 = 4; + constexpr uint32_t NUM_5 = 5; +} + +namespace OHOS { +namespace Media { +#define STATIC_FUNCTION(n, f) { (n), nullptr, (f), nullptr, nullptr, nullptr, napi_static, nullptr } + +napi_value ImagePixelMapNDKTest::Init(napi_env env, napi_value exports) +{ + napi_property_descriptor props[] = { + STATIC_FUNCTION("createPixelMap", CreatePixelMap), + STATIC_FUNCTION("createAlphaPixelMap", CreateAlphaPixelMap), + STATIC_FUNCTION("initNativePixelMap", InitNativePixelMap), + STATIC_FUNCTION("getBytesNumberPerRow", GetBytesNumberPerRow), + STATIC_FUNCTION("getIsEditable", GetIsEditable), + STATIC_FUNCTION("isSupportAlpha", IsSupportAlpha), + STATIC_FUNCTION("setAlphaAble", SetAlphaAble), + STATIC_FUNCTION("getDensity", GetDensity), + STATIC_FUNCTION("setDensity", SetDensity), + STATIC_FUNCTION("setOpacity", SetOpacity), + STATIC_FUNCTION("scale", Scale), + STATIC_FUNCTION("translate", Translate), + STATIC_FUNCTION("rotate", Rotate), + STATIC_FUNCTION("flip", Flip), + STATIC_FUNCTION("crop", Crop), + STATIC_FUNCTION("getImageInfo", GetImageInfo), + STATIC_FUNCTION("accessPixels", AccessPixels), + STATIC_FUNCTION("unAccessPixels", UnAccessPixels), + }; + napi_define_properties(env, exports, sizeof(props) / sizeof(props[0]), props); + return exports; +} + +static bool parseWidth(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + napi_value napiWidth = nullptr; + if (napi_get_named_property(env, root, "width", &napiWidth) != napi_ok || napiWidth == nullptr) { + return false; + } + return (napi_get_value_uint32(env, napiWidth, &(opts->width)) == napi_ok); +} + +static bool parseHeight(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + napi_value napiHeight = nullptr; + if (napi_get_named_property(env, root, "height", &napiHeight) != napi_ok || napiHeight == nullptr) { + return false; + } + return (napi_get_value_uint32(env, napiHeight, &(opts->height)) == napi_ok); +} + +static bool parsePixelFormat(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + napi_value napiPixelFormat = nullptr; + if (napi_get_named_property(env, root, "pixelFormat", &napiPixelFormat) != napi_ok + || napiPixelFormat == nullptr) { + return false; + } + return (napi_get_value_int32(env, napiPixelFormat, &(opts->pixelFormat)) == napi_ok); +} + +static bool parseEditable(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + napi_value napiEditable = nullptr; + if (napi_get_named_property(env, root, "editable", &napiEditable) != napi_ok + || napiEditable == nullptr) { + return false; + } + return (napi_get_value_uint32(env, napiEditable, &(opts->editable)) == napi_ok); +} + +static bool parseAlphaType(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + napi_value napiAlphaType = nullptr; + if (napi_get_named_property(env, root, "alphaType", &napiAlphaType) != napi_ok + || napiAlphaType == nullptr) { + return false; + } + return (napi_get_value_uint32(env, napiAlphaType, &(opts->alphaType)) == napi_ok); +} + +static bool parseScaleMode(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + napi_value napiScaleMode = nullptr; + if (napi_get_named_property(env, root, "scaleMode", &napiScaleMode) != napi_ok + || napiScaleMode == nullptr) { + return false; + } + return (napi_get_value_uint32(env, napiScaleMode, &(opts->scaleMode)) == napi_ok); +} + +static bool parseCreateOptions(napi_env env, napi_value root, struct OhosPixelMapCreateOps* opts) +{ + if (!parseWidth(env, root, opts)) { + return false; + } + if (!parseHeight(env, root, opts)) { + return false; + } + if (!parsePixelFormat(env, root, opts)) { + return false; + } + if (!parseEditable(env, root, opts)) { + return false; + } + if (!parseAlphaType(env, root, opts)) { + return false; + } + if (!parseScaleMode(env, root, opts)) { + return false; + } + return true; +} + +napi_value ImagePixelMapNDKTest::CreatePixelMap(napi_env env, napi_callback_info info) +{ + napi_value udfVar = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_2] = {0}; + size_t argCount = NUM_2; + + void* buffer = nullptr; + size_t bufferSize = NUM_0; + struct OhosPixelMapCreateOps createOps; + napi_value pixelmap = nullptr; + + napi_get_undefined(env, &udfVar); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_2 || argValue[NUM_0] == nullptr || argValue[NUM_1] == nullptr) { + return udfVar; + } + if (napi_get_arraybuffer_info(env, argValue[NUM_0], &buffer, &bufferSize) != napi_ok || + buffer == nullptr || bufferSize == NUM_0) { + return udfVar; + } + if (!parseCreateOptions(env, argValue[NUM_1], &createOps)) { + return udfVar; + } + int32_t res = OH_PixelMap_CreatePixelMap(env, createOps, buffer, bufferSize, &pixelmap); + if (res != OHOS_IMAGE_RESULT_SUCCESS || pixelmap == nullptr) { + return udfVar; + } + return pixelmap; +} + +napi_value ImagePixelMapNDKTest::CreateAlphaPixelMap(napi_env env, napi_callback_info info) +{ + napi_value udfVar = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_1] = {0}; + size_t argCount = NUM_1; + + napi_value alphaPixelmap = nullptr; + + napi_get_undefined(env, &udfVar); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_1 || argValue[NUM_0] == nullptr) { + return udfVar; + } + int32_t res = OH_PixelMap_CreateAlphaPixelMap(env, argValue[NUM_0], &alphaPixelmap); + if (res != OHOS_IMAGE_RESULT_SUCCESS || alphaPixelmap == nullptr) { + return udfVar; + } + return alphaPixelmap; +} +static NativePixelMap* getNativePixelMap(napi_env env, napi_callback_info info) +{ + napi_value thisVar = nullptr; + napi_value argValue[NUM_1] = {0}; + size_t argCount = NUM_1; + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_1 || argValue[NUM_0] == nullptr) { + return nullptr; + } + return OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); +} + +napi_value ImagePixelMapNDKTest::InitNativePixelMap(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + napi_create_int32(env, OHOS_IMAGE_RESULT_SUCCESS, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::GetBytesNumberPerRow(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + int32_t rowBytes = NUM_0; + int32_t res = OH_PixelMap_GetBytesNumberPerRow(native, &rowBytes); + if (res != OHOS_IMAGE_RESULT_SUCCESS || rowBytes == NUM_0) { + return result; + } + + napi_create_int32(env, rowBytes, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::GetIsEditable(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + int32_t editable = NUM_0; + int32_t res = OH_PixelMap_GetIsEditable(native, &editable); + if (res != OHOS_IMAGE_RESULT_SUCCESS) { + return result; + } + + napi_create_int32(env, editable, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::IsSupportAlpha(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + int32_t supportAlpha = NUM_0; + int32_t res = OH_PixelMap_IsSupportAlpha(native, &supportAlpha); + if (res != OHOS_IMAGE_RESULT_SUCCESS) { + return result; + } + + napi_create_int32(env, supportAlpha, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::SetAlphaAble(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_2] = {0}; + size_t argCount = NUM_2; + + napi_get_undefined(env, &result); + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_2 || argValue[NUM_0] == nullptr || argValue[NUM_1] == nullptr) { + return result; + } + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + int32_t alphaAble = NUM_0; + if (napi_get_value_int32(env, argValue[NUM_1], &alphaAble) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_SetAlphaAble(native, alphaAble); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::GetDensity(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + int32_t density = NUM_0; + int32_t res = OH_PixelMap_GetDensity(native, &density); + if (res != OHOS_IMAGE_RESULT_SUCCESS) { + return result; + } + + napi_create_int32(env, density, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::SetDensity(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_2] = {0}; + size_t argCount = NUM_2; + + napi_get_undefined(env, &result); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_2 || argValue[NUM_0] == nullptr || argValue[NUM_1] == nullptr) { + return result; + } + + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + int32_t density = NUM_0; + if (napi_get_value_int32(env, argValue[NUM_1], &density) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_SetDensity(native, density); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::SetOpacity(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_2] = {0}; + size_t argCount = NUM_2; + + napi_get_undefined(env, &result); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_2 || argValue[NUM_0] == nullptr || argValue[NUM_1] == nullptr) { + return result; + } + + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + double opacity = NUM_0; + if (napi_get_value_double(env, argValue[NUM_1], &opacity) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_SetOpacity(native, static_cast(opacity)); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::Scale(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_3] = {0}; + size_t argCount = NUM_3; + + napi_get_undefined(env, &result); + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_3 || argValue[NUM_0] == nullptr || + argValue[NUM_1] == nullptr || argValue[NUM_2] == nullptr) { + return result; + } + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + double x = NUM_0; + double y = NUM_0; + if (napi_get_value_double(env, argValue[NUM_1], &x) != napi_ok || + napi_get_value_double(env, argValue[NUM_2], &y) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_Scale(native, static_cast(x), static_cast(y)); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::Translate(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_3] = {0}; + size_t argCount = NUM_3; + + napi_get_undefined(env, &result); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_3 || argValue[NUM_0] == nullptr || + argValue[NUM_1] == nullptr || argValue[NUM_2] == nullptr) { + return result; + } + + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + double x = NUM_0; + double y = NUM_0; + if (napi_get_value_double(env, argValue[NUM_1], &x) != napi_ok || + napi_get_value_double(env, argValue[NUM_2], &y) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_Translate(native, static_cast(x), static_cast(y)); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::Rotate(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_2] = {0}; + size_t argCount = NUM_2; + + napi_get_undefined(env, &result); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_2 || argValue[NUM_0] == nullptr || argValue[NUM_1] == nullptr) { + return result; + } + + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + double angle = NUM_0; + if (napi_get_value_double(env, argValue[NUM_1], &angle) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_Rotate(native, static_cast(angle)); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::Flip(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_3] = {0}; + size_t argCount = NUM_3; + + napi_get_undefined(env, &result); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_3 || argValue[NUM_0] == nullptr || + argValue[NUM_1] == nullptr || argValue[NUM_2] == nullptr) { + return result; + } + + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + int32_t x = NUM_0; + int32_t y = NUM_0; + if (napi_get_value_int32(env, argValue[NUM_1], &x) != napi_ok || + napi_get_value_int32(env, argValue[NUM_2], &y) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_Flip(native, x, y); + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::Crop(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[NUM_5] = {0}; + size_t argCount = NUM_5; + + napi_get_undefined(env, &result); + + if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || + argCount < NUM_5 || argValue[NUM_0] == nullptr || argValue[NUM_1] == nullptr || + argValue[NUM_2] == nullptr || argValue[NUM_3] == nullptr || argValue[NUM_4] == nullptr) { + return result; + } + + NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[NUM_0]); + if (native == nullptr) { + return result; + } + + int32_t x = NUM_0; + int32_t y = NUM_0; + int32_t width = NUM_0; + int32_t height = NUM_0; + if (napi_get_value_int32(env, argValue[NUM_1], &x) != napi_ok || + napi_get_value_int32(env, argValue[NUM_2], &y) != napi_ok || + napi_get_value_int32(env, argValue[NUM_3], &width) != napi_ok || + napi_get_value_int32(env, argValue[NUM_4], &height) != napi_ok) { + return result; + } + + int32_t res = OH_PixelMap_Crop(native, x, y, width, height); + napi_create_int32(env, res, &result); + return result; +} + +static void setInt32NamedProperty(napi_env env, napi_value object, const char* utf8name, uint32_t value) +{ + napi_value tmp; + napi_create_int32(env, value, &tmp); + napi_set_named_property(env, object, utf8name, tmp); +} + +static void setUint32NamedProperty(napi_env env, napi_value object, const char* utf8name, uint32_t value) +{ + napi_value tmp; + napi_create_uint32(env, value, &tmp); + napi_set_named_property(env, object, utf8name, tmp); +} + +napi_value ImagePixelMapNDKTest::GetImageInfo(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + struct OhosPixelMapInfo pixelmapInfo; + int32_t res = OH_PixelMap_GetImageInfo(native, &pixelmapInfo); + if (res != OHOS_IMAGE_RESULT_SUCCESS) { + return result; + } + napi_create_object(env, &result); + setUint32NamedProperty(env, result, "width", pixelmapInfo.width); + setUint32NamedProperty(env, result, "height", pixelmapInfo.height); + setUint32NamedProperty(env, result, "rowSize", pixelmapInfo.rowSize); + setInt32NamedProperty(env, result, "pixelFormat", pixelmapInfo.pixelFormat); + return result; +} + +napi_value ImagePixelMapNDKTest::AccessPixels(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + void* pixelAddr = nullptr; + int32_t res = OH_PixelMap_AccessPixels(native, &pixelAddr); + if (res != OHOS_IMAGE_RESULT_SUCCESS || pixelAddr == nullptr) { + return result; + } + napi_create_int32(env, res, &result); + return result; +} + +napi_value ImagePixelMapNDKTest::UnAccessPixels(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + + NativePixelMap* native = getNativePixelMap(env, info); + if (native == nullptr) { + return result; + } + + int32_t res = OH_PixelMap_UnAccessPixels(native); + napi_create_int32(env, res, &result); + return result; +} + +EXTERN_C_START +static napi_value ModuleRegister(napi_env env, napi_value exports) +{ + ImagePixelMapNDKTest::Init(env, exports); + return exports; +} + +static napi_module demoModule = { + .nm_version =1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = ModuleRegister, + .nm_modname = "ImagePixelMapNDKTest", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +__attribute__((constructor)) void RegisterModule(void) +{ + napi_module_register(&demoModule); +} +EXTERN_C_END +} +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/napi/image_pixel_map_imgndk_test.h b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/napi/image_pixel_map_imgndk_test.h new file mode 100644 index 0000000000000000000000000000000000000000..4eb2c889fc9f3c68830173b8b8c9898c5cbf5c3f --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/cpp/napi/image_pixel_map_imgndk_test.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 RESOURCE_MANAGER_ADDON_H +#define RESOURCE_MANAGER_ADDON_H + +#include +#include + +#include "napi/native_api.h" +#include "image_pixel_map_napi.h" + +namespace OHOS { +namespace Media { +class ImagePixelMapNDKTest { +public: + static napi_value Init(napi_env env, napi_value exports); + static napi_value CreatePixelMap(napi_env env, napi_callback_info info); + static napi_value CreateAlphaPixelMap(napi_env env, napi_callback_info info); + static napi_value InitNativePixelMap(napi_env env, napi_callback_info info); + static napi_value GetBytesNumberPerRow(napi_env env, napi_callback_info info); + static napi_value GetIsEditable(napi_env env, napi_callback_info info); + static napi_value IsSupportAlpha(napi_env env, napi_callback_info info); + static napi_value SetAlphaAble(napi_env env, napi_callback_info info); + static napi_value GetDensity(napi_env env, napi_callback_info info); + static napi_value SetDensity(napi_env env, napi_callback_info info); + static napi_value SetOpacity(napi_env env, napi_callback_info info); + static napi_value Scale(napi_env env, napi_callback_info info); + static napi_value Translate(napi_env env, napi_callback_info info); + static napi_value Rotate(napi_env env, napi_callback_info info); + static napi_value Flip(napi_env env, napi_callback_info info); + static napi_value Crop(napi_env env, napi_callback_info info); + static napi_value GetImageInfo(napi_env env, napi_callback_info info); + static napi_value AccessPixels(napi_env env, napi_callback_info info); + static napi_value UnAccessPixels(napi_env env, napi_callback_info info); +private: +}; +} // namespace Media +} // namespace OHOS +#endif \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/MainAbility/app.ets b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..6330e1bc9bbed5aae787e3edcccc09e52780ba92 --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,33 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/MainAbility/pages/index.ets b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ef84d18bf4674c8803581ddc2230a3d7e950a80 --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,37 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestAbility/app.ets b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..6330e1bc9bbed5aae787e3edcccc09e52780ba92 --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,33 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..82de1907c886c4d6b6473b77d91719551ddbd22e --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(() => { + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..54791191e57742fe93df7e835e44e8bcc13a52b8 --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : ' + cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/test/ImagePixelMapNDKTest.ets b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/test/ImagePixelMapNDKTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..50b8eacc4aabe83bc7072a52bc18fdac0be8194b --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/test/ImagePixelMapNDKTest.ets @@ -0,0 +1,747 @@ +// @ts-nocheck +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' +import ndkTest from 'libImagePixelMapNDKTest.so' + +export default function ImagePixelMapNDKTest() { + describe('ImagePixelMapNDKTest', function () { + const RESULT_SUCCESS = 0; + const BYTESNUMBER = 16; + function logger(caseName) { + return { + myName: caseName, + log: function (msg) { + console.info(this.myName + ' ' + msg); + } + } + } + function resulter(done) { + return { + myDone: done, + trueDone: function (criterion) { + expect(criterion).assertTrue(); + this.myDone(); + }, + falseDone: function (criterion) { + expect(criterion).assertFalse(); + this.myDone(); + }, + failDone: function () { + expect().assertFail(); + this.myDone(); + }, + eTrue: function (criterion) { + expect(criterion).assertTrue(); + }, + eFalse: function (criterion) { + expect(criterion).assertFalse(); + }, + } + } + beforeAll(function () { console.info('beforeAll case'); }) + + beforeEach(function () { console.info('beforeEach case'); }) + + afterEach(function () { console.info('afterEach case'); }) + + afterAll(function () { console.info('afterAll case'); }) + + let opts = { width: 4, height: 6, pixelFormat: 4, editable: 1, alphaType: 0, scaleMode: 1 }; + function functionTest(log, res, pixelmap) { + return { + myLog: log, + myRes: res, + myPixelmap: pixelmap, + test: function (name, action, want) { + this.myLog.log("test " + name + " begin"); + var result = action(this.myPixelmap); + this.myLog.log("test " + name + " result [" + result + "]"); + if (!want(result)) { + this.myLog.log(name + " Failed"); + this.myRes.trueDone(want(result)); + return undefined; + } + return result; + } + } + } + async function genPixelMap() { + try { + const color = new ArrayBuffer(96); + return ndkTest.createPixelMap(color, opts); + } catch (error) { + console.error("Test exception " + error); + expect().assertFail(); + done(); + } + } + async function pixelMapTest(done, testNum, pixelMapInterface, checkResult, ...params) { + try { + var log = logger(testNum); + var res = resulter(done); + let pixelmap = await genPixelMap(); + if (pixelmap == undefined) { + expect(false).assertTrue(); + done(); + return; + } + let testFunction1 = functionTest(log, res, pixelmap); + testFunction1.test(pixelMapInterface, + (value) => { + return ndkTest[pixelMapInterface](value, ...params); + }, (result) => { + return checkResult(result); + } + ) + res.trueDone(true); + } catch (error) { + console.error(`${testNum} Test exception ` + error); + expect().assertFail(); + done(); + } + } + async function pixelMapErrTest(done, testNum, pixelMapInterface, checkResult, ...params) { + try { + var log = logger(testNum); + var res = resulter(done); + let pixelmap = await genPixelMap(); + if (pixelmap == undefined) { + expect(false).assertTrue(); + done(); + return; + } + let testFunction1 = functionTest(log, res, pixelmap); + testFunction1.test(pixelMapInterface, + (value) => { + return ndkTest[pixelMapInterface](value, ...params); + }, (result) => { + return checkResult(result); + } + ) + res.trueDone(true); + } catch (error) { + console.error(`${testNum} Test exception ` + error); + expect().assertFail(); + done(); + } + } + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0100 + * @tc.name : createPixelMap + * @tc.desc : 1.createPixelMap + * : 2.return pixelmap + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0100', 0, async function (done) { + try { + let pixelmap = await genPixelMap(); + if (pixelmap == undefined) { + return; + } + expect(true).assertTrue(); + done(); + } catch (error) { + console.error("Test exception " + error); + expect().assertFail(); + done(); + } + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0200 + * @tc.name : initNativePixelMap + * @tc.desc : 1.createPixelMap + * : 2.initNativePixelMap + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0200', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0200', 'initNativePixelMap', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0300 + * @tc.name : createAlphaPixelMap + * @tc.desc : 1.createPixelMap + * : 2.createAlphaPixelMap + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0300', 0, async function (done) { + const checkResult = (result) => result != undefined; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0300', 'createAlphaPixelMap', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0400 + * @tc.name : getBytesNumberPerRow + * @tc.desc : 1.createPixelMap + * : 2.getBytesNumberPerRow + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0400', 0, async function (done) { + const checkResult = (result) => result == BYTESNUMBER; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0400', 'getBytesNumberPerRow', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0500 + * @tc.name : getIsEditable + * @tc.desc : 1.createPixelMap + * : 2.getIsEditable + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0500', 0, async function (done) { + const checkResult = (result) => result == opts.editable; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0500', 'getIsEditable', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0600 + * @tc.name : isSupportAlpha + * @tc.desc : 1.createPixelMap + * : 2.isSupportAlpha + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0600', 0, async function (done) { + const checkResult = (result) => result == 1; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0600', 'isSupportAlpha', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0700 + * @tc.name : setAlphaAble + * @tc.desc : 1.createPixelMap + * : 2.setAlphaAble + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0700', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0700', 'setAlphaAble', checkResult, 0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0800 + * @tc.name : setDensity + * @tc.desc : 1.createPixelMap + * : 2.setDensity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0800', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0800', 'setDensity', checkResult, 360); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0900 + * @tc.name : getDensity + * @tc.desc : 1.createPixelMap + * : 2.getDensity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0900', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_0900', 'getDensity', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1000 + * @tc.name : setOpacity + * @tc.desc : 1.createPixelMap + * : 2.setOpacity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1000', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1000', 'setOpacity', checkResult, 0.5); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1100 + * @tc.name : scale + * @tc.desc : 1.createPixelMap + * : 2.scale + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1100', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1100', 'scale', checkResult, 1.5, 1.5); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1200 + * @tc.name : translate + * @tc.desc : 1.createPixelMap + * : 2.translate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1200', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1200', 'translate', checkResult, 2.0, 3.0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1300 + * @tc.name : rotate + * @tc.desc : 1.createPixelMap + * : 2.rotate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1300', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1300', 'rotate', checkResult, 90); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1400 + * @tc.name : flip + * @tc.desc : 1.createPixelMap + * : 2.flip + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1400', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1400', 'flip', checkResult, 1, 0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1500 + * @tc.name : crop + * @tc.desc : 1.createPixelMap + * : 2.crop + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1500', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1500', 'crop', checkResult, 0, 1, 3, 2); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1600 + * @tc.name : getImageInfo + * @tc.desc : 1.createPixelMap + * : 2.getImageInfo + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1600', 0, async function (done) { + const checkResult = (result) => result != undefined; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1600', 'getImageInfo', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1700 + * @tc.name : accessPixels + * @tc.desc : 1.createPixelMap + * : 2.accessPixels + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1700', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1700', 'accessPixels', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1800 + * @tc.name : unAccessPixels + * @tc.desc : 1.createPixelMap + * : 2.unAccessPixels + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1800', 0, async function (done) { + const checkResult = (result) => result == RESULT_SUCCESS; + await pixelMapTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_1800', 'unAccessPixels', checkResult); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0100 + * @tc.name : setAlphaAble + * @tc.desc : 1.createPixelMap + * : 2.setAlphaAble + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0100', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0100', 'setAlphaAble', checkResult, 'a'); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0200 + * @tc.name : setAlphaAble + * @tc.desc : 1.createPixelMap + * : 2.setAlphaAble + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0200', 0, async function (done) { + const checkResult = (result) => result == -1; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0200', 'setAlphaAble', checkResult, 66); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0300 + * @tc.name : setAlphaAble + * @tc.desc : 1.createPixelMap + * : 2.setAlphaAble + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0300', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0300', 'setAlphaAble', checkResult, + { a: 1 }); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0400 + * @tc.name : setDensity + * @tc.desc : 1.createPixelMap + * : 2.setDensity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0400', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0400', 'setDensity', checkResult, { a: 1 }); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0500 + * @tc.name : setDensity + * @tc.desc : 1.createPixelMap + * : 2.setDensity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0500', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0500', 'setDensity', checkResult, + 'density'); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0600 + * @tc.name : setDensity + * @tc.desc : 1.createPixelMap + * : 2.setDensity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0600', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0600', 'setDensity', checkResult, true); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0700 + * @tc.name : setOpacity + * @tc.desc : 1.createPixelMap + * : 2.setOpacity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0700', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0700', 'setOpacity', checkResult, true); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0800 + * @tc.name : setOpacity + * @tc.desc : 1.createPixelMap + * : 2.setOpacity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0800', 0, async function (done) { + const checkResult = (result) => result == -1; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0800', 'setOpacity', checkResult, 2); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0900 + * @tc.name : setOpacity + * @tc.desc : 1.createPixelMap + * : 2.setOpacity + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0900', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_0900', 'setOpacity', checkResult, + { a: 1 }); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1000 + * @tc.name : scale + * @tc.desc : 1.createPixelMap + * : 2.scale + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1000', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1000', 'scale', checkResult, + { a: 10 }, 1.0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1100 + * @tc.name : scale + * @tc.desc : 1.createPixelMap + * : 2.scale + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1100', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1100', 'scale', checkResult, 1.0, null); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1200 + * @tc.name : scale + * @tc.desc : 1.createPixelMap + * : 2.scale + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1200', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1200', 'scale', checkResult, true, 1.0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1300 + * @tc.name : translate + * @tc.desc : 1.createPixelMap + * : 2.translate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1300', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1300', 'translate', checkResult, + { a: 10 }, 1.0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1400 + * @tc.name : translate + * @tc.desc : 1.createPixelMap + * : 2.translate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1400', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1400', 'translate', checkResult, 1.0, null); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1500 + * @tc.name : translate + * @tc.desc : 1.createPixelMap + * : 2.translate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1500', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1500', 'translate', checkResult, true, 1.0); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1600 + * @tc.name : rotate + * @tc.desc : 1.createPixelMap + * : 2.rotate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1600', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1600', 'rotate', checkResult, true); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1700 + * @tc.name : rotate + * @tc.desc : 1.createPixelMap + * : 2.rotate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1700', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1700', 'rotate', checkResult, null); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1800 + * @tc.name : rotate + * @tc.desc : 1.createPixelMap + * : 2.rotate + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1800', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1800', 'rotate', checkResult, 'a'); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1900 + * @tc.name : flip + * @tc.desc : 1.createPixelMap + * : 2.flip + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1900', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_1900', 'flip', checkResult, { a: 10 }); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2000 + * @tc.name : flip + * @tc.desc : 1.createPixelMap + * : 2.flip + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2000', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2000', 'flip', checkResult, null); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2100 + * @tc.name : flip + * @tc.desc : 1.createPixelMap + * : 2.flip + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2100', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2100', 'flip', checkResult, 'a'); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2200 + * @tc.name : crop + * @tc.desc : 1.createPixelMap + * : 2.crop + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2200', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2200', 'crop', checkResult, 'a', 1, 3, 2); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2300 + * @tc.name : crop + * @tc.desc : 1.createPixelMap + * : 2.crop + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2300', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2300', 'crop', checkResult, + 0, { a: 1 }, 3, 2); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2400 + * @tc.name : crop + * @tc.desc : 1.createPixelMap + * : 2.crop + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 0 + */ + it('SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2400', 0, async function (done) { + const checkResult = (result) => result == undefined; + await pixelMapErrTest(done, 'SUB_GRAPHIC_IMAGE_PIXELMAPNDK_ERR_2400', 'crop', checkResult, 0, 1, true, 2); + }) + }) +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/test/List.test.ets b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..37b51cdd33a3b45f176d6b3b253e90c3212be885 --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ImagePixelMapNDKTest from './ImagePixelMapNDKTest'; +export default function testsuite() { + ImagePixelMapNDKTest() +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/base/element/string.json b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..498677efbde065c36668727190d3613cbf278bfc --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/base/media/icon.png b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/base/media/icon.png differ diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/rawfile/test/aa.xml b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/rawfile/test/aa.xml new file mode 100644 index 0000000000000000000000000000000000000000..82b407bc749f8a3b7e0b3e4753d3a04312719cad --- /dev/null +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/resources/rawfile/test/aa.xml @@ -0,0 +1,2 @@ + + diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/signature/openharmony_sx.p7b b/multimedia/image/image_js_standard/imagePixelMapNDK/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..421a019cbe256e1c435962d33bf657c25ff8bec0 Binary files /dev/null and b/multimedia/image/image_js_standard/imagePixelMapNDK/signature/openharmony_sx.p7b differ