From 0fa2bd1c7c0b22330528e98b67ffaf0321f57c73 Mon Sep 17 00:00:00 2001 From: wuxiaodan Date: Thu, 10 Aug 2023 17:00:16 +0800 Subject: [PATCH] add rdb ndk Signed-off-by: wuxiaodan --- .../relationalStoretest/BUILD.gn | 1 + .../relationalStoretest/rdbnapitest/BUILD.gn | 47 + .../relationalStoretest/rdbnapitest/Test.json | 23 + .../rdbnapitest/entry/src/main/config.json | 101 + .../rdbnapitest/entry/src/main/cpp/BUILD.gn | 228 ++ .../entry/src/main/cpp/common/common.h | 103 + .../main/cpp/napi/rdb_store_backup_test.cpp | 682 ++++++ .../main/cpp/napi/rdb_store_cursor_test.cpp | 772 ++++++ .../main/cpp/napi/rdb_store_encrypt_test.cpp | 176 ++ .../main/cpp/napi/rdb_store_level_test.cpp | 313 +++ .../cpp/napi/rdb_store_predicates_test.cpp | 2145 +++++++++++++++++ .../src/main/cpp/napi/rdb_store_test.cpp | 1657 +++++++++++++ .../entry/src/main/ets/MainAbility/app.ets | 36 + .../src/main/ets/MainAbility/pages/index.ets | 37 + .../entry/src/main/ets/TestAbility/app.ets | 35 + .../src/main/ets/TestAbility/pages/index.ets | 50 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 78 + .../entry/src/main/ets/test/List.test.ets | 29 + .../main/ets/test/RdbNdkStoreBackupTest.ets | 159 ++ .../main/ets/test/RdbNdkStoreCursorTest.ets | 245 ++ .../main/ets/test/RdbNdkStoreEncryptTest.ets | 54 + .../main/ets/test/RdbNdkStoreLevelTest.ets | 79 + .../ets/test/RdbNdkStorePredicatesTest.ets | 790 ++++++ .../src/main/ets/test/RdbNdkStoreTest.ets | 378 +++ .../main/resources/base/element/string.json | 20 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../rdbnapitest/signature/openharmony_sx.p7b | Bin 0 -> 3426 bytes 27 files changed, 8238 insertions(+) create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/Test.json create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/media/icon.png create mode 100644 distributeddatamgr/relationalStoretest/rdbnapitest/signature/openharmony_sx.p7b diff --git a/distributeddatamgr/relationalStoretest/BUILD.gn b/distributeddatamgr/relationalStoretest/BUILD.gn index a62aeb6da..f795178ff 100644 --- a/distributeddatamgr/relationalStoretest/BUILD.gn +++ b/distributeddatamgr/relationalStoretest/BUILD.gn @@ -18,6 +18,7 @@ group("relationalStoretest") { if (is_standard_system) { deps = [ "RdbJstest/hap:rdb_js_test", + "rdbnapitest:ActsRdbNapiEtsTest", "relationalStoreJstest/hap:relationalstore_js_test", "relationalStoreStagetest:relationalstore_ets_test", ] diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn b/distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn new file mode 100644 index 000000000..d0c05e471 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn @@ -0,0 +1,47 @@ +# 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" +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/Test.json b/distributeddatamgr/relationalStoretest/rdbnapitest/Test.json new file mode 100644 index 000000000..92c3e7078 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/Test.json @@ -0,0 +1,23 @@ +{ + "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": [] + } + ] +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json new file mode 100644 index 000000000..1e2c88c4e --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json @@ -0,0 +1,101 @@ +{ + "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 diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn new file mode 100644 index 000000000..980226904 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn @@ -0,0 +1,228 @@ +# 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" +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h new file mode 100644 index 000000000..1da36855b --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h @@ -0,0 +1,103 @@ +/* + * 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 diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp new file mode 100644 index 000000000..44b5735fe --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp @@ -0,0 +1,682 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 *storeBackupTestRdbStore_ = NULL; +static OH_Rdb_Config config_; +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 napi_value RdbstoreSetUpTestCase(napi_env env, napi_callback_info info) { + + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + storeBackupTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, storeBackupTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config 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(storeBackupTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value RdbstoreTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeBackupTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeBackupTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + 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_BackupRestoreTest_0100(napi_env env, napi_callback_info info) { + + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + 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"); + + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = ""; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 14800011, "OH_Rdb_Backup is success."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0300(napi_env env, napi_callback_info info) { + 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"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backup.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup1 is fail."); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup2 is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0400(napi_env env, napi_callback_info info) { + 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"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath1[] = "backup1.db"; + char backupPath1[100]; + sprintf(backupPath1, "%s%s", RDB_TEST_PATH, dbpath1); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath1); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup1 is fail."); + + char dbpath2[] = "backup2.db"; + char backupPath2[100]; + sprintf(backupPath2, "%s%s", RDB_TEST_PATH, dbpath2); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath2); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup2 is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath1); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore1 is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath2); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore2 is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0500(napi_env env, napi_callback_info info) { + 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"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backup.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "DeleteData is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0600(napi_env env, napi_callback_info info) { + 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"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = " "; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "DeleteData is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0700(napi_env env, napi_callback_info info) { + 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"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, NULL); + NAPI_ASSERT(env, errCode == 14800001, "OH_Rdb_Backup is success."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0800(napi_env env, napi_callback_info info) { + 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"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backupNull.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "DeleteData is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, NULL); + NAPI_ASSERT(env, errCode == 14800001, "OH_Rdb_Restore is success."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is success."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0900(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + 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"); + + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backupEmpty.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + char dbpath1[] = ""; + char reStorePath[100]; + sprintf(reStorePath, "%s%s", RDB_TEST_PATH, dbpath1); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, reStorePath); + NAPI_ASSERT(env, errCode == 14800011, "OH_Rdb_Restore is success."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0110(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + 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"); + + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backupWrong.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + char dbpath2[] = "wrong.db"; + char reStorePath[100]; + sprintf(reStorePath, "%s%s", RDB_TEST_PATH, dbpath2); + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, reStorePath); + NAPI_ASSERT(env, errCode == 14800011, "OH_Rdb_Restore is success."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + 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[] = { + {"RdbstoreSetUpTestCase", nullptr, RdbstoreSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"RdbstoreTearDownTestCase", nullptr, RdbstoreTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0100", nullptr, SUB_DDM_RDB_BackupRestoreTest_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0300", nullptr, SUB_DDM_RDB_BackupRestoreTest_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0400", nullptr, SUB_DDM_RDB_BackupRestoreTest_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0500", nullptr, SUB_DDM_RDB_BackupRestoreTest_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0600", nullptr, SUB_DDM_RDB_BackupRestoreTest_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0700", nullptr, SUB_DDM_RDB_BackupRestoreTest_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0800", nullptr, SUB_DDM_RDB_BackupRestoreTest_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0900", nullptr, SUB_DDM_RDB_BackupRestoreTest_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0110", nullptr, SUB_DDM_RDB_BackupRestoreTest_0110, 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 = "backup", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp new file mode 100644 index 000000000..be86f796f --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp @@ -0,0 +1,772 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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" + +OH_Rdb_Store *cursorTestRdbStore_ = NULL; + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_cursor_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + +static OH_Rdb_Config config_; +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 napi_value CursorSetUpTestCase(napi_env env, napi_callback_info info) { + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + char table[] = "test"; + cursorTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, cursorTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config 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(cursorTestRdbStore_, createTableSql); + + 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(cursorTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert 1 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(cursorTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert 2 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 3); + valueBucket->putText(valueBucket, "data1", "wangWu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + errCode = OH_Rdb_Insert(cursorTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 3, "OH_Rdb_Insert 3 is fail."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value CursorTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(cursorTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(cursorTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0100 + * @tc.desc: napi test RDB cursor for GetColumnType. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0100(napi_env env, napi_callback_info info) { + + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + cursor->goToNextRow(cursor); + + OH_ColumnType type; + errCode = cursor->getColumnType(cursor, 0, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_INT64, "getColumnType 0 is fail."); + + errCode = cursor->getColumnType(cursor, 1, &type);; + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_TEXT, "getColumnType 1 is fail."); + + errCode = cursor->getColumnType(cursor, 2, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_INT64, "getColumnType 2 is fail."); + + errCode = cursor->getColumnType(cursor, 3, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_REAL, "getColumnType 3 is fail."); + + errCode = cursor->getColumnType(cursor, 4, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_BLOB, "getColumnType 4 is fail."); + + errCode = cursor->getColumnType(cursor, 5, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_TEXT, "getColumnType 5 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0200 + * @tc.desc: napi test RDB cursor for GetColumnIndex. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int columnIndex; + errCode = cursor->getColumnIndex(cursor, "data1", &columnIndex); + NAPI_ASSERT(env, columnIndex == 1, "getColumnIndex 1 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data2", &columnIndex); + NAPI_ASSERT(env, columnIndex == 2, "getColumnIndex 2 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data3", &columnIndex); + NAPI_ASSERT(env, columnIndex == 3, "getColumnIndex 3 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data4", &columnIndex); + NAPI_ASSERT(env, columnIndex == 4, "getColumnIndex 4 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data5", &columnIndex); + NAPI_ASSERT(env, columnIndex == 5, "getColumnIndex 5 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0300 + * @tc.desc: napi test RDB cursor for GetColumnName. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0300(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + char name[10]; + int errCode = cursor->getColumnName(cursor, 1, name, 10); + NAPI_ASSERT(env, strncmp(name, "data1", 5) == 0, "getColumnName data1 is fail."); + + errCode = cursor->getColumnName(cursor, 2, name, 6); + NAPI_ASSERT(env, strncmp(name, "data2", 5) == 0, "getColumnName data2 is fail."); + + errCode = cursor->getColumnName(cursor, 3, name, 6); + NAPI_ASSERT(env, strncmp(name, "data3", 5) == 0, "getColumnName data3 is fail."); + + errCode = cursor->getColumnName(cursor, 4, name, 6); + NAPI_ASSERT(env, strncmp(name, "data4", 5) == 0, "getColumnName data4 is fail."); + + errCode = cursor->getColumnName(cursor, 5, name, 6); + NAPI_ASSERT(env, strncmp(name, "data5", 5) == 0, "getColumnName data5 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0400 + * @tc.desc: napi test RDB cursor for Getxxx. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0400(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int errCode = 0; + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 0, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 0, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", size) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 1, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 2, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 3, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 3, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob 0 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob 1 is fail."); + + cursor->goToNextRow(cursor); + + cursor->getSize(cursor, 0, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 0, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "liSi", size) == 0, "getText is fail."); + + cursor->getInt64(cursor, 1, &data2Value); + NAPI_ASSERT(env, data2Value == 13800, "getInt64 is fail."); + + cursor->getReal(cursor, 2, &data3Value); + NAPI_ASSERT(env, data3Value == 200.1, "getReal is fail."); + + bool isNull = false; + cursor->isNull(cursor, 3, &isNull); + NAPI_ASSERT(env, isNull == true, "isNull is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0500 + * @tc.desc: napi test RDB cursor for GetColumnIndex. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0500(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int columnIndex; + int errCode = cursor->getColumnIndex(cursor, "data", &columnIndex); + NAPI_ASSERT(env, columnIndex == -1, "getColumnIndex is fail."); + + errCode = predicates->destroy(predicates); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0600 + * @tc.desc: napi test RDB cursor for GetColumnIndex. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0600(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int columnIndex; + char *name = NULL; + int errCode = cursor->getColumnIndex(cursor, name, &columnIndex); + NAPI_ASSERT(env, errCode == 14800001, "getColumnIndex is fail."); + + errCode = predicates->destroy(predicates); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0700 + * @tc.desc: napi test RDB cursor for GetColumnType. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0700(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + cursor->goToNextRow(cursor); + + OH_ColumnType type; + int errCode = cursor->getColumnType(cursor, 6, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_NULL, "getColumnType is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0800 + * @tc.desc: napi test RDB cursor for GetColumnName. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0800(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + char name[10] = ""; + int errCode = cursor->getColumnName(cursor, 6, name, 10); + NAPI_ASSERT(env, strncmp(name, "", 10) == 0, "getColumnName is fail."); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0900 + * @tc.desc: napi test RDB cursor for getSize. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0900(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int errCode = 0; + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 6, &size); + NAPI_ASSERT(env, (int)size == 0, "getSize is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1000 + * @tc.desc: napi test RDB cursor for getText. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1000(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 0, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 6, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "", size) == 0, "getText is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1100 + * @tc.desc: napi test RDB cursor for getInt64. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1100(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + int64_t data2Value = 0; + int errCode = cursor->getInt64(cursor, 6, &data2Value); + NAPI_ASSERT(env, data2Value == 0, "getInt64 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1200 + * @tc.desc: napi test RDB cursor for getReal. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1200(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + double data3Value = 0; + cursor->getReal(cursor, 6, &data3Value); + NAPI_ASSERT(env, data3Value == 0, "getReal is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1300 + * @tc.desc: getBlob + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1300(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 3, &size); + unsigned char data4Value[] = "string"; + int errCode = cursor->getBlob(cursor, 6, data4Value, size); + NAPI_ASSERT(env, strncmp((char*)data4Value, "string", size) == 0, "getBlob is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1400 + * @tc.desc: isNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1400(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + bool isNull = false; + int errCode = cursor->isNull(cursor, 6, &isNull); + NAPI_ASSERT(env, isNull == false, "isNull is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1500 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1500(napi_env env, napi_callback_info info) { + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1600 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1600(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "name"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1700 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1700(napi_env env, napi_callback_info info) { + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject1 = OH_Rdb_CreateValueObject(); + const char *data1Value1 = "zhangSan"; + valueObject1->putText(valueObject1, data1Value1); + predicates->equalTo(predicates, "data1", valueObject1); + OH_VObject *valueObject2 = OH_Rdb_CreateValueObject(); + const char *data1Value2 = "name"; + valueObject2->putText(valueObject2, data1Value2); + predicates->equalTo(predicates, "data1", valueObject2); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1800 + * @tc.desc: + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1800(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan1"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + int errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 14800026, "goToNextRow is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + 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[] = { + {"CursorSetUpTestCase", nullptr, CursorSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"CursorTearDownTestCase", nullptr, CursorTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0100", nullptr, SUB_DDM_RDB_CURSOR_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0200", nullptr, SUB_DDM_RDB_CURSOR_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0300", nullptr, SUB_DDM_RDB_CURSOR_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0400", nullptr, SUB_DDM_RDB_CURSOR_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0500", nullptr, SUB_DDM_RDB_CURSOR_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0600", nullptr, SUB_DDM_RDB_CURSOR_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0700", nullptr, SUB_DDM_RDB_CURSOR_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0800", nullptr, SUB_DDM_RDB_CURSOR_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0900", nullptr, SUB_DDM_RDB_CURSOR_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1000", nullptr, SUB_DDM_RDB_CURSOR_1000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1100", nullptr, SUB_DDM_RDB_CURSOR_1100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1200", nullptr, SUB_DDM_RDB_CURSOR_1200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1300", nullptr, SUB_DDM_RDB_CURSOR_1300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1400", nullptr, SUB_DDM_RDB_CURSOR_1400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1500", nullptr, SUB_DDM_RDB_CURSOR_1500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1600", nullptr, SUB_DDM_RDB_CURSOR_1600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1700", nullptr, SUB_DDM_RDB_CURSOR_1700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1800", nullptr, SUB_DDM_RDB_CURSOR_1800, 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 = "cursor", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp new file mode 100644 index 000000000..36c605988 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp @@ -0,0 +1,176 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp new file mode 100644 index 000000000..df5c7dcd5 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp @@ -0,0 +1,313 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp new file mode 100644 index 000000000..2726a833a --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp @@ -0,0 +1,2145 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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" + +OH_Rdb_Store *predicatesTestRdbStore_ = NULL; + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_predicates_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + +static OH_Rdb_Config config_; +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 napi_value PredicatesSetUpTestCase(napi_env env, napi_callback_info info) { + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + char table[] = "test"; + predicatesTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, predicatesTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen 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(predicatesTestRdbStore_, createTableSql); + + 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(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert 1 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert 2 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 3); + valueBucket->putText(valueBucket, "data1", "wangWu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 3, "OH_Rdb_Insert 3 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 4); + valueBucket->putText(valueBucket, "data1", "zhangliu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 4, "OH_Rdb_Insert 4 is fail."); + + errCode = 0; + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + +static napi_value PredicatesTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(predicatesTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(predicatesTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0100 + * @tc.desc: napi test RDB Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + predicates->orOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0200 + * @tc.desc: napi test RDB Predicates for NotEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->notEqualTo(predicates, "data1", valueObject); + NAPI_ASSERT(env, errCode == 0, "notEqualTo is fail."); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0300 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThan(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0400 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThanOrEqualTo(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0500 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThan(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0600 + * @tc.desc: napi test RDB Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThanOrEqualTo(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0700 + * @tc.desc: napi test RDB Predicates for IsNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNull(predicates, "data4"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0800 + * @tc.desc: napi test RDB Predicates for isNotNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNotNull(predicates, "data4"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0900 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data2", valueObject); + double data3Value[] = {0.1, 101.1}; + len = sizeof(data3Value) / sizeof(data3Value[0]); + valueObject->putDouble(valueObject, data3Value, len); + predicates->between(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1000 + * @tc.desc: napi test RDB Predicates for NotBetween + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + int len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->notBetween(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1100 + * @tc.desc: napi test RDB Predicates for OrderBy、Limit、Offset. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + int columnIndex; + cursor->getColumnIndex(cursor, "data2", &columnIndex); + NAPI_ASSERT(env, columnIndex == 2, "getColumnIndex is fail."); + + int64_t longValue; + cursor->getInt64(cursor, columnIndex, &longValue); + NAPI_ASSERT(env, longValue == 12800, "getInt64 is fail."); + + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1200 + * @tc.desc: napi test RDB Predicates for In. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->in(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1300 + * @tc.desc: napi test RDB Predicates for NotIn + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->notIn(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1400 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCD%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data5", valueObject); + const char *data2Value = "%800"; + valueObject->putText(valueObject, data2Value); + predicates->like(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1500 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + int len = sizeof(columnNames) / sizeof(columnNames[0]); + predicates->groupBy(predicates, columnNames, len); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_1600 + * @tc.desc: napi test RDB Predicates for And + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + double data3Value = 100.1; + valueObject->putDouble(valueObject, &data3Value, 1); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_1700 + * @tc.desc: napi test RDB Predicates for Clear + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + errCode = cursor->destroy(cursor); + + predicates->clear(predicates); + predicates->notEqualTo(predicates, "data1", valueObject); + cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1800 + * @tc.desc: napi test RDB Predicates for table name is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1800(napi_env env, napi_callback_info info) { + char *table = NULL; + OH_Predicates *predicates = OH_Rdb_CreatePredicates(table); + NAPI_ASSERT(env, predicates == NULL, "OH_Rdb_CreatePredicates is fail."); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor == NULL, "OH_Rdb_Query is fail."); + + int errCode = 0; + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1900 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2000 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2100 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2200 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 1.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2300 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->notEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2400 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "wangWu"; + valueObject->putText(valueObject, data1Value); + predicates->notEqualTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + OH_VObject *valueObject1 = OH_Rdb_CreateValueObject(); + const char *data1Value1 = "zhangliu"; + valueObject1->putText(valueObject1, data1Value1); + predicates->notEqualTo(predicates, "data1", valueObject1); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + valueObject1->destroy(valueObject1); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2500 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "name"; + valueObject->putText(valueObject, data1Value); + predicates->notEqualTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2600 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->notEqualTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2700 + * @tc.desc: napi test RDB Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2800 + * @tc.desc: napi test RDB Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2900 + * @tc.desc: napi test RDB Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_3000 + * @tc.desc: napi test RDB Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_3100 + * @tc.desc: napi test RDB Predicates for + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + predicates->orOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, 1); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3200 + * @tc.desc: napi test RDB Predicates for And + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->orOperate(predicates); + predicates->orOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, 1); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_3300 + * @tc.desc: napi test RDB Predicates for IsNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNull(predicates, "data"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3400 + * @tc.desc: napi test RDB Predicates for isNotNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNotNull(predicates, "data"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3500 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "%BCD%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3600 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "%BCDx%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3700 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCD%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3800 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 12000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3900 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {13000, 12000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_4000 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4100 + * @tc.desc: napi test RDB Predicates for NotBetween + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + int len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->notBetween(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4200 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4300 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 400.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4400 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThan(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4500 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThan(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4600 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4700 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 10.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4800 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThanOrEqualTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + } + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4900 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5000 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 400.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_5100 + * @tc.desc: napi test RDB Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThanOrEqualTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_5200 + * @tc.desc: napi test RDB Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 1.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5300 + * @tc.desc: napi test RDB Predicates for + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5400 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data", "data2"}; + int len = sizeof(columnNames) / sizeof(columnNames[0]); + predicates->groupBy(predicates, columnNames, len); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5500 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + predicates->groupBy(predicates, columnNames, 0); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5600 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + predicates->groupBy(predicates, columnNames, 2); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5700 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + predicates->groupBy(predicates, columnNames, 3); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5800 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data2", "data3"}; + predicates->groupBy(predicates, columnNames, 1); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5900 + * @tc.desc: napi test RDB Predicates for In. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->in(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6000 + * @tc.desc: napi test RDB Predicates for In. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12800, 13000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->in(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6100 + * @tc.desc: napi test RDB Predicates for NotIn + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->notIn(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6200 + * @tc.desc: napi test RDB Predicates for NotIn + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12800, 13800}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->notIn(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6300 + * @tc.desc: napi test RDB Predicates for OrderBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::DESC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + int columnIndex; + cursor->getColumnIndex(cursor, "data2", &columnIndex); + NAPI_ASSERT(env, columnIndex == 2, "getColumnIndex is fail."); + + int64_t longValue; + cursor->getInt64(cursor, columnIndex, &longValue); + NAPI_ASSERT(env, longValue == 14800, "getInt64 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6400 + * @tc.desc: napi test RDB Predicates for OrderBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6500 + * @tc.desc: napi test RDB Predicates for Limit + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 0); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6600 + * @tc.desc: napi test RDB Predicates for Offset + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 5); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6700 + * @tc.desc: napi test RDB Predicates for Offset + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, -1); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + 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[] = { + {"PredicatesSetUpTestCase", nullptr, PredicatesSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"PredicatesTearDownTestCase", nullptr, PredicatesTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0100", nullptr, SUB_DDM_RDB_Predicates_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0200", nullptr, SUB_DDM_RDB_Predicates_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0300", nullptr, SUB_DDM_RDB_Predicates_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0400", nullptr, SUB_DDM_RDB_Predicates_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0500", nullptr, SUB_DDM_RDB_Predicates_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0600", nullptr, SUB_DDM_RDB_Predicates_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0700", nullptr, SUB_DDM_RDB_Predicates_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0800", nullptr, SUB_DDM_RDB_Predicates_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0900", nullptr, SUB_DDM_RDB_Predicates_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1000", nullptr, SUB_DDM_RDB_Predicates_1000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1100", nullptr, SUB_DDM_RDB_Predicates_1100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1200", nullptr, SUB_DDM_RDB_Predicates_1200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1300", nullptr, SUB_DDM_RDB_Predicates_1300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1400", nullptr, SUB_DDM_RDB_Predicates_1400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1500", nullptr, SUB_DDM_RDB_Predicates_1500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1600", nullptr, SUB_DDM_RDB_Predicates_1600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1700", nullptr, SUB_DDM_RDB_Predicates_1700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1800", nullptr, SUB_DDM_RDB_Predicates_1800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1900", nullptr, SUB_DDM_RDB_Predicates_1900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2000", nullptr, SUB_DDM_RDB_Predicates_2000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2100", nullptr, SUB_DDM_RDB_Predicates_2100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2200", nullptr, SUB_DDM_RDB_Predicates_2200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2300", nullptr, SUB_DDM_RDB_Predicates_2300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2400", nullptr, SUB_DDM_RDB_Predicates_2400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2500", nullptr, SUB_DDM_RDB_Predicates_2500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2600", nullptr, SUB_DDM_RDB_Predicates_2600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2700", nullptr, SUB_DDM_RDB_Predicates_2700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2800", nullptr, SUB_DDM_RDB_Predicates_2800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2900", nullptr, SUB_DDM_RDB_Predicates_2900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3000", nullptr, SUB_DDM_RDB_Predicates_3000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3100", nullptr, SUB_DDM_RDB_Predicates_3100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3200", nullptr, SUB_DDM_RDB_Predicates_3200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3300", nullptr, SUB_DDM_RDB_Predicates_3300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3400", nullptr, SUB_DDM_RDB_Predicates_3400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3500", nullptr, SUB_DDM_RDB_Predicates_3500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3600", nullptr, SUB_DDM_RDB_Predicates_3600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3700", nullptr, SUB_DDM_RDB_Predicates_3700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3800", nullptr, SUB_DDM_RDB_Predicates_3800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3900", nullptr, SUB_DDM_RDB_Predicates_3900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4000", nullptr, SUB_DDM_RDB_Predicates_4000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4100", nullptr, SUB_DDM_RDB_Predicates_4100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4200", nullptr, SUB_DDM_RDB_Predicates_4200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4300", nullptr, SUB_DDM_RDB_Predicates_4300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4400", nullptr, SUB_DDM_RDB_Predicates_4400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4500", nullptr, SUB_DDM_RDB_Predicates_4500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4600", nullptr, SUB_DDM_RDB_Predicates_4600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4700", nullptr, SUB_DDM_RDB_Predicates_4700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4800", nullptr, SUB_DDM_RDB_Predicates_4800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4900", nullptr, SUB_DDM_RDB_Predicates_4900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5000", nullptr, SUB_DDM_RDB_Predicates_5000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5100", nullptr, SUB_DDM_RDB_Predicates_5100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5200", nullptr, SUB_DDM_RDB_Predicates_5200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5300", nullptr, SUB_DDM_RDB_Predicates_5300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5400", nullptr, SUB_DDM_RDB_Predicates_5400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5500", nullptr, SUB_DDM_RDB_Predicates_5500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5600", nullptr, SUB_DDM_RDB_Predicates_5600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5700", nullptr, SUB_DDM_RDB_Predicates_5700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5800", nullptr, SUB_DDM_RDB_Predicates_5800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5900", nullptr, SUB_DDM_RDB_Predicates_5900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6000", nullptr, SUB_DDM_RDB_Predicates_6000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6100", nullptr, SUB_DDM_RDB_Predicates_6100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6200", nullptr, SUB_DDM_RDB_Predicates_6200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6300", nullptr, SUB_DDM_RDB_Predicates_6300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6400", nullptr, SUB_DDM_RDB_Predicates_6400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6500", nullptr, SUB_DDM_RDB_Predicates_6500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6600", nullptr, SUB_DDM_RDB_Predicates_6600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6700", nullptr, SUB_DDM_RDB_Predicates_6700, 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 = "predicates", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp new file mode 100644 index 000000000..fc26f8973 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp @@ -0,0 +1,1657 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 *storeTestRdbStore_ = NULL; +static OH_Rdb_Config config_; +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 napi_value RdbstoreSetUpTestCase(napi_env env, napi_callback_info info) { + + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + storeTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, storeTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config 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(storeTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value RdbstoreTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_0100 + * @tc.desc: napi test RDB store for Insert、Update、Query. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0100(napi_env env, napi_callback_info info) { + + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Update is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "liSi", size) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 13800, "getInt64 is fail."); + + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 200.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob is fail."); + + bool isNull = false; + cursor->isNull(cursor, 5, &isNull); + NAPI_ASSERT(env, isNull == true, "isNull is fail."); + + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + + +/** + * @tc.name: SUB_DDM_RDB_0200 + * @tc.desc: napi test RDB store for Insert with wrong table name or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0200(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "wrong", valueBucket); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Insert id=2 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 3); + valueBucket->putText(valueBucket, "data1", "wangWu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + char *table = NULL; + errCode = OH_Rdb_Insert(storeTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == OH_Rdb_ErrCode::RDB_E_INVALID_ARGS, "OH_Rdb_Insert id=3 is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + +/** + * @tc.name: SUB_DDM_RDB_0300 + * @tc.desc: napi test RDB store for Update with wrong table or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0300(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("wrong"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Update is fail."); + + char *table = NULL; + OH_Predicates *predicates1 = OH_Rdb_CreatePredicates(table); + NAPI_ASSERT(env, predicates1 == NULL, "OH_Rdb_CreatePredicates is fail."); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates1); + NAPI_ASSERT(env, errCode == OH_Rdb_ErrCode::RDB_E_INVALID_ARGS, "OH_Rdb_Update is fail."); + + OH_Predicates *predicates2 = OH_Rdb_CreatePredicates("test"); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates2, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + predicates2->destroy(predicates2); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + +/** + * @tc.name: SUB_DDM_RDB_0400 + * @tc.desc: napi test RDB store for Update with valueBucket is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0400(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Update is fail."); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0500 + * @tc.desc: napi test RDB store for Update with wrong predicates. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0500(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "wangwu"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Update is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0600 + * @tc.desc: napi test RDB store for Query with wrong table or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0600(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("wrong"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + char *table = NULL; + OH_Predicates *predicates1 = OH_Rdb_CreatePredicates(table); + + OH_Cursor *cursor1 = OH_Rdb_Query(storeTestRdbStore_, predicates1, NULL, 0); + NAPI_ASSERT(env, cursor1 == NULL, "OH_Rdb_Query 2 is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0700 + * @tc.desc: napi test RDB store for Query with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0700(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0800 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0800(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0900 + * @tc.desc: napi test RDB store for Delete、ExecuteQuery. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0900(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert 2 is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "liSi", 4) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 13800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 200.1, "getReal is fail."); + + bool isNull = false; + cursor->isNull(cursor, 4, &isNull); + NAPI_ASSERT(env, isNull == true, "isNull is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFGH", 8) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_1000 + * @tc.desc: napi test RDB store for querysql is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1000(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char *querySql = NULL; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + NAPI_ASSERT(env, cursor == NULL, "OH_Rdb_ExecuteQuery is fail."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_1100 + * @tc.desc: napi test RDB store for Delete with wrong table or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1100(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("wrong"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Delete is fail."); + + OH_Predicates *predicates1 = OH_Rdb_CreatePredicates("test"); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates1, NULL, 0); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + char *table = NULL; + OH_Predicates *predicates2 = OH_Rdb_CreatePredicates(table); + NAPI_ASSERT(env, predicates2 == NULL, "OH_Rdb_CreatePredicates is fail."); + + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates2); + NAPI_ASSERT(env, errCode == 14800001, "OH_Rdb_Delete is fail."); + + OH_Cursor *cursor1 = OH_Rdb_Query(storeTestRdbStore_, predicates1, NULL, 0); + int rowCount1 = 0; + cursor1->getRowCount(cursor1, &rowCount1); + NAPI_ASSERT(env, rowCount1 == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + cursor1->destroy(cursor1); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1200 + * @tc.desc: napi test RDB store for Delete with wrong predicates. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1200(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "wangwu"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Delete is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +/** + * @tc.name: SUB_DDM_RDB_1300 + * @tc.desc: napi test RDB store for Delete multiple. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1300(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Delete is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1400 + * @tc.desc: napi test RDB store for Transaction、Commit. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1400(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_Commit(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_1500 + * @tc.desc: napi test RDB store for Transaction、RollBack. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_RollBack(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1600 + * @tc.desc: napi test RDB store for Transaction、Commit. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_Commit(storeTestRdbStore_); + OH_Rdb_Commit(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1700 + * @tc.desc: napi test RDB store for Transaction、Commit. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_RollBack(storeTestRdbStore_); + OH_Rdb_Commit(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1800 + * @tc.desc: napi test RDB store for GetVersion、SetVersion. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1800(napi_env env, napi_callback_info info) { + int errCode = 0; + int version = 0; + int setVersion = 3; + errCode = OH_Rdb_GetVersion(storeTestRdbStore_, &version); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetVersion is fail."); + NAPI_ASSERT(env, version == 0, "OH_Rdb_GetVersion is fail."); + + errCode = OH_Rdb_SetVersion(storeTestRdbStore_, setVersion); + errCode = OH_Rdb_GetVersion(storeTestRdbStore_, &version); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_SetVersion is fail."); + NAPI_ASSERT(env, version == 3, "OH_Rdb_SetVersion is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1900 + * @tc.desc: napi test RDB store for Query with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1900(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2000 + * @tc.desc: napi test RDB store for Update with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2000(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Update is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2100 + * @tc.desc: napi test RDB store for Delete with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2100(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Delete is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2200 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2200(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 2); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2300 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2300(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 7); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2400 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2400(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2500 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2500(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2600 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2600(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2700 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2700(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 2); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_2800 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2800(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 4); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_2900 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2900(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 3); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_3000 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_3000(napi_env env, napi_callback_info info) { + int errCode = 0; + 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(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4","data5"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 5); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = valueBucket->destroy(valueBucket); + + 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[] = { + {"RdbstoreSetUpTestCase", nullptr, RdbstoreSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"RdbstoreTearDownTestCase", nullptr, RdbstoreTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0100", nullptr, SUB_DDM_RDB_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0200", nullptr, SUB_DDM_RDB_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0300", nullptr, SUB_DDM_RDB_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0400", nullptr, SUB_DDM_RDB_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0500", nullptr, SUB_DDM_RDB_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0600", nullptr, SUB_DDM_RDB_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0700", nullptr, SUB_DDM_RDB_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0800", nullptr, SUB_DDM_RDB_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0900", nullptr, SUB_DDM_RDB_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1000", nullptr, SUB_DDM_RDB_1000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1100", nullptr, SUB_DDM_RDB_1100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1200", nullptr, SUB_DDM_RDB_1200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1300", nullptr, SUB_DDM_RDB_1300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1400", nullptr, SUB_DDM_RDB_1400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1500", nullptr, SUB_DDM_RDB_1500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1600", nullptr, SUB_DDM_RDB_1600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1700", nullptr, SUB_DDM_RDB_1700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1800", nullptr, SUB_DDM_RDB_1800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1900", nullptr, SUB_DDM_RDB_1900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2000", nullptr, SUB_DDM_RDB_2000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2100", nullptr, SUB_DDM_RDB_2100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2200", nullptr, SUB_DDM_RDB_2200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2300", nullptr, SUB_DDM_RDB_2300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2400", nullptr, SUB_DDM_RDB_2400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2500", nullptr, SUB_DDM_RDB_2500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2600", nullptr, SUB_DDM_RDB_2600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2700", nullptr, SUB_DDM_RDB_2700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2800", nullptr, SUB_DDM_RDB_2800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2900", nullptr, SUB_DDM_RDB_2900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_3000", nullptr, SUB_DDM_RDB_3000, 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 = "rdbstore", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..74210553e --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,36 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, + + +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..d4be87ada --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,37 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..70605c307 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,35 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + } + + +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..4724a25d8 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..d3cf5bb00 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +// @ts-nocheck +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..d23b3a769 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,29 @@ +/* + * 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 diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets new file mode 100644 index 000000000..d006cc7c8 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets @@ -0,0 +1,159 @@ +/* + * 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 'libbackup.so'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreBackupTest() { + describe('RdbNdkStoreBackupTest', function () { + beforeAll(function () { + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreSetUpTestCase' , ' begin'); + let re = testNapi.RdbstoreSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreTearDownTestCase' , ' begin'); + let re = testNapi.RdbstoreTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + }) + + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0100 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0300 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: backup file name already exists + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0400 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0500 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: backup file name is empty + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0600 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.desc: backup file name is a space + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0700 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.desc: Backup file name is a null + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0800 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.desc: Restore file name is a null + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0900 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: Restore file name is empty + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0110 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: Restore file name is invalid + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0110',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0110' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0110(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets new file mode 100644 index 000000000..3ea01ef18 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets @@ -0,0 +1,245 @@ +/* + * 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 'libcursor.so' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreCursorTest() { + describe('RdbNdkStoreCursorTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag CursorSetUpTestCase' , ' begin'); + let re = testNapi.CursorSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag CursorTearDownTestCase' , ' begin'); + let re = testNapi.CursorTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0100 + * @tc.desc: Normal testCase of NDK cursor for GetColumnType. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0200 + * @tc.desc: Normal testCase of NDK cursor for GetColumnIndex. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0300 + * @tc.desc: Normal testCase of NDK cursor for GetColumnName. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0400 + * @tc.desc: Normal testCase of NDK cursor for Getxxx. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0500 + * @tc.desc: Normal testCase of NDK cursor for GetColumnIndex. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0600 + * @tc.desc: Normal testCase of NDK cursor for GetColumnIndex. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0700 + * @tc.desc: Normal testCase of NDK cursor for GetColumnType. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0800 + * @tc.desc: Normal testCase of NDK cursor for GetColumnName. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0900 + * @tc.desc: Normal testCase of NDK cursor for getSize. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1000 + * @tc.desc: Normal testCase of NDK cursor for getText. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1100 + * @tc.desc: Normal testCase of NDK cursor for getInt64. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1200 + * @tc.desc: Normal testCase of NDK cursor for getReal. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1300 + * @tc.desc: getBlob + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1400 + * @tc.desc: isNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1500 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1600 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1700 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1800 + * @tc.desc: + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets new file mode 100644 index 000000000..37ce839c2 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets @@ -0,0 +1,54 @@ +/* + * 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 diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets new file mode 100644 index 000000000..f889828f9 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets @@ -0,0 +1,79 @@ +/* + * 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 'liblevel.so' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreLevelTest() { + describe('RdbNdkStoreLevelTest', function () { + beforeAll(function () {}) + beforeEach(function () {}) + afterEach(function () {}) + afterAll(function () {}) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0100 + * @tc.desc: Normal testCase of NDK SecurityLevel is S1 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0200 + * @tc.desc: Normal testCase of NDK SecurityLevel is S2 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0300 + * @tc.desc: Normal testCase of NDK SecurityLevel is S3 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0400 + * @tc.desc: Normal testCase of NDK SecurityLevel is S4 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets new file mode 100644 index 000000000..a9144422f --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets @@ -0,0 +1,790 @@ +/* + * 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 'libpredicates.so' + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStorePredicatesTest() { + describe('RdbNdkStorePredicatesTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag PredicatesSetUpTestCase' , ' begin'); + let re = testNapi.PredicatesSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag PredicatesTearDownTestCase' , ' begin'); + let re = testNapi.PredicatesTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_0100 + * @tc.desc: Normal testCase of NDK Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_0200 + * @tc.desc: Normal testCase of NDK Predicates for NotEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0300 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0400 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_0500 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0600 + * @tc.desc: Normal testCase of NDK Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0700 + * @tc.desc: Normal testCase of NDK Predicates for IsNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0800 + * @tc.desc: Normal testCase of NDK Predicates for isNotNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0900 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1000 + * @tc.desc: Normal testCase of NDK Predicates for NotBetween + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + /** + * @tc.name: SUB_DDM_RDB_Predicates_1100 + * @tc.desc: Normal testCase of NDK Predicates for OrderBy、Limit、Offset. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1200 + * @tc.desc: Normal testCase of NDK Predicates for In. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1300 + * @tc.desc: Normal testCase of NDK Predicates for NotIn + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1400 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1500 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1600 + * @tc.desc: Normal testCase of NDK Predicates for And + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1700 + * @tc.desc: Normal testCase of NDK Predicates for Clear + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1800 + * @tc.desc: Normal testCase of NDK Predicates for table name is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1900 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2000 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + /** + * @tc.name: SUB_DDM_RDB_Predicates_2100 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + + it('SUB_DDM_RDB_Predicates_2100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2200 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2300 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2400 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2500 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2600 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2700 + * @tc.desc: Normal testCase of NDK Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2800 + * @tc.desc: Normal testCase of NDK Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2900 + * @tc.desc: Normal testCase of NDK Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3000 + * @tc.desc: Normal testCase of NDK Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3100 + * @tc.desc: Normal testCase of NDK Predicates for + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3200 + * @tc.desc: Normal testCase of NDK Predicates for And + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3300 + * @tc.desc: Normal testCase of NDK Predicates for IsNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3400 + * @tc.desc: Normal testCase of NDK Predicates for isNotNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3500 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3600 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3700 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3800 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3900 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4000 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_4100 + * @tc.desc: Normal testCase of NDK Predicates for NotBetween + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4200 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4300 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4400 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4500 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4600 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4700 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4800 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4900 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5000 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5100 + * @tc.desc: Normal testCase of NDK Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5200 + * @tc.desc: Normal testCase of NDK Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5300 + * @tc.desc: Normal testCase of NDK Predicates for + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5400 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5500 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5600 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5700 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5800 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5900 + * @tc.desc: Normal testCase of NDK Predicates for In. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6000 + * @tc.desc: Normal testCase of NDK Predicates for In. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_6100 + * @tc.desc: Normal testCase of NDK Predicates for NotIn + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6200 + * @tc.desc: Normal testCase of NDK Predicates for NotIn + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6300 + * @tc.desc: Normal testCase of NDK Predicates for OrderBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6400 + * @tc.desc: Normal testCase of NDK Predicates for OrderBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6500 + * @tc.desc: Normal testCase of NDK Predicates for Limit + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6600 + * @tc.desc: Normal testCase of NDK Predicates for Offset + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6700 + * @tc.desc: Normal testCase of NDK Predicates for Offset + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets new file mode 100644 index 000000000..810bfe35e --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets @@ -0,0 +1,378 @@ +/* + * 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 'librdbstore.so' +import featureAbility from '@ohos.ability.featureAbility'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreTest() { + describe('RdbNdkStoreTest', function () { + beforeAll(function () { + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreSetUpTestCase' , ' begin'); + let re = testNapi.RdbstoreSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreTearDownTestCase' , ' begin'); + let re = testNapi.RdbstoreTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + }) + + /** + * @tc.name: SUB_DDM_RDB_0100 + * @tc.desc: Normal testCase of NDK store for Insert、Update、Query. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0100' , ' begin'); + + + let re = testNapi.SUB_DDM_RDB_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_0200 + * @tc.desc: Normal testCase of NDK store for Insert with wrong table name or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0300 + * @tc.desc: Normal testCase of NDK store for Update with wrong table or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0400 + * @tc.desc: Normal testCase of NDK store for Update with valueBucket is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0500 + * @tc.desc: Normal testCase of NDK store for Update with wrong predicates. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0600 + * @tc.desc: Normal testCase of NDK store for Query with wrong table or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0700 + * @tc.desc: Normal testCase of NDK store for Query with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0800 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0900 + * @tc.desc: Normal testCase of NDK store for Delete、ExecuteQuery. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1000 + * @tc.desc: Normal testCase of NDK store for querysql is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1100 + * @tc.desc: Normal testCase of NDK store for Delete with wrong table or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1200 + * @tc.desc: Normal testCase of NDK store for Delete with wrong predicates. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1300 + * @tc.desc: Normal testCase of NDK store for Delete multiple. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1400 + * @tc.desc: Normal testCase of NDK store for Transaction、Commit. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1500 + * @tc.desc: Normal testCase of NDK store for Transaction、RollBack. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1600 + * @tc.desc: Normal testCase of NDK store for Transaction、Commit. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1700 + * @tc.desc: Normal testCase of NDK store for Transaction、Commit. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1800 + * @tc.desc: Normal testCase of NDK store for GetVersion、SetVersion. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1900 + * @tc.desc: Normal testCase of NDK store for Query with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2000 + * @tc.desc: Normal testCase of NDK store for Update with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2100 + * @tc.desc: Normal testCase of NDK store for Delete with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2200 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2300 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2400 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2500 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2600 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2700 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2800 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2900 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_3000 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_3000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_3000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_3000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..498677efb --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/media/icon.png b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}yS>@Plmg)@q$}A4n}I(%nL#ts z>i50h+xPAMzTfxefrRLljI7Cv^owqZc$xgxgvbOEq6$8b2Z_LdjI3FU^gKc!h zMM&gs?nhQCcS%%opp@V$0zf4)x0`^JTs9LAB`4EFfWX592jHQQ#N`V!w9gS?lI!(k zP~k=&$q*hIPoi966c6}ZJ|-?Mno9&4vmsQtqhqhfPwf z0*d7`sR8)Qi<#QG;;5sTQsJ?XilY|zqPZ(*>Q z4B2!pS)mOl?PQ@kOlzubE-h_PV_F&z8Vl`?mISKe6xWqiQlko&H3TaaHg&A7hA8pr zttc6Z8!U2ItBat1wVkXc(XiT!Ly(pzuY;#fwUa5iYmJ&Gv;fyVJ)PF$5l$*tggcpV z5$$pmk$A|*5Md_O^Z~A&NQw^Pfm9fhxCxwzB>P$HzY0wk9&Z z2MPX5Ai+D_D&X_@e4%1{@DLc7(T{V`lT(EPL3$c+LIXfnhM-26k;7LTp`qZpWY9ln zKrjD*MuOZVIv^*z7n)}!@E|k+j86^;az^zYfl6z`E#r9K?VkLn*Uz83Fc#aPxGDJJ+EJ2UXq`6h@TaZj zRawLTxLS5nKrTHx;;lBWU%)ty&X@_p5n%X&p?_V}E*}1u0h=n?J71X7aV>rBW(f)g zB@+hocs~h+0)FNKFeVuf5)Ky*J%L~PaC@`y%&9l`{rXD!{T~}eJWJo234Ce5&4IWwrteDdw8L&S3;boic^o(_zrzh?n_|hgsmtts3 zXbrM;SL=o)7*_CG6b-JZsZ%YF^=<~kS6L`{qix1ca zwgCG47Q5r+wHwaX?_aT}U|auXrv@G@>lpj$g30n``_@gPB^%FtLJ24MYz53ZKFEJ3 z|2NdkT@x}bL$@ru(fT?lpBC5LiDj%|21SH646XImQoaS48*KzMP~ z+t&`ZH>1)1OykMla-SF=-m)nPZarx{J z&a961qu8Bg^d?LDM9IDP>UVvzW=;0TffqZ6Cr00Y?Ywar-L)LQ7_u?TJfF$le(~!f zD8ZY~iR>lrH~^ZSNf~=~)ZQnLRv#Gg@Z^ytfVi>$omY5Z^ur)49U9DSiX}iH<+eqc zOr~f6#g9gXkXV?v_CVWRU=fYB-`sI|Q}*Wk=RfW0$K%cXY3K)$)tM7>!=V4eot!V! z0S!MdINO=E^2m25nSs0BsG4xtDO)}I&V!>P==A2%t+(>l#`t;j=``7vH<#WCWv!gK b`y