Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
78d8d026
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
78d8d026
编写于
3月 07, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 07, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7707 add picker xts
Merge pull request !7707 from yangbo/picker
上级
c99d5cb6
2381071c
变更
25
显示空白变更内容
内联
并排
Showing
25 changed file
with
2014 addition
and
0 deletion
+2014
-0
storage/BUILD.gn
storage/BUILD.gn
+1
-0
storage/storagepickerjstest/AppScope/app.json
storage/storagepickerjstest/AppScope/app.json
+21
-0
storage/storagepickerjstest/AppScope/resources/base/element/string.json
...epickerjstest/AppScope/resources/base/element/string.json
+8
-0
storage/storagepickerjstest/AppScope/resources/base/media/app_icon.png
...gepickerjstest/AppScope/resources/base/media/app_icon.png
+0
-0
storage/storagepickerjstest/BUILD.gn
storage/storagepickerjstest/BUILD.gn
+41
-0
storage/storagepickerjstest/Test.json
storage/storagepickerjstest/Test.json
+65
-0
storage/storagepickerjstest/entry/src/main/ets/Application/AbilityStage.ts
...ckerjstest/entry/src/main/ets/Application/AbilityStage.ts
+9
-0
storage/storagepickerjstest/entry/src/main/ets/MainAbility/MainAbility.ts
...ickerjstest/entry/src/main/ets/MainAbility/MainAbility.ts
+37
-0
storage/storagepickerjstest/entry/src/main/ets/MainAbility/pages/index/index.ets
...test/entry/src/main/ets/MainAbility/pages/index/index.ets
+56
-0
storage/storagepickerjstest/entry/src/main/ets/TestAbility/TestAbility.ts
...ickerjstest/entry/src/main/ets/TestAbility/TestAbility.ts
+53
-0
storage/storagepickerjstest/entry/src/main/ets/TestAbility/pages/index.ets
...ckerjstest/entry/src/main/ets/TestAbility/pages/index.ets
+48
-0
storage/storagepickerjstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
storage/storagepickerjstest/entry/src/main/ets/test/Common.ets
...ge/storagepickerjstest/entry/src/main/ets/test/Common.ets
+189
-0
storage/storagepickerjstest/entry/src/main/ets/test/List.test.ets
...storagepickerjstest/entry/src/main/ets/test/List.test.ets
+29
-0
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerCallback.test.ets
...test/entry/src/main/ets/test/audioPickerCallback.test.ets
+170
-0
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets
...stest/entry/src/main/ets/test/audioPickerPromise.test.ets
+162
-0
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets
...t/entry/src/main/ets/test/documentPickerCallback.test.ets
+219
-0
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets
...st/entry/src/main/ets/test/documentPickerPromise.test.ets
+198
-0
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets
...test/entry/src/main/ets/test/photoPickerCallback.test.ets
+278
-0
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets
...stest/entry/src/main/ets/test/photoPickerPromise.test.ets
+265
-0
storage/storagepickerjstest/entry/src/main/module.json
storage/storagepickerjstest/entry/src/main/module.json
+50
-0
storage/storagepickerjstest/entry/src/main/resources/base/element/string.json
...rjstest/entry/src/main/resources/base/element/string.json
+32
-0
storage/storagepickerjstest/entry/src/main/resources/base/media/icon.png
...pickerjstest/entry/src/main/resources/base/media/icon.png
+0
-0
storage/storagepickerjstest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+5
-0
storage/storagepickerjstest/signature/openharmony_sx.p7b
storage/storagepickerjstest/signature/openharmony_sx.p7b
+0
-0
未找到文件。
storage/BUILD.gn
浏览文件 @
78d8d026
...
...
@@ -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",
...
...
storage/storagepickerjstest/AppScope/app.json
0 → 100644
浏览文件 @
78d8d026
{
"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
storage/storagepickerjstest/AppScope/resources/base/element/string.json
0 → 100644
浏览文件 @
78d8d026
{
"string"
:[
{
"name"
:
"app_name"
,
"value"
:
"storagePicker"
}
]
}
\ No newline at end of file
storage/storagepickerjstest/AppScope/resources/base/media/app_icon.png
0 → 100644
浏览文件 @
78d8d026
6.6 KB
storage/storagepickerjstest/BUILD.gn
0 → 100644
浏览文件 @
78d8d026
# 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"
}
storage/storagepickerjstest/Test.json
0 → 100644
浏览文件 @
78d8d026
{
"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
storage/storagepickerjstest/entry/src/main/ets/Application/AbilityStage.ts
0 → 100644
浏览文件 @
78d8d026
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
;
}
}
storage/storagepickerjstest/entry/src/main/ets/MainAbility/MainAbility.ts
0 → 100644
浏览文件 @
78d8d026
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
storage/storagepickerjstest/entry/src/main/ets/MainAbility/pages/index/index.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
storage/storagepickerjstest/entry/src/main/ets/TestAbility/TestAbility.ts
0 → 100644
浏览文件 @
78d8d026
/*
* 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
storage/storagepickerjstest/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
storage/storagepickerjstest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
78d8d026
/*
* 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
storage/storagepickerjstest/entry/src/main/ets/test/Common.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
storage/storagepickerjstest/entry/src/main/ets/test/List.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerCallback.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
);
});
});
}
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
);
});
});
}
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
);
});
});
}
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
);
});
});
}
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
);
});
});
}
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets
0 → 100644
浏览文件 @
78d8d026
/*
* 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
);
});
});
}
storage/storagepickerjstest/entry/src/main/module.json
0 → 100644
浏览文件 @
78d8d026
{
"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
storage/storagepickerjstest/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
78d8d026
{
"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
storage/storagepickerjstest/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
78d8d026
6.6 KB
storage/storagepickerjstest/entry/src/main/resources/base/profile/main_pages.json
0 → 100644
浏览文件 @
78d8d026
{
"src"
:
[
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
storage/storagepickerjstest/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
78d8d026
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录