Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
40dc8cc7
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看板
提交
40dc8cc7
编写于
7月 21, 2023
作者:
Y
yangbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugfix
Signed-off-by:
N
yangbo
<
yangbo258@huawei.com
>
上级
7465ed7f
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
127 addition
and
96 deletion
+127
-96
multimedia/photoAccess/common.ts
multimedia/photoAccess/common.ts
+11
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AbsAlbum/checkAttr.ets
...hotoAccess/entry/src/main/ets/test/AbsAlbum/checkAttr.ets
+2
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
...ry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
+10
-5
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
.../src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
+23
-23
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
...toAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
+2
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/get.ets
...ss/photoAccess/entry/src/main/ets/test/PhotoAsset/get.ets
+2
-2
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
...em/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
+77
-60
未找到文件。
multimedia/photoAccess/common.ts
浏览文件 @
40dc8cc7
...
@@ -126,9 +126,18 @@ export function isNum(value) : boolean {
...
@@ -126,9 +126,18 @@ export function isNum(value) : boolean {
return
typeof
value
===
'
number
'
&&
!
isNaN
(
value
);
return
typeof
value
===
'
number
'
&&
!
isNaN
(
value
);
};
};
export
function
getId
(
uri
)
:
string
{
export
function
getAssetId
(
uri
)
:
string
{
let
index
=
uri
.
lastIndexOf
(
'
/
'
);
const
tag
=
'
Photo/
'
;
const
index
=
uri
.
indexOf
(
tag
);
let
str
=
uri
.
substring
(
index
+
tag
.
length
);
console
.
info
(
`getAssetId str:
${
str
}
`
);
return
str
;
}
export
function
getAlbumId
(
uri
)
:
string
{
const
index
=
uri
.
lastIndexOf
(
'
/
'
);
let
str
=
uri
.
substring
(
index
+
1
);
let
str
=
uri
.
substring
(
index
+
1
);
console
.
info
(
`getAlbumId str:
${
str
}
`
);
return
str
;
return
str
;
}
}
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AbsAlbum/checkAttr.ets
浏览文件 @
40dc8cc7
...
@@ -20,7 +20,7 @@ import {
...
@@ -20,7 +20,7 @@ import {
albumSubtype
,
albumSubtype
,
fetchOption
,
fetchOption
,
getFileAsset
,
getFileAsset
,
getId
,
get
Album
Id
,
photoKeys
photoKeys
}
from
'../../../../../../../common'
}
from
'../../../../../../../common'
...
@@ -34,7 +34,7 @@ export default function checkAlbumAttrTest () {
...
@@ -34,7 +34,7 @@ export default function checkAlbumAttrTest () {
expect
(
album
.
albumType
)
.
assertEqual
(
albumType
.
USER
);
expect
(
album
.
albumType
)
.
assertEqual
(
albumType
.
USER
);
expect
(
album
.
albumSubtype
)
.
assertEqual
(
albumSubtype
.
USER_GENERIC
);
expect
(
album
.
albumSubtype
)
.
assertEqual
(
albumSubtype
.
USER_GENERIC
);
expect
(
album
.
albumName
)
.
assertEqual
(
testNum
);
expect
(
album
.
albumName
)
.
assertEqual
(
testNum
);
const
id
=
getId
(
album
.
albumUri
);
const
id
=
get
Album
Id
(
album
.
albumUri
);
expect
(
album
.
albumUri
)
.
assertEqual
(
'file://media/PhotoAlbum/'
+
id
);
expect
(
album
.
albumUri
)
.
assertEqual
(
'file://media/PhotoAlbum/'
+
id
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'01.jpg'
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'01.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
浏览文件 @
40dc8cc7
...
@@ -45,7 +45,7 @@ export default function registerChangeTest () {
...
@@ -45,7 +45,7 @@ export default function registerChangeTest () {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on01.jpg');
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
let count = 0;
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
...
@@ -53,6 +53,7 @@ export default function registerChangeTest () {
...
@@ -53,6 +53,7 @@ export default function registerChangeTest () {
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
});
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
await asset.commitModify();
...
@@ -86,10 +87,11 @@ export default function registerChangeTest () {
...
@@ -86,10 +87,11 @@ export default function registerChangeTest () {
changeDataUri = changeData.uris[0];
changeDataUri = changeData.uris[0];
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.type).assertEqual(NOTIFY_ADD);
});
});
await sleep(550);
let albumName = 'testAlbum' + Date.now();
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
let album = await helper.createAlbum(albumName);
let creatAlbumUri = album.albumUri;
let creatAlbumUri = album.albumUri;
await sleep(
2
000);
await sleep(
1
000);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(listenCount).assertEqual(1);
expect(listenCount).assertEqual(1);
...
@@ -117,13 +119,14 @@ export default function registerChangeTest () {
...
@@ -117,13 +119,14 @@ export default function registerChangeTest () {
let albumName = 'testAlbum' + Date.now();
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
albumUri = album.albumUri;
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(albumUri, false, async (changeData) => {
helper.registerChange(albumUri, false, async (changeData) => {
count++;
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(albumUri);
expect(changeData.uris[0]).assertEqual(albumUri);
});
});
await sleep(550);
album.albumName = Date.now() + album.albumName;
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await album.commitModify();
await sleep(1000);
await sleep(1000);
...
@@ -153,7 +156,7 @@ export default function registerChangeTest () {
...
@@ -153,7 +156,7 @@ export default function registerChangeTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on11.jpg');
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on11.jpg');
const asset = await getFileAsset(testNum, fetchOps);
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
let count = 0;
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(album.albumUri, false, async (changeData) => {
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
...
@@ -161,6 +164,7 @@ export default function registerChangeTest () {
...
@@ -161,6 +164,7 @@ export default function registerChangeTest () {
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
});
await sleep(550);
await album.addAssets([asset]);
await album.addAssets([asset]);
await sleep(1000);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
helper.unRegisterChange(album.albumUri);
...
@@ -190,7 +194,7 @@ export default function registerChangeTest () {
...
@@ -190,7 +194,7 @@ export default function registerChangeTest () {
const asset = await getFileAsset(testNum, fetchOps);
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
let count = 0;
await album.addAssets([asset]);
await album.addAssets([asset]);
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(album.albumUri, false, async (changeData) => {
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
...
@@ -198,6 +202,7 @@ export default function registerChangeTest () {
...
@@ -198,6 +202,7 @@ export default function registerChangeTest () {
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
});
await sleep(550);
await album.removeAssets([asset]);
await album.removeAssets([asset]);
await sleep(1000);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
helper.unRegisterChange(album.albumUri);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
浏览文件 @
40dc8cc7
...
@@ -43,14 +43,14 @@ export default function unRegisterChangeTest () {
...
@@ -43,14 +43,14 @@ export default function unRegisterChangeTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off01.jpg'
);
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off01.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
await
asset
.
commitModify
();
...
@@ -80,9 +80,9 @@ export default function unRegisterChangeTest () {
...
@@ -80,9 +80,9 @@ export default function unRegisterChangeTest () {
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
let
albumName
=
testNum
+
Date
.
now
();
let
albumName
=
testNum
+
Date
.
now
();
await
helper
.
createAlbum
(
albumName
);
await
helper
.
createAlbum
(
albumName
);
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -111,14 +111,14 @@ export default function unRegisterChangeTest () {
...
@@ -111,14 +111,14 @@ export default function unRegisterChangeTest () {
let
albumName
=
testNum
+
Date
.
now
();
let
albumName
=
testNum
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
albumUri
=
album
.
albumUri
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
albumUri
);
helper
.
unRegisterChange
(
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
await
album
.
commitModify
();
await
album
.
commitModify
();
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -150,14 +150,14 @@ export default function unRegisterChangeTest () {
...
@@ -150,14 +150,14 @@ export default function unRegisterChangeTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
albumUri
=
album
.
albumUri
;
albumUri
=
album
.
albumUri
;
await
album
.
addAssets
([
asset
]);
await
album
.
addAssets
([
asset
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
albumUri
);
helper
.
unRegisterChange
(
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
album
.
albumName
=
testNum
+
album
.
albumName
;
album
.
albumName
=
testNum
+
album
.
albumName
;
await
album
.
commitModify
();
await
album
.
commitModify
();
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -186,14 +186,14 @@ export default function unRegisterChangeTest () {
...
@@ -186,14 +186,14 @@ export default function unRegisterChangeTest () {
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off11.jpg'
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off11.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
album
.
albumUri
);
helper
.
unRegisterChange
(
album
.
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
album
.
addAssets
([
asset
]);
await
album
.
addAssets
([
asset
]);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
...
@@ -222,14 +222,14 @@ export default function unRegisterChangeTest () {
...
@@ -222,14 +222,14 @@ export default function unRegisterChangeTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
let
count
=
0
;
await
album
.
addAssets
([
asset
]);
await
album
.
addAssets
([
asset
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
album
.
albumUri
);
helper
.
unRegisterChange
(
album
.
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
album
.
removeAssets
([
asset
]);
await
album
.
removeAssets
([
asset
]);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
...
@@ -255,7 +255,7 @@ export default function unRegisterChangeTest () {
...
@@ -255,7 +255,7 @@ export default function unRegisterChangeTest () {
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off15.jpg'
);
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off15.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
listenCount
=
0
;
let
listenCount
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
console
.
info
(
`${testNum} changeData1: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData1: ${JSON.stringify(changeData)}`
);
...
@@ -264,9 +264,9 @@ export default function unRegisterChangeTest () {
...
@@ -264,9 +264,9 @@ export default function unRegisterChangeTest () {
listenCount
++
;
listenCount
++
;
console
.
info
(
`${testNum} changeData2: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData2: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
await
asset
.
commitModify
();
...
@@ -295,7 +295,7 @@ export default function unRegisterChangeTest () {
...
@@ -295,7 +295,7 @@ export default function unRegisterChangeTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
listenCount1
=
0
;
let
listenCount1
=
0
;
let
listenCount2
=
0
;
let
listenCount2
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
const
callback1
=
async
(
changeData
)
=>
{
const
callback1
=
async
(
changeData
)
=>
{
listenCount1
++
;
listenCount1
++
;
console
.
info
(
`${testNum} callback1: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} callback1: ${JSON.stringify(changeData)}`
);
...
@@ -308,9 +308,9 @@ export default function unRegisterChangeTest () {
...
@@ -308,9 +308,9 @@ export default function unRegisterChangeTest () {
helper
.
registerChange
(
asset
.
uri
,
false
,
callback1
);
helper
.
registerChange
(
asset
.
uri
,
false
,
callback1
);
helper
.
registerChange
(
asset
.
uri
,
false
,
callback2
);
helper
.
registerChange
(
asset
.
uri
,
false
,
callback2
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
,
callback1
);
helper
.
unRegisterChange
(
asset
.
uri
,
callback1
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
await
asset
.
commitModify
();
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
浏览文件 @
40dc8cc7
...
@@ -18,7 +18,7 @@ import {
...
@@ -18,7 +18,7 @@ import {
photoKeys
,
photoKeys
,
fetchOption
,
fetchOption
,
getFileAsset
,
getFileAsset
,
getId
,
get
Asset
Id
,
photoType
photoType
}
from
'../../../../../../../common'
}
from
'../../../../../../../common'
...
@@ -30,7 +30,7 @@ export default function checkAttrTest () {
...
@@ -30,7 +30,7 @@ export default function checkAttrTest () {
const
fetchOps
=
fetchOption
(
testNum
,
key
,
displayName
);
const
fetchOps
=
fetchOption
(
testNum
,
key
,
displayName
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
console
.
info
(
`${testNum} uri: ${asset.uri} filetype: ${asset.photoType} displayName: ${asset.displayName}`
)
console
.
info
(
`${testNum} uri: ${asset.uri} filetype: ${asset.photoType} displayName: ${asset.displayName}`
)
const
id
=
getId
(
asset
.
uri
);
const
id
=
get
Asset
Id
(
asset
.
uri
);
const
expectUri
=
'file://media/Photo/'
+
id
;
const
expectUri
=
'file://media/Photo/'
+
id
;
const
isIncludes
=
asset
.
uri
.
includes
(
expectUri
);
const
isIncludes
=
asset
.
uri
.
includes
(
expectUri
);
expect
(
isIncludes
)
.
assertTrue
();
expect
(
isIncludes
)
.
assertTrue
();
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/get.ets
浏览文件 @
40dc8cc7
...
@@ -18,7 +18,7 @@ import {
...
@@ -18,7 +18,7 @@ import {
photoKeys
,
photoKeys
,
photoFetchOption
,
photoFetchOption
,
getFileAsset
,
getFileAsset
,
getId
,
get
Asset
Id
,
isNum
,
isNum
,
photoType
,
photoType
,
}
from
'../../../../../../../common'
}
from
'../../../../../../../common'
...
@@ -30,7 +30,7 @@ export default function getTest () {
...
@@ -30,7 +30,7 @@ export default function getTest () {
let
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
console
.
info
(
`${testNum} key: ${key}, value: ${value}, asset.key: ${asset.get(key)}`
);
console
.
info
(
`${testNum} key: ${key}, value: ${value}, asset.key: ${asset.get(key)}`
);
if
(
key
===
'uri'
)
{
if
(
key
===
'uri'
)
{
const
id
=
getId
(
asset
.
get
(
key
));
const
id
=
get
Asset
Id
(
asset
.
get
(
key
));
const
expectUri
=
value
+
id
;
const
expectUri
=
value
+
id
;
const
uri
=
asset
.
get
(
key
)
.
toString
();
const
uri
=
asset
.
get
(
key
)
.
toString
();
const
isIncludes
=
uri
.
includes
(
expectUri
);
const
isIncludes
=
uri
.
includes
(
expectUri
);
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
浏览文件 @
40dc8cc7
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
fileio
from
"@ohos.fileio"
;
import
fileio
from
"@ohos.fileio"
;
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
beforeAll
,
it
,
expect
}
from
'deccjsunit/index'
import
{
describe
,
beforeAll
,
afterEach
,
it
,
expect
}
from
'deccjsunit/index'
import
{
import
{
albumType
,
albumType
,
albumSubtype
,
albumSubtype
,
...
@@ -40,6 +40,10 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -40,6 +40,10 @@ export default function publicApiTestWithSystemApiTest () {
await
getPermission
()
await
getPermission
()
})
})
afterEach
(
async
function
()
{
await
sleep
(
550
)
})
//callback
//callback
/**
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0100
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0100
...
@@ -277,13 +281,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -277,13 +281,14 @@ export default function publicApiTestWithSystemApiTest () {
let
fd
=
await
createAsset
.
open
(
'rw'
);
let
fd
=
await
createAsset
.
open
(
'rw'
);
await
createAsset
.
close
(
fd
);
await
createAsset
.
close
(
fd
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
550
);
helper
.
unRegisterChange
(
createAsset
.
uri
);
helper
.
unRegisterChange
(
createAsset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
fd
=
await
createAsset
.
getReadOnlyFd
();
fd
=
await
createAsset
.
getReadOnlyFd
();
await
createAsset
.
close
(
fd
);
await
createAsset
.
close
(
fd
);
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -310,14 +315,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -310,14 +315,14 @@ export default function publicApiTestWithSystemApiTest () {
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off02.jpg'
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off02.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
...
@@ -344,14 +349,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -344,14 +349,14 @@ export default function publicApiTestWithSystemApiTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
asset
.
setFavorite
(
false
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
...
@@ -377,16 +382,16 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -377,16 +382,16 @@ export default function publicApiTestWithSystemApiTest () {
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off04.jpg'
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off04.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} asset changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} asset changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
helper
.
deleteAssets
([
asset
.
uri
]);
await
helper
.
deleteAssets
([
asset
.
uri
]);
await
sleep
(
2
000
);
await
sleep
(
1
000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
done
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -418,18 +423,18 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -418,18 +423,18 @@ export default function publicApiTestWithSystemApiTest () {
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
false
)
.
assertTrue
();
expect
(
false
)
.
assertTrue
();
done
();
done
();
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
trashFileAsset
.
uri
);
helper
.
unRegisterChange
(
trashFileAsset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
sleep
(
2
000
);
await
sleep
(
1
000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
done
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -461,14 +466,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -461,14 +466,14 @@ export default function publicApiTestWithSystemApiTest () {
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
trashAlbum
.
albumUri
);
helper
.
unRegisterChange
(
trashAlbum
.
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
...
@@ -494,14 +499,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -494,14 +499,14 @@ export default function publicApiTestWithSystemApiTest () {
let
count
=
0
;
let
count
=
0
;
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
let
album
=
await
helper
.
createAlbum
(
albumName
);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
helper
.
deleteAlbums
([
album
]);
await
helper
.
deleteAlbums
([
album
]);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
0
);
...
@@ -531,30 +536,30 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -531,30 +536,30 @@ export default function publicApiTestWithSystemApiTest () {
let
fd
=
await
fileAsset
.
open
(
'rw'
);
let
fd
=
await
fileAsset
.
open
(
'rw'
);
await
fileAsset
.
close
(
fd
);
await
fileAsset
.
close
(
fd
);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
let
listenCount
=
0
;
let
listenCount
=
0
;
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
// 1
// 1
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
let
album
=
await
helper
.
createAlbum
(
albumName
);
// 2
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
album
.
albumName
=
'hello'
;
album
.
albumName
=
'hello'
;
await
album
.
commitModify
();
await
album
.
commitModify
();
// 3
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
album
.
addAssets
([
asset
]);
await
album
.
addAssets
([
asset
]);
// 5
// 5
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
album
.
removeAssets
([
asset
]);
await
album
.
removeAssets
([
asset
]);
// 6
// 6
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
helper
.
deleteAlbums
([
album
]);
await
helper
.
deleteAlbums
([
album
]);
// 7
// 7
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
...
@@ -587,32 +592,33 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -587,32 +592,33 @@ export default function publicApiTestWithSystemApiTest () {
let
listenCount
=
0
;
let
listenCount
=
0
;
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
);
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
await
sleep
(
550
);
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_PHOTO_URI
);
helper
.
unRegisterChange
(
DEFAULT_PHOTO_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
// 1
// 1
let
fd
=
await
asset
.
open
(
'rw'
);
let
fd
=
await
asset
.
open
(
'rw'
);
await
asset
.
close
(
fd
);
await
asset
.
close
(
fd
);
// 2
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
await
asset
.
commitModify
();
// 3
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
// 4
// 4
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
false
);
await
asset
.
setFavorite
(
false
);
// 5
// 5
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
helper
.
deleteAssets
([
asset
.
uri
]);
await
helper
.
deleteAssets
([
asset
.
uri
]);
// 6
// 6
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbum
=
await
trashAlbumList
.
getFirstObject
();
let
trashAlbum
=
await
trashAlbumList
.
getFirstObject
();
const
fetchOps1
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
)
const
fetchOps1
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
)
...
@@ -644,14 +650,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -644,14 +650,14 @@ export default function publicApiTestWithSystemApiTest () {
const
createAsset
=
await
helper
.
createAsset
(
testNum
+
'.jpg'
);
const
createAsset
=
await
helper
.
createAsset
(
testNum
+
'.jpg'
);
uri
=
createAsset
.
uri
;
uri
=
createAsset
.
uri
;
let
count
=
0
;
let
count
=
0
;
console
.
log
(
`${testNum}: uri: ${uri}`
);
await
sleep
(
550
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
let
fd
=
await
createAsset
.
open
(
'rw'
);
let
fd
=
await
createAsset
.
open
(
'rw'
);
await
fileio
.
write
(
fd
,
testNum
);
await
fileio
.
write
(
fd
,
testNum
);
await
createAsset
.
close
(
fd
);
await
createAsset
.
close
(
fd
);
...
@@ -683,12 +689,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -683,12 +689,14 @@ export default function publicApiTestWithSystemApiTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
uri
=
asset
.
uri
;
uri
=
asset
.
uri
;
let
count
=
0
;
let
count
=
0
;
await
sleep
(
550
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
});
await
sleep
(
550
);
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -720,13 +728,14 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -720,13 +728,14 @@ export default function publicApiTestWithSystemApiTest () {
uri
=
asset
.
uri
;
uri
=
asset
.
uri
;
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
});
await
sleep
(
550
);
await
asset
.
setFavorite
(
false
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -765,7 +774,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -765,7 +774,7 @@ export default function publicApiTestWithSystemApiTest () {
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
uri
=
trashFileAsset
.
uri
;
uri
=
trashFileAsset
.
uri
;
let
count
=
0
;
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
console
.
log
(
`${testNum}: uri: ${uri}`
);
console
.
log
(
`${testNum}: uri: ${uri}`
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
...
@@ -773,8 +782,9 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -773,8 +782,9 @@ export default function publicApiTestWithSystemApiTest () {
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
});
await
sleep
(
550
);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
sleep
(
2
000
);
await
sleep
(
1
000
);
expect
(
count
)
.
assertEqual
(
1
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
done
();
...
@@ -813,6 +823,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -813,6 +823,7 @@ export default function publicApiTestWithSystemApiTest () {
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
console
.
info
(
`${testNum} trashFileAsset.uri: ${trashFileAsset.uri}`
);
console
.
info
(
`${testNum} trashFileAsset.uri: ${trashFileAsset.uri}`
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
550
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
...
@@ -820,6 +831,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -820,6 +831,7 @@ export default function publicApiTestWithSystemApiTest () {
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
extraUris
[
0
])
.
assertEqual
(
trashFileAsset
.
uri
);
expect
(
changeData
.
extraUris
[
0
])
.
assertEqual
(
trashFileAsset
.
uri
);
});
});
await
sleep
(
550
);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -851,7 +863,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -851,7 +863,7 @@ export default function publicApiTestWithSystemApiTest () {
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
albumUri
=
album
.
albumUri
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
uri
=
DEFAULT_ALBUM_URI
;
uri
=
DEFAULT_ALBUM_URI
;
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
...
@@ -860,10 +872,10 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -860,10 +872,10 @@ export default function publicApiTestWithSystemApiTest () {
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
done
();
done
();
});
});
await
sleep
(
550
);
await
helper
.
deleteAlbums
([
album
]);
await
helper
.
deleteAlbums
([
album
]);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
listenCount
)
.
assertEqual
(
1
);
expect
(
listenCount
)
.
assertEqual
(
1
);
done
();
done
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: $${error}`
);
console
.
log
(
`${testNum}: tryError: $${error}`
);
...
@@ -897,7 +909,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -897,7 +909,7 @@ export default function publicApiTestWithSystemApiTest () {
let
fd
=
await
fileAsset
.
open
(
'rw'
);
let
fd
=
await
fileAsset
.
open
(
'rw'
);
await
fileAsset
.
close
(
fd
);
await
fileAsset
.
close
(
fd
);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
uri
=
DEFAULT_ALBUM_URI
;
uri
=
DEFAULT_ALBUM_URI
;
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
...
@@ -942,6 +954,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -942,6 +954,7 @@ export default function publicApiTestWithSystemApiTest () {
break
;
break
;
}
}
});
});
await
sleep
(
550
);
let
testCount
=
0
;
let
testCount
=
0
;
// 1
// 1
testCount
++
;
testCount
++
;
...
@@ -950,34 +963,34 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -950,34 +963,34 @@ export default function publicApiTestWithSystemApiTest () {
let
album
=
await
helper
.
createAlbum
(
albumName
);
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
albumUri
=
album
.
albumUri
;
// 2
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
testCount
++
;
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
console
.
info
(
`${testNum} testCount: ${testCount}`
);
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
await
album
.
commitModify
();
await
album
.
commitModify
();
// 3
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
testCount
++
;
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
console
.
info
(
`${testNum} testCount: ${testCount}`
);
await
album
.
addAssets
([
asset
]);
await
album
.
addAssets
([
asset
]);
// 4
// 4
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
testCount
++
;
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
console
.
info
(
`${testNum} testCount: ${testCount}`
);
album
.
albumName
=
testNum
+
album
.
albumName
;
album
.
albumName
=
testNum
+
album
.
albumName
;
await
album
.
commitModify
();
await
album
.
commitModify
();
// 5
// 5
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
testCount
++
;
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
console
.
info
(
`${testNum} testCount: ${testCount}`
);
await
album
.
removeAssets
([
asset
]);
await
album
.
removeAssets
([
asset
]);
// 6
// 6
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
testCount
++
;
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
console
.
info
(
`${testNum} testCount: ${testCount}`
);
await
helper
.
deleteAlbums
([
album
]);
await
helper
.
deleteAlbums
([
album
]);
// 7
// 7
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
testCount
++
;
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
console
.
info
(
`${testNum} testCount: ${testCount}`
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
...
@@ -1018,6 +1031,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1018,6 +1031,7 @@ export default function publicApiTestWithSystemApiTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on14.jpg'
);
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on14.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
photoAssetUri
=
asset
.
uri
;
let
photoAssetUri
=
asset
.
uri
;
await
sleep
(
550
);
uri
=
DEFAULT_PHOTO_URI
;
uri
=
DEFAULT_PHOTO_URI
;
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
...
@@ -1042,15 +1056,15 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1042,15 +1056,15 @@ export default function publicApiTestWithSystemApiTest () {
}
}
});
});
// 1
// 1
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
await
asset
.
commitModify
();
// 2
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
// 3
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
false
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
await
sleep
(
1000
);
...
@@ -1080,6 +1094,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1080,6 +1094,7 @@ export default function publicApiTestWithSystemApiTest () {
let
listenCount
=
0
;
let
listenCount
=
0
;
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on15.jpg'
);
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on15.jpg'
);
let
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
await
sleep
(
550
);
//notify times lessthan 32 in 500ms
//notify times lessthan 32 in 500ms
let
i
=
0
;
let
i
=
0
;
...
@@ -1100,6 +1115,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1100,6 +1115,7 @@ export default function publicApiTestWithSystemApiTest () {
}
}
});
});
await
sleep
(
550
);
const
endTime
=
Date
.
now
()
+
500
;
const
endTime
=
Date
.
now
()
+
500
;
for
(
let
now
=
Date
.
now
();
now
<
endTime
;
now
=
Date
.
now
())
{
for
(
let
now
=
Date
.
now
();
now
<
endTime
;
now
=
Date
.
now
())
{
i
++
;
i
++
;
...
@@ -1107,7 +1123,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1107,7 +1123,7 @@ export default function publicApiTestWithSystemApiTest () {
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
await
asset
.
commitModify
();
}
}
await
sleep
(
2
000
);
await
sleep
(
1
000
);
done
();
done
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
console
.
log
(
`${testNum}: tryError: ${error}`
);
...
@@ -1136,22 +1152,23 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1136,22 +1152,23 @@ export default function publicApiTestWithSystemApiTest () {
let
fd
=
await
asset
.
open
(
'rw'
);
let
fd
=
await
asset
.
open
(
'rw'
);
await
asset
.
close
(
fd
);
await
asset
.
close
(
fd
);
let
listenCount
=
0
;
let
listenCount
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
});
await
sleep
(
550
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
if
(
i
%
2
==
0
)
{
if
(
i
%
2
==
0
)
{
await
asset
.
setFavorite
(
true
);
await
asset
.
setFavorite
(
true
);
}
else
{
}
else
{
await
asset
.
setFavorite
(
false
);
await
asset
.
setFavorite
(
false
);
}
}
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
}
}
await
sleep
(
2
000
);
await
sleep
(
1
000
);
expect
(
listenCount
)
.
assertEqual
(
10
);
expect
(
listenCount
)
.
assertEqual
(
10
);
done
();
done
();
...
@@ -1184,7 +1201,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1184,7 +1201,7 @@ export default function publicApiTestWithSystemApiTest () {
await
fileio
.
write
(
fd
,
buf
);
await
fileio
.
write
(
fd
,
buf
);
await
fileAsset
.
close
(
fd
);
await
fileAsset
.
close
(
fd
);
let
count
=
0
;
let
count
=
0
;
await
sleep
(
100
0
);
await
sleep
(
55
0
);
uri
=
fileAsset
.
uri
;
uri
=
fileAsset
.
uri
;
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
count
++
;
...
@@ -1193,6 +1210,7 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1193,6 +1210,7 @@ export default function publicApiTestWithSystemApiTest () {
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
done
();
done
();
});
});
await
sleep
(
550
);
fd
=
await
fileAsset
.
open
(
'rw'
);
fd
=
await
fileAsset
.
open
(
'rw'
);
buf
=
new
ArrayBuffer
(
1
);
buf
=
new
ArrayBuffer
(
1
);
buf
[
0
]
=
0
;
buf
[
0
]
=
0
;
...
@@ -1200,7 +1218,6 @@ export default function publicApiTestWithSystemApiTest () {
...
@@ -1200,7 +1218,6 @@ export default function publicApiTestWithSystemApiTest () {
await
fileAsset
.
close
(
fd
);
await
fileAsset
.
close
(
fd
);
await
sleep
(
1000
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
1
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
done
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: $${error}`
);
console
.
log
(
`${testNum}: tryError: $${error}`
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录