From c27e1a2f6c9d3dec9128a280811324c08fb22b70 Mon Sep 17 00:00:00 2001 From: jiyong_sd Date: Sat, 16 Jul 2022 14:01:44 +0800 Subject: [PATCH] modified FA-JS Signed-off-by: jiyong_sd Change-Id: Iaf65341106ab4215497f922e33fad04b988f0303 --- storage/storagefileioerrorjstest/BUILD.gn | 6 +- storage/storagefileioerrorjstest/Test.json | 35 +- .../src/main/config.json | 153 ++- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 0 .../{default => MainAbility}/i18n/zh-CN.json | 0 .../pages/index/index.css | 0 .../pages/index/index.hml | 0 .../pages/index/index.js | 73 +- .../src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 43 +- .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../src/main/js/{default => }/test/Common.js | 108 +- .../js/{default => }/test/FileIOError.test.js | 320 ++--- .../main/js/{default => }/test/List.test.js | 35 +- .../main/resources/base/element/string.json | 38 +- storage/storagesecuritylabeljstest/BUILD.gn | 6 +- storage/storagesecuritylabeljstest/Test.json | 35 +- .../src/main/config.json | 153 ++- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 0 .../{default => MainAbility}/i18n/zh-CN.json | 0 .../pages/index/index.css | 0 .../pages/index/index.hml | 0 .../main/js/MainAbility}/pages/index/index.js | 73 +- .../src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../src/main/js/{default => }/test/Common.js | 79 +- .../src/main/js}/test/List.test.js | 35 +- .../{default => }/test/securitylabel.test.js | 1134 +++++++++-------- .../main/resources/base/element/string.json | 38 +- storage/storagestatfsjstest/BUILD.gn | 6 +- storage/storagestatfsjstest/Test.json | 35 +- .../storagestatfsjstest/src/main/config.json | 153 ++- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 0 .../{default => MainAbility}/i18n/zh-CN.json | 0 .../pages/index/index.css | 0 .../pages/index/index.hml | 0 .../main/js/MainAbility}/pages/index/index.js | 73 +- .../src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../src/main/js/{default => }/test/Common.js | 73 +- .../src/main/js}/test/List.test.js | 35 +- .../main/js/{default => }/test/statfs.test.js | 450 +++---- .../main/resources/base/element/string.json | 38 +- .../function_test/userauth/BUILD.gn | 12 +- .../function_test/userauth/Test.json | 77 +- .../userauth/entry/src/main/config.json | 84 -- .../js/resources/base/element/string.json | 12 - .../userauth/src/main/config.json | 132 ++ .../userauth/src/main/js/MainAbility/app.js | 31 + .../main/js/MainAbility}/i18n/en-US.json | 0 .../main/js/MainAbility}/i18n/zh-CN.json | 0 .../js/MainAbility}/pages/index/index.css | 0 .../js/MainAbility}/pages/index/index.hml | 0 .../main/js/MainAbility}/pages/index/index.js | 132 +- .../main/js/TestAbility}/app.js | 45 +- .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../userauth/src/main/js/test/ListTest.js | 21 + .../{entry => }/src/main/js/test/enumTest.js | 8 +- .../{entry => }/src/main/js/test/execute.js | 6 +- .../main/resources/base/element/string.json | 44 + .../main}/resources/base/media/icon.png | Bin .../function_test/userauthpart2/BUILD.gn | 12 +- .../function_test/userauthpart2/Test.json | 77 +- .../userauthpart2/entry/src/main/config.json | 83 -- .../src/main/js/default/pages/index/index.js | 43 - .../js/resources/base/element/string.json | 12 - .../userauthpart2/src/main/config.json | 115 ++ .../main/js/MainAbility}/app.js | 0 .../main/js/MainAbility}/i18n/en-US.json | 0 .../main/js/MainAbility}/i18n/zh-CN.json | 0 .../js/MainAbility}/pages/index/index.css | 0 .../js/MainAbility}/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 30 + .../src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../{entry => }/src/main/js/test/List.test.js | 7 +- ...ecurity_IAM_PIN_Kit_CallbackJsunit.test.js | 4 +- .../main/resources/base/element/string.json | 28 + .../main}/resources/base/media/icon.png | Bin 106 files changed, 3060 insertions(+), 1960 deletions(-) rename storage/storagefileioerrorjstest/src/main/js/{default => MainAbility}/app.js (100%) rename storage/storagefileioerrorjstest/src/main/js/{default => MainAbility}/i18n/en-US.json (100%) rename storage/storagefileioerrorjstest/src/main/js/{default => MainAbility}/i18n/zh-CN.json (100%) rename storage/storagefileioerrorjstest/src/main/js/{default => MainAbility}/pages/index/index.css (100%) rename storage/storagefileioerrorjstest/src/main/js/{default => MainAbility}/pages/index/index.hml (100%) rename storage/storagefileioerrorjstest/src/main/js/{default => MainAbility}/pages/index/index.js (79%) create mode 100644 storage/storagefileioerrorjstest/src/main/js/TestAbility/app.js create mode 100644 storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/en-US.json create mode 100644 storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.css create mode 100644 storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.hml rename useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/ListTest.js => storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.js (79%) create mode 100644 storage/storagefileioerrorjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename storage/storagefileioerrorjstest/src/main/js/{default => }/test/Common.js (96%) rename storage/storagefileioerrorjstest/src/main/js/{default => }/test/FileIOError.test.js (95%) rename storage/storagefileioerrorjstest/src/main/js/{default => }/test/List.test.js (83%) rename storage/storagesecuritylabeljstest/src/main/js/{default => MainAbility}/app.js (100%) rename storage/storagesecuritylabeljstest/src/main/js/{default => MainAbility}/i18n/en-US.json (100%) rename storage/storagesecuritylabeljstest/src/main/js/{default => MainAbility}/i18n/zh-CN.json (100%) rename storage/storagesecuritylabeljstest/src/main/js/{default => MainAbility}/pages/index/index.css (100%) rename storage/storagesecuritylabeljstest/src/main/js/{default => MainAbility}/pages/index/index.hml (100%) rename storage/{storagestatfsjstest/src/main/js/default => storagesecuritylabeljstest/src/main/js/MainAbility}/pages/index/index.js (79%) create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestAbility/app.js create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/en-US.json create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.css create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.hml create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.js create mode 100644 storage/storagesecuritylabeljstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename storage/storagesecuritylabeljstest/src/main/js/{default => }/test/Common.js (89%) rename storage/{storagestatfsjstest/src/main/js/default => storagesecuritylabeljstest/src/main/js}/test/List.test.js (82%) rename storage/storagesecuritylabeljstest/src/main/js/{default => }/test/securitylabel.test.js (97%) rename storage/storagestatfsjstest/src/main/js/{default => MainAbility}/app.js (100%) rename storage/storagestatfsjstest/src/main/js/{default => MainAbility}/i18n/en-US.json (100%) rename storage/storagestatfsjstest/src/main/js/{default => MainAbility}/i18n/zh-CN.json (100%) rename storage/storagestatfsjstest/src/main/js/{default => MainAbility}/pages/index/index.css (100%) rename storage/storagestatfsjstest/src/main/js/{default => MainAbility}/pages/index/index.hml (100%) rename storage/{storagesecuritylabeljstest/src/main/js/default => storagestatfsjstest/src/main/js/MainAbility}/pages/index/index.js (79%) create mode 100644 storage/storagestatfsjstest/src/main/js/TestAbility/app.js create mode 100644 storage/storagestatfsjstest/src/main/js/TestAbility/i18n/en-US.json create mode 100644 storage/storagestatfsjstest/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 storage/storagestatfsjstest/src/main/js/TestAbility/pages/index/index.css create mode 100644 storage/storagestatfsjstest/src/main/js/TestAbility/pages/index/index.hml create mode 100644 storage/storagestatfsjstest/src/main/js/TestAbility/pages/index/index.js create mode 100644 storage/storagestatfsjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename storage/storagestatfsjstest/src/main/js/{default => }/test/Common.js (86%) rename storage/{storagesecuritylabeljstest/src/main/js/default => storagestatfsjstest/src/main/js}/test/List.test.js (85%) rename storage/storagestatfsjstest/src/main/js/{default => }/test/statfs.test.js (96%) delete mode 100644 useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/config.json delete mode 100644 useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/element/string.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/config.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/app.js rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js/default => src/main/js/MainAbility}/i18n/en-US.json (100%) rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js/default => src/main/js/MainAbility}/i18n/zh-CN.json (100%) rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.css (100%) rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.hml (100%) rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.js (80%) rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js/default => src/main/js/TestAbility}/app.js (96%) create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/en-US.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.css create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.hml create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.js create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestRunner/OpenHarmonyTestRunner.js create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/ListTest.js rename useriam/face_auth/js_api_test/function_test/userauth/{entry => }/src/main/js/test/enumTest.js (93%) rename useriam/face_auth/js_api_test/function_test/userauth/{entry => }/src/main/js/test/execute.js (95%) create mode 100644 useriam/face_auth/js_api_test/function_test/userauth/src/main/resources/base/element/string.json rename useriam/face_auth/js_api_test/function_test/userauth/{entry/src/main/js => src/main}/resources/base/media/icon.png (100%) delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/config.json delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.js delete mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/resources/base/element/string.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/config.json rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry/src/main/js/default => src/main/js/MainAbility}/app.js (100%) rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry/src/main/js/default => src/main/js/MainAbility}/i18n/en-US.json (100%) rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry/src/main/js/default => src/main/js/MainAbility}/i18n/zh-CN.json (100%) rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.css (100%) rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.hml (100%) create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.js create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/app.js create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/en-US.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.css create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.hml create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.js create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry => }/src/main/js/test/List.test.js (80%) rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry => }/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js (96%) create mode 100644 useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/resources/base/element/string.json rename useriam/face_auth/js_api_test/function_test/userauthpart2/{entry/src/main/js => src/main}/resources/base/media/icon.png (100%) diff --git a/storage/storagefileioerrorjstest/BUILD.gn b/storage/storagefileioerrorjstest/BUILD.gn index eede7742f..9e354b7a1 100644 --- a/storage/storagefileioerrorjstest/BUILD.gn +++ b/storage/storagefileioerrorjstest/BUILD.gn @@ -9,7 +9,7 @@ # 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. +# limitations under the License. import("//test/xts/tools/build/suite.gni") @@ -23,7 +23,9 @@ ohos_js_hap_suite("storagefileioerror_js_test") { hap_name = "ActsStorageFileIoErrorJsTest" } ohos_js_assets("storagefileioerror_js_assets") { - source_dir = "./src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("storagefileioerror_js_resources") { sources = [ "./src/main/resources" ] diff --git a/storage/storagefileioerrorjstest/Test.json b/storage/storagefileioerrorjstest/Test.json index da66d7517..e51d814fd 100644 --- a/storage/storagefileioerrorjstest/Test.json +++ b/storage/storagefileioerrorjstest/Test.json @@ -1,18 +1,19 @@ -{ - "description": "Configuration for storage fileio Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "60000", - "package": "ohos.acts.storage.fileioerror", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsStorageFileIoErrorJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for storage fileio Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "shell-timeout": "60000", + "bundle-name": "ohos.acts.storage.fileioerror", + "package-name": "ohos.acts.storage.fileioerror" + }, + "kits": [ + { + "test-file-name": [ + "ActsStorageFileIoErrorJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/config.json b/storage/storagefileioerrorjstest/src/main/config.json index c4441ce4b..db6a5c04e 100644 --- a/storage/storagefileioerrorjstest/src/main/config.json +++ b/storage/storagefileioerrorjstest/src/main/config.json @@ -1,61 +1,94 @@ -{ - "app": { - "bundleName": "ohos.acts.storage.fileioerror", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.storage.fileioerror", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.storage.fileioerror.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard", - "visible": true - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } +{ + "app": { + "bundleName": "ohos.acts.storage.fileioerror", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.storage.fileioerror", + "name": ".entry", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": true + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "mainAbility": ".MainAbility", + "srcPath": "" + } } \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/js/default/app.js b/storage/storagefileioerrorjstest/src/main/js/MainAbility/app.js similarity index 100% rename from storage/storagefileioerrorjstest/src/main/js/default/app.js rename to storage/storagefileioerrorjstest/src/main/js/MainAbility/app.js diff --git a/storage/storagefileioerrorjstest/src/main/js/default/i18n/en-US.json b/storage/storagefileioerrorjstest/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from storage/storagefileioerrorjstest/src/main/js/default/i18n/en-US.json rename to storage/storagefileioerrorjstest/src/main/js/MainAbility/i18n/en-US.json diff --git a/storage/storagefileioerrorjstest/src/main/js/default/i18n/zh-CN.json b/storage/storagefileioerrorjstest/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from storage/storagefileioerrorjstest/src/main/js/default/i18n/zh-CN.json rename to storage/storagefileioerrorjstest/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.css b/storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.css similarity index 100% rename from storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.css rename to storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.css diff --git a/storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.hml b/storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.hml rename to storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.hml diff --git a/storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.js b/storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.js similarity index 79% rename from storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.js rename to storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.js index 9ff705964..4df0bbc73 100644 --- a/storage/storagefileioerrorjstest/src/main/js/default/pages/index/index.js +++ b/storage/storagefileioerrorjstest/src/main/js/MainAbility/pages/index/index.js @@ -1,41 +1,34 @@ -/* - * 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 app from '@system.app' - -import {Core} from 'deccjsunit/index' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: '' - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - require('../../test/List.test') - core.execute() - }, - onReady() { - }, +/* + * 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 app from '@system.app' + + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: '' + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, } \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/js/TestAbility/app.js b/storage/storagefileioerrorjstest/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/storage/storagefileioerrorjstest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/en-US.json b/storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/zh-CN.json b/storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/storage/storagefileioerrorjstest/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.css b/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.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; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.hml b/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/ListTest.js b/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.js similarity index 79% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/ListTest.js rename to storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.js index e8d02e111..88b083a7f 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/ListTest.js +++ b/storage/storagefileioerrorjstest/src/main/js/TestAbility/pages/index/index.js @@ -1,17 +1,26 @@ -/* - * 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. - */ - -require('./execute.js') -require('./enumTest.js') +/* + * 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/storage/storagefileioerrorjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/storage/storagefileioerrorjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/storage/storagefileioerrorjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/storage/storagefileioerrorjstest/src/main/js/default/test/Common.js b/storage/storagefileioerrorjstest/src/main/js/test/Common.js similarity index 96% rename from storage/storagefileioerrorjstest/src/main/js/default/test/Common.js rename to storage/storagefileioerrorjstest/src/main/js/test/Common.js index 701a45121..d8b4fe782 100644 --- a/storage/storagefileioerrorjstest/src/main/js/default/test/Common.js +++ b/storage/storagefileioerrorjstest/src/main/js/test/Common.js @@ -1,55 +1,55 @@ -/* - * 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 fileio from '@ohos.fileio' -import featureAbility from '@ohos.ability.featureAbility'; - -export const FILE_CONTENT = 'hello world' - -export function prepareFile(fpath, content) { - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - fileio.ftruncateSync(fd) - fileio.writeSync(fd, content) - fileio.fsyncSync(fd) - fileio.closeSync(fd) - return true - } - catch (e) { - console.log('Failed to prepareFile for ' + e) - return false - } -} - -export async function nextFileName(testName) { - let context = featureAbility.getContext(); - let data = await context.getCacheDir(); - let BASE_PATH = data + '/'; - return BASE_PATH + testName -} -export async function fileName(testName) { - let context = featureAbility.getContext(); - let data = await context.getFilesDir(); - let BASE_PATH = data + '/'; - return BASE_PATH + testName -} - -export function isIntNum(val) { - return typeof val === 'number' && val % 1 === 0; -} - -export function isInclude(error, message) { - return error.toString().indexOf(message) != -1; +/* + * 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 fileio from '@ohos.fileio' +import featureAbility from '@ohos.ability.featureAbility'; + +export const FILE_CONTENT = 'hello world' + +export function prepareFile(fpath, content) { + try { + let fd = fileio.openSync(fpath, 0o102, 0o666) + fileio.ftruncateSync(fd) + fileio.writeSync(fd, content) + fileio.fsyncSync(fd) + fileio.closeSync(fd) + return true + } + catch (e) { + console.log('Failed to prepareFile for ' + e) + return false + } +} + +export async function nextFileName(testName) { + let context = featureAbility.getContext(); + let data = await context.getCacheDir(); + let BASE_PATH = data + '/'; + return BASE_PATH + testName +} +export async function fileName(testName) { + let context = featureAbility.getContext(); + let data = await context.getFilesDir(); + let BASE_PATH = data + '/'; + return BASE_PATH + testName +} + +export function isIntNum(val) { + return typeof val === 'number' && val % 1 === 0; +} + +export function isInclude(error, message) { + return error.toString().indexOf(message) != -1; } \ No newline at end of file diff --git a/storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js b/storage/storagefileioerrorjstest/src/main/js/test/FileIOError.test.js similarity index 95% rename from storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js rename to storage/storagefileioerrorjstest/src/main/js/test/FileIOError.test.js index cbc7162de..92ceba29d 100644 --- a/storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js +++ b/storage/storagefileioerrorjstest/src/main/js/test/FileIOError.test.js @@ -1,159 +1,161 @@ -/* - * 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 fileio from '@ohos.fileio' -import { - describe, - it, - expect -} -from 'deccjsunit/index' -import { - FILE_CONTENT, - prepareFile, - fileName, - nextFileName, - isIntNum, - isInclude -} -from './Common' - -describe('FileIOError', function () { - - /** - * @tc.number SUB_STORAGE_FileIo_test_error_0000 - * @tc.name fileio_test_error_000 - * @tc.desc Function of API, Delete directories with files - */ - it('fileio_test_error_000', 0, async function (done) { - let dpath = await fileName('fileio_test_error_000d'); - let fpath = dpath + '/fileio_test_error_000f'; - fileio.mkdirSync(dpath); - expect(prepareFile(fpath, 'hello')).assertTrue(); - try { - let fd = fileio.openSync(dpath); - expect(isIntNum(fd)).assertTrue(); - fileio.rmdirSync(dpath); - } - catch (err) { - console.info('fileio_test_error_000 has failed for ' + err); - expect(isInclude(err.message, 'Directory not empty')).assertTrue(); - fileio.unlinkSync(fpath); - fileio.rmdirSync(dpath); - done(); - } - }); - - /** - * @tc.number SUB_STORAGE_FileIo_test_error_0100 - * @tc.name fileio_test_error_001 - * @tc.desc Function of API, delete file - */ - it('fileio_test_error_001', 0, async function (done) { - let fpath = await fileName('fileio_test_error_001f'); - expect(prepareFile(fpath, 'hello')).assertTrue(); - try { - let fd = fileio.openSync(fpath); - expect(isIntNum(fd)).assertTrue(); - fileio.rmdirSync(fpath); - } - catch (err) { - console.info('fileio_test_error_001 has failed for ' + err); - expect(isInclude(err.message, 'Not a directory')).assertTrue(); - fileio.unlinkSync(fpath); - done(); - } - }); - - /** - * @tc.number SUB_STORAGE_FileIo_test_error_0200 - * @tc.name fileio_test_error_002 - * @tc.desc Function of API, flags=0o100. missing mode parameter. - */ - it('fileio_test_error_002', 0, async function (done) { - let fpath = await nextFileName('fileio_test_error_002'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - try { - fileio.openSync(fpath, 0o100); - } - catch (err) { - console.info('fileio_test_error_002 has failed for ' + err); - expect(isInclude(err.message, 'called with O_CREAT/O_TMPFILE but no mode')).assertTrue(); - fileio.unlinkSync(fpath); - done(); - } - }); - - /** - * @tc.number SUB_STORAGE_FileIO_OpenSync_0300 - * @tc.name fileio_test_error_003 - * @tc.desc Function of API, flags=0o302. The test file is exist. - */ - it('fileio_test_error_003', 0, async function (done) { - let fpath = await nextFileName('fileio_test_error_003'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - try { - fileio.openSync(fpath, 0o302, 0o666); - } - catch (err) { - console.info('fileio_test_error_003 has failed for ' + err); - expect(isInclude(err.message, 'File exists')).assertTrue(); - fileio.unlinkSync(fpath); - done(); - } - }); - - /** - * @tc.number SUB_STORAGE_FileIO_OpenSync_0400 - * @tc.name fileio_test_error_004 - * @tc.desc Function of API, flags=0o400000. Symbolic link loop. - */ - it('fileio_test_error_004', 0, async function (done) { - let fpath = await nextFileName('fileio_test_error_004'); - let ffpath = fpath + 'aaaa'; - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - try { - fileio.symlinkSync(fpath, ffpath); - fileio.openSync(ffpath, 0o400000); - } - catch (err) { - console.info('fileio_test_error_004 has failed for ' + err); - expect(isInclude(err.message, 'Symbolic link loop') || - isInclude(err.message, 'Too many symbolic links encountered')).assertTrue(); - fileio.unlinkSync(fpath); - fileio.unlinkSync(ffpath); - done(); - } - }); - - /** - * @tc.number SUB_STORAGE_FileIO_OpenSync_0500 - * @tc.name fileio_test_error_005 - * @tc.desc Function of API, flags=0o200000. Not a directory. - */ - it('fileio_test_error_005', 0, async function (done) { - let fpath = await nextFileName('fileio_test_error_005'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - try { - fileio.openSync(fpath, 0o200000, 0o666); - } - catch (err) { - console.info('fileio_test_error_005 has failed for ' + err); - expect(isInclude(err.message, 'Not a directory')).assertTrue(); - fileio.unlinkSync(fpath); - done(); - } - }); -}); +/* + * 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 fileio from '@ohos.fileio' +import { + describe, + it, + expect +} +from '@ohos/hypium' +import { + FILE_CONTENT, + prepareFile, + fileName, + nextFileName, + isIntNum, + isInclude +} +from './Common' + +export default function FileIOError() { +describe('FileIOError', function () { + + /** + * @tc.number SUB_STORAGE_FileIo_test_error_0000 + * @tc.name fileio_test_error_000 + * @tc.desc Function of API, Delete directories with files + */ + it('fileio_test_error_000', 0, async function (done) { + let dpath = await fileName('fileio_test_error_000d'); + let fpath = dpath + '/fileio_test_error_000f'; + fileio.mkdirSync(dpath); + expect(prepareFile(fpath, 'hello')).assertTrue(); + try { + let fd = fileio.openSync(dpath); + expect(isIntNum(fd)).assertTrue(); + fileio.rmdirSync(dpath); + } + catch (err) { + console.info('fileio_test_error_000 has failed for ' + err); + expect(isInclude(err.message, 'Directory not empty')).assertTrue(); + fileio.unlinkSync(fpath); + fileio.rmdirSync(dpath); + done(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileIo_test_error_0100 + * @tc.name fileio_test_error_001 + * @tc.desc Function of API, delete file + */ + it('fileio_test_error_001', 0, async function (done) { + let fpath = await fileName('fileio_test_error_001f'); + expect(prepareFile(fpath, 'hello')).assertTrue(); + try { + let fd = fileio.openSync(fpath); + expect(isIntNum(fd)).assertTrue(); + fileio.rmdirSync(fpath); + } + catch (err) { + console.info('fileio_test_error_001 has failed for ' + err); + expect(isInclude(err.message, 'Not a directory')).assertTrue(); + fileio.unlinkSync(fpath); + done(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileIo_test_error_0200 + * @tc.name fileio_test_error_002 + * @tc.desc Function of API, flags=0o100. missing mode parameter. + */ + it('fileio_test_error_002', 0, async function (done) { + let fpath = await nextFileName('fileio_test_error_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + fileio.openSync(fpath, 0o100); + } + catch (err) { + console.info('fileio_test_error_002 has failed for ' + err); + expect(isInclude(err.message, 'called with O_CREAT/O_TMPFILE but no mode')).assertTrue(); + fileio.unlinkSync(fpath); + done(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileIO_OpenSync_0300 + * @tc.name fileio_test_error_003 + * @tc.desc Function of API, flags=0o302. The test file is exist. + */ + it('fileio_test_error_003', 0, async function (done) { + let fpath = await nextFileName('fileio_test_error_003'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + fileio.openSync(fpath, 0o302, 0o666); + } + catch (err) { + console.info('fileio_test_error_003 has failed for ' + err); + expect(isInclude(err.message, 'File exists')).assertTrue(); + fileio.unlinkSync(fpath); + done(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileIO_OpenSync_0400 + * @tc.name fileio_test_error_004 + * @tc.desc Function of API, flags=0o400000. Symbolic link loop. + */ + it('fileio_test_error_004', 0, async function (done) { + let fpath = await nextFileName('fileio_test_error_004'); + let ffpath = fpath + 'aaaa'; + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + fileio.symlinkSync(fpath, ffpath); + fileio.openSync(ffpath, 0o400000); + } + catch (err) { + console.info('fileio_test_error_004 has failed for ' + err); + expect(isInclude(err.message, 'Symbolic link loop') || + isInclude(err.message, 'Too many symbolic links encountered')).assertTrue(); + fileio.unlinkSync(fpath); + fileio.unlinkSync(ffpath); + done(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileIO_OpenSync_0500 + * @tc.name fileio_test_error_005 + * @tc.desc Function of API, flags=0o200000. Not a directory. + */ + it('fileio_test_error_005', 0, async function (done) { + let fpath = await nextFileName('fileio_test_error_005'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + fileio.openSync(fpath, 0o200000, 0o666); + } + catch (err) { + console.info('fileio_test_error_005 has failed for ' + err); + expect(isInclude(err.message, 'Not a directory')).assertTrue(); + fileio.unlinkSync(fpath); + done(); + } + }); +}); +} diff --git a/storage/storagefileioerrorjstest/src/main/js/default/test/List.test.js b/storage/storagefileioerrorjstest/src/main/js/test/List.test.js similarity index 83% rename from storage/storagefileioerrorjstest/src/main/js/default/test/List.test.js rename to storage/storagefileioerrorjstest/src/main/js/test/List.test.js index 04baba482..665ffda95 100644 --- a/storage/storagefileioerrorjstest/src/main/js/default/test/List.test.js +++ b/storage/storagefileioerrorjstest/src/main/js/test/List.test.js @@ -1,16 +1,19 @@ -/* - * 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('./FileIOError.test.js') +/* + * 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 FileIOError from './FileIOError.test.js' +export default function testsuite() { +FileIOError() +} diff --git a/storage/storagefileioerrorjstest/src/main/resources/base/element/string.json b/storage/storagefileioerrorjstest/src/main/resources/base/element/string.json index 0fd37c950..5bdb90000 100644 --- a/storage/storagefileioerrorjstest/src/main/resources/base/element/string.json +++ b/storage/storagefileioerrorjstest/src/main/resources/base/element/string.json @@ -1,12 +1,28 @@ -{ - "string": [ - { - "name": "app_name", - "value": "storagefileioerrorjstest" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] +{ + "string": [ + { + "name": "app_name", + "value": "storagefileioerrorjstest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] } \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/BUILD.gn b/storage/storagesecuritylabeljstest/BUILD.gn index cef131ddd..82b82b24f 100644 --- a/storage/storagesecuritylabeljstest/BUILD.gn +++ b/storage/storagesecuritylabeljstest/BUILD.gn @@ -9,7 +9,7 @@ # 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. +# limitations under the License. import("//test/xts/tools/build/suite.gni") @@ -23,7 +23,9 @@ ohos_js_hap_suite("storagesecuritylabel_js_test") { hap_name = "ActsStorageSecurityLabelJSTest" } ohos_js_assets("storagesecuritylabel_js_assets") { - source_dir = "./src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("storagesecuritylabel_js_resources") { sources = [ "./src/main/resources" ] diff --git a/storage/storagesecuritylabeljstest/Test.json b/storage/storagesecuritylabeljstest/Test.json index 540d87082..600c9a4db 100644 --- a/storage/storagesecuritylabeljstest/Test.json +++ b/storage/storagesecuritylabeljstest/Test.json @@ -1,18 +1,19 @@ -{ - "description": "Configuration for storage securitylabel Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "60000", - "package": "ohos.acts.storage.securitylabel", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsStorageSecurityLabelJSTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for storage securitylabel Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "shell-timeout": "60000", + "bundle-name": "ohos.acts.storage.securitylabel", + "package-name": "ohos.acts.storage.securitylabel" + }, + "kits": [ + { + "test-file-name": [ + "ActsStorageSecurityLabelJSTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/config.json b/storage/storagesecuritylabeljstest/src/main/config.json index 24dff049d..59d3307bb 100644 --- a/storage/storagesecuritylabeljstest/src/main/config.json +++ b/storage/storagesecuritylabeljstest/src/main/config.json @@ -1,61 +1,94 @@ -{ - "app": { - "bundleName": "ohos.acts.storage.securitylabel", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.storage.securitylabel", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.storage.securitylabel.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard", - "visible": true - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } +{ + "app": { + "bundleName": "ohos.acts.storage.securitylabel", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.storage.securitylabel", + "name": ".entry", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": true + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "mainAbility": ".MainAbility", + "srcPath": "" + } } \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/app.js b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/app.js similarity index 100% rename from storage/storagesecuritylabeljstest/src/main/js/default/app.js rename to storage/storagesecuritylabeljstest/src/main/js/MainAbility/app.js diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/i18n/en-US.json b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from storage/storagesecuritylabeljstest/src/main/js/default/i18n/en-US.json rename to storage/storagesecuritylabeljstest/src/main/js/MainAbility/i18n/en-US.json diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/i18n/zh-CN.json b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from storage/storagesecuritylabeljstest/src/main/js/default/i18n/zh-CN.json rename to storage/storagesecuritylabeljstest/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/pages/index/index.css b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.css similarity index 100% rename from storage/storagesecuritylabeljstest/src/main/js/default/pages/index/index.css rename to storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.css diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/pages/index/index.hml b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from storage/storagesecuritylabeljstest/src/main/js/default/pages/index/index.hml rename to storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.hml diff --git a/storage/storagestatfsjstest/src/main/js/default/pages/index/index.js b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.js similarity index 79% rename from storage/storagestatfsjstest/src/main/js/default/pages/index/index.js rename to storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.js index 61921cf3b..5f9fe94e4 100644 --- a/storage/storagestatfsjstest/src/main/js/default/pages/index/index.js +++ b/storage/storagesecuritylabeljstest/src/main/js/MainAbility/pages/index/index.js @@ -1,41 +1,34 @@ -/* - * 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 app from '@system.app' - -import {Core} from 'deccjsunit/index' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: '' - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - require('../../test/List.test') - core.execute() - }, - onReady() { - }, +/* + * 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 app from '@system.app' + + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: '' + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, } \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestAbility/app.js b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/en-US.json b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/zh-CN.json b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.css b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.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; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.hml b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.js b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/storage/storagesecuritylabeljstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/storage/storagesecuritylabeljstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/storage/storagesecuritylabeljstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/test/Common.js b/storage/storagesecuritylabeljstest/src/main/js/test/Common.js similarity index 89% rename from storage/storagesecuritylabeljstest/src/main/js/default/test/Common.js rename to storage/storagesecuritylabeljstest/src/main/js/test/Common.js index b6f14c9c5..ff4d298fe 100644 --- a/storage/storagesecuritylabeljstest/src/main/js/default/test/Common.js +++ b/storage/storagesecuritylabeljstest/src/main/js/test/Common.js @@ -1,42 +1,39 @@ -/* - * 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 securityLabel from '@ohos.securityLabel'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; - -import { - describe, beforeAll, beforeEach, afterEach, afterAll, it, expect -} -from 'deccjsunit/index' - -export async function nextFileName(testName) { - let context = featureAbility.getContext(); - let data = await context.getFilesDir(); - let BASE_PATH = data.substring(0, data.length - 5) + 'cache/'; - return BASE_PATH + testName; -} - -export { - describe, - beforeAll, - beforeEach, - afterEach, - afterAll, - it, - expect, - securityLabel, - fileio +/* + * 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 securityLabel from '@ohos.securityLabel'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export async function nextFileName(testName) { + let context = featureAbility.getContext(); + let data = await context.getFilesDir(); + let BASE_PATH = data.substring(0, data.length - 5) + 'cache/'; + return BASE_PATH + testName; +} + +export { + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect, + securityLabel, + fileio }; \ No newline at end of file diff --git a/storage/storagestatfsjstest/src/main/js/default/test/List.test.js b/storage/storagesecuritylabeljstest/src/main/js/test/List.test.js similarity index 82% rename from storage/storagestatfsjstest/src/main/js/default/test/List.test.js rename to storage/storagesecuritylabeljstest/src/main/js/test/List.test.js index 620587e84..12704969b 100644 --- a/storage/storagestatfsjstest/src/main/js/default/test/List.test.js +++ b/storage/storagesecuritylabeljstest/src/main/js/test/List.test.js @@ -1,16 +1,19 @@ -/* - * 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('./statfs.test.js') +/* + * 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 securitylabel from './securitylabel.test.js' +export default function testsuite() { +securitylabel() +} diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/test/securitylabel.test.js b/storage/storagesecuritylabeljstest/src/main/js/test/securitylabel.test.js similarity index 97% rename from storage/storagesecuritylabeljstest/src/main/js/default/test/securitylabel.test.js rename to storage/storagesecuritylabeljstest/src/main/js/test/securitylabel.test.js index 42cf9a60f..db94547a7 100644 --- a/storage/storagesecuritylabeljstest/src/main/js/default/test/securitylabel.test.js +++ b/storage/storagesecuritylabeljstest/src/main/js/test/securitylabel.test.js @@ -1,566 +1,568 @@ -/* - * 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, it, expect, securityLabel, nextFileName, fileio -} from './Common'; - -describe('securitylabel', function () { - - /** - * @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_SYNC_0000 - * @tc.name securitylabel_test_set_security_label_sync_000 - * @tc.desc Test the setSecurityLabelSync() interface,and the getSecurityLabelSync() interface to get the data label. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('securitylabel_test_set_security_label_sync_000', 0, async function () { - try { - let dataLevel = ["s0","s1","s2","s3","s4"]; - for(let i=0;i + + {{ $t('strings.hello') }} {{ title }} + + diff --git a/storage/storagestatfsjstest/src/main/js/TestAbility/pages/index/index.js b/storage/storagestatfsjstest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/storage/storagestatfsjstest/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/storage/storagestatfsjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/storage/storagestatfsjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/storage/storagestatfsjstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/storage/storagestatfsjstest/src/main/js/default/test/Common.js b/storage/storagestatfsjstest/src/main/js/test/Common.js similarity index 86% rename from storage/storagestatfsjstest/src/main/js/default/test/Common.js rename to storage/storagestatfsjstest/src/main/js/test/Common.js index e05e4f3ae..bc92fb897 100644 --- a/storage/storagestatfsjstest/src/main/js/default/test/Common.js +++ b/storage/storagestatfsjstest/src/main/js/test/Common.js @@ -1,39 +1,36 @@ -/* - * 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 statfs from '@ohos.statfs'; - -export const FILE_CONTENT = 'hello world'; - -import { - describe, beforeAll, beforeEach, afterEach, afterAll, it, expect -} -from 'deccjsunit/index' - -function isIntNum(val) { - return typeof val === 'number' && val % 1 === 0; -} - -export { - isIntNum, - describe, - beforeAll, - beforeEach, - afterEach, - afterAll, - it, - expect, - statfs +/* + * 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 statfs from '@ohos.statfs'; + +export const FILE_CONTENT = 'hello world'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +function isIntNum(val) { + return typeof val === 'number' && val % 1 === 0; +} + +export { + isIntNum, + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect, + statfs }; \ No newline at end of file diff --git a/storage/storagesecuritylabeljstest/src/main/js/default/test/List.test.js b/storage/storagestatfsjstest/src/main/js/test/List.test.js similarity index 85% rename from storage/storagesecuritylabeljstest/src/main/js/default/test/List.test.js rename to storage/storagestatfsjstest/src/main/js/test/List.test.js index 1d4d53741..5d427bab4 100644 --- a/storage/storagesecuritylabeljstest/src/main/js/default/test/List.test.js +++ b/storage/storagestatfsjstest/src/main/js/test/List.test.js @@ -1,16 +1,19 @@ -/* - * 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('./securitylabel.test.js'); +/* + * 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 statfs from './statfs.test.js' +export default function testsuite() { +statfs() +} diff --git a/storage/storagestatfsjstest/src/main/js/default/test/statfs.test.js b/storage/storagestatfsjstest/src/main/js/test/statfs.test.js similarity index 96% rename from storage/storagestatfsjstest/src/main/js/default/test/statfs.test.js rename to storage/storagestatfsjstest/src/main/js/test/statfs.test.js index dd634f9a5..73482a020 100644 --- a/storage/storagestatfsjstest/src/main/js/default/test/statfs.test.js +++ b/storage/storagestatfsjstest/src/main/js/test/statfs.test.js @@ -1,224 +1,226 @@ -/* - * 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, it, expect, isIntNum, statfs} from './Common'; -import featureAbility from '@ohos.ability.featureAbility'; - -describe('statfs', function () { - - /** - * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0000 - * @tc.name statfs_test_get_free_bytes_async_000 - * @tc.desc Test getFreeBytes() interfaces, When the path is a sandbox path, promise way back. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_free_bytes_async_000', 0, async function (done) { - try { - let context = featureAbility.getContext(); - let data = await context.getFilesDir(); - let number = await statfs.getFreeBytes(data); - console.info("getFreeBytes getFilesDir===>" + (number / 1024)); - expect(isIntNum(number)).assertTrue(); - done(); - } catch (e) { - console.info('statfs_test_get_free_bytes_async_000 has failed for ' + e); - expect(null).assertFail(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0010 - * @tc.name statfs_test_get_free_bytes_async_001 - * @tc.desc Test getFreeBytes() interfaces, When the path is dev, callback way back. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_free_bytes_async_001', 0, async function (done) { - try { - statfs.getFreeBytes("/dev",(err,number)=>{ - console.info("getFreeBytesNumber dev===>:" + (number / 1024)); - expect(isIntNum(number)).assertTrue(); - done(); - }); - } catch (e) { - console.info('statfs_test_get_free_bytes_async_001 has failed for ' + e); - expect(null).assertFail(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0020 - * @tc.name statfs_test_get_free_bytes_async_002 - * @tc.desc Test getFreeBytes() interfaces, When the parameter type is wrong. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_free_bytes_async_002', 0, async function (done) { - try { - await statfs.getFreeBytes(1); - } catch (err) { - console.info('statfs_test_get_free_bytes_async_002 has failed for ' + err); - expect(err.message == "Invalid path").assertTrue(); - done(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0030 - * @tc.name statfs_test_get_free_bytes_async_003 - * @tc.desc Test getFreeBytes() interfaces, When there are no parameters. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_free_bytes_async_003', 0, async function (done) { - try { - await statfs.getFreeBytes(); - } catch (err) { - console.info('statfs_test_get_free_bytes_async_003 has failed for ' + err); - expect(err.message == "Number of arguments unmatched").assertTrue(); - done(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0040 - * @tc.name statfs_test_get_free_bytes_async_004 - * @tc.desc Test getFreeBytes() interfaces, When the path is empty. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_free_bytes_async_004', 0, async function (done) { - try { - await statfs.getFreeBytes(""); - } catch (err) { - console.info('statfs_test_get_free_bytes_async_004 has failed for ' + err); - expect(err.message == "No such file or directory").assertTrue(); - done(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0000 - * @tc.name statfs_test_get_total_bytes_async_000 - * @tc.desc Test getTotalBytes() interfaces, When the path is a sandbox path, promise way back. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_total_bytes_async_000', 0, async function (done) { - try { - let context = featureAbility.getContext(); - let data = await context.getFilesDir(); - let number = await statfs.getTotalBytes(data); - console.info("getTotalBytesNumber GetFilesDir====>:" + (number / 1024)); - expect(isIntNum(number)).assertTrue(); - done(); - } catch (e) { - console.info('statfs_test_get_total_bytes_async_000 has failed for ' + e); - expect(null).assertFail(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0010 - * @tc.name statfs_test_get_total_bytes_async_001 - * @tc.desc Test getTotalBytes() interfaces, When the path is dev, callback way back. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_total_bytes_async_001', 0, async function (done) { - try { - statfs.getTotalBytes("/dev",(err,number)=>{ - console.info("getTotalBytesNumber dev===>:" + (number / 1024)); - expect(isIntNum(number)).assertTrue(); - done(); - }); - } catch (e) { - console.info('statfs_test_get_total_bytes_async_001 has failed for ' + e); - expect(null).assertFail(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0020 - * @tc.name statfs_test_get_total_bytes_async_002 - * @tc.desc Test getTotalBytes() interfaces, When the parameter type is wrong. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_total_bytes_async_002', 0, async function (done) { - try { - await statfs.getTotalBytes(1); - } catch (err) { - console.info('statfs_test_get_total_bytes_async_002 has failed for ' + err); - expect(err.message == "Invalid path").assertTrue(); - done(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0030 - * @tc.name statfs_test_get_total_bytes_async_003 - * @tc.desc Test getTotalBytes() interfaces, When there are no parameters. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_total_bytes_async_003', 0, async function (done) { - try { - await statfs.getTotalBytes(); - } catch (err) { - console.info('statfs_test_get_total_bytes_async_003 has failed for ' + err); - expect(err.message == "Number of arguments unmatched").assertTrue(); - done(); - } - }); - - /** - * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0040 - * @tc.name statfs_test_get_total_bytes_async_004 - * @tc.desc Test getTotalBytes() interfaces, When the path is empty. - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - * @tc.require - */ - it('statfs_test_get_total_bytes_async_004', 0, async function (done) { - try { - await statfs.getTotalBytes(""); - } catch (err) { - console.info('statfs_test_get_total_bytes_async_004 has failed for ' + err); - expect(err.message == "No such file or directory").assertTrue(); - done(); - } - }); -}); +/* + * 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, it, expect, isIntNum, statfs} from './Common'; +import featureAbility from '@ohos.ability.featureAbility'; + +export default function statfs() { +describe('statfs', function () { + + /** + * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0000 + * @tc.name statfs_test_get_free_bytes_async_000 + * @tc.desc Test getFreeBytes() interfaces, When the path is a sandbox path, promise way back. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_free_bytes_async_000', 0, async function (done) { + try { + let context = featureAbility.getContext(); + let data = await context.getFilesDir(); + let number = await statfs.getFreeBytes(data); + console.info("getFreeBytes getFilesDir===>" + (number / 1024)); + expect(isIntNum(number)).assertTrue(); + done(); + } catch (e) { + console.info('statfs_test_get_free_bytes_async_000 has failed for ' + e); + expect(null).assertFail(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0010 + * @tc.name statfs_test_get_free_bytes_async_001 + * @tc.desc Test getFreeBytes() interfaces, When the path is dev, callback way back. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_free_bytes_async_001', 0, async function (done) { + try { + statfs.getFreeBytes("/dev",(err,number)=>{ + console.info("getFreeBytesNumber dev===>:" + (number / 1024)); + expect(isIntNum(number)).assertTrue(); + done(); + }); + } catch (e) { + console.info('statfs_test_get_free_bytes_async_001 has failed for ' + e); + expect(null).assertFail(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0020 + * @tc.name statfs_test_get_free_bytes_async_002 + * @tc.desc Test getFreeBytes() interfaces, When the parameter type is wrong. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_free_bytes_async_002', 0, async function (done) { + try { + await statfs.getFreeBytes(1); + } catch (err) { + console.info('statfs_test_get_free_bytes_async_002 has failed for ' + err); + expect(err.message == "Invalid path").assertTrue(); + done(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0030 + * @tc.name statfs_test_get_free_bytes_async_003 + * @tc.desc Test getFreeBytes() interfaces, When there are no parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_free_bytes_async_003', 0, async function (done) { + try { + await statfs.getFreeBytes(); + } catch (err) { + console.info('statfs_test_get_free_bytes_async_003 has failed for ' + err); + expect(err.message == "Number of arguments unmatched").assertTrue(); + done(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_FREE_BYTES_0040 + * @tc.name statfs_test_get_free_bytes_async_004 + * @tc.desc Test getFreeBytes() interfaces, When the path is empty. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_free_bytes_async_004', 0, async function (done) { + try { + await statfs.getFreeBytes(""); + } catch (err) { + console.info('statfs_test_get_free_bytes_async_004 has failed for ' + err); + expect(err.message == "No such file or directory").assertTrue(); + done(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0000 + * @tc.name statfs_test_get_total_bytes_async_000 + * @tc.desc Test getTotalBytes() interfaces, When the path is a sandbox path, promise way back. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_total_bytes_async_000', 0, async function (done) { + try { + let context = featureAbility.getContext(); + let data = await context.getFilesDir(); + let number = await statfs.getTotalBytes(data); + console.info("getTotalBytesNumber GetFilesDir====>:" + (number / 1024)); + expect(isIntNum(number)).assertTrue(); + done(); + } catch (e) { + console.info('statfs_test_get_total_bytes_async_000 has failed for ' + e); + expect(null).assertFail(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0010 + * @tc.name statfs_test_get_total_bytes_async_001 + * @tc.desc Test getTotalBytes() interfaces, When the path is dev, callback way back. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_total_bytes_async_001', 0, async function (done) { + try { + statfs.getTotalBytes("/dev",(err,number)=>{ + console.info("getTotalBytesNumber dev===>:" + (number / 1024)); + expect(isIntNum(number)).assertTrue(); + done(); + }); + } catch (e) { + console.info('statfs_test_get_total_bytes_async_001 has failed for ' + e); + expect(null).assertFail(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0020 + * @tc.name statfs_test_get_total_bytes_async_002 + * @tc.desc Test getTotalBytes() interfaces, When the parameter type is wrong. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_total_bytes_async_002', 0, async function (done) { + try { + await statfs.getTotalBytes(1); + } catch (err) { + console.info('statfs_test_get_total_bytes_async_002 has failed for ' + err); + expect(err.message == "Invalid path").assertTrue(); + done(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0030 + * @tc.name statfs_test_get_total_bytes_async_003 + * @tc.desc Test getTotalBytes() interfaces, When there are no parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_total_bytes_async_003', 0, async function (done) { + try { + await statfs.getTotalBytes(); + } catch (err) { + console.info('statfs_test_get_total_bytes_async_003 has failed for ' + err); + expect(err.message == "Number of arguments unmatched").assertTrue(); + done(); + } + }); + + /** + * @tc.number SUB_DF_STATFS_GET_TOTAL_BYTES_0040 + * @tc.name statfs_test_get_total_bytes_async_004 + * @tc.desc Test getTotalBytes() interfaces, When the path is empty. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('statfs_test_get_total_bytes_async_004', 0, async function (done) { + try { + await statfs.getTotalBytes(""); + } catch (err) { + console.info('statfs_test_get_total_bytes_async_004 has failed for ' + err); + expect(err.message == "No such file or directory").assertTrue(); + done(); + } + }); +}); +} diff --git a/storage/storagestatfsjstest/src/main/resources/base/element/string.json b/storage/storagestatfsjstest/src/main/resources/base/element/string.json index a3b97c0ac..c550020f7 100644 --- a/storage/storagestatfsjstest/src/main/resources/base/element/string.json +++ b/storage/storagestatfsjstest/src/main/resources/base/element/string.json @@ -1,12 +1,28 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Storagestatfsjstest" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] +{ + "string": [ + { + "name": "app_name", + "value": "Storagestatfsjstest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] } \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/BUILD.gn b/useriam/face_auth/js_api_test/function_test/userauth/BUILD.gn index 49437a6df..b4e2cfe91 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/BUILD.gn +++ b/useriam/face_auth/js_api_test/function_test/userauth/BUILD.gn @@ -9,12 +9,12 @@ # 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. +# limitations under the License. import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsUserauthTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsUserauthTest") { hap_name = "ActsUserauthTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/useriam/face_auth/js_api_test/function_test/userauth/Test.json b/useriam/face_auth/js_api_test/function_test/userauth/Test.json index 639bd86e7..dbc66873c 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/Test.json +++ b/useriam/face_auth/js_api_test/function_test/userauth/Test.json @@ -1,38 +1,39 @@ -{ - "description": "Configuration for hjunit demo Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "600000", - "package": "com.example.myapplication101", - "shell-timeout": "600000" - }, - "kits": [ - { - "test-file-name": [ - "ActsUserauthTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - }, - { - "type": "ShellKit", - "run-command": [ - "remount", - "mkdir /data/test" - ] - }, - { - "type": "PushKit", - "push": [ - "ActsUserauthTest.hap->/data/test/ActsUserauthTest.hap" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "chmod 644 /data/test/*.hap", - "chmod 777 -R data" - ] - } - ] -} +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "shell-timeout": "600000", + "bundle-name": "com.example.myapplication101", + "package-name": "com.example.myapplication101" + }, + "kits": [ + { + "test-file-name": [ + "ActsUserauthTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsUserauthTest.hap->/data/test/ActsUserauthTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap", + "chmod 777 -R data" + ] + } + ] +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/config.json b/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/config.json deleted file mode 100644 index 3a9c1d22d..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/config.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "app": { - "bundleName": "com.example.myapplication101", - "vendor": "example", - "version": { - "code": 12, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.myapplication101", - "name": ".MyApplication", - "mainAbility": "com.example.myapplication101.MainAbility", - "deviceType": [ - "phone", - "tablet", - "tv", - "wearable" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.myapplication101.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", - "type": "page", - "launchType": "standard", - "visible": true - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ], - "reqPermissions": [ - { - "reason": "reason_manage_face", - "usedScene": { - "ability": ["com.myface.Ability","com.myface.AbilityBackground"], - "when": "always" - }, - "name": "ohos.permission.MANAGE_FACE" - }, - { - "reason": "reason_access_biometric", - "usedScene": { - "ability": ["com.mybiometric.Ability","com.mybiometric.AbilityBackground"], - "when": "always" - }, - "name": "ohos.permission.ACCESS_BIOMETRIC" - } - ] - } -} diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/element/string.json b/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index 0bae6bd40..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "mainability_description", - "value": "JS_Empty Ability" - } - ] -} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/config.json b/useriam/face_auth/js_api_test/function_test/userauth/src/main/config.json new file mode 100644 index 000000000..707536ee7 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/config.json @@ -0,0 +1,132 @@ +{ + "app": { + "bundleName": "com.example.myapplication101", + "vendor": "example", + "version": { + "code": 12, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication101", + "name": ".entry", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet", + "tv", + "wearable" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "reason": "reason_manage_face", + "usedScene": { + "ability": [ + "com.myface.Ability", + "com.myface.AbilityBackground" + ], + "when": "always" + }, + "name": "ohos.permission.MANAGE_FACE" + }, + { + "reason": "reason_access_biometric", + "usedScene": { + "ability": [ + "com.mybiometric.Ability", + "com.mybiometric.AbilityBackground" + ], + "when": "always" + }, + "name": "ohos.permission.ACCESS_BIOMETRIC" + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "srcPath": "" + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/app.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..71bc14aec --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; + diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/en-US.json b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/en-US.json rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/i18n/en-US.json diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/zh-CN.json b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/zh-CN.json rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.css b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.css similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.css rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.css diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.hml b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.hml rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.hml diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.js similarity index 80% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.js rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.js index f818fec4c..7c3c73abb 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.js +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/MainAbility/pages/index/index.js @@ -1,72 +1,60 @@ -/* - * 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 {Core, ExpectExtend} from 'deccjsunit/index' -import fileio from '@ohos.fileio' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow start') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - const configService = core.getDefaultService('config') - this.timeout = 35000; - configService.setConfig(this) - require('../../../test/ListTest') - core.execute() - console.info('onShow end') - }, - onReady() { - }, - fileSave(caseNum, codeNum, ...code) { - console.log(caseNum + ' fileSave start'); - var path = "/data/config.dat" - let fd = fileio.openSync(path, 0o102, 0o666); - var message = caseNum + "\r\n" + codeNum + "\r\n"; - for(var i = 0; i < code.length; i++){ - message = message + code[i] + "\r\n"; - } - fileio.writeSync(fd, message); - fileio.closeSync(fd); - console.log(caseNum + ' fileSave end'); - }, - fileSaveB(caseNum, code) { - console.log(caseNum + ' fileSave start'); - var path = "/data/config.dat" - let fd = fileio.openSync(path, 0o102, 0o666); - var message = code; - fileio.writeSync(fd, message); - fileio.closeSync(fd); - console.log(caseNum + ' fileSave end'); - }, - saveNull() { - console.log('JSAPI null file faceid.dat start'); - var path = "/data/faceId.dat" - let fd = fileio.openSync(path, 0o102, 0o666); - var message = ""; - fileio.writeSync(fd, message); - fileio.closeSync(fd); - console.log('JSAPI null file faceid.dat end'); - }, -} +/* + * 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 fileio from '@ohos.fileio' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow start') + + }, + onReady() { + }, + fileSave(caseNum, codeNum, ...code) { + console.log(caseNum + ' fileSave start'); + var path = "/data/config.dat" + let fd = fileio.openSync(path, 0o102, 0o666); + var message = caseNum + "\r\n" + codeNum + "\r\n"; + for(var i = 0; i < code.length; i++){ + message = message + code[i] + "\r\n"; + } + fileio.writeSync(fd, message); + fileio.closeSync(fd); + console.log(caseNum + ' fileSave end'); + }, + fileSaveB(caseNum, code) { + console.log(caseNum + ' fileSave start'); + var path = "/data/config.dat" + let fd = fileio.openSync(path, 0o102, 0o666); + var message = code; + fileio.writeSync(fd, message); + fileio.closeSync(fd); + console.log(caseNum + ' fileSave end'); + }, + saveNull() { + console.log('JSAPI null file faceid.dat start'); + var path = "/data/faceId.dat" + let fd = fileio.openSync(path, 0o102, 0o666); + var message = ""; + fileio.writeSync(fd, message); + fileio.closeSync(fd); + console.log('JSAPI null file faceid.dat end'); + }, +} diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/app.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/app.js similarity index 96% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/app.js rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/app.js index 2d316a0a0..875191631 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/app.js +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/app.js @@ -1,22 +1,23 @@ -/* - * 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. - */ -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; +/* + * 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. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/en-US.json b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/zh-CN.json b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.css b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.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; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.hml b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..05ba57825 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/ListTest.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/ListTest.js new file mode 100644 index 000000000..67380c83a --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/ListTest.js @@ -0,0 +1,21 @@ +/* + * 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 ActsAmsCallBackFourthScene from './execute.js' +import ActsAmsCallBackFourthScene from './enumTest.js' +export default function testsuite() { + userAuthTestEnum() + userAuthTestExecute() +} + diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/enumTest.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/enumTest.js similarity index 93% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/enumTest.js rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/enumTest.js index ea7953e13..f16ef4adf 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/enumTest.js +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/enumTest.js @@ -14,12 +14,13 @@ */ import userAuth from '@ohos.userIAM.userAuth' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -var index = require('../default/pages/index/index.js'); +var index = require('../MainAbility/pages/index/index.js'); +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' /** * test case */ +export default function userAuthTestEnum() { describe('userAuthTestEnum', function () { beforeEach(function(done) { let waitTime = 1000; @@ -161,4 +162,5 @@ describe('userAuthTestEnum', function () { expect(typeof userAuth.AuthenticationResult.GENERAL_ERROR !==undefined).assertTrue() expect(userAuth.AuthenticationResult.GENERAL_ERROR).assertEqual(100) }) -}) \ No newline at end of file +}) +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js similarity index 95% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js index 948e89560..3fb916a26 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/js/test/execute.js @@ -14,13 +14,14 @@ */ import userAuth from '@ohos.userIAM.userAuth' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -var index = require('../default/pages/index/index.js'); +var index = require('../MainAbility/pages/index/index.js'); var waitFlag = false; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' /** * test case */ +export default function AbilityDisable() { describe('userAuthTestExecute', function () { beforeEach(function(done) { let waitTime = 1000; @@ -120,3 +121,4 @@ describe('userAuthTestExecute', function () { console.log("JSAPI_Function_Execute_2100 end"); }) }) +} diff --git a/useriam/face_auth/js_api_test/function_test/userauth/src/main/resources/base/element/string.json b/useriam/face_auth/js_api_test/function_test/userauth/src/main/resources/base/element/string.json new file mode 100644 index 000000000..6341f7fcb --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauth/src/main/resources/base/element/string.json @@ -0,0 +1,44 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/media/icon.png b/useriam/face_auth/js_api_test/function_test/userauth/src/main/resources/base/media/icon.png similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/media/icon.png rename to useriam/face_auth/js_api_test/function_test/userauth/src/main/resources/base/media/icon.png diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/BUILD.gn b/useriam/face_auth/js_api_test/function_test/userauthpart2/BUILD.gn index e3eeb5921..4f839ab20 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/BUILD.gn +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/BUILD.gn @@ -9,12 +9,12 @@ # 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. +# limitations under the License. import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsUserauthTwoTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsUserauthTwoTest") { hap_name = "ActsUserauthTwoTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/Test.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/Test.json index 1f6f0b231..b083f183e 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/Test.json +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/Test.json @@ -1,38 +1,39 @@ -{ - "description": "Configuration for hjunit demo Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "900000", - "package": "com.example.myapplication101", - "shell-timeout": "600000" - }, - "kits": [ - { - "test-file-name": [ - "ActsUserauthTwoTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - }, - { - "type": "ShellKit", - "run-command": [ - "remount", - "mkdir /data/test" - ] - }, - { - "type": "PushKit", - "push": [ - "ActsUserauthTwoTest.hap->/data/test/ActsUserauthTwoTest.hap" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "chmod 644 /data/test/*.hap", - "chmod 777 -R data" - ] - } - ] -} +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "900000", + "shell-timeout": "900000", + "bundle-name": "com.example.myapplication101", + "package-name": "com.example.myapplication101" + }, + "kits": [ + { + "test-file-name": [ + "ActsUserauthTwoTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsUserauthTwoTest.hap->/data/test/ActsUserauthTwoTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap", + "chmod 777 -R data" + ] + } + ] +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/config.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/config.json deleted file mode 100644 index d87573df9..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "app": { - "bundleName": "com.example.myapplication101", - "vendor": "example", - "version": { - "code": 12, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.myapplication101", - "name": ".MyApplication", - "mainAbility": "com.example.myapplication101.MainAbility", - "deviceType": [ - "phone", - "tablet", - "tv", - "wearable" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.myapplication101.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", - "type": "page", - "launchType": "standard", - "visible": true - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.ACCESS_BIOMETRIC" - }, - { - "name": "ohos.permission.USE_USER_IDM" - }, - { - "name": "ohos.permission.MANAGE_USER_IDM" - }, - { - "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL" - }, - { - "name": "ohos.permission.ACCESS_PIN_AUTH" - } - ] - } -} diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 0676b40b1..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 {Core, ExpectExtend} from 'deccjsunit/index' -import fileio from '@ohos.fileio' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow start') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - const configService = core.getDefaultService('config') - this.timeout = 35000; - configService.setConfig(this) - require('../../../test/List.test.js') - core.execute() - console.info('onShow end') - }, - onReady() { - }, -} diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/resources/base/element/string.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index 0bae6bd40..000000000 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "mainability_description", - "value": "JS_Empty Ability" - } - ] -} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/config.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/config.json new file mode 100644 index 000000000..358611b86 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/config.json @@ -0,0 +1,115 @@ +{ + "app": { + "bundleName": "com.example.myapplication101", + "vendor": "example", + "version": { + "code": 12, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication101", + "name": ".entry", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet", + "tv", + "wearable" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.ACCESS_BIOMETRIC" + }, + { + "name": "ohos.permission.USE_USER_IDM" + }, + { + "name": "ohos.permission.MANAGE_USER_IDM" + }, + { + "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL" + }, + { + "name": "ohos.permission.ACCESS_PIN_AUTH" + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "srcPath": "" + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/app.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/app.js similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/app.js rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/app.js diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/i18n/en-US.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/i18n/en-US.json rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/i18n/en-US.json diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/i18n/zh-CN.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/i18n/zh-CN.json rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.css b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.css similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.css rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.css diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.hml b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/default/pages/index/index.hml rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.hml diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..440a39998 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,30 @@ +/* + * 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 fileio from '@ohos.fileio' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow start') + }, + onReady() { + }, +} diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/app.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/en-US.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/zh-CN.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.css b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.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; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.hml b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/List.test.js similarity index 80% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/List.test.js index 19131de46..62b597a38 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/List.test.js +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/List.test.js @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -require('./Security_IAM_PIN_Kit_CallbackJsunit.test.js') - +import userauthTest from './Security_IAM_PIN_Kit_CallbackJsunit.test.js' +export default function testsuite() { + userauthTest() +} diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js similarity index 96% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js index 5d6e92b0c..7beb362d3 100644 --- a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/js/test/Security_IAM_PIN_Kit_CallbackJsunit.test.js @@ -13,12 +13,13 @@ * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index' +import {describe, it, expect} from '@ohos/hypium' import userAuthNorth from '@ohos.userIAM.userAuth' let UserAuthKit = new userAuthNorth.UserAuth() +export default function userauthTest() { describe('userauthTest', function () { /* @@ -208,3 +209,4 @@ describe('userauthTest', function () { }) +} diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/resources/base/element/string.json b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/resources/base/element/string.json new file mode 100644 index 000000000..8afb12da3 --- /dev/null +++ b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/resources/base/media/icon.png b/useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/resources/base/media/icon.png similarity index 100% rename from useriam/face_auth/js_api_test/function_test/userauthpart2/entry/src/main/js/resources/base/media/icon.png rename to useriam/face_auth/js_api_test/function_test/userauthpart2/src/main/resources/base/media/icon.png -- GitLab