提交 b7f23176 编写于 作者: Y y00314596

add by yangqing3@huawei.com

Signed-off-by: Ny00314596 <yangqing3@huawei.com>
上级 e824b8e0
# 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("ActsGlobalNapiTest") {
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 = "ActsGlobalNapiTest"
shared_libraries = [ "./entry/src/main/cpp:resmgrndk" ]
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "ohos.global.napitest",
"package-name": "ohos.global.napitest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsGlobalNapiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.global.napitest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "ohos.global.napitest",
"name": ".MyApplication",
"mainAbility": "ohos.global.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("resmgrndk") {
sources = [ "./napi/test_string.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 = [ "//test/xts/acts/arkui/ace_napi_test/entry/src/main/cpp" ]
configs = [ ":config" ]
deps = [
"//base/global/resource_management/frameworks/resmgr:librawfile",
"//base/global/resource_management/interfaces/native/resource:librawfile_ndk",
"//foundation/arkui/napi:ace_napi",
]
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 RESOURCE_MANAGER_ADDON_H
#define RESOURCE_MANAGER_ADDON_H
#include <memory>
#include <string>
#include "napi/native_api.h"
//#include "napi/native_node_api.h"
#include "rawfile/raw_file_manager.h"
namespace OHOS {
namespace Global {
namespace Resource {
class NdkAddon {
public:
static napi_value Init(napi_env env, napi_value exports);
private:
static napi_value GetResourceManager(napi_env env, napi_callback_info info);
static napi_async_execute_callback TestRawFileExecute();
};
struct NdkAsyncContext {
napi_async_work work_;
std::string path_;
typedef napi_value (*CreateNapiValue)(napi_env env, NdkAsyncContext &context);
CreateNapiValue createValueFunc_;
std::string value_;
std::unique_ptr<char[]> mediaData;
long len_;
napi_deferred deferred_;
napi_ref callbackRef_;
std::string errMsg_;
int success_;
NativeResourceManager* ndk_;
NdkAsyncContext() : work_(nullptr), createValueFunc_(nullptr), deferred_(nullptr),
callbackRef_(nullptr), success_(true), ndk_(nullptr) {}
void SetErrorMsg(const std::string &msg);
};
} // namespace Resource
} // namespace Global
} // namespace OHOS
#endif
\ 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.
*/
#include "native_common.h"
#include "rawfile/raw_file_manager.h"
#include <fstream>
#include <memory>
#include <vector>
#include "hilog/log.h"
#include "node_api.h"
namespace OHOS {
namespace Global {
namespace Resource {
#define GET_PARAMS(env, info, num) \
size_t argc = num; \
napi_value argv[num] = {nullptr}; \
napi_value thisVar = nullptr; \
void *data = nullptr; \
napi_get_cb_info(env, info , &argc, argv, &thisVar, &data)
void NdkAsyncContext::SetErrorMsg(const std::string &msg)
{
errMsg_ = msg;
success_ = false;
// HiLog::Error(LABEL, "%{public}s", msg.c_str());
}
napi_async_execute_callback TestRawFileExecute()
{
return [](napi_env env, void* data) {
NdkAsyncContext *asyncContext = static_cast<NdkAsyncContext*>(data);
// test OH_ResourceManager_OpenRawDir
RawDir* rawDir = OH_ResourceManager_OpenRawDir(asyncContext->ndk_, asyncContext->path_.c_str());
// HiLog::Error(LABEL, "OpenRawDir ndk_:%{public}p path_:%{public}s",asyncContext->ndk_, asyncContext->path_.c_str());
// test OH_ResourceManager_GetRawFileCount
int count = OH_ResourceManager_GetRawFileCount(rawDir);
// HiLog::Error(LABEL, "GetRawFileCount:%{public}d", count);
// test OH_ResourceManager_GetRawFileName
for (int i = 0; i< count; i++) {
std::string tempFileName = OH_ResourceManager_GetRawFileName(rawDir, i);
// HiLog::Error(LABEL, "GetRawFileName[%{public}d]:%{public}s", i, tempFileName.c_str());
}
// test OH_ResourceManager_OpenRawFile
std::string fileName = OH_ResourceManager_GetRawFileName(rawDir, 0);
asyncContext->path_ = fileName;
RawFile* rawFile = OH_ResourceManager_OpenRawFile(asyncContext->ndk_, fileName.c_str());
// HiLog::Error(LABEL, "OpenRawFile fileName:%{public}s", fileName.c_str());
// test OH_ResourceManager_GetRawFileSize
asyncContext->len_ = OH_ResourceManager_GetRawFileSize(rawFile);
// HiLog::Error(LABEL, "GetRawFileSize:%{public}ld", asyncContext->len_);
// // test OH_ResourceManager_SeekRawFile
// HiLog::Error(LABEL, "SeekRawFile SEEK_END:%{public}d", OH_ResourceManager_SeekRawFile(rawFile, 0 ,2));
// HiLog::Error(LABEL, "SeekRawFile SEEK_SET:%{public}d", OH_ResourceManager_SeekRawFile(rawFile, 0 ,0));
// HiLog::Error(LABEL, "SeekRawFile SEEK_CUR:%{public}d", OH_ResourceManager_SeekRawFile(rawFile, 0 ,1));
// // test OH_ResourceManager_GetRawFileOffset
// HiLog::Error(LABEL, "GetRawFileOffset:%{public}ld", OH_ResourceManager_GetRawFileOffset(rawFile));
// test OH_ResourceManager_GetRawFileDescriptor
RawFileDescriptor descriptor;
bool getFd = OH_ResourceManager_GetRawFileDescriptor(rawFile, descriptor);
// HiLog::Error(LABEL, "GetRawFileDescriptor getFd:%{public}d fd:%{public}d length:%{public}ld start:%{public}ld",
// getFd, descriptor.fd, descriptor.length, descriptor.start);
// test OH_ResourceManager_ReadRawFile
asyncContext->mediaData = std::make_unique<char[]>(asyncContext->len_);
// HiLog::Error(LABEL, "ReadRawFile:%{public}d", OH_ResourceManager_ReadRawFile(rawFile, asyncContext->mediaData.get(), asyncContext->len_));
// test OH_ResourceManager_ReleaseRawFileDescriptor
OH_ResourceManager_ReleaseRawFileDescriptor(descriptor);
// HiLog::Error(LABEL, "ReleaseRawFileDescriptor ok");
// test OH_ResourceManager_CloseRawFile
OH_ResourceManager_CloseRawFile(rawFile);
// HiLog::Error(LABEL, "CloseRawFile ok");
// test OH_ResourceManager_CloseRawDir
OH_ResourceManager_CloseRawDir(rawDir);
// HiLog::Error(LABEL, "CloseRawDir ok");
// test OH_ResourceManager_ReleaseNativeResourceManager
OH_ResourceManager_ReleaseNativeResourceManager(asyncContext->ndk_);
// HiLog::Error(LABEL, "ReleaseNativeResourceManager ok asyncContext->ndk_:%{public}p", asyncContext->ndk_);
asyncContext->createValueFunc_ = [](napi_env env, NdkAsyncContext &context) -> napi_value {
napi_value buffer;
napi_status status = napi_create_external_arraybuffer(env, context.mediaData.get(), context.len_,
[](napi_env env, void *data, void *hint) {
// HiLog::Error(LABEL, "Media buffer finalized");
delete[] static_cast<char*>(data);
}, nullptr, &buffer);
if (status != napi_ok) {
context.SetErrorMsg("Failed to create media external array buffer");
return nullptr;
}
napi_value result = nullptr;
status = napi_create_typedarray(env, napi_uint8_array, context.len_, buffer, 0, &result);
if (status != napi_ok) {
context.SetErrorMsg("Failed to create media typed array");
return nullptr;
}
context.mediaData.release();
return result;
};
};
}
auto completeFunc = [](napi_env env, napi_status status, void* data) {
NdkAsyncContext* asyncContext = static_cast<NdkAsyncContext*>(data);
napi_value finalResult = nullptr;
if (asyncContext->createValueFunc_ != nullptr) {
finalResult = asyncContext->createValueFunc_(env, *asyncContext);
}
napi_value result[] = { nullptr, nullptr };
if (asyncContext->success_) {
napi_get_undefined(env, &result[0]);
result[1] = finalResult;
} else {
napi_value message = nullptr;
napi_create_string_utf8(env, asyncContext->errMsg_.c_str(), NAPI_AUTO_LENGTH, &message);
napi_create_error(env, nullptr, message, &result[0]);
napi_get_undefined(env, &result[1]);
}
do {
if (asyncContext->deferred_) {
if (asyncContext->success_) {
if (napi_resolve_deferred(env, asyncContext->deferred_, result[1]) != napi_ok) {
// HiLog::Error(LABEL, "napi_resolve_deferred failed");
}
} else {
if (napi_reject_deferred(env, asyncContext->deferred_, result[0]) != napi_ok) {
// HiLog::Error(LABEL, "napi_reject_deferred failed");
}
}
} else {
napi_value callback = nullptr;
napi_status status = napi_get_reference_value(env, asyncContext->callbackRef_, &callback);
if (status != napi_ok) {
// HiLog::Error(LABEL, "napi_get_reference_value failed status=%{public}d", status);
break;
}
napi_value userRet = nullptr;
status = napi_call_function(env, nullptr, callback, sizeof(result) / sizeof(napi_value), result, &userRet);
if (status != napi_ok) {
// HiLog::Error(LABEL, "napi_call_function failed status=%{public}d", status);
break;
}
status = napi_delete_reference(env, asyncContext->callbackRef_);
if (status != napi_ok) {
// HiLog::Error(LABEL, "napi_delete_reference failed status=%{public}d", status);
break;
}
}
} while (false);
napi_delete_async_work(env, asyncContext->work_);
delete asyncContext;
};
napi_value GetResourceManager(napi_env env, napi_callback_info info)
{
GET_PARAMS(env, info, 3);
std::unique_ptr<NdkAsyncContext> asyncContext = std::make_unique<NdkAsyncContext>();
for (size_t i = 0; i < argc; i++) {
napi_valuetype valueType;
napi_typeof(env, argv[i], &valueType);
if (i == 0 && valueType == napi_string) {
size_t len = 0;
napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to get bundle name length");
return nullptr;
}
std::vector<char> buf(len + 1);
status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to get bundle name");
return nullptr;
}
asyncContext->path_ = buf.data();
} else if (i == 1 && valueType == napi_object) {
// test OH_ResourceManager_InitNativeResourceManager
asyncContext->ndk_ = OH_ResourceManager_InitNativeResourceManager(env, argv[i]);
// HiLog::Error(LABEL, "InitNativeResourceManager asyncContext->ndk_:%{public}p", asyncContext->ndk_);
} else if (i == 2 && valueType == napi_function) {
napi_create_reference(env, argv[i], 1, &asyncContext->callbackRef_);
break;
} else {
// self resorucemanager with promise
}
}
napi_value result = nullptr;
if (asyncContext->callbackRef_ == nullptr) {
napi_create_promise(env, &asyncContext->deferred_, &result);
} else {
napi_get_undefined(env, &result);
}
napi_value resource = nullptr;
napi_create_string_utf8(env, "testRawFile", NAPI_AUTO_LENGTH, &resource);
// HiLog::Error(LABEL, "guojia testRawFile");
napi_status status = napi_create_async_work(env, nullptr, resource, TestRawFileExecute(), completeFunc,
static_cast<void*>(asyncContext.get()), &asyncContext->work_);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to create async work for testRawFile %{public}d",status);
return result;
}
status = napi_queue_async_work(env, asyncContext->work_);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to queue async work for testRawFile %{public}d",status);
return result;
}
asyncContext.release();
return result;
}
EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
{ "add", nullptr, GetResourceManager, nullptr, nullptr, nullptr, napi_default, nullptr }
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
return exports;
}
EXTERN_C_END
static napi_module demoModule = {
.nm_version =1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = Init,
.nm_modname = "resmgrndk",
.nm_priv = ((void*)0),
.reserved = { 0 },
};
extern "C" __attribute__((constructor)) void RegisterModule(void)
{
napi_module_register(&demoModule);
}
}
}
}
\ 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 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('ACE 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 napiStringTest from './NativeApiStringTest';
export default function testsuite() {
napiStringTest()
}
\ 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import resManager from '@ohos.resourceManager'
import ndk from 'libresmgrndk.so'
export default function abilityTest() {
describe('ActsAbilityTest', function () {
it('assertContain',0, function () {
console.info("it begin")
let a = 'abc'
let b = 'b'
expect(a).assertContain(b)
expect(a).assertEqual(a)
})
/* *
* @tc.number SUB_GLOBAL_RESMGR_NDK_0100
* @tc.name test ResourceManager NDK interface
* @tc.desc test ResourceManager NDK interface
*/
it('getResourceManager_ndktest_0100', 0, async function (done) {
resManager.getResourceManager().then(mgr => {
expect(mgr !== null).assertTrue();
ndk.testRawFile("test",mgr,(error,value) => {
if(error != null){
console.log("getResourceManager_ndktest_0100" + error);
} else{
console.log("getResourceManager_ndktest_0100" + value.length);
expect(value.length > 0).assertTrue();
}
});
})
done();
})
})
}
\ No newline at end of file
{
"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.
先完成此消息的编辑!
想要评论请 注册