提交 e17f9aa8 编写于 作者: F fengzewu

image ndk test

Signed-off-by: Nfengzewu <fengzewu@huawei.com>
上级 2b52be99
...@@ -21,6 +21,7 @@ group("multimedia") { ...@@ -21,6 +21,7 @@ group("multimedia") {
#"camera/camera_js_standard:camera_standard_ets_hap", #"camera/camera_js_standard:camera_standard_ets_hap",
"image/image_js_standard/image:image_js_hap", "image/image_js_standard/image:image_js_hap",
"image/image_js_standard/image_ndk_test:image_pixelmap_ndk_hap",
"image/image_js_standard/imageColorspace:image_colorspace_js_hap", "image/image_js_standard/imageColorspace:image_colorspace_js_hap",
"image/image_js_standard/imageDecodeOptions:image_DecodeOptions_js_hap", "image/image_js_standard/imageDecodeOptions:image_DecodeOptions_js_hap",
"image/image_js_standard/imageExif:image_exif_js_hap", "image/image_js_standard/imageExif:image_exif_js_hap",
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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_pixelmap_ndk_hap") {
hap_profile = "./entry/src/main/config.json"
deps = [
":pixelmap_ets_assets",
":pixelmap_ets_resources",
":pixelmap_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsPixelMapNapiEtsTest"
shared_libraries = [ "./entry/src/main/cpp:imagePixelmap" ]
}
ohos_js_assets("pixelmap_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("pixelmap_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("pixelmap_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "ohos.image.napitest",
"package-name": "ohos.image.napitest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsPixelMapNapiEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.image.napitest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "ohos.image.napitest",
"name": ".MyApplication",
"mainAbility": "ohos.image.napitest.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"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
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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",
]
}
config("public_config") {
}
ohos_shared_library("imagePixelmap") {
sources = [ "./napi/imagePixelmap.cpp" ]
if (!(product_name == "m40")) {
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 = [
"//test/xts/acts/multimedia/image/image_js_standard/image_ndk_test/entry/src/main/cpp",
]
configs = [ ":config" ]
deps = [
"//foundation/arkui/napi:ace_napi",
"//foundation/multimedia/image_standard/frameworks/kits/js/common/pixelmap_ndk:pixelmap_ndk",
]
output_extension = "so"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_COMMON_H
#define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_COMMON_H
#define DEPRECATED __attribute__((__deprecated__))
#define NAPI_VERSION 8
#define NAPI_RETVAL_NOTHING
#define GET_AND_THROW_LAST_ERROR(env) \
do { \
const napi_extended_error_info* errorInfo = nullptr; \
napi_get_last_error_info((env), &errorInfo); \
bool isPending = false; \
napi_is_exception_pending((env), &isPending); \
if (!isPending && errorInfo != nullptr) { \
const char* errorMessage = \
errorInfo->error_message != nullptr ? errorInfo->error_message : "empty error message"; \
napi_throw_error((env), nullptr, errorMessage); \
} \
} while (0)
#define NAPI_ASSERT_BASE(env, assertion, message, retVal) \
do { \
if (!(assertion)) { \
napi_throw_error((env), nullptr, "assertion (" #assertion ") failed: " message); \
return retVal; \
} \
} while (0)
#define NAPI_ASSERT(env, assertion, message) NAPI_ASSERT_BASE(env, assertion, message, nullptr)
#define NAPI_ASSERT_RETURN_VOID(env, assertion, message) NAPI_ASSERT_BASE(env, assertion, message, NAPI_RETVAL_NOTHING)
#define NAPI_CALL_BASE(env, theCall, retVal) \
do { \
if ((theCall) != napi_ok) { \
GET_AND_THROW_LAST_ERROR((env)); \
return retVal; \
} \
} while (0)
#define NAPI_CALL(env, theCall) NAPI_CALL_BASE(env, theCall, nullptr)
#define NAPI_CALL_RETURN_VOID(env, theCall) NAPI_CALL_BASE(env, theCall, NAPI_RETVAL_NOTHING)
#define DECLARE_NAPI_PROPERTY(name, val) \
{ \
(name), nullptr, nullptr, nullptr, nullptr, val, napi_default, nullptr \
}
#define DECLARE_NAPI_STATIC_PROPERTY(name, val) \
{ \
(name), nullptr, nullptr, nullptr, nullptr, val, napi_static, nullptr \
}
#define DECLARE_NAPI_FUNCTION(name, func) \
{ \
(name), nullptr, (func), nullptr, nullptr, nullptr, napi_default, nullptr \
}
#define DECLARE_NAPI_FUNCTION_WITH_DATA(name, func, data) \
{ \
(name), nullptr, (func), nullptr, nullptr, nullptr, napi_default, data \
}
#define DECLARE_NAPI_STATIC_FUNCTION(name, func) \
{ \
(name), nullptr, (func), nullptr, nullptr, nullptr, napi_static, nullptr \
}
#define DECLARE_NAPI_GETTER(name, getter) \
{ \
(name), nullptr, nullptr, (getter), nullptr, nullptr, napi_default, nullptr \
}
#define DECLARE_NAPI_SETTER(name, setter) \
{ \
(name), nullptr, nullptr, nullptr, (setter), nullptr, napi_default, nullptr \
}
#define DECLARE_NAPI_GETTER_SETTER(name, getter, setter) \
{ \
(name), nullptr, nullptr, (getter), (setter), nullptr, napi_default, nullptr \
}
#endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_COMMON_H */
#include "napi/native_api.h"
#include "image_pixel_map_napi.h"
constexpr int TEST_ARG_SUM = 1;
static napi_value TestGetImageInfo(napi_env env, napi_callback_info info)
{
napi_value result = nullptr;
napi_get_undefined(env, &result);
napi_value thisVar = nullptr;
napi_value argValue[TEST_ARG_SUM] = {0};
size_t argCount = TEST_ARG_SUM;
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
OHOS::Media::OhosPixelMapInfo pixelMapInfo;
OHOS::Media::OH_GetImageInfo(env, argValue[0], &pixelMapInfo);
return result;
}
static napi_value TestAccessPixels(napi_env env, napi_callback_info info)
{
napi_value result = nullptr;
napi_get_undefined(env, &result);
napi_value thisVar = nullptr;
napi_value argValue[TEST_ARG_SUM] = {0};
size_t argCount = TEST_ARG_SUM;
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
void* addrPtr = nullptr;
OHOS::Media::OH_AccessPixels(env, argValue[0], &addrPtr);
return result;
}
static napi_value TestUnAccessPixels(napi_env env, napi_callback_info info)
{
napi_value result = nullptr;
napi_get_undefined(env, &result);
napi_value thisVar = nullptr;
napi_value argValue[TEST_ARG_SUM] = {0};
size_t argCount = TEST_ARG_SUM;
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
OHOS::Media::OH_UnAccessPixels(env, argValue[0]);
return result;
}
EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
{ "testGetImageInfo", nullptr, TestGetImageInfo, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "testAccessPixels", nullptr, TestAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "testUnAccessPixels", nullptr, TestUnAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr },
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
return exports;
}
EXTERN_C_END
/*
* module define
*/
static napi_module g_module = {
.nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = Init,
.nm_modname = "imagePixelmap",
.nm_priv = ((void*)0),
.reserved = {0}
};
/*
* module register
*/
extern "C" __attribute__((constructor)) void MyPixelMapRegisterModule(void)
{
napi_module_register(&g_module);
}
\ No newline at end of file
//
// Created on 2022/7/18.
//
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @addtogroup image
* @{
*
* @brief Provides access to pixel data and pixel map information.
*
* @Syscap SystemCapability.Multimedia.Image
* @since 8
* @version 1.0
*/
/**
* @file image_pixel_map_napi.h
*
* @brief Declares functions for you to lock and access or unlock pixel data, and obtain the width and height of a pixel
* map.
*
* @since 8
* @version 1.0
*/
#ifndef nkd_xts_test_image_pixel_map_napi_H
#define nkd_xts_test_image_pixel_map_napi_H
#include <stdint.h>
#include "napi/native_api.h"
namespace OHOS {
namespace Media {
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enumerates the result codes that may be returned by a function.
*
* @since 8
* @version 1.0
*/
enum {
/** Success result */
OHOS_IMAGE_RESULT_SUCCESS = 0,
/** Invalid parameters */
OHOS_IMAGE_RESULT_BAD_PARAMETER = -1,
};
/**
* @brief Enumerates pixel formats.
*
* @since 8
* @version 1.0
*/
enum {
/**
* Unknown format
*/
OHOS_PIXEL_MAP_FORMAT_NONE = 0,
/**
* 32-bit RGBA. Components R, G, B, and A each occupies 8 bits
* and are stored from the higher-order to the lower-order bits.
*/
OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3,
/**
* 16-bit RGB. Only the R, G, and B components are encoded
* from the higher-order to the lower-order bits: red is stored with 5 bits of precision,
* green is stored with 6 bits of precision, and blue is stored with 5 bits of precision.
*/
OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2,
};
/**
* @brief Defines pixel map information.
*
* @since 8
* @version 1.0
*/
struct OhosPixelMapInfo {
/** Image width, in pixels. */
uint32_t width;
/** Image height, in pixels. */
uint32_t height;
/** Number of bytes in each row of a pixel map */
uint32_t rowSize;
/** Pixel format */
int32_t pixelFormat;
};
/**
* @brief Obtains information about a given <b>PixelMap</b> and stores the information in a {@link OhosPixelMapInfo}
* structure.
*
* @param env Indicates the pointer to the JNI environment.
* @param pixelMapObject Indicates the Java <b>PixelMap</b> object.
* @param info Indicates the pointer to the pixel map information to obtain. For details, see {@link
* OhosPixelMapInfo}.
* @return Returns <b>0</b> if the information is obtained and stored in the structure; returns result codes if the
* operation fails.
* @see OhosPixelMapInfo
* @since 8
* @version 1.0
*/
int32_t OH_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info);
/**
* @brief Obtains the memory address of a given <b>PixelMap</b> object and locks the memory.
*
* If this function call is successful, <b>*addrPtr</b> is set to the memory address. After accessing the pixel data,
* you must use {@link UnAccessPixels} to unlock the memory. Otherwise, resources cannot be released.
* After the memory is unlocked, it can be invalid and should not be accessed.
*
* @param env Indicates the pointer to the JNI environment.
* @param pixelMapObject Indicates the Java <b>PixelMap</b> object.
* @param addrPtr Indicates the double pointer to the memory address.
* @see UnAccessPixels
* @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns other result codes if
* the operation fails.
* @since 8
* @version 1.0
*/
int32_t OH_AccessPixels(napi_env env, napi_value value, void** addrPtr);
/**
* @brief Unlocks the memory storing the pixel data of a given <b>PixelMap</b> to balance a successful call to {@link
* AccessPixels}.
*
* @param env Indicates the pointer to the JNI environment.
* @param pixelMapObject Indicates the Java <b>PixelMap</b> object.
* @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns other result codes if
* the operation fails.
* @see AccessPixels
* @since 8
* @version 1.0
*/
int32_t OH_UnAccessPixels(napi_env env, napi_value value);
#ifdef __cplusplus
};
#endif
/** @} */
} // namespace Media
} // namespace OHOS
#endif //nkd_xts_test_image_pixel_map_napi_H
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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('IMAGE ETS TEST')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import napiTest from './NativeApiTest'
export default function testsuite() {
napiTest()
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium/index'
import mypixelmap from "libimagePixelmap.so"
export default function nativeApiImageJsunit() {
describe('napiTest', function () {
beforeAll(function () {
console.info('beforeAll case');
})
beforeEach(function () {
isTimeOut = false;
console.info('beforeEach case');
})
afterEach(function () {
console.info('afterEach case');
})
afterAll(function () {
console.info('afterAll case');
})
/* *
* @tc.number : TC_001
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it('TC_001', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
if (pixelmap == null) {
console.info('TC_001 createPixelMap failed');
expect(false).assertTrue()
done();
return;
}
console.info('TC_001 test |begin');
console.info('TC_001 test |GetImageInfo');
mypixelmap.testGetImageInfo(pixelmap);
console.info('TC_001 test |AccessPixels');
mypixelmap.testAccessPixels(pixelmap);
console.info('TC_001 test |release begin');
pixelmap.release();
console.info('TC_001 test |release end');
console.info('TC_001 test |UnAccessPixels');
mypixelmap.testUnAccessPixels(pixelmap);
console.info('TC_001 test |release again begin');
pixelmap.release();
console.info('TC_001 test |release again end');
expect(true).assertTrue();
done();
console.info('TC_001 test |end');
})
.catch(error => {
console.log('TC_001 error: ' + error);
expect().assertFail();
done();
})
})
})
}
{
"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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册