Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ab3db6c4
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看板
提交
ab3db6c4
编写于
3月 28, 2023
作者:
Y
yangbo
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix picker xts
Signed-off-by:
N
yangbo
<
yangbo258@huawei.com
>
上级
977de50b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
113 addition
and
236 deletion
+113
-236
storage/storagepickerjstest/Test.json
storage/storagepickerjstest/Test.json
+2
-19
storage/storagepickerjstest/entry/src/main/ets/test/Common.ets
...ge/storagepickerjstest/entry/src/main/ets/test/Common.ets
+13
-168
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerCallback.test.ets
...test/entry/src/main/ets/test/audioPickerCallback.test.ets
+15
-5
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets
...stest/entry/src/main/ets/test/audioPickerPromise.test.ets
+19
-5
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets
...t/entry/src/main/ets/test/documentPickerCallback.test.ets
+15
-6
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets
...st/entry/src/main/ets/test/documentPickerPromise.test.ets
+19
-6
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets
...test/entry/src/main/ets/test/photoPickerCallback.test.ets
+15
-13
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets
...stest/entry/src/main/ets/test/photoPickerPromise.test.ets
+15
-9
storage/storagepickerjstest/entry/src/main/module.json
storage/storagepickerjstest/entry/src/main/module.json
+0
-5
storage/storagepickerjstest/signature/openharmony_sx.p7b
storage/storagepickerjstest/signature/openharmony_sx.p7b
+0
-0
未找到文件。
storage/storagepickerjstest/Test.json
浏览文件 @
ab3db6c4
...
...
@@ -13,10 +13,6 @@
"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"
,
...
...
@@ -26,32 +22,19 @@
{
"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"
]
"push"
:
[]
},
{
"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
"
"
reboot
"
]
},
{
...
...
storage/storagepickerjstest/entry/src/main/ets/test/Common.ets
浏览文件 @
ab3db6c4
...
...
@@ -13,177 +13,22 @@
* limitations under the License.
*/
import
{
Driver
,
ON
}
from
'@ohos.UiTest'
import
abilityDelegatorRegistry
from
'@ohos.application.abilityDelegatorRegistry'
;
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
);
}
const
delegator
=
abilityDelegatorRegistry
.
getAbilityDelegator
();
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
startAbility
(
bundleName
:
string
,
abilityName
:
string
)
{
await
delegator
.
executeShellCommand
(
`aa start -b ${bundleName} -a ${abilityName}`
)
.
then
(
result
=>
{
console
.
info
(
`[picker] start abilityFinished: ${result}`
)
})
.
catch
(
err
=>
{
console
.
error
(
`[picker] start abilityFailed: ${err}`
)
})
}
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
);
export
async
function
sleep
(
times
)
{
if
(
!
times
)
{
times
=
10
;
}
await
new
Promise
((
res
)
=>
setTimeout
(
res
,
times
));
};
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/audioPickerCallback.test.ets
浏览文件 @
ab3db6c4
...
...
@@ -14,11 +14,17 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
;
import
{
doSingleSelect
,
doMultiSelect
,
doFileSelect
,
doSave
,
saveAndConcel
}
from
"./Common"
import
{
sleep
,
startAbility
}
from
"./Common"
import
picker
from
'@ohos.file.picker'
export
default
function
audioPickerCallback
(
abilityContext
)
{
describe
(
"audioPickerCallback"
,
function
()
{
afterEach
(
async
function
()
{
await
sleep
(
500
);
await
startAbility
(
'ohos.acts.storage.picker'
,
'com.example.myapplication.MainAbility'
);
await
sleep
(
500
);
})
async
function
select
(
testNum
,
done
,
dirName
,
fileName
)
{
try
{
let
audioPicker
=
new
picker
.
AudioViewPicker
();
...
...
@@ -33,7 +39,8 @@ export default function audioPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
1
);
done
();
});
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::select error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -55,7 +62,8 @@ export default function audioPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
1
);
done
();
});
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::selectWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -77,7 +85,8 @@ export default function audioPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
0
);
done
();
});
await
saveAndConcel
(
testNum
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -99,7 +108,8 @@ export default function audioPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
1
);
done
();
});
await
doSave
(
testNum
,
dirName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
storage/storagepickerjstest/entry/src/main/ets/test/audioPickerPromise.test.ets
浏览文件 @
ab3db6c4
...
...
@@ -14,11 +14,17 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
;
import
{
doSingleSelect
,
doMultiSelect
,
doFileSelect
,
doSave
,
saveAndConcel
}
from
"./Common"
import
{
sleep
,
startAbility
}
from
"./Common"
import
picker
from
'@ohos.file.picker'
export
default
function
audioPickerPromise
(
abilityContext
)
{
describe
(
"audioPickerPromise"
,
function
()
{
afterEach
(
async
function
()
{
await
sleep
(
500
);
await
startAbility
(
'ohos.acts.storage.picker'
,
'com.example.myapplication.MainAbility'
);
await
sleep
(
500
);
})
async
function
select
(
testNum
,
done
,
dirName
,
fileName
)
{
try
{
let
audioPicker
=
new
picker
.
AudioViewPicker
();
...
...
@@ -30,8 +36,10 @@ export default function audioPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::select err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::select error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -50,8 +58,10 @@ export default function audioPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::selectWithOption err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::selectWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -70,8 +80,10 @@ export default function audioPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
})
await
saveAndConcel
(
testNum
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -90,8 +102,10 @@ export default function audioPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::saveWithOption err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
doSave
(
testNum
,
dirName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerCallback.test.ets
浏览文件 @
ab3db6c4
...
...
@@ -13,13 +13,18 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
;
import
{
doSingleSelect
,
doMultiSelect
,
doFileSelect
,
doSave
,
saveAndConcel
}
from
"./Common"
import
{
sleep
,
startAbility
}
from
"./Common"
import
picker
from
'@ohos.file.picker'
export
default
function
documentPickerCallback
(
abilityContext
)
{
describe
(
"documentPickerCallback"
,
function
()
{
afterEach
(
async
function
()
{
await
sleep
(
500
);
await
startAbility
(
'ohos.acts.storage.picker'
,
'com.example.myapplication.MainAbility'
);
await
sleep
(
500
);
})
async
function
select
(
testNum
,
done
,
dirName
,
fileName
)
{
try
{
let
documentPicker
=
new
picker
.
DocumentViewPicker
();
...
...
@@ -34,7 +39,8 @@ export default function documentPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
1
);
done
();
});
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::select error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -56,7 +62,8 @@ export default function documentPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
1
);
done
();
});
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::selectWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -78,7 +85,8 @@ export default function documentPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
0
);
done
();
});
await
saveAndConcel
(
testNum
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -100,7 +108,8 @@ export default function documentPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
1
);
done
();
});
await
doSave
(
testNum
,
dirName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
storage/storagepickerjstest/entry/src/main/ets/test/documentPickerPromise.test.ets
浏览文件 @
ab3db6c4
...
...
@@ -13,13 +13,18 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
;
import
{
doSingleSelect
,
doMultiSelect
,
doFileSelect
,
doSave
,
saveAndConcel
}
from
"./Common"
import
{
sleep
,
startAbility
}
from
"./Common"
import
picker
from
'@ohos.file.picker'
export
default
function
documentPickerPromise
(
abilityContext
)
{
describe
(
"documentPickerPromise"
,
function
()
{
afterEach
(
async
function
()
{
await
sleep
(
500
);
await
startAbility
(
'ohos.acts.storage.picker'
,
'com.example.myapplication.MainAbility'
);
await
sleep
(
500
);
})
async
function
select
(
testNum
,
done
,
dirName
,
fileName
)
{
try
{
let
documentPicker
=
new
picker
.
DocumentViewPicker
();
...
...
@@ -31,8 +36,10 @@ export default function documentPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::select err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::select error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -51,8 +58,10 @@ export default function documentPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::selectWithOption err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
doFileSelect
(
testNum
,
dirName
,
fileName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::selectWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -71,8 +80,10 @@ export default function documentPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
saveAndConcel
(
testNum
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -91,8 +102,10 @@ export default function documentPickerPromise(abilityContext) {
console
.
info
(
`${testNum}::saveWithOption err: ${JSON.stringify(err)}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
})
await
doSave
(
testNum
,
dirName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerCallback.test.ets
浏览文件 @
ab3db6c4
...
...
@@ -14,15 +14,17 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
;
import
{
getPermission
,
doSingleSelect
,
doMultiSelect
,
doFileSelect
,
doSave
,
saveAndConcel
}
from
"./Common"
import
{
sleep
,
startAbility
}
from
"./Common"
import
picker
from
'@ohos.file.picker'
export
default
function
photoPickerCallback
(
abilityContext
)
{
describe
(
"photoPickerCallback"
,
function
()
{
beforeAll
(
async
function
()
{
//await getPermission(abilityContext);
});
afterEach
(
async
function
()
{
await
sleep
(
500
);
await
startAbility
(
'ohos.acts.storage.picker'
,
'com.example.myapplication.MainAbility'
);
await
sleep
(
500
);
})
async
function
select
(
testNum
,
done
,
isSelectOriginal
,
expectSelectNum
=
2
)
{
try
{
let
photoPicker
=
new
picker
.
PhotoViewPicker
();
...
...
@@ -38,7 +40,8 @@ export default function photoPickerCallback(abilityContext) {
expect
(
result
.
isOriginalPhoto
)
.
assertEqual
(
isSelectOriginal
);
done
();
});
await
doMultiSelect
(
testNum
,
expectSelectNum
,
isSelectOriginal
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::select error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -60,11 +63,8 @@ export default function photoPickerCallback(abilityContext) {
expect
(
result
.
photoUris
.
length
)
.
assertEqual
(
expectSelectNum
);
done
();
});
if
(
option
.
maxSelectNumber
!=
undefined
&&
option
.
maxSelectNumber
==
1
)
{
await
doSingleSelect
(
testNum
);
}
else
{
await
doMultiSelect
(
testNum
,
expectSelectNum
,
false
);
}
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::selectWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -86,7 +86,8 @@ export default function photoPickerCallback(abilityContext) {
expect
(
result
.
length
)
.
assertEqual
(
0
);
done
();
});
await
saveAndConcel
(
testNum
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -108,7 +109,8 @@ export default function photoPickerCallback(abilityContext) {
expect
(
result
!=
undefined
)
.
assertTrue
();
done
();
});
await
doSave
(
testNum
,
dirName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
storage/storagepickerjstest/entry/src/main/ets/test/photoPickerPromise.test.ets
浏览文件 @
ab3db6c4
...
...
@@ -14,11 +14,17 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
"deccjsunit/index"
;
import
{
doSingleSelect
,
doMultiSelect
,
doFileSelect
,
doSave
,
saveAndConcel
}
from
"./Common"
import
{
sleep
,
startAbility
}
from
"./Common"
import
picker
from
'@ohos.file.picker'
export
default
function
photoPickerPromise
(
abilityContext
)
{
describe
(
"photoPickerPromise"
,
function
()
{
afterEach
(
async
function
()
{
await
sleep
(
500
);
await
startAbility
(
'ohos.acts.storage.picker'
,
'com.example.myapplication.MainAbility'
);
await
sleep
(
500
);
})
async
function
select
(
testNum
,
done
,
isSelectOriginal
,
expectSelectNum
=
2
)
{
try
{
let
photoPicker
=
new
picker
.
PhotoViewPicker
();
...
...
@@ -31,7 +37,8 @@ export default function photoPickerPromise(abilityContext) {
expect
(
false
)
.
assertTrue
();
done
();
})
await
doMultiSelect
(
testNum
,
expectSelectNum
,
isSelectOriginal
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::select error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -51,11 +58,8 @@ export default function photoPickerPromise(abilityContext) {
expect
(
false
)
.
assertTrue
();
done
();
})
if
(
option
.
maxSelectNumber
!=
undefined
&&
option
.
maxSelectNumber
==
1
)
{
await
doSingleSelect
(
testNum
);
}
else
{
await
doMultiSelect
(
testNum
,
expectSelectNum
,
false
);
}
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::selectWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -75,7 +79,8 @@ export default function photoPickerPromise(abilityContext) {
expect
(
false
)
.
assertTrue
();
done
();
})
await
saveAndConcel
(
testNum
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -95,7 +100,8 @@ export default function photoPickerPromise(abilityContext) {
expect
(
false
)
.
assertTrue
();
done
();
})
await
doSave
(
testNum
,
dirName
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}::saveWithOption error: ${JSON.stringify(error)}`
);
expect
(
false
)
.
assertTrue
();
...
...
storage/storagepickerjstest/entry/src/main/module.json
浏览文件 @
ab3db6c4
...
...
@@ -40,11 +40,6 @@
}
]
}
],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
storage/storagepickerjstest/signature/openharmony_sx.p7b
浏览文件 @
ab3db6c4
无法预览此类型文件
鸿蒙社区
@harmonycommunity
mentioned in commit
2a644437
·
3月 29, 2023
mentioned in commit
2a644437
mentioned in commit 2a6444379bfab383f91146ac10285e1b66f7c2d9
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录