提交 0fa2bd1c 编写于 作者: W wuxiaodan

add rdb ndk

Signed-off-by: Nwuxiaodan <wuxiaodan5@huawei.com>
上级 4058cdf1
...@@ -18,6 +18,7 @@ group("relationalStoretest") { ...@@ -18,6 +18,7 @@ group("relationalStoretest") {
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"RdbJstest/hap:rdb_js_test", "RdbJstest/hap:rdb_js_test",
"rdbnapitest:ActsRdbNapiEtsTest",
"relationalStoreJstest/hap:relationalstore_js_test", "relationalStoreJstest/hap:relationalstore_js_test",
"relationalStoreStagetest:relationalstore_ets_test", "relationalStoreStagetest:relationalstore_ets_test",
] ]
......
# 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("ActsRdbNapiEtsTest") {
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 = "ActsRdbNapiEtsTest"
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
shared_libraries = [
"./entry/src/main/cpp:backup",
"./entry/src/main/cpp:encrypt",
"./entry/src/main/cpp:level",
"./entry/src/main/cpp:cursor",
"./entry/src/main/cpp:predicates",
"./entry/src/main/cpp:rdbstore",
]
}
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": "com.acts.rdb.napitest",
"package-name": "com.acts.rdb.napitest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsRdbNapiEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": []
}
]
}
{
"app": {
"bundleName": "com.acts.rdb.napitest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.acts.rdb.napitest",
"name": ".MyApplication",
"mainAbility": "com.acts.rdb.napitest.MainAbility",
"deviceType": [
"tablet",
"default",
"phone",
"2in1"
],
"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) 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")
import("//foundation/distributeddatamgr/relational_store/relational_store.gni")
relational_store_ndk_path = "${relational_store_base_path}/interfaces"
config("config") {
visibility = [ ":*" ]
cflags = [
"-Wall",
"-Werror",
"-g3",
"-Wunused-variable",
]
}
## backup ###############################################################
ohos_shared_library("backup") {
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
sources = [ "./napi/rdb_store_backup_test.cpp" ]
include_dirs = [
"../cpp",
"../cpp/common",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/include",
"${relational_store_ndk_path}/ndk/include/",
"${relational_store_ndk_path}/ndk/src/",
"${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h",
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp",
"${relational_store_base_path}/interfaces/ndk/include",
]
configs = [ ":config" ]
deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ]
external_deps = [ "napi:ace_napi" ]
output_extension = "so"
}
## encrypt ###############################################################
ohos_shared_library("encrypt") {
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
sources = [ "./napi/rdb_store_encrypt_test.cpp" ]
include_dirs = [
"../cpp",
"../cpp/common",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/include",
"${relational_store_ndk_path}/ndk/include/",
"${relational_store_ndk_path}/ndk/src/",
"${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h",
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp",
"${relational_store_base_path}/interfaces/ndk/include",
]
configs = [ ":config" ]
deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ]
external_deps = [ "napi:ace_napi" ]
output_extension = "so"
}
## level ###############################################################
ohos_shared_library("level") {
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
sources = [ "./napi/rdb_store_level_test.cpp" ]
include_dirs = [
"../cpp",
"../cpp/common",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/include",
"${relational_store_ndk_path}/ndk/include/",
"${relational_store_ndk_path}/ndk/src/",
"${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h",
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp",
"${relational_store_base_path}/interfaces/ndk/include",
]
configs = [ ":config" ]
deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ]
external_deps = [ "napi:ace_napi" ]
output_extension = "so"
}
## cursor ###############################################################
ohos_shared_library("cursor") {
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
sources = [ "./napi/rdb_store_cursor_test.cpp" ]
include_dirs = [
"../cpp",
"../cpp/common",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/include",
"${relational_store_ndk_path}/ndk/include/",
"${relational_store_ndk_path}/ndk/src/",
"${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h",
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp",
"${relational_store_base_path}/interfaces/ndk/include",
]
configs = [ ":config" ]
deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ]
external_deps = [ "napi:ace_napi" ]
output_extension = "so"
}
## predicates ###############################################################
ohos_shared_library("predicates") {
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
sources = [ "./napi/rdb_store_predicates_test.cpp" ]
include_dirs = [
"../cpp",
"../cpp/common",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/include",
"${relational_store_ndk_path}/ndk/include/",
"${relational_store_ndk_path}/ndk/src/",
"${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h",
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp",
"${relational_store_base_path}/interfaces/ndk/include",
]
configs = [ ":config" ]
deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ]
external_deps = [ "napi:ace_napi" ]
output_extension = "so"
}
## rdbstore ###############################################################
ohos_shared_library("rdbstore") {
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
sources = [ "./napi/rdb_store_test.cpp" ]
include_dirs = [
"../cpp",
"../cpp/common",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/include",
"${relational_store_ndk_path}/ndk/include/",
"${relational_store_ndk_path}/ndk/src/",
"${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h",
"${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store.h",
"${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h",
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp",
"${relational_store_base_path}/interfaces/ndk/include",
]
configs = [ ":config" ]
deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ]
external_deps = [ "napi:ace_napi" ]
output_extension = "so"
}
/*
* 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 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 */
\ No newline at end of file
/*
* 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 <iostream>
#include <stdio.h>
#include <unistd.h>
#include <string>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#include <securec.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "napi/native_api.h"
#include "common/common.h"
#include "relational_store.h"
#include "relational_store_error_code.h"
#include "oh_cursor.h"
#include "oh_predicates.h"
#include "oh_value_object.h"
#include "oh_values_bucket.h"
char RDB_TEST_PATH[] = "/data/storage/el2/database/";
char RDB_STORE_NAME[] = "rdb_store_encrypt_test.db";
char RDB_STORE_NAME2[] = "Encrypt.db";
char BUNDLE_NAME[] = "com.acts.rdb.napitest";
char MODULE_NAME[] = "com.acts.rdb.napitest";
OH_Rdb_Store *storeEncryptTestRdbStore_ = NULL;
OH_Rdb_Store *storeEncryptTestRdbStore2_ = NULL;
static OH_Rdb_Config config_;
static OH_Rdb_Config config1_;
static OH_Rdb_Config config2_;
static OH_Rdb_Config config3_;
static void InitRdbConfig()
{
config_.dataBaseDir = RDB_TEST_PATH;
config_.storeName = RDB_STORE_NAME;
config_.bundleName = BUNDLE_NAME;
config_.moduleName = MODULE_NAME;
config_.securityLevel = OH_Rdb_SecurityLevel::S1;
config_.isEncrypt = false;
config_.selfSize = sizeof(OH_Rdb_Config);
}
static void InitRdbConfig1()
{
config1_.dataBaseDir = RDB_TEST_PATH;
config1_.storeName = RDB_STORE_NAME;
config1_.bundleName = BUNDLE_NAME;
config1_.moduleName = MODULE_NAME;
config1_.securityLevel = OH_Rdb_SecurityLevel::S2;
config1_.isEncrypt = false;
config1_.selfSize = sizeof(OH_Rdb_Config);
}
static void InitRdbConfig2()
{
config2_.dataBaseDir = RDB_TEST_PATH;
config2_.storeName = RDB_STORE_NAME2;
config2_.bundleName = BUNDLE_NAME;
config2_.moduleName = MODULE_NAME;
config2_.securityLevel = OH_Rdb_SecurityLevel::S1;
config2_.isEncrypt = true;
config2_.selfSize = sizeof(OH_Rdb_Config);
}
static void InitRdbConfig3()
{
config3_.dataBaseDir = RDB_TEST_PATH;
config3_.storeName = RDB_STORE_NAME2;
config3_.bundleName = BUNDLE_NAME;
config3_.moduleName = MODULE_NAME;
config3_.securityLevel = OH_Rdb_SecurityLevel::S1;
config3_.isEncrypt = false;
config3_.selfSize = sizeof(OH_Rdb_Config);
}
static napi_value SUB_DDM_RDB_ENCRYPT_0100(napi_env env, napi_callback_info info) {
InitRdbConfig2();
mkdir(config2_.dataBaseDir, 0770);
InitRdbConfig3();
mkdir(config3_.dataBaseDir, 0770);
int errCode = 0;
storeEncryptTestRdbStore_ = OH_Rdb_GetOrOpen(&config2_, &errCode);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail.");
NAPI_ASSERT(env, storeEncryptTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config2 is fail.");
storeEncryptTestRdbStore2_ = OH_Rdb_GetOrOpen(&config3_, &errCode);
NAPI_ASSERT(env, storeEncryptTestRdbStore2_ == NULL, "OH_Rdb_GetOrOpen config3 is success.");
errCode = OH_Rdb_CloseStore(storeEncryptTestRdbStore_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail.");
storeEncryptTestRdbStore_ = NULL;
storeEncryptTestRdbStore2_ = NULL;
errCode = OH_Rdb_DeleteStore(&config2_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
errCode = OH_Rdb_DeleteStore(&config3_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
napi_value returnCode;
napi_create_double(env, errCode, &returnCode);
return returnCode;
}
static napi_value SUB_DDM_RDB_ENCRYPT_0200(napi_env env, napi_callback_info info) {
InitRdbConfig();
mkdir(config_.dataBaseDir, 0770);
InitRdbConfig1();
mkdir(config1_.dataBaseDir, 0770);
int errCode = 0;
storeEncryptTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail.");
NAPI_ASSERT(env, storeEncryptTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config1 is fail.");
storeEncryptTestRdbStore2_ = OH_Rdb_GetOrOpen(&config1_, &errCode);
NAPI_ASSERT(env, storeEncryptTestRdbStore2_ == NULL, "OH_Rdb_GetOrOpen config is success.");
errCode = OH_Rdb_CloseStore(storeEncryptTestRdbStore_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail.");
storeEncryptTestRdbStore_ = NULL;
storeEncryptTestRdbStore2_ = NULL;
errCode = OH_Rdb_DeleteStore(&config1_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
napi_value returnCode;
napi_create_double(env, errCode, &returnCode);
return returnCode;
}
EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc[] = {
{"SUB_DDM_RDB_ENCRYPT_0100", nullptr, SUB_DDM_RDB_ENCRYPT_0100, nullptr, nullptr, nullptr, napi_default, nullptr},
{"SUB_DDM_RDB_ENCRYPT_0200", nullptr, SUB_DDM_RDB_ENCRYPT_0200, 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 = "encrypt",
.nm_priv = ((void *)0),
.reserved = {0},
};
extern "C" __attribute__((constructor)) void RegisterEntryModule(void) {
napi_module_register(&demoModule);
}
/*
* 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 <iostream>
#include <stdio.h>
#include <unistd.h>
#include <string>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#include <securec.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "napi/native_api.h"
#include "common/common.h"
#include "relational_store.h"
#include "relational_store_error_code.h"
#include "oh_cursor.h"
#include "oh_predicates.h"
#include "oh_value_object.h"
#include "oh_values_bucket.h"
char RDB_TEST_PATH[] = "/data/storage/el2/database/";
char RDB_STORE_NAME[] = "rdb_store_test.db";
char BUNDLE_NAME[] = "com.acts.rdb.napitest";
char MODULE_NAME[] = "com.acts.rdb.napitest";
OH_Rdb_Store *storeLevelTestRdbStore_ = NULL;
static OH_Rdb_Config config1_;
static OH_Rdb_Config config2_;
static OH_Rdb_Config config3_;
static OH_Rdb_Config config4_;
static void InitRdbConfig1()
{
config1_.dataBaseDir = RDB_TEST_PATH;
config1_.storeName = RDB_STORE_NAME;
config1_.bundleName = BUNDLE_NAME;
config1_.moduleName = MODULE_NAME;
config1_.securityLevel = OH_Rdb_SecurityLevel::S1;
config1_.isEncrypt = false;
config1_.selfSize = sizeof(OH_Rdb_Config);
}
static void InitRdbConfig2()
{
config2_.dataBaseDir = RDB_TEST_PATH;
config2_.storeName = RDB_STORE_NAME;
config2_.bundleName = BUNDLE_NAME;
config2_.moduleName = MODULE_NAME;
config2_.securityLevel = OH_Rdb_SecurityLevel::S2;
config2_.isEncrypt = false;
config2_.selfSize = sizeof(OH_Rdb_Config);
}
static void InitRdbConfig3()
{
config3_.dataBaseDir = RDB_TEST_PATH;
config3_.storeName = RDB_STORE_NAME;
config3_.bundleName = BUNDLE_NAME;
config3_.moduleName = MODULE_NAME;
config3_.securityLevel = OH_Rdb_SecurityLevel::S3;
config3_.isEncrypt = false;
config3_.selfSize = sizeof(OH_Rdb_Config);
}
static void InitRdbConfig4()
{
config4_.dataBaseDir = RDB_TEST_PATH;
config4_.storeName = RDB_STORE_NAME;
config4_.bundleName = BUNDLE_NAME;
config4_.moduleName = MODULE_NAME;
config4_.securityLevel = OH_Rdb_SecurityLevel::S4;
config4_.isEncrypt = false;
config4_.selfSize = sizeof(OH_Rdb_Config);
}
static napi_value SUB_DDM_RDB_LEVEL_0100(napi_env env, napi_callback_info info) {
InitRdbConfig1();
mkdir(config1_.dataBaseDir, 0770);
int errCode = 0;
storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config1_, &errCode);
NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail.");
char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, "
"data3 FLOAT, data4 BLOB, data5 TEXT);";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql);
NAPI_ASSERT(env, errCode == 0, "createTable is fail.");
OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket();
valueBucket->putInt64(valueBucket, "id", 1);
valueBucket->putText(valueBucket, "data1", "zhangSan");
valueBucket->putInt64(valueBucket, "data2", 12800);
valueBucket->putReal(valueBucket, "data3", 100.1);
uint8_t arr[] = {1, 2, 3, 4, 5};
int len = sizeof(arr) / sizeof(arr[0]);
valueBucket->putBlob(valueBucket, "data4", arr, len);
valueBucket->putText(valueBucket, "data5", "ABCDEFG");
errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket);
NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail.");
char querySql[] = "SELECT * FROM test";
OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql);
int rowCount = 0;
cursor->getRowCount(cursor, &rowCount);
NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail.");
valueBucket->destroy(valueBucket);
cursor->destroy(cursor);
char dropTableSql[] = "DROP TABLE IF EXISTS test";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail.");
errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail.");
errCode = OH_Rdb_DeleteStore(&config1_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
napi_value returnCode;
napi_create_double(env, errCode, &returnCode);
return returnCode;
}
static napi_value SUB_DDM_RDB_LEVEL_0200(napi_env env, napi_callback_info info) {
InitRdbConfig2();
mkdir(config2_.dataBaseDir, 0770);
int errCode = 0;
storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config2_, &errCode);
NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail.");
char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, "
"data3 FLOAT, data4 BLOB, data5 TEXT);";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql);
NAPI_ASSERT(env, errCode == 0, "createTable is fail.");
OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket();
valueBucket->putInt64(valueBucket, "id", 1);
valueBucket->putText(valueBucket, "data1", "zhangSan");
valueBucket->putInt64(valueBucket, "data2", 12800);
valueBucket->putReal(valueBucket, "data3", 100.1);
uint8_t arr[] = {1, 2, 3, 4, 5};
int len = sizeof(arr) / sizeof(arr[0]);
valueBucket->putBlob(valueBucket, "data4", arr, len);
valueBucket->putText(valueBucket, "data5", "ABCDEFG");
errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket);
NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail.");
char querySql[] = "SELECT * FROM test";
OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql);
int rowCount = 0;
cursor->getRowCount(cursor, &rowCount);
NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail.");
valueBucket->destroy(valueBucket);
cursor->destroy(cursor);
char dropTableSql[] = "DROP TABLE IF EXISTS test";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail.");
errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail.");
errCode = OH_Rdb_DeleteStore(&config2_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
napi_value returnCode;
napi_create_double(env, errCode, &returnCode);
return returnCode;
}
static napi_value SUB_DDM_RDB_LEVEL_0300(napi_env env, napi_callback_info info) {
InitRdbConfig3();
mkdir(config3_.dataBaseDir, 0770);
int errCode = 0;
storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config3_, &errCode);
NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail.");
char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, "
"data3 FLOAT, data4 BLOB, data5 TEXT);";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql);
NAPI_ASSERT(env, errCode == 0, "createTable is fail.");
OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket();
valueBucket->putInt64(valueBucket, "id", 1);
valueBucket->putText(valueBucket, "data1", "zhangSan");
valueBucket->putInt64(valueBucket, "data2", 12800);
valueBucket->putReal(valueBucket, "data3", 100.1);
uint8_t arr[] = {1, 2, 3, 4, 5};
int len = sizeof(arr) / sizeof(arr[0]);
valueBucket->putBlob(valueBucket, "data4", arr, len);
valueBucket->putText(valueBucket, "data5", "ABCDEFG");
errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket);
NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail.");
char querySql[] = "SELECT * FROM test";
OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql);
int rowCount = 0;
cursor->getRowCount(cursor, &rowCount);
NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail.");
valueBucket->destroy(valueBucket);
cursor->destroy(cursor);
char dropTableSql[] = "DROP TABLE IF EXISTS test";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail.");
errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail.");
errCode = OH_Rdb_DeleteStore(&config3_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
napi_value returnCode;
napi_create_double(env, errCode, &returnCode);
return returnCode;
}
static napi_value SUB_DDM_RDB_LEVEL_0400(napi_env env, napi_callback_info info) {
InitRdbConfig4();
mkdir(config4_.dataBaseDir, 0770);
int errCode = 0;
storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config4_, &errCode);
NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail.");
char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, "
"data3 FLOAT, data4 BLOB, data5 TEXT);";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql);
NAPI_ASSERT(env, errCode == 0, "createTable is fail.");
OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket();
valueBucket->putInt64(valueBucket, "id", 1);
valueBucket->putText(valueBucket, "data1", "zhangSan");
valueBucket->putInt64(valueBucket, "data2", 12800);
valueBucket->putReal(valueBucket, "data3", 100.1);
uint8_t arr[] = {1, 2, 3, 4, 5};
int len = sizeof(arr) / sizeof(arr[0]);
valueBucket->putBlob(valueBucket, "data4", arr, len);
valueBucket->putText(valueBucket, "data5", "ABCDEFG");
errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket);
NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail.");
char querySql[] = "SELECT * FROM test";
OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql);
int rowCount = 0;
cursor->getRowCount(cursor, &rowCount);
NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail.");
valueBucket->destroy(valueBucket);
cursor->destroy(cursor);
char dropTableSql[] = "DROP TABLE IF EXISTS test";
errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail.");
errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail.");
errCode = OH_Rdb_DeleteStore(&config4_);
NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail.");
napi_value returnCode;
napi_create_double(env, errCode, &returnCode);
return returnCode;
}
EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc[] = {
{"SUB_DDM_RDB_LEVEL_0100", nullptr, SUB_DDM_RDB_LEVEL_0100, nullptr, nullptr, nullptr, napi_default, nullptr},
{"SUB_DDM_RDB_LEVEL_0200", nullptr, SUB_DDM_RDB_LEVEL_0200, nullptr, nullptr, nullptr, napi_default, nullptr},
{"SUB_DDM_RDB_LEVEL_0300", nullptr, SUB_DDM_RDB_LEVEL_0300, nullptr, nullptr, nullptr, napi_default, nullptr},
{"SUB_DDM_RDB_LEVEL_0400", nullptr, SUB_DDM_RDB_LEVEL_0400, 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 = "level",
.nm_priv = ((void *)0),
.reserved = {0},
};
extern "C" __attribute__((constructor)) void RegisterEntryModule(void) {
napi_module_register(&demoModule);
}
// @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
// @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%')
}
}
// @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
// @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
// @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
/*
* 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 RdbNdkStoreBackupTest from './RdbNdkStoreBackupTest'
import RdbNdkStoreEncryptTest from './RdbNdkStoreEncryptTest'
import RdbNdkStoreLevelTest from './RdbNdkStoreLevelTest'
import RdbNdkStoreCursorTest from './RdbNdkStoreCursorTest'
import RdbNdkStorePredicatesTest from './RdbNdkStorePredicatesTest'
import RdbNdkStoreTest from './RdbNdkStoreTest'
export default function testsuite() {
RdbNdkStoreEncryptTest()
RdbNdkStoreLevelTest()
RdbNdkStoreCursorTest()
RdbNdkStorePredicatesTest()
RdbNdkStoreTest()
RdbNdkStoreBackupTest()
}
\ No newline at end of file
/*
* 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 hilog from '@ohos.hilog';
import testNapi from 'libencrypt.so'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index';
const TAG = "[RdbNdkStoreTest]";
export default function RdbNdkStoreEncryptTest() {
describe('RdbNdkStoreEncryptTest', function () {
beforeAll(function () {})
beforeEach(function () {})
afterEach(function () {})
afterAll(function () {})
/**
* @tc.name: SUB_DDM_RDB_ENCRYPT_0100
* @tc.desc: Exception testCase of NDK ENCRYPT.
* @tc.type: FUNC
*/
it('SUB_DDM_RDB_ENCRYPT_0100',0, async function () {
hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_ENCRYPT_0100' , ' begin');
let re = testNapi.SUB_DDM_RDB_ENCRYPT_0100();
hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa');
expect(re == 0).assertTrue();
})
/**
* @tc.name: SUB_DDM_RDB_ENCRYPT_0200
* @tc.desc: Exception testCase of NDK SecurityLevel.
* @tc.type: FUNC
*/
it('SUB_DDM_RDB_ENCRYPT_0200',0, async function () {
hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_ENCRYPT_0200' , ' begin');
let re = testNapi.SUB_DDM_RDB_ENCRYPT_0200();
hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa');
expect(re == 0).assertTrue();
})
})
}
\ 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.
先完成此消息的编辑!
想要评论请 注册