diff --git a/preferences/preferenceTest/entry/src/main/js/MainAbility/pages/second/second.js b/preferences/preferenceTest/entry/src/main/js/MainAbility/pages/second/second.js
new file mode 100644
index 0000000000000000000000000000000000000000..ac4f4f83da1d046e0dd8f5aa7d625092e99cc805
--- /dev/null
+++ b/preferences/preferenceTest/entry/src/main/js/MainAbility/pages/second/second.js
@@ -0,0 +1,12 @@
+import router from '@system.router'
+
+export default {
+ data: {
+ title: 'World'
+ },
+ onclick: function () {
+ router.replace({
+ uri: "pages/index/index"
+ })
+ }
+}
diff --git a/preferences/preferenceTest/entry/src/main/resources/base/element/string.json b/preferences/preferenceTest/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/preferences/preferenceTest/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/preferences/preferenceTest/entry/src/main/resources/base/media/icon.png b/preferences/preferenceTest/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/preferences/preferenceTest/entry/src/main/resources/base/media/icon.png differ
diff --git a/preferences/preferenceTest/gradle.properties b/preferences/preferenceTest/gradle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..be492496f9a20ac2d980ef4fc30061f4184c1c40
--- /dev/null
+++ b/preferences/preferenceTest/gradle.properties
@@ -0,0 +1,13 @@
+# Project-wide Gradle settings.
+# IDE (e.g. DevEco Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# If the Chinese output is garbled, please configure the following parameter.
+# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
+# more information see https://docs.gradle.org/current/userguide/performance.html
+# org.gradle.parallel=false
+# org.gradle.jvmargs=-Dfile.encoding=GBK
\ No newline at end of file
diff --git a/preferences/preferenceTest/gradle/wrapper/gradle-wrapper.jar b/preferences/preferenceTest/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000000000000000000000000000000000..490fda8577df6c95960ba7077c43220e5bb2c0d9
Binary files /dev/null and b/preferences/preferenceTest/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/preferences/preferenceTest/gradle/wrapper/gradle-wrapper.properties b/preferences/preferenceTest/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000000000000000000000000000000000..f59159e865d4b59feb1b8c44b001f62fc5d58df4
--- /dev/null
+++ b/preferences/preferenceTest/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/preferences/preferenceTest/gradlew b/preferences/preferenceTest/gradlew
new file mode 100644
index 0000000000000000000000000000000000000000..536f0272dd995f3afdb5e34e0f42bdf3d1986c22
--- /dev/null
+++ b/preferences/preferenceTest/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG=$(dirname "$PRG")"/$link"
+ fi
+done
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=$(basename "$0")
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn() {
+ echo "$*"
+}
+
+die() {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$(uname)" in
+CYGWIN*)
+ cygwin=true
+ ;;
+Darwin*)
+ darwin=true
+ ;;
+MINGW*)
+ msys=true
+ ;;
+NONSTOP*)
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ]; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then
+ MAX_FD_LIMIT=$(ulimit -H -n)
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+ APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+ CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+ JAVACMD=$(cygpath --unix "$JAVACMD")
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ]; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@"; do
+ CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -)
+ CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition
+ eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
+ else
+ eval $(echo args$i)="\"$arg\""
+ fi
+ i=$(expr $i + 1)
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save() {
+ for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/preferences/preferenceTest/gradlew.bat b/preferences/preferenceTest/gradlew.bat
new file mode 100644
index 0000000000000000000000000000000000000000..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d
--- /dev/null
+++ b/preferences/preferenceTest/gradlew.bat
@@ -0,0 +1,103 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/preferences/preferenceTest/package.json b/preferences/preferenceTest/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93
--- /dev/null
+++ b/preferences/preferenceTest/package.json
@@ -0,0 +1 @@
+{}
diff --git a/preferences/preferenceTest/settings.gradle b/preferences/preferenceTest/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07
--- /dev/null
+++ b/preferences/preferenceTest/settings.gradle
@@ -0,0 +1 @@
+include ':entry'
diff --git a/preferences/systemStorageTest/.gitignore b/preferences/systemStorageTest/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..32fb92cdf2678a6d9da0ea3ef3dc72889d1b8393
--- /dev/null
+++ b/preferences/systemStorageTest/.gitignore
@@ -0,0 +1,6 @@
+.idea
+local.properties
+build
+entry/build
+.gradle
+.DS_Store
\ No newline at end of file
diff --git a/preferences/systemStorageTest/README.en.md b/preferences/systemStorageTest/README.en.md
new file mode 100644
index 0000000000000000000000000000000000000000..3ac828864ea1d5e4bc1ba811b05dda8d3e2d3b80
--- /dev/null
+++ b/preferences/systemStorageTest/README.en.md
@@ -0,0 +1,36 @@
+# JsHelloWorld
+
+#### Description
+{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
+
+#### Software Architecture
+Software architecture description
+
+#### Installation
+
+1. xxxx
+2. xxxx
+3. xxxx
+
+#### Instructions
+
+1. xxxx
+2. xxxx
+3. xxxx
+
+#### Contribution
+
+1. Fork the repository
+2. Create Feat_xxx branch
+3. Commit your code
+4. Create Pull Request
+
+
+#### Gitee Feature
+
+1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
+2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
+3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
+4. The most valuable open source project [GVP](https://gitee.com/gvp)
+5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
+6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
diff --git a/preferences/systemStorageTest/README.md b/preferences/systemStorageTest/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9b68cbb66b1a1abd18f07956f57e4ad171e3df70
--- /dev/null
+++ b/preferences/systemStorageTest/README.md
@@ -0,0 +1,39 @@
+# JsHelloWorld
+
+#### 介绍
+{**以下是 Gitee 平台说明,您可以替换此简介**
+Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
+无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
+
+#### 软件架构
+软件架构说明
+
+
+#### 安装教程
+
+1. xxxx
+2. xxxx
+3. xxxx
+
+#### 使用说明
+
+1. xxxx
+2. xxxx
+3. xxxx
+
+#### 参与贡献
+
+1. Fork 本仓库
+2. 新建 Feat_xxx 分支
+3. 提交代码
+4. 新建 Pull Request
+
+
+#### 特技
+
+1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
+2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
+3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
+4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
+5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
+6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
diff --git a/preferences/systemStorageTest/README_zh.md b/preferences/systemStorageTest/README_zh.md
new file mode 100644
index 0000000000000000000000000000000000000000..b947592390deea92a345c49aacf28975fa989ae3
--- /dev/null
+++ b/preferences/systemStorageTest/README_zh.md
@@ -0,0 +1,5 @@
+# JsHelloWorld
+
+- 本示例适用于应用开发的初学者。
+
+ 编写两个简单的页面,实现在第一个页面点击按钮跳转到第二个页面。
diff --git a/preferences/systemStorageTest/build.gradle b/preferences/systemStorageTest/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..e1c8320dfc651d674fb3a647eed9892258726b13
--- /dev/null
+++ b/preferences/systemStorageTest/build.gradle
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ signingConfigs {
+ debug {
+ storeFile file('D:\\key\\startup.p12')
+ storePassword '00000019F33EAC90CD228EAD3F774CB954FBCC2D96F79F6BF5A4C865C340CF9B03EF60C4B088144EDA'
+ keyAlias = 'test'
+ keyPassword '000000194DF4F74A90DE3F81C5142D484BB8A6C679017D1014A71FC7EBE22FD8C84F5B6DE3E48FD152'
+ signAlg = 'SHA256withECDSA'
+ profile file('D:\\key\\startup.p7b')
+ certpath file('D:\\key\\startup.cer')
+ }
+ }
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 6
+ }
+}
+buildscript {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.huawei.ohos:hap:3.0.5.2'
+ }
+}
+allprojects {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+}
diff --git a/preferences/systemStorageTest/entry/build.gradle b/preferences/systemStorageTest/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..921386f38e8d5e8e0272b5326c80b80bcf5a067d
--- /dev/null
+++ b/preferences/systemStorageTest/entry/build.gradle
@@ -0,0 +1,16 @@
+apply plugin: 'com.huawei.ohos.hap'
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 6
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+ supportSystem "standard"
+}
diff --git a/preferences/systemStorageTest/entry/src/main/config.json b/preferences/systemStorageTest/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..3634b447cf2e845edb067d237fe4c0cbc4be3763
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/config.json
@@ -0,0 +1,62 @@
+{
+ "app": {
+ "bundleName": "ohos.acts.startup.js.function",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.acts.startup.js.function",
+ "name": ".MyApplication",
+ "mainAbility": "ohos.acts.startup.js.function.MainAbility",
+ "reqCapabilities": [
+ "video_support"
+ ],
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "visible": true,
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/default/app.js b/preferences/systemStorageTest/entry/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..58d12b7b501fbf46db906a86187aaf18dfb1f677
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/default/app.js
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export default {
+ onCreate() {
+ console.info("Application onCreate");
+ },
+ onDestroy() {
+ console.info("Application onDestroy");
+ }
+};
diff --git a/preferences/systemStorageTest/entry/src/main/js/default/i18n/en-US.json b/preferences/systemStorageTest/entry/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..08e34eac912bf2651eefc20e26aa479b5e4e7ec2
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,11 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World",
+ "page": "Second Page",
+ "next": "Next Page",
+ "back": "Back"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/default/i18n/zh-CN.json b/preferences/systemStorageTest/entry/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,11 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界",
+ "page": "第二页",
+ "next": "下一页",
+ "back": "返回"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.css b/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..a6053c61f9615fcd50fefb51f878568f3e39e59b
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.css
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 60px;
+ text-align: center;
+ width: 100%;
+ height: 40%;
+ margin: 10px;
+}
+.btn {
+ width: 50%;
+ height: 100px;
+ font-size: 40px;
+}
diff --git a/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.hml b/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..7af5439d22184a259c8218b573388c58cc525385
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.js b/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..dae669201ebb7f0df0b665948f12995aab1581a6
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/default/pages/index/index.js
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import file from '@system.file'
+import storage from '@system.storage';
+import preferences from '@ohos.data.preferences';
+import data_storage from '@ohos.data.storage';
+import featureAbility from '@ohos.ability.featureAbility';
+import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: "",
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ test_storage_get: function () {
+ console.info('testStorageGet START');
+ storage.get({
+ key: "storage_key",
+ default: "123456",
+ success: function (data) {
+ console.info('LJT [storage.get] success: ' + data);
+ },
+ fail: function (data, code) {
+ console.log('LJT [storage.get] fail, code: ' + code + ', data: ' + data);
+ },
+ complete: function () {
+ console.log('LJT [storage.get] complete');
+ }
+ })
+ },
+ test_storage_get2: function () {
+ console.info('testStorageGet START');
+ storage.get({
+ key: "storage_key2",
+ success: function (data) {
+ console.info('LJT [storage.get2] success: ' + data);
+ },
+ fail: function (data, code) {
+ console.log('LJT [storage.get2] fail, code: ' + code + ', data: ' + data);
+ },
+ complete: function () {
+ console.log('LJT [storage.get2] complete');
+ }
+ })
+ },
+ test_storage_set: function () {
+ console.info('testStorageSet START');
+ storage.set({
+ key: 'storage_key',
+ value: 'value1',
+ success: function () {
+ console.info('LJT [storage.set] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.set] fail, code: ' + code + ', data: ' + data);
+ },
+ });
+ },
+ test_storage_set2: function () {
+ console.info('testStorageSet START');
+ storage.set({
+ key: 'storage_key2',
+ value: 'value2',
+ success: function () {
+ console.info('LJT [storage.set2] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.set2] fail, code: ' + code + ', data: ' + data);
+ },
+ });
+ },
+ test_storage_set3: function () {
+ console.info('testStorageSet START');
+ storage.set({
+ key: 'storage_key3',
+ value: 'value3',
+ success: function () {
+ console.info('LJT [storage.set3] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.set3] fail, code: ' + code + ', data: ' + data);
+ },
+ });
+ },
+ test_storage_set_empty: function () {
+ console.info('testStorageSet EMPTY START');
+ storage.set({
+ key: '',
+ value: 'value3',
+ success: function () {
+ console.info('LJT [storage.setEmpty] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.setEmpty] fail, code: ' + code + ', data: ' + data);
+ },
+ });
+ },
+ test_storage_set_maxKey: function () {
+ console.info('testStorageSet MAXKEY START');
+ storage.set({
+ key: 'x'.repeat(33),
+ value: 'max',
+ success: function () {
+ console.info('LJT [storage.setMaxKey] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.setMaxKey] fail, code: ' + code + ', data: ' + data);
+ },
+ });
+ },
+ test_storage_set_maxValue: function () {
+ console.info('testStorageSet MAXVALUE START');
+ storage.set({
+ key: 'max',
+ value: 'x'.repeat(129),
+ success: function () {
+ console.info('LJT [storage.setMaxValue] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.setMaxValue] fail, code: ' + code + ', data: ' + data);
+ },
+ });
+ },
+ test_storage_clear: function () {
+ console.info('testStorageClear START');
+ storage.clear({
+ success: function () {
+ console.info('LJT [storage.clear] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.clear] fail, code: ' + code + ', data: ' + data);
+ },
+ })
+ },
+ test_storage_delete: function () {
+ console.info('testStorageDelete START');
+ storage.delete({
+ key: "storage_key2",
+ success: function () {
+ console.info('LJT [storage.delete] success');
+ },
+ fail: function (data, code) {
+ console.info('LJT [storage.delete] fail, code: ' + code + ', data: ' + data);
+ },
+ })
+ },
+ onclick: function () {
+ },
+ onShow: function () {
+ console.info('RDB_TEST:onShow')
+ const core = Core.getInstance()
+ const expectExtend = new ExpectExtend({
+ 'id': 'extend'
+ })
+ const reportExtend = new ReportExtend(file)
+ core.addService('expect', expectExtend)
+ core.addService('report', reportExtend)
+ core.init()
+
+ const configService = core.getDefaultService('config')
+ configService.setConfig(this)
+
+ require('../../../test/List.test')
+ core.execute()
+
+ this.title = 'RDB_TEST:onShow finished.'
+ console.info('RDB_TEST:onShow finished.')
+ }
+}
+
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/List.test.js b/preferences/systemStorageTest/entry/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0c2cd8ac3042e51aca29785269ffaf045dae8db3
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/List.test.js
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+//require('./StorageHelperJsunit.test.js')
+//require('./StoragePromiseJsunit.test.js')
+//require('./StorageCallBackJsunit.test.js')
+//require('./StorageSyncJsunit.test.js')
+//require('./RdbstoreInsertJsunit.test.js')
+//require('./RdbstoreDeleteJsunit.test.js')
+//require('./RdbStoreResultSetJsunit.test.js')
+//require('./RdbstorePredicatesJsunit.test.js')
+//require('./RdbstoreRdbstoreJsunit.test.js')
+//require('./RdbstoreStoreExcuteSqlJsunit.test.js')
+//require('./RdbstoreUpdateJsunit.test.js')
+//require('./ObjectStoreJsunit.test.js')
+//require('./RdbstoreTransactionJsunit.test.js')
+//require('./DataAbilityPredicatesJsunit.test1.js')
+require('./SystemStorage.test.js')
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/ObjectStoreJsunit.test.js b/preferences/systemStorageTest/entry/src/main/js/test/ObjectStoreJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..a8d108726b1075686610d3b55d80e22048e74b81
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/ObjectStoreJsunit.test.js
@@ -0,0 +1,671 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import distributedObject from '@ohos.data.distributedDataObject';
+
+var baseLine = 500; //0.5 second
+const TAG = "OBJECTSTORE_TEST";
+
+function changeCallback(sessionId, changeData) {
+ console.info("get init change111" + sessionId + " " + changeData);
+ if (changeData != null && changeData != undefined) {
+ changeData.forEach(element => {
+ console.info(TAG + "data changed !" + element);
+ });
+ }
+ console.info(TAG + "get init change111 end" + sessionId + " " + changeData);
+}
+
+function changeCallback2(sessionId, changeData) {
+ console.info("get init change222" + sessionId + " " + changeData);
+ if (changeData != null && changeData != undefined) {
+ changeData.forEach(element => {
+ console.info(TAG + "data changed !" + element);
+ });
+ }
+ console.info(TAG + "get init change222 end" + sessionId + " " + changeData);
+}
+
+function statusCallback1(sessionId, networkId, status) {
+ console.info(TAG + "test init change111" + sessionId);
+ this.response += "\nstatus changed " + sessionId + " " + status + " " + networkId;
+}
+
+function statusCallback2(sessionId, networkId, status) {
+ console.info(TAG + "test init change222" + sessionId);
+ this.response += "\nstatus changed " + sessionId + " " + status + " " + networkId;
+}
+
+function statusCallback3(sessionId, networkId, status) {
+ console.info(TAG + "test init change333" + sessionId);
+ this.response += "\nstatus changed " + sessionId + " " + status + " " + networkId;
+}
+
+describe('objectStoreTest', function () {
+ beforeAll(function () {
+ console.info(TAG + 'beforeAll')
+ })
+
+ beforeEach(function () {
+ console.info(TAG + 'beforeEach')
+ })
+
+ afterEach(function () {
+ console.info(TAG + 'afterEach')
+ })
+
+ afterAll(function () {
+ console.info(TAG + 'afterAll')
+ })
+
+ console.log(TAG + "*************Unit Test Begin*************");
+
+
+ /**
+ * @tc.name: testOn001
+ * @tc.desc: object join session and on,object can receive callback when data has been changed
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testOn001', 0, function (done) {
+ console.log(TAG + "************* testOn001 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session1");
+ if (g_object != undefined && g_object != null) {
+ expect("session1" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testOn001 joinSession failed");
+ }
+ console.info(TAG + " start call watch change");
+ g_object.on("change", changeCallback);
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testOn001 end *************");
+ })
+
+ /**
+ * @tc.name: testOn002
+ * @tc.desc object join session and no on,obejct can not receive callback when data has been changed
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testOn002', 0, function (done) {
+ console.log(TAG + "************* testOn002 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session2");
+ if (g_object != undefined && g_object != null) {
+ expect("session2" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testOn002 joinSession failed");
+ }
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testOn002 end *************");
+ })
+
+ /**
+ * @tc.name: testOn003
+ * @tc.desc: object join session and on,then object change data twice,object can receive two callbacks when data has been changed
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testOn003', 0, function (done) {
+ console.log(TAG + "************* testOn003 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session3");
+ if (g_object != undefined && g_object != null) {
+ expect("session3" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testOn003 joinSession failed");
+ }
+ g_object.on("change", changeCallback);
+ console.info(TAG + " start call watch change");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ g_object.name = "jack2";
+ g_object.age = 20;
+ g_object.isVis = false;
+ expect(g_object.name == "jack2");
+ expect(g_object.age == 20);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testOn003 end *************");
+ })
+
+ /**
+ * @tc.name: testOn004
+ * @tc.desc object join session and on,then object do not change data,object can not receive callbacks
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testOn004', 0, function (done) {
+ console.log(TAG + "************* testOn004 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session4");
+ if (g_object != undefined && g_object != null) {
+ expect("session4" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testOn004 joinSession failed");
+ }
+ g_object.on("change", changeCallback);
+ console.info(TAG + " start call watch change");
+ console.info(TAG + " end call watch change");
+
+ done()
+ console.log(TAG + "************* testOn004 end *************");
+ })
+
+ /**
+ * @tc.name testOff001
+ * @tc.desc object join session and on&off,object can not receive callback after off
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testOff001', 0, function (done) {
+ console.log(TAG + "************* testOff001 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session5");
+ if (g_object != undefined && g_object != null) {
+ expect("session5" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testOff001 joinSession failed");
+ }
+ g_object.on("change", changeCallback);
+ console.info(TAG + " start call watch change");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+ g_object.off("change");
+ console.info(TAG + " end call watch change");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack2";
+ g_object.age = 20;
+ g_object.isVis = false;
+ expect(g_object.name == "jack2");
+ expect(g_object.age == 20);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testOff001 end *************");
+ })
+
+ /**
+ * @tc.name:testOff002
+ * @tc.desc object join session and off,object can not receive callback
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testOff002', 0, function (done) {
+ console.log(TAG + "************* testOff002 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session6");
+ if (g_object != undefined && g_object != null) {
+ expect("session6" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testOff002 joinSession failed");
+ }
+ g_object.off("change");
+ console.info(TAG + " end call watch change");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testOff002 end *************");
+ })
+
+ /**
+ * @tc.name: testMultiObjectOn001
+ * @tc.desc: two objects join session and on,then object change data,user can receive two callbacks from two objects
+ * @tc.type: FUNC
+ * @tc.number: SUB_DDM_DistributedD_testRdbTransactionInsert0001
+ * @tc.require: I4H3LS
+ */
+ it('testMultiObjectOn001', 0, function (done) {
+ console.log(TAG + "************* testMultiObjectOn001 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session7");
+ if (g_object != undefined && g_object != null) {
+ expect("session7" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testMultiObjectOn001 joinSession failed");
+ }
+ var test_object = distributedObject.createDistributedObject({ name: "Eric", age: 81, isVis: true });
+ test_object.setSessionId("testSession1");
+ if (test_object != undefined && test_object != null) {
+ expect("testSession1").assertEqual(test_object.__sessionId);
+ } else {
+ console.log(TAG + "testMultiObjectOn001 joinSession failed");
+ }
+ g_object.on("change", changeCallback);
+ test_object.on("change", changeCallback2);
+ console.info(TAG + " start call watch change");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+ if (test_object != undefined && test_object != null) {
+ test_object.name = "jack2";
+ test_object.age = 20;
+ test_object.isVis = false;
+ expect(test_object.name == "jack2");
+ expect(test_object.age == 20);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testMultiObjectOn001 end *************");
+ })
+
+ /**
+ * @tc.name: testMultiObjectOff001
+ * @tc.desc: two objects join session and on&off,then two objects can not receive callbacks
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testMultiObjectOff001', 0, function (done) {
+ console.log(TAG + "************* testMultiObjectOff001 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session8");
+ if (g_object != undefined && g_object != null) {
+ expect("session8" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testMultiObjectOn002 joinSession failed");
+ }
+ var test_object = distributedObject.createDistributedObject({ name: "Eric", age: 81, isVis: true });
+ test_object.setSessionId("testSession2");
+ if (test_object != undefined && test_object != null) {
+ expect("testSession2" == test_object.__sessionId);
+ } else {
+ console.log(TAG + "testMultiObjectOn002 joinSession failed");
+ }
+ console.log(TAG + " start call watch change")
+ g_object.on("change", changeCallback);
+ test_object.on("change", changeCallback2);
+ console.info(TAG + " watch success");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack1";
+ g_object.age = 19;
+ g_object.isVis = true;
+ expect(g_object.name == "jack1");
+ expect(g_object.age == 19);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+ if (test_object != undefined && test_object != null) {
+ test_object.name = "jack2";
+ test_object.age = 20;
+ test_object.isVis = false;
+ expect(test_object.name == "jack2");
+ expect(test_object.age == 20);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+ g_object.off("change");
+ if (g_object != undefined && g_object != null) {
+ g_object.name = "jack3";
+ g_object.age = 21;
+ g_object.isVis = false;
+ expect(g_object.name == "jack3");
+ expect(g_object.age == 21);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+ test_object.off("change");
+ if (test_object != undefined && test_object != null) {
+ test_object.name = "jack4";
+ test_object.age = 22;
+ test_object.isVis = true;
+ expect(test_object.name == "jack4");
+ expect(test_object.age == 22);
+ console.info(TAG + " set data success!");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testMultiObjectOff001 end *************");
+ })
+
+ /**
+ * @tc.name: testChangeSession001
+ * @tc.desc: objects join session,then change sessionId
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testChangeSession001', 0, function (done) {
+ console.log(TAG + "************* testChangeSession001 start *************");
+ var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ objectTest.setSessionId("session9");
+ if (objectTest != undefined && objectTest != null) {
+ expect("session9" == objectTest.__sessionId);
+ } else {
+ console.log(TAG + "testChangeSession001 joinSession failed");
+ }
+ console.log(TAG+"start change sessionId");
+ setTimeout(() => objectTest.setSessionId("session9"), 1000);
+ if (objectTest != undefined && objectTest != null) {
+ expect("session9" == objectTest.__sessionId);
+ } else {
+ console.log(TAG + "testChangeSession001 joinSession again failed");
+ }
+
+ done()
+ console.log(TAG + "************* testChangeSession001 end *************");
+ })
+
+ /**
+ * @tc.name: testUndefinedType001
+ * @tc.desc: object use undefined type,can not join session
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testUndefinedType001', 0, function (done) {
+ console.log(TAG + "************* testUndefinedType001 start *************");
+ var undefined_object = distributedObject.createDistributedObject({ name: undefined, age: undefined, isVis: undefined });
+ try {
+ undefined_object.setSessionId("session11");
+ if (undefined_object != undefined && undefined_object != null) {
+ expect("session11" == undefined_object.__sessionId);
+ } else {
+ console.log(TAG + "testChangeSession001 joinSession session11 failed");
+ }
+ } catch (error) {
+ console.error(TAG + error);
+ }
+
+ done()
+ console.log(TAG + "************* testUndefinedType001 end *************");
+ })
+
+ /**
+ * @tc.name: testGenSessionId001
+ * @tc.desc: object generate random sessionId
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testGenSessionId001', 0, function (done) {
+ console.log(TAG + "************* testGenSessionId001 start *************");
+ var sessionId = distributedObject.genSessionId();
+ expect(sessionId != null && sessionId.length > 0 && typeof (sessionId) == 'string');
+
+ done()
+ console.log(TAG + "************* testGenSessionId001 end *************");
+ })
+
+ /**
+ * @tc.name: testGenSessionId002
+ * @tc.desc: object generate 2 random sessionId and not equal
+ * @tc.type: FUNC
+ * @tc.require: I4H3LS
+ */
+ it('testGenSessionId002', 0, function (done) {
+ console.log(TAG + "************* testGenSessionId001 start *************");
+ var sessionId1 = distributedObject.genSessionId();
+ var sessionId2 = distributedObject.genSessionId();
+ expect(sessionId1 != sessionId2);
+
+ done()
+ console.log(TAG + "************* testGenSessionId002 end *************");
+ })
+
+ /**
+ * @tc.name: testOnStatus001
+ * @tc.desc: object set a listener to watch another object online/offline
+ * @tc.type: FUNC
+ * @tc.require: I4H3M8
+ */
+ it('testOnStatus001', 0, function (done) {
+ console.log(TAG + "************* testOnStatus001 start *************");
+ console.log(TAG + "start watch status");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.on("status", statusCallback1);
+ console.log(TAG + "watch success");
+
+ done()
+ console.log(TAG + "************* testOnStatus001 end *************");
+ })
+
+ /**
+ * @tc.name: testOnStatus002
+ * @tc.desc: object set several listener and can unset specified listener
+ * @tc.type: FUNC
+ * @tc.require: I4H3M8
+ */
+ it('testOnStatus002', 0, function (done) {
+ console.log(TAG + "************* testOnStatus002 start *************");
+ console.log(TAG + "start watch status");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.on("status", statusCallback1);
+ g_object.on("status", statusCallback2);
+ g_object.on("status", statusCallback3);
+ console.log(TAG + "watch success");
+ console.log(TAG + "start call unwatch status");
+ g_object.off("status", statusCallback1);
+ console.log(TAG + "unwatch success");
+
+ done()
+ console.log(TAG + "************* testOnStatus002 end *************");
+ })
+
+ /**
+ * @tc.name: testOnStatus003
+ * @tc.desc: object set several listener and can unWatch all watcher
+ * @tc.type: FUNC
+ * @tc.require: I4H3M8
+ */
+ it('testOnStatus003', 0, function (done) {
+ console.log(TAG + "************* testOnStatus003 start *************");
+ console.log(TAG + "start watch status");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.on("status", statusCallback1);
+ g_object.on("status", statusCallback2);
+ g_object.on("status", statusCallback3);
+ console.log(TAG + "watch success");
+ console.log(TAG + "start call unwatch status");
+ g_object.off("status");
+ console.log(TAG + "unwatch success");
+
+ done()
+ console.log(TAG + "************* testOnStatus003 end *************");
+ })
+
+ /**
+ * @tc.name: testComplex001
+ * @tc.desc: object can get/set complex data
+ * @tc.type: FUNC
+ * @tc.require: I4H3M8
+ */
+ it('testComplex001', 0, function (done) {
+ console.log(TAG + "************* testComplex001 start *************");
+ var complex_object = distributedObject.createDistributedObject({
+ name: undefined,
+ age: undefined,
+ parent: undefined,
+ list: undefined
+ });
+ complex_object.setSessionId("session12");
+ if (complex_object != undefined && complex_object != null) {
+ expect("session12" == complex_object.__sessionId);
+ } else {
+ console.log(TAG + "testOnComplex001 joinSession session12 failed");
+ }
+ complex_object.name = "jack";
+ complex_object.age = 19;
+ complex_object.isVis = false;
+ complex_object.parent = { mother: "jack mom", father: "jack Dad" };
+ complex_object.list = [{ mother: "jack mom" }, { father: "jack Dad" }];
+ expect(complex_object.name == "jack");
+ expect(complex_object.age == 19);
+ expect(complex_object.parent == { mother: "jack1 mom", father: "jack1 Dad" });
+ expect(complex_object.list == [{ mother: "jack1 mom", father: "jack1 Dad" }]);
+
+ done()
+ console.log(TAG + "************* testComplex001 end *************");
+ })
+
+ /**
+ * @tc.name: testMaxSize001
+ * @tc.desc: object can get/set data under 4MB size
+ * @tc.type: FUNC
+ * @tc.require: I4H3M8
+ */
+ it('testMaxSize001', 0, function (done) {
+ console.log(TAG + "************* testMaxSize001 start *************");
+ var g_object = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
+ g_object.setSessionId("session13");
+ if (g_object != undefined && g_object != null) {
+ expect("session13" == g_object.__sessionId);
+ } else {
+ console.log(TAG + "testMaxSize001 joinSession session13 failed");
+ }
+ //maxString = 32byte
+ var maxString = "12345678123456781234567812345678".repeat(131072);
+ if (g_object != undefined && g_object != null) {
+ g_object.name = maxString;
+ g_object.age = 42;
+ g_object.isVis = false;
+ expect(g_object.name == maxString);
+ console.log(TAG + "get/set maxSize string success");
+ } else {
+ console.info(TAG + " object is null,set name fail");
+ }
+
+ done()
+ console.log(TAG + "************* testMaxSize001 end *************");
+ })
+
+ /**
+ * @tc.name: testPerformance001
+ * @tc.desc: performanceTest for set/get data
+ * @tc.type: FUNC
+ * @tc.require: I4H3M8
+ */
+ it('testPerformance001', 0, function (done) {
+ console.log(TAG + "************* testPerformance001 start *************");
+ var complex_object = distributedObject.createDistributedObject({
+ name: undefined,
+ age: undefined,
+ parent: undefined,
+ list: undefined
+ });
+ var st1;
+ var totalTime = 0;
+ var setSessionIdTime = 0;
+ var setTime = 0;
+ var onTime = 0;
+ var offTime = 0;
+ for (var i = 0;i < 100; i++) {
+ st1 = Date.now();
+ complex_object.setSessionId("session14");
+ setSessionIdTime += Date.now() - st1;
+ if (complex_object != undefined && complex_object != null) {
+ expect("session14" == complex_object.__sessionId);
+ } else {
+ console.log(TAG + "testPerformance001 joinSession session14 failed");
+ }
+ console.info(TAG + " start call watch change");
+ st1 = Date.now();
+ complex_object.on("change", changeCallback);
+ onTime += Date.now() - st1;
+ console.info(TAG + "on change success");
+ st1 = Date.now();
+ complex_object.name = "jack2";
+ complex_object.age = 20;
+ complex_object.isVis = false;
+ complex_object.parent = { mother: "jack1 mom1", father: "jack1 Dad1" };
+ complex_object.list = [{ mother: "jack1 mom1" }, { father: "jack1 Dad1" }];
+ setTime += Date.now() - st1;
+ expect(complex_object.name == "jack2");
+ expect(complex_object.age == 20);
+ expect(complex_object.parent == { mother: "jack1 mom1", father: "jack1 Dad1" });
+ expect(complex_object.list == [{ mother: "jack1 mom1", father: "jack1 Dad1" }]);
+
+ console.log(TAG + "start unWatch change");
+ st1 = Date.now();
+ complex_object.off("change");
+ offTime += Date.now() - st1;
+ totalTime += setSessionIdTime;
+ totalTime += setTime;
+ totalTime += onTime;
+ totalTime += offTime;
+ console.log(TAG + "end unWatch success");
+ }
+ console.log(TAG + "totalTime = " + (totalTime / 100));
+ expect(totalTime < baseLine);
+ done()
+ console.log(TAG + "************* testPerformance001 end *************");
+ })
+
+
+ console.log(TAG + "*************Unit Test End*************");
+})
+
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/StorageCallBackJsunit.test.js b/preferences/systemStorageTest/entry/src/main/js/test/StorageCallBackJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..e58813134ff6b15f58d123a97cbd1d3db9d44567
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/StorageCallBackJsunit.test.js
@@ -0,0 +1,262 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import storage from '@ohos.data.storage'
+
+const PATH = '/data/test_storage';
+const KEY_TEST_INT_ELEMENT = 'key_test_int';
+const KEY_TEST_LONG_ELEMENT = 'key_test_long';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string';
+var mPref;
+
+describe('storageTest', function () {
+ beforeAll(function () {
+ console.info('beforeAll')
+ mPref = storage.getStorageSync(PATH);
+ })
+
+ afterAll(function () {
+ console.info('afterAll')
+ storage.deleteStorageSync(PATH);
+ })
+
+ /**
+ * @tc.name clear callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0010
+ * @tc.desc clear callback interface test
+ */
+ it('testClear0012', 0, async function (done) {
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+ mPref.flushSync();
+ await mPref.clear(function (err, ret) {
+ expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+ done();
+ });
+ })
+
+ /**
+ * @tc.name has string callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0020
+ * @tc.desc has string callback interface test
+ */
+ it('testHasKey0032', 0, async function (done) {
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+ await mPref.has(KEY_TEST_STRING_ELEMENT, function (err, ret) {
+ expect(true).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name has int callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0130
+ * @tc.desc has int callback interface test
+ */
+ it('testHasKey0033', 0, async function (done) {
+ mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
+ await mPref.has(KEY_TEST_INT_ELEMENT, function (err, ret) {
+ expect(true).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name has float callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0140
+ * @tc.desc has float callback interface test
+ */
+ it('testHasKey0034', 0, async function (done) {
+ mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1);
+ await mPref.has(KEY_TEST_FLOAT_ELEMENT, function (err, ret) {
+ expect(true).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name has long callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0150
+ * @tc.desc has long callback interface test
+ */
+ it('testHasKey0035', 0, async function (done) {
+ mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
+ await mPref.has(KEY_TEST_LONG_ELEMENT, function (err, ret) {
+ expect(true).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name has boolean callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0160
+ * @tc.desc has boolean callback interface test
+ */
+ it('testHasKey0036', 0, async function (done) {
+ mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
+ await mPref.has(KEY_TEST_BOOLEAN_ELEMENT, function (err, ret) {
+ expect(true).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name get defaultValue callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0030
+ * @tc.desc get defaultValue callback interface test
+ */
+ it('testGetDefValue0062', 0, async function (done) {
+ mPref.clearSync();
+ await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue", function (err, ret) {
+ expect('defaultValue').assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name get float callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0040
+ * @tc.desc get float callback interface test
+ */
+ it('testGetFloat0072', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
+ await mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0, function (err, ret) {
+ expect(3.0).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name get int callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0050
+ * @tc.desc get int callback interface test
+ */
+ it('testGetInt0082', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
+ await mPref.get(KEY_TEST_INT_ELEMENT, 0.0, function (err, ret) {
+ expect(3).assertEqual(ret);
+ done();
+ })
+ })
+
+ /**
+ * @tc.name get long callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0060
+ * @tc.desc get long callback interface test
+ */
+ it('testGetLong0092', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
+ expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+ await mPref.get(KEY_TEST_LONG_ELEMENT, 0, function (err, ret) {
+ expect(3).assertEqual(ret);
+ done();
+ });
+ })
+
+ /**
+ * @tc.name get String callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0070
+ * @tc.desc get String callback interface test
+ */
+ it('testGetString102', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+ mPref.flushSync();
+ await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, ret) {
+ expect('test').assertEqual(ret);
+ done();
+ });
+ })
+
+ /**
+ * @tc.name put boolean callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0080
+ * @tc.desc put boolean callback interface test
+ */
+ it('testPutBoolean0122', 0, async function (done) {
+ mPref.clearSync();
+ await mPref.put(KEY_TEST_BOOLEAN_ELEMENT, true, function (err, ret) {
+ expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
+ mPref.flushSync();
+ expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
+ done();
+ });
+ })
+
+ /**
+ * @tc.name put float callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0090
+ * @tc.desc put float callback interface test
+ */
+ it('testPutFloat0132', 0, async function (done) {
+ mPref.clearSync();
+ await mPref.put(KEY_TEST_FLOAT_ELEMENT, 4.0, function (err, ret) {
+ expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+ mPref.flushSync();
+ expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+ done();
+ });
+ })
+
+ /**
+ * @tc.name put int callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0100
+ * @tc.desc put int callback interface test
+ */
+ it('testPutInt0142', 0, async function (done) {
+ mPref.clearSync();
+ await mPref.put(KEY_TEST_INT_ELEMENT, 4, function (err, ret) {
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+ mPref.flushSync();
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+ done();
+ });
+ })
+
+ /**
+ * @tc.name put long callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0110
+ * @tc.desc put long callback interface test
+ */
+ it('testPutLong0152', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
+ await mPref.put(KEY_TEST_LONG_ELEMENT, 4, function (err, ret) {
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+ mPref.flushSync();
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+ done();
+ });
+ })
+
+ /**
+ * @tc.name put String callback interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0120
+ * @tc.desc put String callback interface test
+ */
+ it('testPutString0162', 0, async function (done) {
+ mPref.clearSync();
+ await mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) {
+ expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+ mPref.flushSync();
+ expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+ done();
+ });
+ })
+})
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/StorageHelperJsunit.test.js b/preferences/systemStorageTest/entry/src/main/js/test/StorageHelperJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..b5d89ba9f3f384cda7223f58e4fa82797c49b66c
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/StorageHelperJsunit.test.js
@@ -0,0 +1,134 @@
+// @ts-nocheck
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import storage from '@ohos.data.storage'
+
+const PATH = '/data/test_storage';
+var mPref;
+
+describe('storageTest', function () {
+ beforeAll(function () {
+ console.info('beforeAll')
+ mPref = storage.getStorageSync(PATH);
+ })
+
+ afterAll(function () {
+ console.info('afterAll')
+ storage.deleteStorageSync(PATH);
+ })
+
+ /**
+ * @tc.name getStorageSync interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0010
+ * @tc.desc getStorageSync interface test
+ */
+ it('testGetStorageHelper001', 0, function () {
+ mPref = storage.getStorageSync(PATH);
+ mPref.putSync('test', 2);
+ mPref.flushSync();
+ var value = mPref.getSync('test', 0);
+ expect(value).assertEqual(2);
+ })
+
+ /**
+ * @tc.name getStorage interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
+ * @tc.desc getStorage interface test
+ */
+ it('testGetStorageHelper002', 0, async function (done) {
+ const promise = storage.getStorage(PATH);
+ promise.then((pref) => {
+ pref.putSync('test', 2);
+ pref.flushSync();
+ var value = mPref.getSync('test', 0);
+ expect(value).assertEqual(2);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name removeStorageFromCacheSync interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
+ * @tc.desc removeStorageFromCacheSync interface test
+ */
+ it('testRemoveStorageFromCache001', 0, function () {
+ let perf = storage.getStorageSync('/data/test_storage1');
+ perf.putSync('test', 2);
+ try {
+ storage.removeStorageFromCacheSync('/data/test_storage1');
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ var value = mPref.getSync('test', 0);
+ expect(value).assertEqual(2);
+ })
+
+ /**
+ * @tc.name removeStorageFromCache interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0040
+ * @tc.desc removeStorageFromCache interface test
+ */
+ it('testRemoveStorageFromCache002', 0, async function (done) {
+ let perf = storage.getStorageSync('/data/test_storage2');
+ perf = null;
+ const promise = storage.removeStorageFromCache('/data/test_storage2');
+ promise.then((pref) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name deleteStorageSync interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0050
+ * @tc.desc deleteStorageSync interface test
+ */
+ it('testDeleteStorageHelper001', 0, function () {
+ let perf = storage.getStorageSync('/data/test_storage3');
+ try {
+ storage.deleteStorageSync('/data/test_storage3');
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ try {
+ perf.putSync("int", 3);
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ })
+
+ /**
+ * @tc.name deleteStorage interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0060
+ * @tc.desc deleteStorage interface test
+ */
+ it('testDeleteStorageHelper002', 0, async function (done) {
+ let perf = storage.getStorageSync('/data/test_storage4');
+ perf = null;
+ const promise = storage.deleteStorage('/data/test_storage4');
+ promise.then((pref) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+})
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/StoragePromiseJsunit.test.js b/preferences/systemStorageTest/entry/src/main/js/test/StoragePromiseJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..f39ba9a1e84ff3598cd573fdc0db54f32bcd1d85
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/StoragePromiseJsunit.test.js
@@ -0,0 +1,326 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import storage from '@ohos.data.storage'
+
+const PATH = '/data/test_storage';
+const KEY_TEST_INT_ELEMENT = 'key_test_int';
+const KEY_TEST_LONG_ELEMENT = 'key_test_long';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string';
+var mPref;
+
+describe('storageTest', function () {
+ beforeAll(function () {
+ console.info('beforeAll')
+ mPref = storage.getStorageSync(PATH);
+ })
+
+ afterAll(function () {
+ console.info('afterAll')
+ storage.deleteStorageSync(PATH);
+ })
+
+ /**
+ * @tc.name clear promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Promise_0010
+ * @tc.desc clear promise interface test
+ */
+ it('testClear0011', 0, async function (done) {
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+ mPref.flushSync();
+ const promise = mPref.clear();
+ promise.then((ret) => {
+ expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name has string interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
+ * @tc.desc has string interface test
+ */
+ it('testHasKey0031', 0, async function (done) {
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+ const promise = mPref.has(KEY_TEST_STRING_ELEMENT);
+ promise.then((ret) => {
+ expect(true).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name has int interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0140
+ * @tc.desc has int interface test
+ */
+ it('testHasKey0032', 0, async function (done) {
+ mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
+ const promise = mPref.has(KEY_TEST_INT_ELEMENT);
+ promise.then((ret) => {
+ expect(true).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name has float interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0150
+ * @tc.desc has float interface test
+ */
+ it('testHasKey0033', 0, async function (done) {
+ mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 2.0);
+ const promise = mPref.has(KEY_TEST_FLOAT_ELEMENT);
+ promise.then((ret) => {
+ expect(true).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name has boolean interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0160
+ * @tc.desc has boolean interface test
+ */
+ it('testHasKey0034', 0, async function (done) {
+ mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
+ const promise = mPref.has(KEY_TEST_BOOLEAN_ELEMENT);
+ promise.then((ret) => {
+ expect(true).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name has long interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0170
+ * @tc.desc has long interface test
+ */
+ it('testHasKey0035', 0, async function (done) {
+ mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
+ const promise = mPref.has(KEY_TEST_LONG_ELEMENT);
+ promise.then((ret) => {
+ expect(true).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name get string promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
+ * @tc.desc get string promise interface test
+ */
+ it('testGetDefValue0061', 0, async function (done) {
+ mPref.clearSync();
+ const promise = mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue");
+ promise.then((ret) => {
+ expect('defaultValue').assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name get float promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0040
+ * @tc.desc get float promise interface test
+ */
+ it('testGetFloat0071', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
+ const promise = mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
+ promise.then((ret) => {
+ expect(3.0).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name get int promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0050
+ * @tc.desc get int promise interface test
+ */
+ it('testGetInt0081', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
+ const promise = mPref.get(KEY_TEST_INT_ELEMENT, 0.0);
+ promise.then((ret) => {
+ expect(3).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name get long promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0060
+ * @tc.desc get long promise interface test
+ */
+ it('testGetLong0091', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
+ const promise = mPref.get(KEY_TEST_LONG_ELEMENT, 0);
+ promise.then((ret) => {
+ expect(3).assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name get String promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0070
+ * @tc.desc get String promise interface test
+ */
+ it('testGetString101', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+ mPref.flushSync();
+ const promise = mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue");
+ promise.then((ret) => {
+ expect('test').assertEqual(ret);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name put boolean promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0090
+ * @tc.desc put boolean promise interface test
+ */
+ it('testPutBoolean0121', 0, async function (done) {
+ mPref.clearSync();
+ const promise = mPref.put(KEY_TEST_BOOLEAN_ELEMENT, true);
+ promise.then((ret) => {
+ expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
+ mPref.flushSync();
+ expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name put float promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0100
+ * @tc.desc put float promise interface test
+ */
+ it('testPutFloat0131', 0, async function (done) {
+ mPref.clearSync();
+ const promise = mPref.put(KEY_TEST_FLOAT_ELEMENT, 4.0);
+ promise.then((ret) => {
+ expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+ mPref.flushSync();
+ expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name put int promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0110
+ * @tc.desc put int promise interface test
+ */
+ it('testPutInt0141', 0, async function (done) {
+ mPref.clearSync();
+ const promise = mPref.put(KEY_TEST_INT_ELEMENT, 4);
+ promise.then((ret) => {
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+ mPref.flushSync();
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name put long promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0120
+ * @tc.desc put long promise interface test
+ */
+ it('testPutLong0151', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
+ const promise = mPref.put(KEY_TEST_LONG_ELEMENT, 4);
+ promise.then((ret) => {
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+ mPref.flushSync();
+ expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+
+ /**
+ * @tc.name put String promise interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0130
+ * @tc.desc put String promise interface test
+ */
+ it('testPutString0161', 0, async function (done) {
+ mPref.clearSync();
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
+ const promise = mPref.put(KEY_TEST_STRING_ELEMENT, '');
+ promise.then((ret) => {
+ expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+ mPref.flushSync();
+ expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ done();
+ })
+})
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/StorageSyncJsunit.test.js b/preferences/systemStorageTest/entry/src/main/js/test/StorageSyncJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..fca3f2801ecdc8c31c27dbee4a3686c68e9e9252
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/StorageSyncJsunit.test.js
@@ -0,0 +1,312 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import storage from '@ohos.data.storage'
+
+const PATH = '/data/test_storage';
+const KEY_TEST_INT_ELEMENT = 'key_test_int';
+const KEY_TEST_LONG_ELEMENT = 'key_test_long';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string';
+
+var mPref;
+var changeResult;
+
+describe('storageTest', function () {
+ beforeAll(function() {
+ console.info('beforeAll')
+ mPref = storage.getStorageSync(PATH);
+ })
+
+ afterAll(function () {
+ console.info('afterAll')
+ storage.deleteStorageSync(PATH);
+ })
+
+// it('testClear001', 0, function () {
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+// mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
+// mPref.flushSync();
+// mPref.clearSync();
+// expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+// expect(0).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+// })
+//
+// /**
+// * @tc.name Constructor test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0010
+// * @tc.desc Constructor test
+// */
+// it('testConstructor002', 0, function () {
+// expect(typeof mPref).assertEqual("object");
+//
+// })
+//
+// /**
+// * @tc.name put string sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0020
+// * @tc.desc put string sync interface test
+// */
+// it('testHasKey003', 0, function () {
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+// expect(true).assertEqual(mPref.hasSync(KEY_TEST_STRING_ELEMENT));
+// })
+//
+// /**
+// * @tc.name put int sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0170
+// * @tc.desc put int sync interface test
+// */
+// it('testHasKey004', 0, function () {
+// mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
+// expect(true).assertEqual(mPref.hasSync(KEY_TEST_INT_ELEMENT));
+// })
+//
+// /**
+// * @tc.name put boolean sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0180
+// * @tc.desc put boolean sync interface test
+// */
+// it('testHasKey005', 0, function () {
+// mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
+// expect(true).assertEqual(mPref.hasSync(KEY_TEST_BOOLEAN_ELEMENT));
+// })
+//
+// /**
+// * @tc.name put long sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0190
+// * @tc.desc put long sync interface test
+// */
+// it('testHasKey006', 0, function () {
+// mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
+// expect(true).assertEqual(mPref.hasSync(KEY_TEST_LONG_ELEMENT));
+// })
+//
+// /**
+// * @tc.name put float sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0200
+// * @tc.desc put float sync interface test
+// */
+// it('testHasKey007', 0, function () {
+// mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1);
+// expect(true).assertEqual(mPref.hasSync(KEY_TEST_FLOAT_ELEMENT));
+// })
+//
+// /**
+// * @tc.name put boolean sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0030
+// * @tc.desc put boolean sync interface test
+// */
+// it('testGetBoolean005', 0, function () {
+// mPref.putSync(KEY_TEST_LONG_ELEMENT, true);
+// expect(true).assertEqual(mPref.hasSync(KEY_TEST_LONG_ELEMENT));
+// })
+//
+// /**
+// * @tc.name get defaultValue sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0040
+// * @tc.desc get defaultValue sync interface test
+// */
+// it('testGetDefValue006', 0, function () {
+// mPref.clearSync();
+// expect(-1).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, -1));
+// expect(1.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 1.0));
+// expect(10000).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 10000));
+// expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, true));
+// expect('defaultValue').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultValue"));
+// })
+//
+// /**
+// * @tc.name put float sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0050
+// * @tc.desc put float sync interface test
+// */
+// it('testGetFloat007', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
+// expect(3.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+// expect(0.0).assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, 0.0));
+// })
+//
+// /**
+// * @tc.name put int sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0060
+// * @tc.desc put int sync interface test
+// */
+// it('testGetInt008', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
+// expect(3).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0.0));
+// })
+//
+// /**
+// * @tc.name put long sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0070
+// * @tc.desc put long sync interface test
+// */
+// it('testGetLong009', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
+// expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+// expect(0).assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, 0));
+// })
+//
+// /**
+// * @tc.name put String & int sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0080
+// * @tc.desc put String & int sync interface test
+// */
+// it('testGetString10', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
+// mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
+// mPref.flushSync();
+// expect('test').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+// expect('defaultvalue').assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, "defaultvalue"));
+// })
+//
+// /**
+// * @tc.name put boolean sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0090
+// * @tc.desc put boolean sync interface test
+// */
+// it('testPutBoolean012', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, true);
+// expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
+// mPref.flushSync();
+// expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
+// })
+//
+// /**
+// * @tc.name put float sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0100
+// * @tc.desc put float sync interface test
+// */
+// it('testPutFloat013', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 4.0);
+// expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+// mPref.flushSync();
+// expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
+// })
+//
+// /**
+// * @tc.name put int sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0110
+// * @tc.desc put int sync interface test
+// */
+// it('testPutInt014', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_INT_ELEMENT, 4);
+// expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+// mPref.flushSync();
+// expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
+// })
+//
+// /**
+// * @tc.name put long sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0120
+// * @tc.desc put long sync interface test
+// */
+// it('testPutLong015', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
+// expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+// mPref.flushSync();
+// expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
+// })
+//
+// /**
+// * @tc.name put String sync interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0130
+// * @tc.desc put String sync interface test
+// */
+// it('testPutString016', 0, function () {
+// mPref.clearSync();
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, '');
+// expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+// mPref.flushSync();
+// expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
+// })
+//
+// /**
+// * @tc.name put interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0140
+// * @tc.desc put interface test
+// */
+// it('testRegisterObserver001', 0, function () {
+// mPref.clearSync();
+// var observer = function (key) {
+// expect('abcd').assertEqual(key);
+// };
+// mPref.on('change', observer);
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, "abcd");
+// })
+
+ /**
+ * @tc.name repeat on interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0150
+ * @tc.desc repeat on interface test
+ */
+ it('testRegisterObserver002', 0, function () {
+ mPref.clearSync();
+ var observer = function (key) {
+ console.info('testRegisterObserver001 key' + key);
+ expect(KEY_TEST_STRING_ELEMENT).assertEqual(key);
+ };
+ mPref.on('change', observer);
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
+ console.log("Observe On Test before putSync");
+ mPref.flushSync();
+ console.log("Observe On Test after flushSync");
+ })
+
+ /**
+ * @tc.name repeat on interface test
+ * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0150
+ * @tc.desc repeat on interface test
+ */
+ it('testRegisterObserver004', 0, function () {
+ mPref.clearSync();
+ var observer = function (key) {
+ console.info('testRegisterObserver004 key' + key);
+ changeResult = key;
+ };
+ mPref.on('change', observer);
+ mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
+ console.log("Observe On Test before putSync");
+ mPref.flushSync();
+ console.log("Observe On Test after flushSync");
+ expect(KEY_TEST_STRING_ELEMENT).assertEqual(changeResult);
+ })
+
+// /**
+// * @tc.name off interface test
+// * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0160
+// * @tc.desc off interface test
+// */
+// it('testUnRegisterObserver001', 0, function () {
+// var observer = function (key) {
+// console.info('testUnRegisterObserver001 key' + key);
+// expect('').assertEqual(key);
+// };
+// mPref.on('change', observer);
+// mPref.off('change', observer);
+// mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
+// })
+})
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/js/test/SystemStorage.test.js b/preferences/systemStorageTest/entry/src/main/js/test/SystemStorage.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..f3e5b5d2c7b892050fcc5c4e1ab9e5f890b8f6f1
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/js/test/SystemStorage.test.js
@@ -0,0 +1,262 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an 'AS IS' BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import storage from '@system.storage';
+
+const TAG = '[SYSTEM_STORAGE_JSKITS_TEST]'
+describe('systemStorageTest', function () {
+ beforeAll(function () {
+ console.info(TAG + 'beforeAll')
+ })
+
+ afterAll(function () {
+ console.info(TAG + 'afterAll')
+ storage.clear({
+ success: function () {
+ console.info(TAG + 'afterAll clear success')
+ },
+ fail: function (data, errCode) {
+ console.info(TAG + 'afterAll clear fail, data = ' + data + ', errCode = ' + errCode)
+ }
+ })
+ })
+
+ /**
+ * @tc.name testSet001
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Set_0001
+ * @tc.desc set and can get correct value in success callback, finally get complete callback
+ */
+ it('testSet001', 0, async function (done) {
+ console.log(TAG + '************* testSet001 start *************');
+ var completeRet = false;
+ storage.set({
+ key: 'storageKey',
+ value: 'testValue',
+ success: function () {
+ var getValue;
+ storage.get({
+ key: 'storageKey',
+ success: function (data) {
+ getValue = data;
+ }
+ })
+ expect(getValue).assertEquals('testValue');
+ },
+ complete: function () {
+ completeRet = true;
+ }
+ })
+ setTimeout(() => expect(completeRet), 500);
+
+ done();
+
+ console.log(TAG + '************* testSet001 end *************');
+ })
+
+ /**
+ * @tc.name testSet002
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Set_0002
+ * @tc.desc set null key can receive fail callback
+ */
+ it('testSet002', 0, async function (done) {
+ console.log(TAG + '************* testSet002 start *************');
+ var testData = undefined;
+ var testErrCode = undefined;
+ storage.set({
+ key: '',
+ value: 'testValue',
+ success: function () {
+ },
+ fail: function (data, errCode) {
+ testData = data;
+ testErrCode = errCode;
+ }
+ })
+
+ expect(testData != undefined);
+ expect(testErrCode != undefined);
+
+ done();
+
+ console.log(TAG + '************* testSet002 end *************');
+ })
+
+ /**
+ * @tc.name testSet003
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Set_0003
+ * @tc.desc set key which size over 32 bytes and can receive fail callback
+ */
+ /*
+ it('testSet003', 0, async function (done) {
+ console.log(TAG + '************* testSet003 start *************');
+ var testData = undefined;
+ var testErrCode = undefined;
+ storage.set({
+ key: 'x'.repeat(33),
+ value: 'testValue',
+ success: function () {
+ },
+ fail: function (data, errCode) {
+ testData = data;
+ testErrCode = errCode;
+ }
+ })
+
+ setTimeout(function () {
+ expect(testData != undefined);
+ expect(testErrCode != undefined);
+ }, 500);
+
+ done();
+
+ console.log(TAG + '************* testSet003 end *************');
+ })
+
+ */
+ /**
+ * @tc.name testSet003
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Set_0004
+ * @tc.desc set value which size over 128 bytes and can receive fail callback
+ */
+ /*
+ it('testSet004', 0, async function (done) {
+ console.log(TAG + '************* testSet004 start *************');
+ var testData = undefined;
+ var testErrCode = undefined;
+ storage.set({
+ key: 'testKey',
+ value: 'x'.repeat(129),
+ success: function () {
+ },
+ fail: function (data, errCode) {
+ testData = data;
+ testErrCode = errCode;
+ }
+ })
+
+ setTimeout(function () {
+ expect(testData != undefined);
+ expect(testErrCode != undefined);
+ }, 500);
+
+ done();
+
+ console.log(TAG + '************* testSet004 end *************');
+ })
+
+ */
+ /**
+ * @tc.name testGet001
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Get_0001
+ * @tc.desc set and can get correct value in success callback, finally receive a get complete callback
+ */
+ /*
+ it('testGet001', 0, async function (done) {
+ console.log(TAG + '************* testGet001 start *************');
+ var completeRet = false;
+ storage.set({
+ key: 'storageKey',
+ value: 'testValue',
+ success: function () {
+ var getValue;
+ storage.get({
+ key: 'storageKey',
+ success: function (data) {
+ getValue = data;
+ },
+ complete: function () {
+ completeRet = true;
+ }
+ })
+ expect(getValue).assertEquals('testValue');
+ }
+ })
+ setTimeout(() => expect(true).assertEquals(completeRet), 500);
+
+ done();
+
+ console.log(TAG + '************* testGet001 end *************');
+ })
+
+ */
+ /**
+ * @tc.name testGet002
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Get_0002
+ * @tc.desc get value without set any value and can get default in success callback
+ */
+ /*
+ it('testGet002', 0, async function (done) {
+ console.log(TAG + '************* testGet002 start *************');
+ var testVal = undefined;
+ var completeRet = false;
+ storage.get({
+ key: 'storageKey',
+ default: '123',
+ success: function (data) {
+ testVal = data;
+ },
+ complete: function () {
+ completeRet = true;
+ }
+ })
+
+ setTimeout(function () {
+ expect(true).assertEquals(completeRet);
+ expect('123').assertEquals(testVal);
+ }, 500);
+
+ done();
+
+ console.log(TAG + '************* testGet002 end *************');
+ })
+
+ */
+ /**
+ * @tc.name testGet003
+ * @tc.number SUB_DDM_AppDataFWK_SystemStorage_Get_0003
+ * @tc.desc set default size over 128 and can receive fail callback
+ */
+ /*
+ it('testGet003', 0, async function (done) {
+ console.log(TAG + '************* testGet003 start *************');
+ var testVal = undefined;
+ var completeRet = false;
+ var failRet = false;
+ storage.get({
+ key: 'storageKey',
+ default: 'x'.repeat(129),
+ success: function (data) {
+ testVal = data;
+ },
+ fail: function(){
+ failRet = true;
+ },
+ complete: function () {
+ completeRet = true;
+ }
+ })
+
+ setTimeout(function () {
+ expect(true).assertEquals(failRet);
+ expect(true).assertEquals(completeRet);
+ }, 500);
+
+ done();
+
+ console.log(TAG + '************* testGet003 end *************');
+ })*/
+
+
+})
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/resources/base/element/string.json b/preferences/systemStorageTest/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..76e501f214f84c96a44d08973dbbdeab8515e1de
--- /dev/null
+++ b/preferences/systemStorageTest/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "JsHelloWorld"
+ },
+ {
+ "name": "mainability_description",
+ "value": "hap sample empty page"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/preferences/systemStorageTest/entry/src/main/resources/base/media/icon.png b/preferences/systemStorageTest/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/preferences/systemStorageTest/entry/src/main/resources/base/media/icon.png differ
diff --git a/preferences/systemStorageTest/screenshots/device/main.png b/preferences/systemStorageTest/screenshots/device/main.png
new file mode 100644
index 0000000000000000000000000000000000000000..8cd63e0150f076b9b36a4ae20ea9e1f9c94c578b
Binary files /dev/null and b/preferences/systemStorageTest/screenshots/device/main.png differ
diff --git a/preferences/systemStorageTest/screenshots/device/second.png b/preferences/systemStorageTest/screenshots/device/second.png
new file mode 100644
index 0000000000000000000000000000000000000000..ab6bbc1b9c7e065ac0bbd3dbd6468ae345c3767a
Binary files /dev/null and b/preferences/systemStorageTest/screenshots/device/second.png differ
diff --git a/preferences/systemStorageTest/settings.gradle b/preferences/systemStorageTest/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..7dc3285c045cc590e49d231a4280ef52ba646d91
--- /dev/null
+++ b/preferences/systemStorageTest/settings.gradle
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+include ':entry'