diff --git a/storage/BUILD.gn b/storage/BUILD.gn index ad14746a324a3f249a70906abee41e288da219d8..ff332d555d8ed70d6de8a2b6ad70709569fef5ed 100644 --- a/storage/BUILD.gn +++ b/storage/BUILD.gn @@ -21,6 +21,7 @@ group("storage") { "storagefileiov9jstest:storagefileiov9_js_test", "storagefilejstest:storagefile_js_test", "storagefileurijstest:storagefileuri_js_test", + "storagepickerjstest:storagepicker_js_test", "storagesecuritylabeljstest:storagesecuritylabel_js_test", "storagestatfsjstest:storagestatfs_js_test", "storagestatisticsjstest:storagestatistics_js_test", diff --git a/storage/storagepickerjstest/AppScope/app.json b/storage/storagepickerjstest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..1afa781d3a8125c2b34a8743a39e00d2c8a786ea --- /dev/null +++ b/storage/storagepickerjstest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "ohos.acts.storage.picker", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/storage/storagepickerjstest/AppScope/resources/base/element/string.json b/storage/storagepickerjstest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9e92a688888b69b121df793408b06b89cd3383fe --- /dev/null +++ b/storage/storagepickerjstest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"storagePicker" + } + ] +} \ No newline at end of file diff --git a/storage/storagepickerjstest/AppScope/resources/base/media/app_icon.png b/storage/storagepickerjstest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/storage/storagepickerjstest/AppScope/resources/base/media/app_icon.png differ diff --git a/storage/storagepickerjstest/BUILD.gn b/storage/storagepickerjstest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8ba0e4ba0ab7664c17f322e97d193857aa9e5a65 --- /dev/null +++ b/storage/storagepickerjstest/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("storagepicker_js_test") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":storagepicker_js_assets", + ":storagepicker_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsStoragePickerJSTest" +} + +ohos_app_scope("storagepicker_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("storagepicker_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("storagepicker_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":storagepicker_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/storage/storagepickerjstest/Test.json b/storage/storagepickerjstest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..2fbb14d77dba673d1017e2d555a93dd2043d3f41 --- /dev/null +++ b/storage/storagepickerjstest/Test.json @@ -0,0 +1,65 @@ +{ + "description": "Configuration for storage picker Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.storage.picker", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 100000 + }, + "kits": [ + { + "type": "ShellKit", + "pre-push": [], + "run-command": [ + "rm -rf /storage/media/100/local/files/*", + "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", + "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", + "mkdir -p /storage/media/100/local/temp", + "param set persist.ace.testmode.enabled 1", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ] + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/01.jpg", + "cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/01.mp3", + "cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/01.mp4", + "cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/01.dat", + + "chmod -R 777 /storage/media/100/local/files/*", + "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", + "hilog -Q pidoff", + "hilog -p off", + "hilog -b I", + "hilog -b D -D 0xD002B70", + "scanner", + "sleep 10" + ], + "teardown-command": [ + "hilog -b X -D 0xD002B70" + ] + }, + { + "test-file-name": [ + "ActsStoragePickerJSTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/Application/AbilityStage.ts b/storage/storagepickerjstest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/storage/storagepickerjstest/entry/src/main/ets/MainAbility/MainAbility.ts b/storage/storagepickerjstest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..7bf9231bc36654ff4806a90a52984ec413384953 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,37 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.context = this.context; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/MainAbility/pages/index/index.ets b/storage/storagepickerjstest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..61adec753ccbe22dadb12d30745894f82df7c8a4 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/TestAbility/TestAbility.ts b/storage/storagepickerjstest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..41706ca30a8f9e459e6759576894ab3386f30ffb --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + var permissions=['ohos.permission.START_ABILITIES_FROM_BACKGROUND'] + this.context.requestPermissionsFromUser(permissions,(err,result) => {}) + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/TestAbility/pages/index.ets b/storage/storagepickerjstest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cf6eda5d963e40bc2e277218b30397f3ad43b09 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/storage/storagepickerjstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b6d3d5798810b63d39012677856a809ca22291 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/Common.ets b/storage/storagepickerjstest/entry/src/main/ets/test/Common.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6b3ce02b81fa4049b5556f4838d9a20ae11b28f --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/Common.ets @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest' + +export async function getPermission(context) { + var permissions=['ohos.permission.START_ABILITIES_FROM_BACKGROUND'] + context.requestPermissionsFromUser(permissions,(err,result) => {}) +} + +export async function doSingleSelect(testNum) { + let driver = Driver.create(); + await driver.delayMs(1000); + let columns = await driver.findComponents(ON.type("Column").clickable(true)); + console.info(`${testNum}::doSingleSelect columns: ${columns}`); + if (columns != undefined) { + await columns[columns.length - 1].click(); + await driver.delayMs(1000); + } + + let on = ON.text("选择图片"); + let rows = await driver.findComponents(ON.isAfter(on).type("Row").clickable(true)); + console.info(`${testNum}::doSingleSelect rows: ${rows}`); + if (rows != undefined) { + await rows[0].click(); + } +} + +export async function doMultiSelect(testNum, selectNum, isSelectOriginal) { + let driver = Driver.create(); + await driver.delayMs(1000); + let images = await driver.findComponents(ON.type("Image").clickable(true)); + console.info(`${testNum}::doMultiSelect images: ${images}`); + if (images != undefined) { + for (let i = 0; i < images.length; i++) { + if ((i + 1) % 2 == 0 && (i + 1) / 2 <= selectNum) { + await images[i].click(); + } + } + await driver.delayMs(1000); + } + + if (isSelectOriginal) { + let buttonOrigin = await driver.findComponent(ON.type("Radio")); + console.info(`${testNum}::doMultiSelect buttonOrigin: ${buttonOrigin}`); + if (buttonOrigin != undefined) { + await buttonOrigin.click(); + await driver.delayMs(1000); + } + } + + let text = await driver.findComponent(ON.text("完成")); + console.info(`${testNum}::doMultiSelect text: ${text}`); + if (text != undefined) { + await text.click(); + } +} + +export async function doFileSelect(testNum, dirName, fileName) { + let driver = Driver.create(); + await driver.delayMs(1000); + + let enter = await driver.findComponent(ON.text("com.huawei.hmos.filemanager")); + console.info(`${testNum}::doFileSelect enter: ${enter}`); + if (enter != undefined) { + await enter.click(); + await driver.delayMs(1000); + } + + let buttonAllow = await driver.findComponent(ON.text("允许")); + console.info(`${testNum}::doFileSelect buttonAllow: ${buttonAllow}`); + if (buttonAllow != undefined) { + await buttonAllow.click(); + await driver.delayMs(1000); + } + + let row1 = await driver.findComponent(ON.text("文档")); + console.info(`${testNum}::doFileSelect row1: ${row1}`); + if (row1 != undefined) { + await row1.click(); + await driver.delayMs(1000); + } + + let myPhone = await driver.findComponent(ON.text("我的手机")); + console.info(`${testNum}::doFileSelect myPhone: ${myPhone}`); + if (myPhone != undefined) { + await myPhone.click(); + await driver.delayMs(1000); + } + + let row2 = await driver.findComponent(ON.text(dirName)); + console.info(`${testNum}::doFileSelect row2: ${row2}`); + if (row2 != undefined) { + await row2.click(); + await driver.delayMs(1000); + } + + let asset = await driver.findComponent(ON.text(fileName)); + console.info(`${testNum}::doFileSelect asset: ${asset}`); + if (asset != undefined) { + await asset.click(); + await driver.delayMs(1000); + } + + let button = await driver.findComponent(ON.text("上传")); + if (button != undefined) { + await button.click(); + } +} + +export async function doSave(testNum, dirName) { + let driver = Driver.create(); + await driver.delayMs(1000); + + let enter = await driver.findComponent(ON.text("com.huawei.hmos.filemanager")); + console.info(`${testNum}::doSave enter: ${enter}`); + if (enter != undefined) { + await enter.click(); + await driver.delayMs(1000); + } + + let buttonAllow = await driver.findComponent(ON.text("允许")); + console.info(`${testNum}::doSave buttonAllow: ${buttonAllow}`); + if (buttonAllow != undefined) { + await buttonAllow.click(); + await driver.delayMs(1000); + } + + let row1 = await driver.findComponent(ON.text("文档")); + console.info(`${testNum}::doSave row1: ${row1}`); + if (row1 != undefined) { + await row1.click(); + await driver.delayMs(1000); + } + + let myPhone = await driver.findComponent(ON.text("我的手机")); + console.info(`${testNum}::doFileSelect myPhone: ${myPhone}`); + if (myPhone != undefined) { + await myPhone.click(); + await driver.delayMs(1000); + } + + let row2 = await driver.findComponent(ON.text(dirName)); + console.info(`${testNum}::doSave row2: ${row2}`); + if (row2 != undefined) { + await row2.click(); + await driver.delayMs(1000); + } + + let button = await driver.findComponent(ON.text("保存")); + if (button != undefined) { + await button.click(); + } +} + +export async function saveAndConcel(testNum) { + let driver = Driver.create(); + await driver.delayMs(1000); + + let enter = await driver.findComponent(ON.text("com.huawei.hmos.filemanager")); + console.info(`${testNum}::saveAndConcel enter: ${enter}`); + if (enter != undefined) { + await enter.click(); + await driver.delayMs(1000); + } + + let buttonAllow = await driver.findComponent(ON.text("允许")); + if (buttonAllow != undefined) { + await buttonAllow.click(); + await driver.delayMs(1000); + } + + let button = await driver.findComponent(ON.text("取消")); + if (button != undefined) { + await button.click(); + } +} \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/List.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7780ed2a1905a6d86de5969a22f535c3e4b1f750 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import photoPickerCallback from './photoPickerCallback.test.ets' +import photoPickerPromise from './photoPickerPromise.test.ets' +import documentPickerCallback from './documentPickerCallback.test.ets' +import documentPickerPromise from './documentPickerPromise.test.ets' +import audioPickerCallback from './audioPickerCallback.test.ets' +import audioPickerPromise from './audioPickerPromise.test.ets' +export default function testsuite() { + photoPickerCallback(globalThis.abilityContext) + photoPickerPromise(globalThis.abilityContext) + documentPickerCallback(globalThis.abilityContext) + documentPickerPromise(globalThis.abilityContext) + audioPickerCallback(globalThis.abilityContext) + audioPickerPromise(globalThis.abilityContext) +} \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/audioPickerCallback.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/audioPickerCallback.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c99713ed1a882aee5403d2fd36767b8f204f5413 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/audioPickerCallback.test.ets @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common" +import picker from '@ohos.file.picker' + +export default function audioPickerCallback(abilityContext) { + describe("audioPickerCallback", function () { + async function select(testNum, done, dirName, fileName) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.select((err, result) => { + if (err != undefined) { + console.info(`${testNum}::select fail, err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::select result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }); + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::select error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function selectWithOption(testNum, done, option, dirName, fileName) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.select(option, (err, result) => { + if (err != undefined) { + console.info(`${testNum}::selectWithOption fail, err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::selectWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }); + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithoutSelect(testNum, done) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.save((err, result) => { + if (err != undefined) { + console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::saveWithoutSelect result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(0); + done(); + }); + await saveAndConcel(testNum); + } catch (error) { + console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithOption(testNum, done, option, dirName) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.save(option, (err, result) => { + if (err != undefined) { + console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::saveWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }); + await doSave(testNum, dirName); + } catch (error) { + console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SELECT_CALLBACK_0000 + * @tc.name : audiopicker_select_callback_000 + * @tc.desc : select with option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("audiopicker_select_callback_000", 0, async function (done) { + let testNum = "audiopicker_select_callback_000"; + let option = new picker.AudioSelectOptions(); + let dirName = "Audios"; + let fileName = "01.mp3"; + await selectWithOption(testNum, done, option, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SELECT_CALLBACK_0100 + * @tc.name : audiopicker_select_callback_001 + * @tc.desc : select without option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("audiopicker_select_callback_001", 0, async function (done) { + let testNum = "audiopicker_select_callback_001"; + let dirName = "Audios"; + let fileName = "01.mp3"; + await select(testNum, done, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SAVE_CALLBACK_0000 + * @tc.name : audiopicker_save_callback_000 + * @tc.desc : save mp3 in Audios + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("audiopicker_save_callback_000", 0, async function (done) { + let testNum = "audiopicker_save_callback_000"; + let option = new picker.AudioSaveOptions(); + option.newFileNames = ["AudioViewPicker01.mp3"]; + let saveDir = "Audios"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SAVE_CALLBACK_0100 + * @tc.name : audiopicker_save_callback_001 + * @tc.desc : save without option, cancel + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("audiopicker_save_callback_001", 0, async function (done) { + let testNum = "audiopicker_save_callback_001"; + await saveWithoutSelect(testNum, done); + }); + }); +} diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..814bd156d25d3508813b7ef40fdd760d9df5d152 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common" +import picker from '@ohos.file.picker' + +export default function audioPickerPromise(abilityContext) { + describe("audioPickerPromise", function () { + async function select(testNum, done, dirName, fileName) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.select().then((result) => { + console.info(`${testNum}::select result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::select err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::select error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function selectWithOption(testNum, done, option, dirName, fileName) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.select(option).then((result) => { + console.info(`${testNum}::selectWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::selectWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithoutSelect(testNum, done) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.save().then((result) => { + console.info(`${testNum}::saveWithoutSelect result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(0); + done(); + }).catch((err) => { + console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await saveAndConcel(testNum); + } catch (error) { + console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithOption(testNum, done, option, dirName) { + try { + let audioPicker = new picker.AudioViewPicker(); + audioPicker.save(option).then((result) => { + console.info(`${testNum}::saveWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doSave(testNum, dirName); + } catch (error) { + console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SELECT_PROMISE_0000 + * @tc.name : audiopicker_select_promise_000 + * @tc.desc : select with option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("audiopicker_select_promise_000", 0, async function (done) { + let testNum = "audiopicker_select_promise_000"; + let option = new picker.AudioSelectOptions(); + let dirName = "Audios"; + let fileName = "01.mp3"; + await selectWithOption(testNum, done, option, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SELECT_PROMISE_0100 + * @tc.name : audiopicker_select_promise_001 + * @tc.desc : select without option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("audiopicker_select_promise_001", 0, async function (done) { + let testNum = "audiopicker_select_promise_001"; + let dirName = "Audios"; + let fileName = "01.mp3"; + await select(testNum, done, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SAVE_PROMISE_0000 + * @tc.name : audiopicker_save_promise_000 + * @tc.desc : save mp3 in Audios + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("audiopicker_save_promise_000", 0, async function (done) { + let testNum = "audiopicker_save_promise_000"; + let option = new picker.AudioSaveOptions(); + option.newFileNames = ["AudioViewPicker01.mp3"]; + let saveDir = "Audios"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_AUDIOPICKER_SAVE_PROMISE_0100 + * @tc.name : audiopicker_save_promise_001 + * @tc.desc : save without option, cancel + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("audiopicker_save_promise_001", 0, async function (done) { + let testNum = "audiopicker_save_promise_001"; + await saveWithoutSelect(testNum, done); + }); + }); +} diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2aeaa2cccbe6b5d808482b6ef4befa7e001f8152 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common" +import picker from '@ohos.file.picker' + +export default function documentPickerCallback(abilityContext) { + describe("documentPickerCallback", function () { + async function select(testNum, done, dirName, fileName) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.select((err, result) => { + if (err != undefined) { + console.info(`${testNum}::select fail, err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::select result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }); + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::select error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function selectWithOption(testNum, done, option, dirName, fileName) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.select(option, (err, result) => { + if (err != undefined) { + console.info(`${testNum}::selectWithOption fail, err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::selectWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }); + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithoutSelect(testNum, done) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.save((err, result) => { + if (err != undefined) { + console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::saveWithoutSelect result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(0); + done(); + }); + await saveAndConcel(testNum); + } catch (error) { + console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithOption(testNum, done, option, dirName) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.save(option, (err, result) => { + if (err != undefined) { + console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::saveWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }); + await doSave(testNum, dirName); + } catch (error) { + console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SELECT_CALLBACK_0000 + * @tc.name : documentpicker_select_callback_000 + * @tc.desc : select with option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("documentpicker_select_callback_000", 0, async function (done) { + let testNum = "documentpicker_select_callback_000"; + let option = new picker.DocumentSelectOptions(); + let dirName = "Pictures"; + let fileName = "01.jpg"; + await selectWithOption(testNum, done, option, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SELECT_CALLBACK_0100 + * @tc.name : documentpicker_select_callback_001 + * @tc.desc : select without option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_select_callback_001", 0, async function (done) { + let testNum = "documentpicker_select_callback_001"; + let dirName = "Pictures"; + let fileName = "01.jpg"; + await select(testNum, done, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_CALLBACK_0000 + * @tc.name : documentpicker_save_callback_000 + * @tc.desc : save image in Pictures + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("documentpicker_save_callback_000", 0, async function (done) { + let testNum = "documentpicker_save_callback_000"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.jpg"]; + let saveDir = "Pictures"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_CALLBACK_0100 + * @tc.name : documentpicker_save_callback_001 + * @tc.desc : save file in Documents + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("documentpicker_save_callback_001", 0, async function (done) { + let testNum = "documentpicker_save_callback_001"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.dat"]; + let saveDir = "Documents"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_CALLBACK_0200 + * @tc.name : documentpicker_save_callback_002 + * @tc.desc : save mp4 in Videos + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_save_callback_002", 0, async function (done) { + let testNum = "documentpicker_save_callback_002"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.mp4"]; + let saveDir = "Videos"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_CALLBACK_0300 + * @tc.name : documentpicker_save_callback_003 + * @tc.desc : save mp3 in Audios + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_save_callback_003", 0, async function (done) { + let testNum = "documentpicker_save_callback_003"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.mp3"]; + let saveDir = "Audios"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_CALLBACK_0400 + * @tc.name : documentpicker_save_callback_004 + * @tc.desc : save without option, cancel + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_save_callback_004", 0, async function (done) { + let testNum = "documentpicker_save_callback_004"; + await saveWithoutSelect(testNum, done); + }); + }); +} diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..48507cdd48b18fe5915f98a4ab00b64f24840c6d --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common" +import picker from '@ohos.file.picker' + +export default function documentPickerPromise(abilityContext) { + describe("documentPickerPromise", function () { + async function select(testNum, done, dirName, fileName) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.select().then((result) => { + console.info(`${testNum}::select result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::select err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::select error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function selectWithOption(testNum, done, option, dirName, fileName) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.select(option).then((result) => { + console.info(`${testNum}::selectWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::selectWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doFileSelect(testNum, dirName, fileName); + } catch (error) { + console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithoutSelect(testNum, done) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.save().then((result) => { + console.info(`${testNum}::saveWithoutSelect result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(0); + done(); + }).catch((err) => { + console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await saveAndConcel(testNum); + } catch (error) { + console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithOption(testNum, done, option, dirName) { + try { + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.save(option).then((result) => { + console.info(`${testNum}::saveWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doSave(testNum, dirName); + } catch (error) { + console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SELECT_PROMISE_0000 + * @tc.name : documentpicker_select_promise_000 + * @tc.desc : select with option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("documentpicker_select_promise_000", 0, async function (done) { + let testNum = "documentpicker_select_promise_000"; + let option = new picker.DocumentSelectOptions(); + let dirName = "Pictures"; + let fileName = "01.jpg"; + await selectWithOption(testNum, done, option, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SELECT_PROMISE_0100 + * @tc.name : documentpicker_select_promise_001 + * @tc.desc : select without option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_select_promise_001", 0, async function (done) { + let testNum = "documentpicker_select_promise_001"; + let dirName = "Pictures"; + let fileName = "01.jpg"; + await select(testNum, done, dirName, fileName); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_PROMISE_0000 + * @tc.name : documentpicker_save_promise_000 + * @tc.desc : save image in Pictures + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("documentpicker_save_promise_000", 0, async function (done) { + let testNum = "documentpicker_save_promise_000"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.jpg"]; + let saveDir = "Pictures"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_PROMISE_0100 + * @tc.name : documentpicker_save_promise_001 + * @tc.desc : save file in Documents + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("documentpicker_save_promise_001", 0, async function (done) { + let testNum = "documentpicker_save_promise_001"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.dat"]; + let saveDir = "Documents"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_PROMISE_0200 + * @tc.name : documentpicker_save_promise_002 + * @tc.desc : save mp4 in Videos + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_save_promise_002", 0, async function (done) { + let testNum = "documentpicker_save_promise_002"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.mp4"]; + let saveDir = "Videos"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_DOCUMENTPICKER_SAVE_PROMISE_0300 + * @tc.name : documentpicker_save_promise_003 + * @tc.desc : save mp3 in Audios + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("documentpicker_save_promise_003", 0, async function (done) { + let testNum = "documentpicker_save_promise_003"; + let option = new picker.DocumentSaveOptions(); + option.newFileNames = ["DocumentViewPicker01.mp3"]; + let saveDir = "Audios"; + await saveWithOption(testNum, done, option, saveDir); + }); + }); +} diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f48aaad293650b0656aba1911abe2d65b5542ad3 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { getPermission, doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common" +import picker from '@ohos.file.picker' + +export default function photoPickerCallback(abilityContext) { + describe("photoPickerCallback", function () { + beforeAll(async function () { + //await getPermission(abilityContext); + }); + + async function select(testNum, done, isSelectOriginal, expectSelectNum = 2) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.select((err, result) => { + if (err != undefined) { + console.info(`${testNum}::select err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::select result: ${JSON.stringify(result)}`); + expect(result.photoUris.length).assertEqual(expectSelectNum); + expect(result.isOriginalPhoto).assertEqual(isSelectOriginal); + done(); + }); + await doMultiSelect(testNum, expectSelectNum, isSelectOriginal); + } catch (error) { + console.info(`${testNum}::select error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function selectWithOption(testNum, done, option, expectSelectNum) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.select(option, (err, result) => { + if (err != undefined) { + console.info(`${testNum}::selectWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::selectWithOption result: ${JSON.stringify(result)}`); + expect(result.photoUris.length).assertEqual(expectSelectNum); + done(); + }); + if (option.maxSelectNumber != undefined && option.maxSelectNumber == 1) { + await doSingleSelect(testNum); + } else { + await doMultiSelect(testNum, expectSelectNum, false); + } + } catch (error) { + console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithoutSelect(testNum, done) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.save((err, result) => { + if (err != undefined) { + console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::saveWithoutSelect result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(0); + done(); + }); + await saveAndConcel(testNum); + } catch (error) { + console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithOption(testNum, done, option, dirName) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.save(option, (err, result) => { + if (err != undefined) { + console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + console.info(`${testNum}::saveWithOption result: ${JSON.stringify(result)}`); + expect(result != undefined).assertTrue(); + done(); + }); + await doSave(testNum, dirName); + } catch (error) { + console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0000 + * @tc.name : photopicker_select_callback_000 + * @tc.desc : select image + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_callback_000", 0, async function (done) { + let testNum = "photopicker_select_callback_000"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0100 + * @tc.name : photopicker_select_callback_001 + * @tc.desc : select video + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_callback_001", 0, async function (done) { + let testNum = "photopicker_select_callback_001"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.VIDEO_TYPE; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0200 + * @tc.name : photopicker_select_callback_002 + * @tc.desc : select image&video + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_callback_002", 0, async function (done) { + let testNum = "photopicker_select_callback_002"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0300 + * @tc.name : photopicker_select_callback_003 + * @tc.desc : select image&video, singleSelect + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("photopicker_select_callback_003", 0, async function (done) { + let testNum = "photopicker_select_callback_003"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + option.maxSelectNumber = 1; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0400 + * @tc.name : photopicker_select_callback_004 + * @tc.desc : select image&video, multipleselect + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("photopicker_select_callback_004", 0, async function (done) { + let testNum = "photopicker_select_callback_004"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + option.maxSelectNumber = 2; + let expectSelectNum = 2; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0500 + * @tc.name : photopicker_select_callback_005 + * @tc.desc : select image&video, default selectNum + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_callback_005", 0, async function (done) { + let testNum = "photopicker_select_callback_005"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + option.maxSelectNumber = 0; + let expectSelectNum = 2; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_CALLBACK_0600 + * @tc.name : photopicker_select_callback_006 + * @tc.desc : select without option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_callback_006", 0, async function (done) { + let testNum = "photopicker_select_callback_006"; + let expectSelectNum = 2; + let isSelectOriginal = true; + await select(testNum, done, isSelectOriginal, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SAVE_CALLBACK_0000 + * @tc.name : photopicker_save_callback_000 + * @tc.desc : save jpg in Pictures + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("photopicker_save_callback_000", 0, async function (done) { + let testNum = "photopicker_save_callback_000"; + let option = new picker.PhotoSaveOptions(); + option.newFileNames = ["PhotoViewPicker01.jpg"]; + let saveDir = "Pictures"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SAVE_CALLBACK_0100 + * @tc.name : photopicker_save_callback_001 + * @tc.desc : save mp4 in Videos + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_save_callback_001", 0, async function (done) { + let testNum = "photopicker_save_callback_001"; + let option = new picker.PhotoSaveOptions(); + option.newFileNames = ["PhotoViewPicker01.mp4"]; + let saveDir = "Videos"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SAVE_CALLBACK_0200 + * @tc.name : photopicker_save_callback_002 + * @tc.desc : save without option, cancel + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_save_callback_002", 0, async function (done) { + let testNum = "photopicker_save_callback_002"; + await saveWithoutSelect(testNum, done); + }); + }); +} diff --git a/storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets b/storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..44061082100a906bd7a2770760b90b920f07e5b2 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common" +import picker from '@ohos.file.picker' + +export default function photoPickerPromise(abilityContext) { + describe("photoPickerPromise", function () { + async function select(testNum, done, isSelectOriginal, expectSelectNum = 2) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.select().then((result) => { + console.info(`${testNum}::select result: ${JSON.stringify(result)}`); + expect(result.photoUris.length).assertEqual(expectSelectNum); + done(); + }).catch((err) => { + console.info(`${testNum}::select err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doMultiSelect(testNum, expectSelectNum, isSelectOriginal); + } catch (error) { + console.info(`${testNum}::select error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function selectWithOption(testNum, done, option, expectSelectNum) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.select(option).then((result) => { + console.info(`${testNum}::selectWithOption result: ${JSON.stringify(result)}`); + expect(result.photoUris.length).assertEqual(expectSelectNum); + done(); + }).catch((err) => { + console.info(`${testNum}::selectWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + if (option.maxSelectNumber != undefined && option.maxSelectNumber == 1) { + await doSingleSelect(testNum); + } else { + await doMultiSelect(testNum, expectSelectNum, false); + } + } catch (error) { + console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithoutSelect(testNum, done) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.save().then((result) => { + console.info(`${testNum}::saveWithoutSelect result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(0); + done(); + }).catch((err) => { + console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await saveAndConcel(testNum); + } catch (error) { + console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + async function saveWithOption(testNum, done, option, dirName) { + try { + let photoPicker = new picker.PhotoViewPicker(); + photoPicker.save(option).then((result) => { + console.info(`${testNum}::saveWithOption result: ${JSON.stringify(result)}`); + expect(result.length).assertEqual(1); + done(); + }).catch((err) => { + console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + }) + await doSave(testNum, dirName); + } catch (error) { + console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0000 + * @tc.name : photopicker_select_promise_000 + * @tc.desc : select image + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_promise_000", 0, async function (done) { + let testNum = "photopicker_select_promise_000"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0100 + * @tc.name : photopicker_select_promise_001 + * @tc.desc : select video + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_promise_001", 0, async function (done) { + let testNum = "photopicker_select_promise_001"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.VIDEO_TYPE; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0200 + * @tc.name : photopicker_select_promise_002 + * @tc.desc : select image&video + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_promise_002", 0, async function (done) { + let testNum = "photopicker_select_promise_002"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0300 + * @tc.name : photopicker_select_promise_003 + * @tc.desc : select image&video, singleSelect + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("photopicker_select_promise_003", 0, async function (done) { + let testNum = "photopicker_select_promise_003"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + option.maxSelectNumber = 1; + let expectSelectNum = 1; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0400 + * @tc.name : photopicker_select_promise_004 + * @tc.desc : select image&video, multipleselect + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("photopicker_select_promise_004", 0, async function (done) { + let testNum = "photopicker_select_promise_004"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + option.maxSelectNumber = 2; + let expectSelectNum = 2; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0500 + * @tc.name : photopicker_select_promise_005 + * @tc.desc : select image&video, default selectNum + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_promise_005", 0, async function (done) { + let testNum = "photopicker_select_promise_005"; + let option = new picker.PhotoSelectOptions(); + option.MIMEType = picker.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE; + option.maxSelectNumber = 0; + let expectSelectNum = 2; + await selectWithOption(testNum, done, option, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SELECT_PROMISE_0600 + * @tc.name : photopicker_select_promise_006 + * @tc.desc : select without option + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_select_promise_006", 0, async function (done) { + let testNum = "photopicker_select_promise_006"; + let expectSelectNum = 2; + let isSelectOriginal = true; + await select(testNum, done, isSelectOriginal, expectSelectNum); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SAVE_PROMISE_0000 + * @tc.name : photopicker_save_promise_000 + * @tc.desc : save jpg in Pictures + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("photopicker_save_promise_000", 0, async function (done) { + let testNum = "photopicker_save_promise_000"; + let option = new picker.PhotoSaveOptions(); + option.newFileNames = ["PhotoViewPicker01.jpg"]; + let saveDir = "Pictures"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SAVE_PROMISE_0100 + * @tc.name : photopicker_save_promise_001 + * @tc.desc : save mp4 in Videos + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_save_promise_001", 0, async function (done) { + let testNum = "photopicker_save_promise_001"; + let option = new picker.PhotoSaveOptions(); + option.newFileNames = ["PhotoViewPicker01.mp4"]; + let saveDir = "Videos"; + await saveWithOption(testNum, done, option, saveDir); + }); + + /** + * @tc.number : SUB_STORAGE_PHOTOPICKER_SAVE_PROMISE_0200 + * @tc.name : photopicker_save_promise_002 + * @tc.desc : save without option, cancel + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("photopicker_save_promise_002", 0, async function (done) { + let testNum = "photopicker_save_promise_002"; + await saveWithoutSelect(testNum, done); + }); + }); +} diff --git a/storage/storagepickerjstest/entry/src/main/module.json b/storage/storagepickerjstest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..6bef1fbbf7dbda1b48705c171e9b13cc6da5f61b --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/module.json @@ -0,0 +1,50 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "com.example.myapplication.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } + ] + } +} \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/resources/base/element/string.json b/storage/storagepickerjstest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ad3ea7cb2c1df4763ba0582d2efb42e2da8a479a --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsStoragePickerTest" + }, + { + "name": "form_description", + "value": "picker" + }, + { + "name": "serviceability_description", + "value": "picker" + }, + { + "name": "description_application", + "value": "picker test" + }, + { + "name": "app_name", + "value": "ActsStoragePickerTest" + } + ] +} \ No newline at end of file diff --git a/storage/storagepickerjstest/entry/src/main/resources/base/media/icon.png b/storage/storagepickerjstest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/storage/storagepickerjstest/entry/src/main/resources/base/media/icon.png differ diff --git a/storage/storagepickerjstest/entry/src/main/resources/base/profile/main_pages.json b/storage/storagepickerjstest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..ceb075cd80946aade673d707aac904fb8998bce9 --- /dev/null +++ b/storage/storagepickerjstest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/index/index" + ] +} \ No newline at end of file diff --git a/storage/storagepickerjstest/signature/openharmony_sx.p7b b/storage/storagepickerjstest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..01b0bb07e57d2e318cf7a47cb28e4683dd87add2 Binary files /dev/null and b/storage/storagepickerjstest/signature/openharmony_sx.p7b differ