From 1af05e22c158746ba71f0cee160c15b9bab43d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=87=AF=E7=A5=A5?= Date: Fri, 30 Dec 2022 09:25:02 +0800 Subject: [PATCH] fixed 93c99bd from https://gitee.com/jaychao/xts_acts/pulls/7061 Add FileUri Test Module. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张凯祥 --- storage/BUILD.gn | 1 + storage/storagefileurijstest/BUILD.gn | 35 +++++++ storage/storagefileurijstest/Test.json | 19 ++++ .../signature/openharmony_sx.p7b | Bin 0 -> 3427 bytes .../storagefileurijstest/src/main/config.json | 96 +++++++++++++++++ .../src/main/js/MainAbility/app.js | 23 +++++ .../src/main/js/MainAbility/i18n/en-US.json | 6 ++ .../src/main/js/MainAbility/i18n/zh-CN.json | 6 ++ .../main/js/MainAbility/pages/index/index.css | 9 ++ .../main/js/MainAbility/pages/index/index.hml | 5 + .../main/js/MainAbility/pages/index/index.js | 34 ++++++ .../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/test/List.test.js | 19 ++++ .../src/main/js/test/fileuri.test.js | 97 ++++++++++++++++++ .../main/resources/base/element/string.json | 28 +++++ .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes 22 files changed, 545 insertions(+) create mode 100644 storage/storagefileurijstest/BUILD.gn create mode 100644 storage/storagefileurijstest/Test.json create mode 100644 storage/storagefileurijstest/signature/openharmony_sx.p7b create mode 100644 storage/storagefileurijstest/src/main/config.json create mode 100644 storage/storagefileurijstest/src/main/js/MainAbility/app.js create mode 100644 storage/storagefileurijstest/src/main/js/MainAbility/i18n/en-US.json create mode 100644 storage/storagefileurijstest/src/main/js/MainAbility/i18n/zh-CN.json create mode 100644 storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.css create mode 100644 storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.hml create mode 100644 storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.js create mode 100644 storage/storagefileurijstest/src/main/js/TestAbility/app.js create mode 100644 storage/storagefileurijstest/src/main/js/TestAbility/i18n/en-US.json create mode 100644 storage/storagefileurijstest/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.css create mode 100644 storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.hml create mode 100644 storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.js create mode 100644 storage/storagefileurijstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js create mode 100644 storage/storagefileurijstest/src/main/js/test/List.test.js create mode 100644 storage/storagefileurijstest/src/main/js/test/fileuri.test.js create mode 100644 storage/storagefileurijstest/src/main/resources/base/element/string.json create mode 100644 storage/storagefileurijstest/src/main/resources/base/media/icon.png diff --git a/storage/BUILD.gn b/storage/BUILD.gn index e4c6a0da4..ad14746a3 100644 --- a/storage/BUILD.gn +++ b/storage/BUILD.gn @@ -20,6 +20,7 @@ group("storage") { "storagefileiojstest:storagefileio_js_test", "storagefileiov9jstest:storagefileiov9_js_test", "storagefilejstest:storagefile_js_test", + "storagefileurijstest:storagefileuri_js_test", "storagesecuritylabeljstest:storagesecuritylabel_js_test", "storagestatfsjstest:storagestatfs_js_test", "storagestatisticsjstest:storagestatistics_js_test", diff --git a/storage/storagefileurijstest/BUILD.gn b/storage/storagefileurijstest/BUILD.gn new file mode 100644 index 000000000..3f2dec2bc --- /dev/null +++ b/storage/storagefileurijstest/BUILD.gn @@ -0,0 +1,35 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("storagefileuri_js_test") { + hap_profile = "./src/main/config.json" + deps = [ + ":storagefileuri_js_assets", + ":storagefileuri_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsStorageFileUriJsTest" + subsystem_name = "filemanagement" + part_name = "app_file_service" +} +ohos_js_assets("storagefileuri_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} +ohos_resources("storagefileuri_js_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/storage/storagefileurijstest/Test.json b/storage/storagefileurijstest/Test.json new file mode 100644 index 000000000..4b4be45f8 --- /dev/null +++ b/storage/storagefileurijstest/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for storage fileuri Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "shell-timeout": "60000", + "bundle-name": "ohos.acts.storage.fileuri", + "package-name": "ohos.acts.storage.fileuri" + }, + "kits": [ + { + "test-file-name": [ + "ActsStorageFileUriJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/storage/storagefileurijstest/signature/openharmony_sx.p7b b/storage/storagefileurijstest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..33e5146b419e5f79cb81d759cb782a1017a21d33 GIT binary patch literal 3427 zcmcgvYj6|S8P&@MV}uO`3>2^t1XGOcyLwoXDIvSk>S23rR>-y_Ow3AJy)3O{Y2}qn zAyfp)n-E$c;bkxwNPtivF>V_Y(gs3EU`VK&Nil&CCWVqv!Xq>^q`Sf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CoAbn>(5-&z$=Gf#Y9I`unR}*R_9+taP1q-@35l=7r_yCA03mvXPzA zve4iB*}eXy@YQiME7Ha+Inp+-3Y^uQUoyVSJmPJ>cIV}B2U?Zc@m=?#b1!|7b%526 zj@8fcZvA9kP%rJx1$cjE=_Y{j_e+=exYC(JA^ImGf)tRthlo<)6J*i^vLA{kt?)M@ zoH#2z~8@gXOb3q?sF<-n?S7ou09N>odvk-uT!iGAzXm z>%wc0?YmoUcGTaswDlj*$puwr{;#KjiNCyrq$@{9lg3qc+oARUgB@ zTM_UK$l`>O!wDx12-#b2CGpdHC@Hrzd&{fCe|?EpwfpqCg8l34%zzJjS5N5S0ha(U zcBTOO@LOi*(`z?&S`V(=ThP{T`KkVgN;^g`m^V?`T(^D8Na?0C?}kKUeYOI6y#S1R zb=+@5Gk1^eV;;P1`OTJPploVF_n#PgDZH&|#hoQw5@n zBR1don4YiQyEFavo@)goPIRso|M8G&+uX2q@v*tT2=8xdd*cH$s6F`U+6g7oUT=Tx zo%JI&Y`?L1arTYV>&7g;^W3b1g?V?b9KW#QJ85;R6A-=3>5&@wKQ#78bL+Lk2)#T& z3PAAev+DUT(bt~acc;`_zw21Zri+KOk9Fo;oa4@}x@4^WZ1KF|-geVBXRfpl`RGdL zK-R2|_6;$+N+Vm$?c=3)U$^dlcg>pYcLI~Uh9*aTzvx`$^2ntX#Ko|UUha8cv3c^R zMNpCtvm%?q9tS|f6Dec&j@t9&(c%Nc9-KTfgb+LS<9US-Mm`8K(x5DMQ{*;84Nxg$ zaft*6KgZ}ZrHc#@1wo|gY13#9UJh%mlF@yrcEvz|GOi{Mc;sa4|Z~a z$N*5m7~U(-fAUi34_RvUr1Q^a9oh6^#_UzMei&ASR%8F2zxsn^ZGwCmdYzuyDoTGZ dqu-y_oUa&J(8)91Ib(F+Ua+|(xNp&){|B3;O~U{H literal 0 HcmV?d00001 diff --git a/storage/storagefileurijstest/src/main/config.json b/storage/storagefileurijstest/src/main/config.json new file mode 100644 index 000000000..6a331a256 --- /dev/null +++ b/storage/storagefileurijstest/src/main/config.json @@ -0,0 +1,96 @@ +{ + "app": { + "bundleName": "ohos.acts.storage.fileuri", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.storage.fileuri", + "name": ".entry", + "deviceType": [ + "tablet", + "default", + "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/storagefileurijstest/src/main/js/MainAbility/app.js b/storage/storagefileurijstest/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..3a55a2493 --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/MainAbility/app.js @@ -0,0 +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('ohos.acts.storage.fileuri onCreate'); + }, + onDestroy() { + console.info('ohos.acts.storage.fileuri onDestroy'); + } +}; diff --git a/storage/storagefileurijstest/src/main/js/MainAbility/i18n/en-US.json b/storage/storagefileurijstest/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 000000000..ead52ed2e --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "Test" + } +} \ No newline at end of file diff --git a/storage/storagefileurijstest/src/main/js/MainAbility/i18n/zh-CN.json b/storage/storagefileurijstest/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 000000000..3f48f2585 --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "测试" + } +} \ No newline at end of file diff --git a/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.css b/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..6fda79275 --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.hml b/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 000000000..f64b040a5 --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.js b/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..9049ac0ec --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,34 @@ +/* + * 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 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/storagefileurijstest/src/main/js/TestAbility/app.js b/storage/storagefileurijstest/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/storage/storagefileurijstest/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/storagefileurijstest/src/main/js/TestAbility/i18n/en-US.json b/storage/storagefileurijstest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/storage/storagefileurijstest/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/storagefileurijstest/src/main/js/TestAbility/i18n/zh-CN.json b/storage/storagefileurijstest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/storage/storagefileurijstest/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/storagefileurijstest/src/main/js/TestAbility/pages/index/index.css b/storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/storage/storagefileurijstest/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/storagefileurijstest/src/main/js/TestAbility/pages/index/index.hml b/storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.js b/storage/storagefileurijstest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/storage/storagefileurijstest/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/storagefileurijstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/storage/storagefileurijstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/storage/storagefileurijstest/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/storagefileurijstest/src/main/js/test/List.test.js b/storage/storagefileurijstest/src/main/js/test/List.test.js new file mode 100644 index 000000000..1f7817abc --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 fileuri_test from './fileuri.test.js' +export default function testsuite() { + fileuri_test() +} diff --git a/storage/storagefileurijstest/src/main/js/test/fileuri.test.js b/storage/storagefileurijstest/src/main/js/test/fileuri.test.js new file mode 100644 index 000000000..cbc5dbad5 --- /dev/null +++ b/storage/storagefileurijstest/src/main/js/test/fileuri.test.js @@ -0,0 +1,97 @@ +/* + * 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 fileUri from '@ohos.file.fileuri'; +import { + describe, + it, + expect +} +from '@ohos/hypium' + +export default function fileuri_test() { +describe('file_uri_test', function () { + + /** + * @tc.number SUB_STORAGE_FileUri_GetUriFromPath_0000 + * @tc.name FileUri_GetUriFromPath_000 + * @tc.desc Function of API, get Uri from Path. Test normal function. + */ + it('FileUri_GetUriFromPath_000', 0, async function () { + try { + let path = "/data/storage/el2/base/haps/entry/files/sync.jpg"; + let uri = fileUri.getUriFromPath(path); + let result = "file://ohos.acts.storage.fileuri/data/storage/el2/base/haps/entry/files/sync.jpg" + console.log("FileUri_GetUriFromPath_000 uri:" + uri); + console.log("FileUri_GetUriFromPath_000 result:" + result); + expect(uri != "").assertTrue(); + expect(uri == result).assertTrue(); + } catch (e) { + console.log('FileUri_GetUriFromPath_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileUri_GetUriFromPath_0100 + * @tc.name FileUri_GetUriFromPath_001 + * @tc.desc Function of API, get Uri from Path. Test path is empty. + */ + it('FileUri_GetUriFromPath_001', 0, async function () { + try { + let uri = fileUri.getUriFromPath(""); + let result = "file://ohos.acts.storage.fileuri" + console.log("FileUri_GetUriFromPath_001 uri:" + uri); + console.log("FileUri_GetUriFromPath_001 result:" + result); + expect(uri != "").assertTrue(); + expect(uri == result).assertTrue(); + } catch (e) { + console.log('FileUri_GetUriFromPath_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileUri_GetUriFromPath_0200 + * @tc.name FileUri_GetUriFromPath_002 + * @tc.desc Function of API, get Uri from Path. Test argument is empty. + */ + it('FileUri_GetUriFromPath_002', 0, async function () { + try { + fileUri.getUriFromPath(); + expect(false).assertTrue(); + } catch (e) { + console.log('FileUri_GetUriFromPath_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_STORAGE_FileUri_GetUriFromPath_0300 + * @tc.name FileUri_GetUriFromPath_003 + * @tc.desc Function of API, get Uri from Path. Test argument is number. + */ + it('FileUri_GetUriFromPath_003', 0, async function () { + try { + fileUri.getUriFromPath(5); + expect(false).assertTrue(); + } catch (e) { + console.log('FileUri_GetUriFromPath_003 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + +}) +} diff --git a/storage/storagefileurijstest/src/main/resources/base/element/string.json b/storage/storagefileurijstest/src/main/resources/base/element/string.json new file mode 100644 index 000000000..c550020f7 --- /dev/null +++ b/storage/storagefileurijstest/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "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/storage/storagefileurijstest/src/main/resources/base/media/icon.png b/storage/storagefileurijstest/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qo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